<?php
include_once("c_kt_setting.php");
class c_page_cab_kt_setting_device extends c_page_cab_kt_setting
{
  public $h1='Конфигурация устройство контроля трезвости' ;


   function block_main()
   { $this->panel_group_create() ;
     //$this->panel_member_create() ;
     //$this->panel_arm_create() ;
     $this->panel_terminal_create() ;
     $this->panel_terminal_list() ;
   }

   function panel_terminal_list()
   {
       $recs=DEVICE()->get_list_terminals(0,'kt') ;

       ?><table class="basic fz_small auto">
       <tr><th rowspan="2">ID</th><th rowspan="2">Зона доступа</th><th rowspan="2">Наименование</th><th rowspan="2">IP</th><th rowspan="2">Версия ПО</th><th rowspan="2">Состояние</th><th colspan="2">Исправность оборудования</th><th rowspan="2">Карточка терминала</th></tr>
          <tr><th>Видео</th><th>Алкотестер</th></tr>
       <?  if (_sizeof($recs)) foreach($recs as $rec) {?>
          <tr><td><?echo $rec['id']?></td>
              <td class="left"><?echo $rec['_zone_path']?></td>
              <td class="left"><?echo addslashes($rec['obj_name'])?></td>
              <td class="left"><?echo $rec['ip']?></td>
              <td class="center"><?echo $rec['vers']?></td>
              <td class="status"><? echo $_SESSION['ARR_terminal_status_color'][$rec['status']]?></td>
              <td class="status"><img src="/images/status_<? echo $rec['video']?>.png"></td>
              <td class="status"><img src="/images/status_<? echo $rec['alcotester']?>.png"></td>
              <td class="center"><a href="/window/kt/setting/terminal/<?echo $rec['pkey']?>/" class="new_window">Карточка</a></td>
           </tr>
       <?}?>
     </table>
     <?
    }

