<?php
include_once(_DIR_TO_CLASS."/c_page.php");
class c_page_cab_events_db extends c_page
{ 
  public $h1='Участник мероприятия - исходные данные' ;
  public $page_type='window' ;


  function menu_config()
  { $this->menu['/window/events/status/'._CUR_ID.'/']=array('title'=>'Ведомость занятий') ;
    $this->menu['/window/events/pass/'._CUR_ID.'/']=array('title'=>'История прохождения') ;
    $this->menu['/window/events/db/'._CUR_ID.'/']=array('title'=>'Исходные данные') ;
  }

  function block_main()
  {
	$rec_event_pass=EVENTS()->get_event_pass_by_id(_CUR_ID) ;
  	$event_obj=EVENTS()->get_event_obj_by_id($rec_event_pass['event_id']) ;
    ?><h3>Участие в мероприятии <span class="small">[obj_site_events_pass]</span></h3><?
    unset($rec_event_pass['tkey'],$rec_event_pass['temp'],$rec_event_pass['_reffer'],$rec_event_pass['_parent_reffer'],$rec_event_pass['indx'],$rec_event_pass['_enabled'],$rec_event_pass['obj_name']) ;
      $rec_event_pass['status']=$event_obj->arr_status[$rec_event_pass['status']].' ['.$rec_event_pass['status'].']' ;
    $arr[]=$rec_event_pass ;
    print_2x_arr($arr) ;

	?><h3>Темы мероприятия <span class="small">[obj_site_events_themes]</span></h3><?
	$recs_themes=EVENTS()->get_themes_of_events($rec_event_pass['event_id']) ; $recs_lession=array() ;

	print_2x_arr($recs_themes) ;
	?><h3>Участие сотрудника в занятиях <span class="small">[obj_site_lession_persons]</span></h3><?
	$recs_lession_pass=execSQL('select * from obj_site_lession_persons where personal_id='.$rec_event_pass['personal_id'].' and event_id='.$rec_event_pass['event_id']) ;
    if (_sizeof($recs_lession_pass)) foreach($recs_lession_pass as $id=>$rec)
    {   unset($recs_lession_pass[$id]['tkey'],$recs_lession_pass[$id]['temp'],$recs_lession_pass[$id]['_reffer'],$recs_lession_pass[$id]['_parent_reffer'],$recs_lession_pass[$id]['indx'],$recs_lession_pass[$id]['_enabled']) ;
	    $recs_lession_pass[$id]['status']=$event_obj->arr_status_lession_person[$rec['status']].' ['.$rec['status'].']' ;
    }

	print_2x_arr($recs_lession_pass) ;
	?><h3>Занятия, в которых учавствовал сотрудник <span class="small">[obj_site_lession]</span></h3><?
	$recs_lession=execSQL('select * from obj_site_lession where pkey in (select parent from obj_site_lession_persons where personal_id='.$rec_event_pass['personal_id'].' and event_id='.$rec_event_pass['event_id'].')') ;
	if (_sizeof($recs_lession)) foreach($recs_lession as $id=>$rec)
	{   unset($recs_lession[$id]['tkey'],$recs_lession[$id]['temp'],$recs_lession[$id]['_reffer'],$recs_lession[$id]['_parent_reffer'],$recs_lession[$id]['parent'],$recs_lession[$id]['indx'],$recs_lession[$id]['_enabled']) ;
		$recs_lession[$id]['status']=$event_obj->arr_status_lession[$rec['status']].' ['.$rec['status'].']' ;
	}
	print_2x_arr($recs_lession) ;
	?><h3>Темы, которые были прослушаны на этих занятиях <span class="small">[obj_site_lession_themes]</span></h3><?
	$recs_lession_themes=execSQL('select * from obj_site_lession_themes where parent in (select parent from obj_site_lession_persons where personal_id='.$rec_event_pass['personal_id'].' and event_id='.$rec_event_pass['event_id'].')') ;
	if (_sizeof($recs_lession_themes)) foreach($recs_lession_themes as $id=>$rec)
	{   unset($recs_lession_themes[$id]['tkey'],$recs_lession_themes[$id]['temp'],$recs_lession_themes[$id]['_reffer'],$recs_lession_themes[$id]['_parent_reffer'],$recs_lession_themes[$id]['indx'],$recs_lession[$id]['_enabled']) ;
	 	//$recs_lession[$id]['status']=$event_obj->arr_status_lession[$rec['status']].' ['.$rec['status'].']' ;
	}
	print_2x_arr($recs_lession_themes) ;

	?><h3>История статусов участия в мероприятии <span class="small">[obj_site_events_pass_status]</span></h3><?
	$recs_history=execSQL('select * from obj_site_events_pass_status where personal_id='.$rec_event_pass['personal_id'].' and event_id='.$rec_event_pass['event_id'].' order by pkey desc') ;
	if (_sizeof($recs_history)) foreach($recs_history as $id=>$rec)
	{   unset($recs_history[$id]['tkey'],$recs_history[$id]['temp'],$recs_history[$id]['_reffer'],$recs_history[$id]['_parent_reffer'],$recs_history[$id]['indx'],$recs_history[$id]['_enabled']) ;
	 	//$recs_lession[$id]['status']=$event_obj->arr_status_lession[$rec['status']].' ['.$rec['status'].']' ;
	}
      print_2x_arr($recs_history) ;



  }


}



?>
