<?php
include_once("c_esmo_magnit_pmo_card_personals_in_process.php");
class c_page_cab_esmo_magnit_pmo_card_personals_org_notice extends c_page_cab_esmo_magnit_pmo_card_personals_in_process
{
  public $h1='Редактирование параметров ПМО - email организаций' ;
  public $rec_doc=array();

  function select_obj_info()
  {  parent::select_obj_info();
     if ($this->rec_event['pkey']) $this->h1=$this->obj_event->name.' "'.$this->rec_event['obj_name'].'" - сроки по организациям' ;
  }


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

  function panel_select_dates()
   {   // получаем список всех организаций, которые участвуют в мероприятии
       // получаем список всех организаций на основании данных сотрудников вьювера мероприятия
       $arr_orgs=execSQL('select so.parent2,count(distinct(so.personal_id)) as cnt,org.obj_name
                               from '.$this->rec_event['viewer_name'].' tv
                               left join obj_site_workers so on so.personal_id=tv.pkey
                               left join obj_site_personals org on org.pkey=so.parent2
                               left join obj_site_events_pass pass on pass.personal_id=tv.pkey and pass.event_id='.$this->rec_event['pkey'].'
                               where pass.status in (2,3,4,5,22,6,7)
                               group by so.parent2
                               ');


       //execSQL('select * from '.$this->rec_event['viewer_name'].'',2) ;
       //execSQL('select * from obj_site_events_pass where event_id=26',2) ;
     ?><div id="panel_debug"></div><div id="panel_filter"><?
          ?><table class="basic fz_small auto"><tr class="head"><th>Организация</th><th>Email контактного лица</th><th>Число сотрудников на прохождение ПМО</th><th></th></tr><?
           if (_sizeof($arr_orgs)) foreach($arr_orgs as $rec)
           {  $org_id=$rec['parent2'] ;
              $email=(isset($this->rec_event['_ext_info']['emails_to_orgs'][$org_id]))? $this->rec_event['_ext_info']['emails_to_orgs'][$org_id]:'' ; // должна быть теккуща дата
              ?><tr>
                 <td class="left"><?echo $rec['obj_name']?></td>
                 <td class="center"><?echo $email?></td>
                 <td class="center"><?echo $rec['cnt']?></td>
               <td class="center"><?if ($email){?><button class="v2" cmd="esmo_magnit_pmo/send_doc_pach" org_id="<?echo $org_id?>" event_id="<?echo $this->rec_event['pkey']?>">Отправить список сотрудников</button><?}?></td>
               </tr>
             <?
           }
           ?>
            </table><br>
           </div>
           <?
       //damp_array($this->rec_event,1,-1) ;
      }


}
?>
