<?php
class report_personal_passcard extends c_report
{
 var $title='Пропуск сотрудника' ;
 var $view_by_space_filter=1 ;
 var $allow_org_ids=1 ;
 var $usl_select_org='' ;
 public $use_datepicker=1 ;

 function setting($options=array())
    {   if ($this->filter['personal_id'] and !$this->filter['name']) $this->filter['name']=PERSONAL()->get_name_by_id($this->filter['personal_id']) ;
        ?><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" id="person_info">
                              <section class="col col-2">
                                  <label class="label">ФИО сотрудника</label>
                                  <label class="input">
                                       <input type="text" name="filter[name]" placeholder="" SetAutoComplete cmd="autocomplette_personal_name" value="<?echo $this->filter['name']?>">
                                  </label>
                              </section>
                             <section class="col col-2">
                                 <label class="label">Номер пропуска</label>
                                 <label class="input">
                                     <input type="text" name="filter[propusk]" placeholder="" LANG="LAT" value="<?echo $this->filter['propusk']?>">
                                 </label>
                             </section>
                           </div>
                     </fieldset>
                     <?$this->panel_button_apply();?>
                 </form>
          </div><br>
        <?
     }


  function create_usl_select_obj($_params,&$options)
  {  //damp_array($this->filter,1,-1) ;
     $usl=array() ;
     $usl[]='clss=211' ;
     if ($this->filter['personal_id'])              $usl[]='pkey='.$this->filter['personal_id'];
     //if ($this->personal_ids)              $usl[]='pkey in ('.$this->personal_ids.')';
     $usl_res=implode(' and ',$usl) ;
     //damp_array($usl,1,-1) ;
     return($usl_res) ;
  }


  function get_cnt_items($usl,$options=array())
  { $cnt=execSQL_value('select count(pkey) from  '.PERSONAL()->view_personal.' where '.$usl,$options) ;
    return($cnt) ;
  }

  function get_items($usl,$options=array())
  { $limit=($options['limit'])? ' '.$options['limit']:'' ;
    $order=($this->filter['order'])? ' order by '.$this->filter['order']:' order by c_data desc' ;
    $options['debug']=0 ;
 	$list_rec=execSQL('select *
                       from  '.PERSONAL()->view_personal.'
                       where '.$usl.$order.$limit,$options) ;
    if (_sizeof($list_rec))
    { foreach($list_rec as $id=>$rec) PERSONAL()->prepare_public_info_to_personal($list_rec[$id],$options) ;
    }
    return($list_rec) ;
  }


    // шаблон - вывод ссылками без разделитея
    function print_template_HTML($recs,$options=array())
      {
        if (_sizeof($recs)) foreach($recs as $rec)
        {   $arr_name=explode(' ',$rec['obj_name']) ;
            ?><div id="panel_propusk_view">
             <table class="account_info">
             <tr>
               <td class="img"><div class="photo"></div></td>
               <td class="info"><br><br><br><br>
                 <font size="11">ПРОПУСК<?echo ($rec['propusk'])? '№ '.$rec['propusk']:''?></font><br><br>
                 <font size="14"><strong><?echo $arr_name[0]?></strong></font><br>
                 <font size="14"><strong><?echo $arr_name[1]?></strong></font><br>
                 <font size="14"><strong><?echo $arr_name[2]?></strong></font><br><br>
                 <font size="8">Дата рождения: <strong><?echo $rec['dr']?></strong></font>
              </td>
             </tr>
             </table>
           </div>
         <?}?>
         <style>
             div#panel_propusk_view{width:480px;position:relative;}
             div#panel_propusk_view div.title{font-weight:bold;text-align:center;}
             div#panel_propusk_view p{margin:0;padding:0;}
             div#panel_propusk_view table.account_info{width:100%;}
             div#panel_propusk_view table.account_info td.img{width:180px;}
             div#panel_propusk_view table.account_info td.info{width:auto;}
         </style>
         <?
      }
}
?>
