<?php
include_once("c_setting_members.php");
class c_page_cab_setting_members_group extends c_page_cab_setting_members
{
  public $h1='Карточка рабочей группы ЭСМО' ;
  public $rec_group=array() ;
  public $ARR_timezones=array (  'Europe/Amsterdam', 'Europe/Andorra', 'Europe/Astrakhan', 'Europe/Athens',
                                           'Europe/Belgrade', 'Europe/Berlin', 'Europe/Bratislava', 'Europe/Brussels',
                                           'Europe/Bucharest', 	'Europe/Budapest', 	'Europe/Busingen', 	'Europe/Chisinau',
                                           'Europe/Copenhagen', 	'Europe/Dublin', 	'Europe/Gibraltar', 	'Europe/Guernsey',
                                           'Europe/Helsinki', 	'Europe/Isle_of_Man', 	'Europe/Istanbul', 	'Europe/Jersey',
                                           'Europe/Kaliningrad', 	'Europe/Kiev', 	'Europe/Kirov', 	'Europe/Lisbon',
                                           'Europe/Ljubljana', 	'Europe/London', 	'Europe/Luxembourg', 	'Europe/Madrid',
                                           'Europe/Malta', 	'Europe/Mariehamn', 	'Europe/Minsk', 	'Europe/Monaco',
                                           'Europe/Moscow', 	'Europe/Oslo', 	'Europe/Paris', 	'Europe/Podgorica',
                                           'Europe/Prague', 	'Europe/Riga', 	'Europe/Rome', 	'Europe/Samara',
                                           'Europe/San_Marino', 	'Europe/Sarajevo', 	'Europe/Saratov', 	'Europe/Simferopol',
                                           'Europe/Skopje', 	'Europe/Sofia', 	'Europe/Stockholm', 	'Europe/Tallinn',
                                           'Europe/Tirane', 	'Europe/Ulyanovsk', 	'Europe/Uzhgorod', 	'Europe/Vaduz',
                                           'Europe/Vatican', 	'Europe/Vienna', 	'Europe/Vilnius', 	'Europe/Volgograd',
                                           'Europe/Warsaw', 	'Europe/Zagreb', 	'Europe/Zaporozhye', 	'Europe/Zurich',
                                           'Asia/Aden', 	'Asia/Almaty', 	'Asia/Amman', 	'Asia/Anadyr',
                                           'Asia/Aqtau', 	'Asia/Aqtobe', 	'Asia/Ashgabat', 	'Asia/Atyrau',
                                           'Asia/Baghdad', 	'Asia/Bahrain', 	'Asia/Baku', 	'Asia/Bangkok',
                                           'Asia/Barnaul', 	'Asia/Beirut', 	'Asia/Bishkek', 	'Asia/Brunei',
                                           'Asia/Chita', 	'Asia/Choibalsan', 	'Asia/Colombo', 	'Asia/Damascus',
                                           'Asia/Dhaka', 	'Asia/Dili', 	'Asia/Dubai', 	'Asia/Dushanbe',
                                           'Asia/Famagusta', 	'Asia/Gaza', 	'Asia/Hebron', 	'Asia/Ho_Chi_Minh',
                                           'Asia/Hong_Kong', 	'Asia/Hovd', 	'Asia/Irkutsk', 	'Asia/Jakarta',
                                           'Asia/Jayapura', 	'Asia/Jerusalem', 	'Asia/Kabul', 	'Asia/Kamchatka',
                                           'Asia/Karachi', 	'Asia/Kathmandu', 	'Asia/Khandyga', 	'Asia/Kolkata',
                                           'Asia/Krasnoyarsk', 	'Asia/Kuala_Lumpur', 	'Asia/Kuching', 	'Asia/Kuwait',
                                           'Asia/Macau', 	'Asia/Magadan', 	'Asia/Makassar', 	'Asia/Manila',
                                           'Asia/Muscat', 	'Asia/Nicosia', 	'Asia/Novokuznetsk', 	'Asia/Novosibirsk',
                                           'Asia/Omsk', 	'Asia/Oral', 	'Asia/Phnom_Penh', 	'Asia/Pontianak',
                                           'Asia/Pyongyang', 	'Asia/Qatar', 	'Asia/Qyzylorda', 	'Asia/Riyadh',
                                           'Asia/Sakhalin', 	'Asia/Samarkand', 	'Asia/Seoul', 	'Asia/Shanghai',
                                           'Asia/Singapore', 	'Asia/Srednekolymsk', 	'Asia/Taipei', 	'Asia/Tashkent',
                                           'Asia/Tbilisi', 	'Asia/Tehran', 	'Asia/Thimphu', 	'Asia/Tokyo',
                                           'Asia/Tomsk', 	'Asia/Ulaanbaatar', 	'Asia/Urumqi', 	'Asia/Ust-Nera',
                                           'Asia/Vientiane', 	'Asia/Vladivostok', 	'Asia/Yakutsk', 	'Asia/Yangon',
                                           'Asia/Yekaterinburg',	'Asia/Yerevan'
       );
  var $arr_mo_type=array(0=>'Все',1=>'Только предсменные',2=>'Только послесменные') ;