   function panel_group_create()
     {   $this->page_title('Зоны доступа') ;
         $arr_groups=SKD()->get_list_zone() ;
         ?><div id="panel_filter">
                 <form id="sky-form" class="sky-form">
                     <input type="hidden" name="filter_dir" value="<?echo _CUR_REPORT_DIR?>">
                      <fieldset>
                          <div class="row">
                              <section class="col col-4">
                                  <label class="label">Родительская зона доступа</label>
                                  <label class="select">
                                      <select name="filter[zone_id]">
                                         <?if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['group_id']==$id) echo 'selected'?>><?echo SKD()->get_full_zone_path($id) ?></option><?}?>
                                      </select>
                                  </label>
                              </section>
                              <section class="col col-2">
                                  <label class="label">Название зоны доступа:</label>
                                  <label class="input"><input type="text" data-required name="filter[name]" value="<?echo $this->filter['name']?>"></label>
                              </section>
                          </div>
                      </fieldset>
                     <div id="panel_buttons"><input type="submit" class="button v2" cmd="kt/zone_create" value="Добавить зону доступа"  validate="form"></div><br>
                  </form>
           </div><br>
         <?
     }
 /*
   function panel_member_create()
     {   $arr_groups=ACCOUNTS()->get_list_workgoups(array('usl'=>'(clss=206 and enabled=1) or (clss=1 and parent=1)')) ;
         $this->page_title('Персонал') ;
         ?><div id="panel_filter">
                 <form id="sky-form" class="sky-form">
                     <input type="hidden" name="filter_dir" value="<?echo _CUR_REPORT_DIR?>">
                      <fieldset>
                          <div class="row">
                              <section class="col col-2">
                                  <label class="label">ФИО:</label>
                                  <label class="input"><input type="text" name="filter[name]" data-required value="<?echo $this->filter['name']?>"></label>
                              </section>
                              <section class="col col-2">
                                  <label class="label">Группа</label>
                                  <label class="select">
                                      <select name="filter[group_id]" data-required >
                                         <?if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['group_id']==$id) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                                      </select>
                                  </label>
                              </section>
                              <section class="col col-2">
                               <label class="label">Роль</label>
                               <label class="select" >
                                   <select name="filter[rol]" data-required>
                                      <?if (_sizeof($_SESSION['ARR_roll'])) foreach($_SESSION['ARR_roll'] as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['rol']==$id) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                                   </select>
                               </label>
                              </section>
                          </div>
                          <div class="row">
                              <section class="col col-2">
                                  <label class="label">Логин:</label>
                                  <label class="input"><input type="text" name="filter[login]" data-required  value="<?echo $this->filter['login']?>"></label>
                              </section>
                              <section class="col col-2">
                                  <label class="label">Пароль:</label>
                                  <label class="input"><input type="password" name="filter[password]" data-required  value="<?echo $this->filter['password']?>"></label>
                              </section>
                          </div>
                      </fieldset>
                     <div id="panel_buttons"><input type="submit" class="button v2" cmd="aspmo_setting/account_create" value="Добавить нового сотрудника"  validate="form"></div><br>
                  </form>
           </div><br>
         <?
     }

     function panel_arm_create()
       {   $this->page_title('АРМ ЭСМО') ;
           $arr_groups=ACCOUNTS()->get_list_workgoups() ;
           ?><div id="panel_filter">
                   <form id="sky-form" class="sky-form">
                       <input type="hidden" name="filter_dir" value="<?echo _CUR_REPORT_DIR?>">
                        <fieldset>
                            <div class="row">
                                <section class="col col-2">
                                    <label class="label">Группа</label>
                                    <label class="select">
                                        <select name="filter[group_id]" data-required >
                                           <?if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['group_id']==$id) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                                        </select>
                                    </label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">Название АРМ:</label>
                                    <label class="input"><input type="text" name="filter[name]" data-required  value="<?echo $this->filter['name']?>"></label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">IP адрес:</label>
                                    <label class="input"><input type="text" name="filter[ip]" data-required  value="<?echo $this->filter['ip']?>"></label>
                                </section>
                            </div>
                        </fieldset>
                       <div id="panel_buttons"><input type="submit" class="button v2" cmd="aspmo_setting/arm_create" value="Добавить новый АРМ"  validate="form"></div><br>
                    </form>
             </div><br>
           <?
       }
    */
     function panel_terminal_create()
       {   $this->page_title('Терминалы контроля трезвости') ;
           $arr_groups=SKD()->get_list_zone() ;
           ?><div id="panel_filter">
                   <form id="sky-form" class="sky-form">
                       <input type="hidden" name="filter_dir" value="<?echo _CUR_REPORT_DIR?>">
                        <fieldset>
                            <div class="row">
                                <section class="col col-4">
                                    <label class="label">Зона доступа</label>
                                    <label class="select">
                                        <select name="filter[zone_id]" data-required >
                                           <?if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['zone_id']==$id) echo 'selected'?>><?echo SKD()->get_full_zone_path($id)?></option><?}?>
                                        </select>
                                    </label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">Название терминала:</label>
                                    <label class="input"><input type="text" data-required name="filter[name]" value="<?echo $this->filter['name']?>"></label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">ID терминала:</label>
                                    <label class="input"><input type="text" data-required name="filter[id]" value="<?echo $this->filter['id']?>"></label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">IP адрес:</label>
                                    <label class="input"><input type="text" data-required name="filter[ip]" value="<?echo $this->filter['ip']?>"></label>
                                </section>
                                <section class="col col-2">
                                    <label class="label">Тип контроля:</label>
                                    <label class="select">
                                        <select name="filter[kt_type]">
                                            <option value="0" <?if (!$this->filter['kt_type']) echo 'selected';?>></option>
                                            <option value="1" <?if ($this->filter['kt_type'] == 1) echo 'selected';?>>только предсменный</option>
                                            <option value="2" <?if ($this->filter['kt_type'] == 2) echo 'selected';?>>только послесменный</option>
                                        </select>
                                    </label>
                                </section>
                                <!--<section class="col col-2">
                                 <label class="label">Профиль</label>
                                 <label class="select">
                                     <select name="filter[profil]">
                                        <?if (_sizeof(_IL('IL_term_prof')->recs)) foreach(_IL('IL_term_prof')->recs as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->filter['profil']==$id) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                                     </select>
                                 </label>
                                </section>-->
                            </div>
                        </fieldset>
                       <div id="panel_buttons"><input type="submit" class="button v2" cmd="kt/terminal_create" value="Добавить терминал КТ"  validate="form"></div><br>
                    </form>
             </div><br>
           <?
       }




}



?>
