<?php
include_once('c_rmt.php') ;
class c_page_cab_rmt_org extends c_page_cab_rmt
{
 public $h1='Справочник организаций' ;
 //public $body_type='window' ;

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


 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'])) $this->page_type='window' ;
 }

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


 function _tabs_config()
 { if (!isset($_GET['print'])) parent::tabs_config() ;
   // вкладки для сотрудника
   if ($this->rec_TO['pkey'])
      { $this->tabs[$this->rec_TO['__href']]='ТО '.$this->rec_personal['obj_name'] ;
        //$this->tabs[$this->rec_TO['__href'].'log/']='Журнал событий' ;
        //$this->tabs[$this->rec_TO['__href'].'db/']='Исходные данные' ;
      }

 }


 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 src="http://docs.google.com/gview?url=http://<?echo _MAIN_DOMAIN?>/docs/<?echo $this->rec_TO['doc_name']?>&embedded=true" style="width:718px; height:700px;" frameborder="0"></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>
   <?
 }

}
?>