<?php
include_once("c_esmo_magnit_instruction_lession.php");
class c_page_cab_esmo_magnit_instruction_lession_register extends c_page_cab_esmo_magnit_instruction_lession
{
  public $h1='Занятие по инструктажу - регистрация участников' ;

  function block_main()
  { $this->page_title('Регистрация сотрудников на занятие по "'.$this->rec_event['obj_name'].'"') ;
    $this->panel_lession_info() ;
    $this->panel_lession_themes() ;

    //damp_array($this->rec_event,1,-1) ;
    $this->select_personal() ;
    $this->page_title('Зарегистрированные на инструктаж сотрудники') ;
    $this->panel_personal_status_4() ;
    //execSQL('select * from view_event_personals where event_id='.$this->rec_event['pkey'].' order by event_status desc limit 10',2) ;
    ?><div id="panel_reg_personal_to_start_inst"></div>
      <style type="text/css">
        #panel_reg_personal_to_start_inst{}
        #panel_reg_personal_to_start_inst div.item{float:left;text-align:center;}
      </style>
    <?
  }


  function select_personal($options=array())
   {   if (!is_array($options['disabled_filter'])) $options['disabled_filter']=array() ;
       ?><div id="panel_filter">
               <form id="sky-form" class="sky-form">
                   <fieldset>
                      <div class="row">
                          <section class="col col-3">
                                 <label class="label">Пропуск</label>
                                 <label class="input"><input type="text" id=propusk name="propusk" value=""></label>
                          </section>
                          <section class="col col-3">
                                 <label class="label">&nbsp;</label>
                                 <button class="button v2" event_id="<?echo $this->rec_event['pkey']?>" lession_id="<?echo $this->rec_lession['pkey']?>" cmd="esmo_magnit_instruction/reg_personal_in_lession" style="margin:0;float:none;">Поиск</button>
                          </section>
                          <section class="col col-6">
                                 <label class="label">&nbsp;</label>
                              <button class="button v2" cmd="esmo_magnit_instruction/cancel_lession" lession_id=<?echo $this->rec_lession['pkey']?> style="margin-top:0;margin-bottom:0;">Отменить занятие</button>
                              <button class="button v2" cmd="esmo_magnit_instruction/start_lession" lession_id=<?echo $this->rec_lession['pkey']?> style="margin-top:0;margin-bottom:0;">Начать занятие</button>
                          </section>
                      </div>
                  </fieldset>
                </form>
         </div><br>
         <script type="text/javascript">
         $j(document).ready(function()
           {
               $j('body').everyTime(1000,'set_focus',function(){$j('#propusk').focus();})
               $j('#propusk').on('keyup',function()
                                     {   console.log('propusk length='+$j(this).val().length) ;
                                         if ($j(this).val().length==14) send_ajax_request({cmd:"esmo_magnit_instruction/reg_personal_in_lession",
                                                                                          event_id:<?echo $this->rec_event['pkey']?>,
                                                                                          lession_id:<?echo $this->rec_lession['pkey']?>,
                                                                                          propusk:$j(this).val()
                                                                                         }) ;
                                     }) ;
            });
         </script>
       <?
   }

  function panel_personal_status_4()
  { $usl=array() ;
    $usl[]='clss=211';
    $usl[]='event_id='.$this->rec_event['pkey'] ;
    $usl[]='lession_id='.$this->rec_lession['pkey'] ;
    //$usl[]='event_status in (4)' ;
    $recs=execSQL('select * from view_lession_personals where '.implode(' and ',$usl).' order by lession_person_pkey desc') ;
    echo 'На занятие '.get_case_by_count_1_2_5(_sizeof($recs),'зарегистрирован,зарегистрировано,зарегистрированы').' <strong>'._sizeof($recs).'</strong> '.get_case_by_count_1_2_5(_sizeof($recs),'сотрудник,сотрудника,сотрудников').'<br><br>';
       ?><table id="panel_reg_personal_to_start_inst"><?
       $col=0 ;
       if (_sizeof($recs)) foreach($recs as $rec)
           {  if (!$col) echo '<tr>' ; $col++ ;

              ?><td class="item right"><img class="photo" src="<?echo img_clone($rec,'200')?>"  height="266" width="200"></td>
                <td class="item">
                    <div class="name"><?echo $rec['obj_name']?></div>
                    <div class="propusk small"><?echo $rec['propusk']?></div>
                    <div class="org_name"><?echo $rec['_org_name']?></div>
                    <div class="otdel_name"><?echo $rec['_otdel_name']?></div>
                    <div class="working_name"><?echo $rec['working_name']?></div>

                    <?if ($rec['lession_person_status']==1) {?><button class="v2" cmd="esmo_magnit_instruction/lession_personal_unregister" event_id=<?echo $rec['event_id']?> lession_id=<?echo $rec['lession_id']?> personal_id="<?echo $rec['pkey']?>">Исключить</button><?}?>
                    <div class="clear"></div>
               </td><?
               if ($col==3) { echo '</tr>' ; $col=0  ;}

           }
       ?></table>
         <style type="text/css">
                 #panel_reg_personal_to_start_inst{width:auto;table-layout:fixed;}
                 #panel_reg_personal_to_start_inst td{vertical-align:top;text-align:left;padding-bottom:25px;width:210px;}
                 #panel_reg_personal_to_start_inst td.item img{border:1px solid #aaaaaa;float:left;}
                 #panel_reg_personal_to_start_inst td.item .name{font-size:16px;font-weight:bold;}
                 #panel_reg_personal_to_start_inst td.item div.org_name{font-size:13px;}
                 #panel_reg_personal_to_start_inst td.item div.otdel_name{font-size:11px;}
                 #panel_reg_personal_to_start_inst td.item div.working_name{font-size:11px;margin-bottom:12px;}
         </style>
    <?
  }




}



?>
