<?php
include_once (_DIR_EXT.'/events/report_events_info.php') ;
class report_events_poll_info extends report_events_info
{
 var $title='Мероприятия контроля знаний' ;
 var $ext='events_poll%' ;

    function panel_report_buttons($options=array())
      {
          if(MEMBER()->rol==1)
          {
              if($this->status!=5)
              { ?>
                  <button use_form="form_report" class="button v2" cmd="events/check_to_arhive">В архив</button>&nbsp;&nbsp;<?
              }
              else
              { ?>
                  <button use_form="form_report" class="button v2" cmd="events/check_out_arhive">Из архива</button>&nbsp;&nbsp;<?
              }

          }
          if ($options['show_button_create_event']) {?><button use_form="form_report" class="button v2" cmd="events/create_event" event_type="events_poll/i_event_poll">Новое мероприятие опроса</button><?}
      }

  function print_template_HTML($list_recs,$options=array())
  { $id=($options['id'])? 'id='.$options['id']:'' ;
    if (_sizeof($list_recs)) $arr_themes=execSQL('select pkey,obj_name,event_id from poll_themes where event_id in ('.implode(',',array_keys($list_recs)).')') ;
    else $arr_themes=[] ;
    $arr_themes_for_event=array() ;
    if (_sizeof($arr_themes)) foreach($arr_themes as  $rec_themes) $arr_themes_for_event[$rec_themes['event_id']][]=$rec_themes['obj_name'] ;
    ?><form id="form_report"><table class="basic fz_small full auto"<?echo $id?>>
        <tr><?if (MEMBER()->rol==1){?><th>Выбор</th><?}?>
            <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>
        </tr><?
          if (_sizeof($list_recs)) foreach($list_recs as $rec)
          {   // данные по участникам мероприятия с учетом группы текущего аккаунта
              $arr_personals_status=EVENTS()->get_event_personals_status($rec['pkey'],0,MEMBER()->setting['personal']['usl_select']) ;
              $personals_count=array_sum($arr_personals_status) ;
              $cnt_in=$arr_personals_status[1] ;
              $cnt_process=$arr_personals_status[2];
              $cnt_end=$arr_personals_status[3] ;
              $kv=($personals_count)? $cnt_end/$personals_count*100:0 ;
              $themes_info=(_sizeof($arr_themes_for_event[$rec['pkey']]))? '<div class="green">Темы КЗ: '.implode(', ',$arr_themes_for_event[$rec['pkey']]).'</div>':'' ;
              ?><tr>
                   <?if (MEMBER()->rol==1){?><td><input type="checkbox" name="_check[<?echo $rec['pkey']?>]" value="1"></td><?}?>
                  <td><?echo $rec['pkey']?></td>
                  <td><?echo date('d.m.Y H:i',$rec['c_data'])?><??></td>
                  <td><?echo $rec['_status']?></td>
                  <td class="left"><?echo $rec['__href_name']?></td>
                  <td><?echo $rec['_date_from_to'].$rec['_day_status'].$rec['_time_status']?></td>
                  <td><? echo $rec['_group_ids']?></td>
                  <td><? echo $rec['_ext_info']['info_filter'].$themes_info ;?></td>
                  <td><?echo $rec['_close_period']?><?echo $rec['_close_status']?></td>
                  <td><?echo ($personals_count)? $personals_count:'-'?></td>
                  <td><?echo ($cnt_in)? $cnt_in:'-'?></td>
                  <td><?echo ($cnt_process)? $cnt_process:'-'?></td>
                  <td><?echo ($cnt_end)? $cnt_end:'-'?></td>
                  <td><?echo ($kv)? '<span class="nowrap">'.round($kv,2).' %</span>':'-'?></td>
              </tr><?
          }
       ?></table></form><?
      //print_2x_arr($list_recs) ;
  }


}

?>