 function select_obj_info()
 { $cur_id=(_CUR_ID)? _CUR_ID:MEMBER()->id ;
   $this->rec_group=ACCOUNTS()->get_workgroup_by_id($cur_id) ;
   if (!$this->rec_group['pkey']) $this->result=404 ;
   else $this->h1='Карточка рабочей группы "'.$this->rec_group['obj_name'].'"' ;
 }

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

function menu_config()
 { if (_CUR_ROOT_DIR_NAME=='cab') parent::menu_config() ;
   elseif ($this->rec_group['pkey'])
   { $this->menu[$this->rec_group['__href_window']]=array('title'=>'Карточка группы "'.$this->rec_group['obj_name'].'"','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'terminals/']=array('title'=>'Терминалы','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'arm/']=array('title'=>'АРМы','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'mo_schedule/']=array('title'=>'Расписание МО','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'personals/']=array('title'=>'Персонал группы','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'personals_set/']=array('title'=>'Выбор персонала','_class'=>'fa fa-user-md') ;
     $this->menu[$this->rec_group['__href_window'].'db/']=array('title'=>'Дамп БД','_class'=>'fa fa-user-md') ;
   }
 }

 function _second_menu_config()
 { if ($this->rec_group['pkey'] and _CUR_ROOT_DIR_NAME=='cab')
   { $this->second_menu[$this->rec_group['__href']]=array('title'=>'Карточка персонала "'.$this->rec_group['obj_name'].'"','class'=>'fa fa-user-md') ;
     $this->second_menu[$this->rec_group['__href'].'terminals/']=array('title'=>'Терминалы','_class'=>'fa fa-user-md') ;
     $this->second_menu[$this->rec_group['__href'].'arm/']=array('title'=>'АРМы','_class'=>'fa fa-user-md') ;
     $this->second_menu[$this->rec_group['__href'].'personals/']=array('title'=>'Фильтр персонала','_class'=>'fa fa-user-md') ;
     $this->second_menu[$this->rec_group['__href'].'db/']=array('title'=>'Дамп БД','_class'=>'fa fa-user-md') ;
   }
 }

 function panel_group_edit()
 {
     //$settings=unserialize(execSQL_value('select settings from obj_site_account where pkey='.$this->rec_group['pkey'])) ;
     //damp_array($this->rec_group,1,-1);
     if (!$this->rec_group['_settings']['timezone']) $this->rec_group['_settings']['timezone']='Europe/Moscow' ;
     $arr_groups=ACCOUNTS()->get_list_workgoups(array('usl'=>'(clss=206 or clss=1) and enabled=1 and pkey!='.$this->rec_group['pkey'])) ;
     $arr_med_orgs=ESMO()->get_arr_med_ords_for_select() ;
     $options_list=$this->get_group_tree_list($arr_groups);
     //damp_array($this->rec_group)  ;
     //damp_array($this->ARR_timezones)  ;
     //echo 'timezone='.$this->rec_group['_settings']['timezone'] ;
     ?>
     <div id="panel_filter">
         <form id="sky-form" class="sky-form">
             <fieldset>
                 <input type="hidden" name="group_id" value="<?echo $this->rec_group['pkey']?>">
                 <div class="row">
                     <?
                     $this->filter_section_input_text('group_name','Наименование группы:',3,array('nospace_element'=>1,'cur_value'=>$this->rec_group['obj_name'])) ;
                     if ($this->rec_group['parent']) $this->filter_section_select('parent_id','Родительская группа',3,$options_list,array('nospace_element'=>1,'cur_value'=>$this->rec_group['parent'])) ;
                     $this->filter_section_select('timezone','Часовой пояс:',3,$this->ARR_timezones,array('nospace_element'=>1,'cur_value'=>$this->rec_group['_settings']['timezone'],'value_is_id'=>1)) ;
                     $this->filter_section_select('mo_type','Тип проводимых МО:',3,$this->arr_mo_type,array('nospace_element'=>1,'cur_value'=>$this->rec_group['_settings']['mo_type'],'value_is_id'=>0)) ;
                     $this->filter_section_select('med_org_id','Мед.организация фельдшеров:',3,$arr_med_orgs,array('nospace_element'=>1,'cur_value'=>$this->rec_group['med_org_id'])) ;
                     ?>
                 </div>
             </fieldset>
             <div id="panel_buttons">
                 <input class="button v2" type="submit" cmd="aspmo_setting/save_ESMO_single_group" value="Сохранить изменения">
                 <button class="button v2" cmd="aspmo_setting/delete_ESMO_single_group">Удалить группу</button>
             </div>
   </form>
     </div>
    <?

}

    function get_group_tree_list($arr_groups) {
        $temp_arr_groups=$arr_groups ;
        convert_list_to_tree($temp_arr_groups,$arr_tree) ;
        $this->convert_tree_to_select_options_arr($arr_tree,$arr_groups,$result) ;
        return $result;
    }

}



?>
