thermostat.php 7.37 KB
Newer Older
nextime's avatar
nextime committed
1 2 3
<? @include_once("../../includes/common.php"); ?>
<? 
if($panel && is_array($panel)) { 
nextime's avatar
nextime committed
4 5 6
   $thermo=DB::queryFirstRow("SELECT * from thermostats WHERE name=%s AND active='yes'", $panel['panel_content']);
   $buttonar=getPanelButtons($_DOMOTIKA['username'],$thermo['sensor_domain'],$panel['panel_sections'],$panel['panel_websections'],$panel['panel_selector'],true);

nextime's avatar
nextime committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
   $climastatus=DB::queryOneField("value", "SELECT * FROM uniques WHERE name='climastatus'");
   if(!$climastatus) { 
      DB::insert('uniques', array('name'=>'climastatus','value'=>'WINTER'));
      $climastatus='WINTER';
   }
   $climastatuses=DB::query("SELECT DISTINCT(clima_status) FROM thermostats_progs group by clima_status");

   if(is_numeric($panel['panel_height'])) $panel['panel_height'].="px";
   $visible="";
   if($panel['panel_visible']!="all") $visible=$panel['panel_visible'];
   if(count($buttonar)<=0) {
      $visible.=" hidden-xs hidden-sm";
   }
   if(!array_key_exists('id', $panel))
      $panel['id']=mt_rand();

?>
      <div class="panel panel-theme-<?=$_DOMOTIKA['gui_theme']?> col-lg-<?=$panel['panel_cols']?> panel-media-low <?=$visible?>" style="height:<?=$panel['panel_height'];?>;">
<?
   if($panel['panel_title']!="") {
?>
         <div class="panel-heading panel-head-theme-<?=$_DOMOTIKA['gui_theme']?>"><h2 class="panel-title"><?=$panel['panel_title']?></h2></div>
<? 
   }

   $height="";
   $dmfull="";
   if($panel['panel_height']!="" && intval($panel['panel_height'])>0) {
      $height="style=\"height:".$panel['panel_height']."\"";
      $dmheight="style=\"height:".strval(intval($panel['panel_height'])-70)."px\"";
      if(endsWith($panel['panel_height'], '%')) {
            $dmfull="domotika-panel-full";
            $dmheight="style=\"height:100%;\"";
      }
   }
   elseif($panel['panel_height']!="" && intval($panel['panel_height'])==0) {
      $height="style=\"height:100%;\"";
      $dmfull="domotika-panel-full";
      $dmheight="style=\"height:100%;\"";
   }
?>
    <div class="domotika-panel <?=$dmfull;?>" <?=$dmheight;?>>
      <div class="home-panel" <?=$dmheight;?>>
         <div class="list-group theme-<?=$_DOMOTIKA['gui_theme']?>">     
            <?
            foreach($buttonar as $button) {
               if($button['devtype']=='analog') {
                  //$_SESSION['PANELS_CHARTS'][$chart['name']."-".$panel['id']]=$chart;
            ?>
               <div style="width:100%;margin:0 auto;text-align:center;" class="devlist-item devlist-item-theme-<?=$_DOMOTIKA['gui_theme']?>">
                  <div>
                     <button type="button" data-domotika-type="btn-choosestatuses" 
                        id="thermo-btnchoosestatus-<?=$button['id']."-".$panel['id']?>"
                        class="btn btn-primary" style="width:150px;height:40px;"><b><?=$climastatus?></b>
                        <i class="glyphicon glyphicon-chevron-down"></i>
                     </button>
                  </div>
                  <div  id="thermo-statuschooselist-<?=$button['id']."-".$panel['id']?>"
                      class="panel panel-theme-<?=$_DOMOTIKA['gui_theme']?> thermo-statuspanel text-on-white-theme-<?=$_DOMOTIKA['gui_theme']?>">
                      <div class="notifylist">
                         <div class="list-group theme-<?=$_DOMOTIKA['gui_theme']?>" data-snap-ignore="true">
                            <? foreach($climastatuses as $cs) { if($cs['clima_status']!=$climastatus) { ?>
                               <button type="button" style="width:100%;margin-top:5px;"
                                       data-domotika-statusselect="<?=$cs['clima_status']?>"
                                       data-domotika-type="statuschoose"
                                       data-domotika-panel="thermo-statuschooselist-<?=$button['id']."-".$panel['id']?>"
                                       class="btn btn-success"><?=$cs['clima_status']?></button>
                            <? }} ?>
                         </div>
                      </div>
                   </div>
                  <div style="display:inline-block;margin:0 auto;text-align:center;">
                     <div id="gauge-<?=$button['id']."-".$panel['id']?>" data-domotika-type="gauge" 
                        data-dmval-min="<?=floatval($button['minval'])?>"
                        data-dmval-max="<?=floatval($button['maxval'])?>"
nextime's avatar
nextime committed
82 83
                        data-dmval-low="0.0"
                        data-dmval-high="<?=floatval($thermo['setval'])*floatval($button['divider'])?>"
nextime's avatar
nextime committed
84
                        data-dmval-divider="<?=floatval($button['divider'])?>"
nextime's avatar
nextime committed
85 86 87 88
                        data-dmcolor-min="blue"
                        data-dmcolor-low="blue"
                        data-dmcolor-medium="blue"
                        data-dmcolor-high="red"
nextime's avatar
nextime committed
89 90 91 92 93 94 95 96
                        data-domotika-name="<?=$button['button_name']?>"
                        data-dmval="<?=floatval($button['status'])?>"
                        data-domotika-label="<?=$button['unit']?>"
                        data-domotika-gaugeid="<?=$button['id']?>" style="height:250px;min-width:240px;margin:0 auto;text-align:center;">
                     </div>
                   </div>
                   <div style="display:inline-block;width:20%;min-width:68px;height:250px;margin:0 auto;text-align:center;">
                      <div><button type="button" id="thermo-showset-<?=$button['id']."-".$panel['id']?>" class="btn btn-gray">--.-</button></div>
nextime's avatar
nextime committed
97 98 99 100
                      <div style="margin:0 auto;text-align:center;height:150px;margin-top:25px;margin-bottom:25px;"
                           data-domotika-maxval="<?=$thermo['maxslide']?>"
                           data-domotika-minval="<?=$thermo['minslide']?>" 
                           data-domotika-setval="<?=$thermo['setval']?>"
nextime's avatar
nextime committed
101 102 103
                           id="thermo-level-<?=$button['id']."-".$panel['id']?>" data-domotika-type="thermo-level">
                      </div>
                      <div class="btn-group">
nextime's avatar
nextime committed
104 105 106 107 108 109
                        <button type="button" class="btn btn-primary btn-small"
                              id="thermo-minus-<?=$button['id']."-".$panel['id']?>">
                              <i class="glyphicon glyphicon-chevron-down"></i></button>
                        <button type="button" class="btn btn-danger btn-small"
                              id="thermo-plus-<?=$button['id']."-".$panel['id']?>">
                              <i class="glyphicon glyphicon-chevron-up"></i></button>
nextime's avatar
nextime committed
110 111 112
                     </div>
                   </div>
                  <div style="margin-top:45px;">
nextime's avatar
nextime committed
113 114 115 116 117 118 119 120 121 122 123 124
                     <button type="button" class="btn btn-gray " 
                        id="thermo-btnmanual-<?=$button['id']."-".$panel['id']?>"
                        data-dmcolor-on="btn-primary"
                        data-dmcolor-off="btn-gray"
                        data-domotika-type="btnmanual"
                        style="width:150px;height:40px;"><b>Manual</b></button>
                     <button type="button" class="btn btn-primary " 
                        id="thermo-btnprogram-<?=$button['id']."-".$panel['id']?>"
                        data-dmcolor-on="btn-primary"
                        data-dmcolor-off="btn-gray"
                        data-domotika-type="btnprogram"
                        style="width:150px;height:40px;"><b>Program</b></button>
nextime's avatar
nextime committed
125 126 127 128 129 130 131 132 133 134 135
                  </div>
               </div>
            <?
               }
            }?>

         </div>
      </div>
    </div>
 </div>
<?}?>