<?php
include_once(_DIR_EXT."/esmo_magnit_pmo/i_event_pmo.php");
include_once(_DIR_EXT."/esmo_magnit_instruction/i_event_instruction.php");
include_once(_DIR_EXT."/events/c_events.php");

class c_page_cab_esmo_magnit_pmo extends c_page_cab_events
{
	public $h1='ПМО';

	function block_main()
	{ //$this->page_title() ;
		$this->panel_report_scan();
	}

	function panel_report_scan()
	{
		// не используем отчет так число мероприятий ограничено и надо использовать свой шаблон таблицы статистки
		$list_recs=execSQL('select * from obj_site_events_schedule where clss=222 and enabled=1 and status<5 and ext like "esmo_magnit_pmo%" order by pkey desc');
		if(_sizeof($list_recs)) foreach($list_recs as $id=>&$rec) EVENTS()->prepare_public_info_to_event($rec);

		?>
      <table class="basic fz_small full auto">
      <tbody>
      <tr>
          <th>ID</th>
          <th>Дата/время<br>создания</th>
          <th>Статус</th>
          <th>Тип</th>
          <th>Наименование</th>
          <th>Переодичность</th>
          <th>Сроки проведения</th>
          <th>Отбор персонала</th>
          <th>Всего</th>
          <th>Подлежит ПМО</th>
          <th>Дообследование</th>
          <th>Заблокирован по ПМО</th>
          <th>ПМО пройден, годен</th>
          <th>ПМО пройден, не годен</th>
          <th>КВ</th>
      </tr>

			<?
			if(_sizeof($list_recs)) foreach($list_recs as $rec_event)
			{

				$arr_cnt=EVENTS()->get_event_personals_status($rec_event['pkey']);

				$cnt_all=0;
				$status2=0;
				foreach($arr_cnt as $status=>$cnt)
				{
					$cnt_all+=$cnt;
					if($status<7 or $status==22) $status2+=$cnt;
				}
				$kv=round(($arr_cnt[8]+$arr_cnt[9])/$cnt_all*100,1);

				?>
          <tr>
              <td><? echo $rec_event['pkey'] ?></td>
              <td><? echo date('d.m.Y H:i',$rec_event['c_data']) ?><? ?></td>
              <td><? echo $rec_event['_status']; ?></td>
              <td><? echo $rec_event['__type_name'] ?></td>
              <td class="left"><? echo $rec_event['__href_name'] ?></td>
              <td><? echo $rec_event['_mode'] ?></td>
              <td><? echo $rec_event['_date_from_to'].$rec_event['_day_status'].$rec_event['_time_status'] ?></td>
              <td class="left">
                  <div style="max-height:100px;overflow:auto;"><? PERSONALS_FILTER()->get_personals_filter_info_to_item($rec_event['_reffer']); ?></div>
              </td>
              <td><? echo ($cnt_all)? $cnt_all:'-' ?></td>
              <td><? echo ($status2)? $status2:'-' ?></td>
              <td><? echo ($arr_cnt[10])? $arr_cnt[10]:'-' ?></td>
              <td><? echo ($arr_cnt[7])? $arr_cnt[7]:'-' ?></td>
              <td><? echo ($arr_cnt[8])? $arr_cnt[8]:'-' ?></td>
              <td><? echo ($arr_cnt[9])? $arr_cnt[9]:'-' ?></td>
              <td><? echo $kv ?>%</td>
          </tr>
			<?
			} ?>
      </tbody></table>

		<?
      if ($GLOBALS['LS_esmo_PMO_event']!=$rec_event['pkey']) update_site_setting('LS_esmo_PMO_event',$rec_event['pkey']) ;
	}
}

?>
