<?php
include_once (_DIR_EXT.'/events/report_events_info.php') ;
class report_events_meeting_info extends report_events_info
{
 var $title='Собрания' ;

// шаблон - вывод ссылками без разделитея
  function print_template_HTML($list_recs,$options=array())
  { $id=($options['id'])? 'id='.$options['id']:'' ;
    if (_sizeof($list_recs))
    { $stats_lession=execSQL_row('select event_id,count(pkey) 
                                  from obj_site_lession where event_id in ('.implode(',',array_keys($list_recs)).') and status in (4,5)
                                  and  group_id in ('.MEMBER()->cur_groups_visible.') 
                                  group by event_id') ;

      $stats_persons=execSQL_row('select event_id,count(distinct(personal_id)) 
                                  from obj_site_lession_persons
                                  where event_id in ('.implode(',',array_keys($list_recs)).') and status=4 
                                  and  parent in (select distinct(pkey) from obj_site_lession where group_id in ('.MEMBER()->cur_groups_visible.') and event_id in ('.implode(',',array_keys($list_recs)).')) 
                                  group by event_id') ;
    }
    ?><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>Место<br>проведения</th>-->
            <th>Наименование</th>
            <th>Проведено собраний</th>
            <th>Участвовало сотрудников</th>
        </tr><?
          if (_sizeof($list_recs)) foreach($list_recs as $rec)
          {   $ext_info=$rec['_ext_info'] ;
              $cur_groups_visible=explode(',',MEMBER()->cur_groups_visible) ;
              $cur_groups_meeting=(isset($ext_info['filter']['group_ids']))? $ext_info['filter']['group_ids']:[]  ;
              if (_sizeof($cur_groups_meeting) and MEMBER()->rol>1)
              {
                  //print_r($cur_groups_visible) ; echo '<br>' ;
                  //print_r($cur_groups_meeting) ; echo '<br>' ;
                  $arr=array_intersect($cur_groups_visible,array_keys($cur_groups_meeting)) ;
                  //print_r($arr) ; echo '<br>' ;
                  //echo '<hr>' ;
                  $show_link=(_sizeof($arr))? 1:0 ;
              }
              else $show_link=1 ;

              //$show_link=(isset($ext_info['filter']['group_ids']) and isset($ext_info['filter']['group_ids'][$this->group_id]))? 1:0 ;
              //if (!isset($ext_info['filter']['group_ids'])) $show_link=1 ;
              //if (MEMBER()->rol==1) $show_link=1 ;
              if (!$rec['obj_name']) $rec['obj_name']='Собрание # '.$rec['pkey'] ;
              ?><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><?echo ACCOUNTS()->get_group_name($rec['group_id'])?><??></td>-->
                  <!--<td class="nowrap"><?if ($rec['date_from']) echo date('d.m.Y',$rec['date_from']) ; ?></td>-->
                  <td class="left"><?if ($show_link){?><a href="<?echo $rec['__href']?>" target="blank" title="window_event"><?echo $rec['obj_name']?></a><?}
                                     else echo $rec['obj_name'] ; ?>
                  <?
                 //execSQL('select distinct(personal_id) from obj_site_lession_persons where event_id=73 and status=4',2) ;
                  ?>

                  </td>
                  <td><?echo $stats_lession[$rec['pkey']]?></td>
                  <td><?echo $stats_persons[$rec['pkey']]?></td>
              </tr><?
          }
       ?></table></form><?
      //print_2x_arr($list_recs) ;
  }


}

?>
