<?php
include_once('c_rmt.php') ;
class c_page_cab_rmt_to extends c_page_cab_rmt
{
 public $h1='Технический осмотр' ;
 //public $page_type='window' ;
 //public $body_type='window' ;

 function set_head_tags()
 {parent::set_head_tags() ;
  $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_ecp/script.js' ; // для подписи путевых листов
 }

 function menu_config()
 {
   if (!isset($_GET['print']) or isset($_GET['tablet'])) parent::menu_config() ;
 }

 function select_obj_info()
 { if (_CUR_ID)
    { $this->rec_TO=CAR_TO()->get_TO_by_id(_CUR_ID) ;
      if ($this->rec_TO['pkey'])
      { $this->rec_personal=ESMO()->get_personal_by_id($this->rec_TO['personal_id']) ;
        $this->rec_MO=ESMO()->get_mo_by_id($this->rec_TO['mo_id']) ;

      }
      else $this->result=404 ;
    }
   if (isset($_GET['print']) and !isset($_GET['tablet'])) $this->page_type='window' ;
 }

 function get_cur_page_meta_tags()
 {
   if ($this->rec_personal['pkey']) $this->h1='ТО авто сотрудника '.$this->rec_personal['obj_name'] ;
 }


 function second_menu_config()
 { if ($this->rec_TO['pkey'])
   { if (isset($_GET['tablet'])) $this->second_menu['/cab/rmt/check_s/']=array('title'=>'Новый осмотр') ;
     $this->second_menu[$this->rec_TO['__href']]=array('title'=>'ТО "'.$this->rec_personal['obj_name'].'"','class'=>'fa fa-user-md') ;
     //$this->second_menu[$this->rec_TO['__href'].'log/']=array('title'=>'Журнал событий','class'=>'fa fa-user-md') ;
     //$this->second_menu[$this->rec_TO['__href'].'db/']=array('title'=>'Исходные данные','class'=>'fa fa-user-md') ;
   }
   else parent::second_menu_config() ;
 }


 function block_main()
 {  if (MEMBER()->certificate['SerialNumber']) {?><object type="application/x-rutoken-pki" id="plugin-object" width="0" height="0"><param name="onload" value="onPluginLoaded"/></object><?}
    $this->page_title() ;
    if ($this->rec_TO['pkey'])
    { $this->panel_TO() ;
      if (isset($_GET['print']))
      {$this->use_printPage=1 ;
       ?><script type="text/javascript">
        $j(document).ready(function()
           {  $j('div#div_backgroudPrint').printPage({url:'/docs/<?echo $this->rec_TO['doc_name']?>'}) ;
                 $j('div#div_backgroudPrint').click() ;
           }) ;
               </script><?
      }
    }
    else
    { $this->panel_filter_TO() ;

    }
 }

 function panel_TO()
 { include_once('panel_driver_info.php');
   include_once('panel_check_result.php');
   include_once('panel_TO_info.php');
   include_once('panel_MO_info.php');

   ?><div id="panel_TO">
           <?$this->panel_img_mo_view();?>
           <table class="col2x">
             <tr><td class="info">
                     <?if ($this->rec_TO['doc_name']){?><iframe name="PDF_INV" src="http://<?echo _MAIN_DOMAIN?>/docs/<?echo $this->rec_TO['doc_name']?>" style="width:718px; height:700px;" frameborder="1"></iframe><br><br><?}?>
                     <?if (MEMBER()->certificate['SerialNumber']) {?><button class="v2" cmd="aspmo_ecp/sign_doc" doc_id="<?echo $this->rec_TO['doc_id']?>">Подписать документ</button><?}?>
                     <button class="v2" cmd="aspmo_rmt/recreate_put_list" to_id="<?echo $this->rec_TO['pkey']?>">Пересоздать путевой лист</button>

             </td>
                 <td class="krit"><? panel_check_result($this->rec_TO) ; ?></td>
             </tr>
             <tr><td><?panel_driver_info($this->rec_personal,array());?></td>
                 <td><? panel_TO_info($this->rec_TO,array('read_only'=>1)) ;
                        panel_MO_info($this->rec_MO,array('read_only'=>1)) ;
                     ?>
                 </td>

             </tr>
           </table>
      </div>
   <?
 }

}
?>