<?php
include_once(_DIR_TO_CLASS.'/c_page.php') ;
class c_page_cab_doc extends c_page
{
 public $rec_doc ;

 function select_obj_info()
  { if (_CUR_ID)
    { $this->rec_doc=DOCS()->get_doc_by_id(_CUR_ID) ;
      if ($this->rec_doc['pkey'])
      { $this->h1=$this->rec_doc['obj_name'] ;
        $this->no_panel_smena_is_out=1 ;
      }
      else $this->result=404 ;
    }
  }

 function get_cur_page_meta_tags()
 {
   //if (is_object($this->doc_obj)) $this->h1=$this->doc_obj->title ;
 }

 function second_menu_config()
 { $this->second_menu['/cab/reports/']=array('title'=>'Все отчеты','class'=>'fa fa-file-text-o') ;
   if (_sizeof($this->arr_allow_reports)>1) foreach($this->arr_allow_reports as $system_name=>$arr_reports)
        $this->second_menu['/cab/reports/[group='.$system_name.']/']=array('title'=>$system_name,'class'=>'fa fa-file-text-o') ;

   //if (is_object($this->doc_obj)) $this->second_menu[$this->doc_obj->url_report]=array('title'=>$this->doc_obj->title,'class'=>'fa fa-file-text-o') ;  ;
 }


 function block_main()
 { if (_CUR_ID) $this->panel_doc_view() ;
   else         $this->panel_doc_create() ;
 }

 function panel_doc_create()
 { $res=DOCS()->doc_create('doc/'._CUR_DOC_EXT.'/'._CUR_DOC_CODE,$this->filter,array('obj_reffer'=>$_POST['obj_reffer'],'report_seria'=>$_POST['report_seria'],'pdf_options'=>$_POST['pdf_options'])) ;
     //damp_array($res,1,-1) ;
   if (!$res['error'])
     {  $url_page_doc_view=_PATH_TO_SITE.'/cab/doc/'._CUR_DOC_EXT.'/'._CUR_DOC_CODE.'/'.$res['doc_id'].'/' ;
        DOC()->panel_view_pdf_convert($res['result_convert']['cmd_uid'],$url_page_doc_view) ;
     }
   else {?><div class="alert"><?echo $res['error']?></div><?}
 }



}
?>
