<?php
include_once("c_events_opo_card_edit_step1.php");
class c_page_cab_events_opo_card_edit_step4 extends c_page_cab_events_opo_card_edit_step1
{
  public $h1='Редактирование параметров ОПО - срок действия ОПО' ;
  function block_main()
  { $this->page_title() ;
    $this->panel_setup_PMO_len() ;
  }

  function panel_setup_PMO_len()
  {   //damp_array($this->rec_event['_ext_info']['pmo_len_union'],1,-1);
      $this->form_open() ;
      ?>
        <table class="basic fz_small full auto">
            <tr>
                <th>Выбор</th>
                <th>Срок действия ОПО</th>
                <th>Основание выбора срока ОПО</th>
                <th>Число сотрудников</th>
            </tr>
            <tr>
                <td></td>
                <td><?$this->form->select(['name'=>'pmo_len_def','recs'=>OPO()->arr_opo_len,'value'=>$this->rec_event['_ext_info']['pmo_len'],'style'=>'_width:150px;text-align:center;float:none;display:inline;']);?></td>
                <td class="left">значение по умолчанию для всех участников ОПО</td>
                <td><? $cnt=execSQL_value('select count(*) from '.$this->rec_event['viewer_name'].' ') ;
                       echo $cnt ;
                    ?></td>
            </tr>
            <tr>
                <td><input type="checkbox" name="_check_vpf" value="1" <?if ($this->rec_event['_ext_info']['pmo_len_union']['use_vpf']) echo 'checked=1'?></td>
                <td>в настройках ВФП</td>
                <td class="left">на основнии ВПФ по ИНРМ сотрудника</td>
                <td><? $cnt=execSQL_value('select count(distinct(personal_id)) from obj_site_workers  where inrm!="" and enabled=1') ;
                      echo $cnt ;
                    ?></td>
            </tr>
            <tr>
            </tr></table><br><?
      $this->button('Сохранить','save_pmo_len_info',array('cmd_method'=>'v1','cmd'=>'save_pmo_len_info','title'=>'Сохранить')) ;
      $this->form_close() ;
  }


  function CMD_save_pmo_len_info()
  {
      //damp_array($_POST);
      $data=[] ;
      if ($_POST['filter']['pmo_len_def']) $data['pmo_len']=$_POST['filter']['pmo_len_def'] ; // исправить, pmo_len_def должны быть сразу в POST
      if ($_POST['_check_vpf']) $data['pmo_len_union']['use_vpf']=1 ;
      if (_sizeof($_POST['_check_gb'])) foreach($_POST['_check_gb'] as $gb_id=>$use) $data['pmo_len_union']['use_gb'][$gb_id]=$_POST['pmo_len'][$gb_id] ;
      //damp_array($data,1,-1);
      //$data['']
      EVENTS()->save_events($this->rec_event['pkey'],$data) ;
      $this->select_obj_info() ;
  }
  function CMD_save_event()
  { //damp_array($_POST) ;
    EVENTS()->save_events($this->rec_event['pkey'],$_POST['filter']) ;
    if (!$this->rec_event['enabled']) redirect_301_to($this->rec_event['__href'].'/personals/free/') ;
    else $this->rec_event=EVENTS()->get_event_by_id($this->rec_event['pkey']) ;
  }



}
?>
