<?php
include_once("c_setting_members_group.php");
class c_page_cab_setting_members_group_mo_schedule extends c_page_cab_setting_members_group
{
  public $h1='Рабочие группы ЭСМО - Расписание МО' ;

 function block_main()
 { $this->page_title() ;
   //damp_array($this->rec_group) ;
   ?><button class="button v2" cmd="aspmo_setting/mo_schedule_check" workgroup_id="<?echo $this->rec_group['pkey']?>">Проверить расписание</button>
     <button class="button v2" cmd="aspmo_setting/mo_schedule_create" workgroup_id="<?echo $this->rec_group['pkey']?>">Добавить расписание</button>
     <br><?
   $this->panel_view_schedule() ;
     //$arr_personal_groups=PERSONAL()->get_list_groups() ;
     //print_2x_arr($arr_personal_groups);
   //$this->panel_create_schedule() ;
 }


    function panel_view_schedule()
      {
          echo '<h2>Текущее расписание для группы:</h2>';

          $recs=execSQL('select * from mo_schedule where work_group_id='.$this->rec_group['pkey'].' order by personal_group_id,pkey') ;
          ?><table class="basic fz_small full auto">
                <tr><th rowspan="2">ID</th>
                    <th rowspan="2">Активность</th>
                    <th rowspan="2">Группа сотрудников</th>
                    <th rowspan="2">Время от</th>
                    <th rowspan="2">Время до</th>
                    <th colspan="7">Дни недели</th>
                    <th rowspan="2">Действие</th>
                    <th rowspan="2">Операции</th>
                </tr>
                <tr>
                    <th>ПН</th>
                    <th>ВТ</th>
                    <th>СР</th>
                    <th>ЧТ</th>
                    <th>ПТ</th>
                    <th>СБ</th>
                    <th>ВС</th>
                </tr>
            <? if (_sizeof($recs)) foreach($recs as $rec)
                {  $days=$arr=str_split($rec['days']) ;
                    ?><tr>
                      <td><?echo $rec['pkey']?></td>
                      <td><?echo ($rec['enabled'])? '<i class="far fa-check-circle green"></i>':'<i class="fas fa-times red"></i>'?></td>
                      <td><?echo _IL('IL_groups')->recs[$rec['personal_group_id']]['obj_name']?></td>
                      <td><?echo $rec['time_from']?></td>
                      <td><?echo $rec['time_to']?></td>
                      <? for($i=1;$i<=7;$i++) if ($days[$i-1]) echo '<td><i class="fas fa-check green"></i></td>' ; else echo '<td><i class="fas fa-times red"></i></i></td>' ; ?>
                      <td><? echo ($rec['action'])? '<span class=green>МО разрешено':'<span class=red>МО запрещено'?></td>
                      <td>
                          <a href="" class="v2" cmd="aspmo_setting/mo_schedule_edit" item_id="<?echo $rec['pkey']?>">Редактировать</a>&nbsp;&nbsp;
                          <a href="" class="v2" cmd="aspmo_setting/mo_schedule_remove" item_id="<?echo $rec['pkey']?>">Удалить</a>
                      </td>
                   </tr>
                <?} ?>
            </table>
          <?
      }




}



?>
