<?php
include_once("c_esmo_magnit_instruction_lession.php");
class c_page_cab_esmo_magnit_instruction_lession_report extends c_page_cab_esmo_magnit_instruction_lession
{
  public $h1='Занятие по инструктажу - ведомость прохождения' ;
  var $doc_id ;
  var $rec_doc ;
  var $jurnal_class_name ;
  var $report_code ;

  function init($options=array())
  {  parent::init() ;
 	 $this->jurnal_class_name='doc_lession_personal_status' ; //$this->obj_event->report_lessions_jurnal ;
     $this->report_code='lession_personal_status' ; //str_replace('doc_','',$this->jurnal_class_name) ;
     $this->doc_id=execSQL_value('select pkey from obj_site_docs where obj_reffer="'.$this->rec_lession['_reffer'].'" and report_code="'.$this->report_code.'" order by pkey desc limit 1') ;
     if ($this->doc_id) $this->rec_doc=DOCS()->get_doc_by_id($this->doc_id) ;
  }

  function second_menu_config() {}

  function block_main()
  {	 //damp_array($this) ;
  	 if ($this->rec_doc['pkey'])
	 {  $options=array() ;
	    $options['after_delete_doc_go_url']='/window/esmo_magnit_instruction/lession/'.$this->rec_lession['pkey'].'/sign/' ;
	    $options['after_sign_doc_go_url']=_CUR_PAGE_DIR ;
	    $options['doc_sign_page']=_CUR_PAGE_DIR.'sign/' ;
	    $options['sign_before_print']=1 ;
	    $this->panel_doc_view($options) ;
	 }
     else
     {  // покажет HTML-документ с кнопкой "Сохранить в документах",
     	// по нажатию кнопки все hidden_params попадут в class_v.esmo/ext/docs/c_ajax.php:doc_create
	    //
     	include_once(_DIR_EXT.'/events/'.$this->jurnal_class_name.'.php') ;
        $default_filter=array('lession_id'=>$this->rec_lession['pkey']) ;
        $report_obj=new $this->jurnal_class_name(array('default_filter'=>$default_filter)) ;
        $options=array() ;
        $options['url_page_doc_view']=_CUR_PAGE_DIR ;
        $options['filter[lession_id]']=$this->rec_lession['pkey'] ;
        $options['obj_reffer']=$this->rec_lession['_reffer'] ;
	    $options['lession_id']=$this->rec_lession['pkey'] ;
        $options['report_seria']=htmlspecialchars(MEMBER()->cur_group_name);
        $report_obj->setting_small(array('hidden_params'=>$options)) ;
        $report_obj->view() ;
     }
  }
}



?>