<?php
include_once(_DIR_EXT.'/aspmo_reports/report_mo3.php') ;
class report_mo_otstrannye extends report_mo3
{
 public $view_by_space_filter=1 ;
 var $title='Журнал учета водителей, отстраненных от рейса' ;

 function __construct($create_options=array())
  { parent::__construct($create_options) ;
    $this->filter['dopusk'][2]=1 ;
  }

 function _setting($options=array())
{

  ?><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">Подразделениe:</label>
                               <label class="select">
                                    <select name="filter[dep_id]"><option value="0">Все</option>
                                      <? echo PERSONAL()->get_select_option(1,$this->filter['dep_id']) ;?>
                                    </select>
                               </label>
                           </section>
                           <?$arr_groups=execSQL_row('select pkey,obj_name,clss from obj_site_account where clss=206')?>
                           <section class="col col-2">
                               <label class="label">Группа:</label>
                               <label class="select">
                                   <select name="filter[group_id]"><option value="0">Все</option><?
                                     if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$name) {?><option value="<?echo $id?>" <?if($this->filter['group_id']==$id) echo 'selected'?>><?echo $name?></option><?}?>
                                   </select>
                               </label>
                           </section>
                           <section class="col col-2">
                               <label class="label">Тип контроля:</label>
                               <label class="select">
                                   <select name="filter[tk]"><option value="0">Все</option><?
                                     if (_sizeof($_SESSION['ARR_mo_tk_type'])) foreach($_SESSION['ARR_mo_tk_type'] as $id=>$name) {?><option value="<?echo $id+1?>" <?if($this->filter['tk']==($id+1)) echo 'selected'?>><?echo $name?></option><?}?>
                                   </select>
                               </label>
                           </section>
                           <section class="col col-2">
                               <label class="label">От:</label>
                               <label class="input"><input type="text" name="filter[data_from]" class="datetimepicker" data-required value="<?echo $this->filter['data_from']?>"></label>
                           </section>
                           <section class="col col-2">
                               <label class="label">До:</label>
                               <label class="input"><input type="text" name="filter[data_to]" class="datetimepicker" data-required value="<?echo $this->filter['data_to']?>"></label>
                           </section>
                       </div>
                   </fieldset>
                   <?$this->panel_buttons();?>
               </form>
   </div>
  <?
}

function print_template_HTML($list_recs,$options=array())
{
    //damp_array($_POST) ;

    $id=($options['id'])? 'id='.$options['id']:'' ;
       ?>
         <table class="basic fz_small full auto">
           <colgroup><col id="c0"><col id="c1"><col id="c3"><col id="c4"><col id="c11"><col id="c12"><col id="c13"></colgroup>
           <tr><th rowspan="2">№</th>
               <th rowspan="2">Фамилия, имя, отчество</th>
               <th rowspan="2">Дата рождения</th>
               <th rowspan="2">Профессия (должность)</th>
               <th rowspan="2">Дата обследования</th>
               <th rowspan="2">Время обследования</th>
               <th colspan="2">Причина обследования</th>
               <th rowspan="2">Подпись мед.работника</th>
           </tr>
           <tr>
               <th>Данные обследования</th>
               <th>Заключение</th>
           </tr>
           <?
           $i=$this->first_obj ; ;
           if (_sizeof($list_recs)) foreach($list_recs as $rec)
           {   if (!isset($recs_doctor[$rec['doctor_id']])) $recs_doctor[$rec['doctor_id']]=ACCOUNTS()->get_member_by_id($rec['doctor_id']) ;
               $rec_doctor=$recs_doctor[$rec['doctor_id']] ;
               ?><tr class=item>
                   <td><?echo '<a href="/cab/mo/'.$rec['pkey'].'/" target=_blank>'.$i.'</a>' ;  $i++ ;?></td>
                   <td class="left"><?echo $rec['member_name']?></td>
                   <td><?if ($rec['member_dr']) echo $rec['member_dr'];?></td>
                   <td class="left"><?echo $rec['_work_name'];?></td>
                   <td><?echo date('d.m.Y',$rec['c_data'])?></td>
                   <td><?echo date('H:i',$rec['c_data'])?></td>
                   <td class="left"><?
                       if ($rec['res_s']>1 or $rec['res_d']>1) echo '<strong>АД</strong>: '.$rec['_sd'].'<br>' ;
                       if ($rec['res_p']>1)                   echo '<strong>Пульс</strong>: '.$rec['_pulse'] ;
                       if ($rec['res_t']>1)                    echo '<strong>Температура</strong>: '.$rec['_temperature'] ;
                       if ($rec['res_a']>1)                    echo '<strong>Алкоголь</strong>: '.$rec['_alko'] ;
                       if ($rec['_question']>1)                echo '<strong>Жалобы</strong>: '.$rec['_question'] ;

                       ?>
                   </td>
                   <td class="left"><? $arr=array() ;
                         if ($rec['_comment'])  $arr[]=$rec['_comment'] ;
                         if ($rec['question_comment'])  $arr[]=$rec['question_comment'] ;
                         if ($rec['status']>=2 and $rec['status']<=3 and $rec['simptoms']) $arr[]=_IL('IL_diagnoz')->recs[$rec['simptoms']]['obj_name'] ;
                         if ($rec['doctor_fixed_comment']) $arr[]=$rec['doctor_fixed_comment'];
                         if ($rec['doctor_comment']) $arr[]=$rec['doctor_comment'];
                         if (_sizeof($arr)) echo implode('<br>',$arr) ;
                       ?></td>
                   <td><?if($rec_doctor['signature']){?><img src="<?echo img_clone($rec_doctor['signature'],'source')?>" width="100"><?}?></td>
               </tr><?
           }
         ?></table><?

//        damp_array($rec,1,-1) ;

    // обязательно возвращем id записей отчета - они будут сохранены в базе
    return(array_keys($list_recs)) ;
}


}


?>
