<?php // этот модуль необходимо делать тольео для крупных проектов, для небольшых описание пунктов меню и файлов меню лучше делать в init.php
$__functions['init'][]      ='_personal_admin_vars' ;
$__functions['boot_admin'][] ='_personal_admin_boot' ;
//$__functions['alert'][]   ='_personal_admin_alert' ;
$__functions['install'][]	='_personal_install_modul' ;



function _personal_admin_vars()
{

    //Юр.лицо
    $_SESSION['descr_clss'][207]['name']='Организация' ;
    $_SESSION['descr_clss'][207]['parent']=1 ;
    $_SESSION['descr_clss'][207]['fields']['obj_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][207]['fields']['full_name']=array('type'=>'varchar(256)') ;
    //$_SESSION['descr_clss'][207]['fields']['email']=array('type'=>'varchar(128)') ;
    //$_SESSION['descr_clss'][207]['fields']['phone']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][207]['fields']['phone2']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][207]['fields']['email']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][207]['fields']['inn']=array('type'=>'varchar(16)') ;
    $_SESSION['descr_clss'][207]['fields']['kpp']=array('type'=>'varchar(16)') ;
    //$_SESSION['descr_clss'][207]['fields']['bik']=array('type'=>'varchar(16)') ;
    //$_SESSION['descr_clss'][207]['fields']['bank']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['ks']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][207]['fields']['rs']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][207]['fields']['adres1']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['adres2']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['director_fio']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['director_working']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['buh_fio']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['buh_working']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][207]['fields']['read_only']=array('type'=>'int(1)') ;
    $_SESSION['descr_clss'][207]['fields']['client_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][207]['fields']['group_id']=array('type'=>'int(11)','default'=>1) ;
    $_SESSION['descr_clss'][207]['fields']['demo']=array('type'=>'int(1)') ;
    //$_SESSION['descr_clss'][207]['fields']['HR_ID']=array('type'=>'int(11)') ;


    $_SESSION['descr_clss'][207]['list']['field']['pkey']=array('title'=>'ID') ;
    $_SESSION['descr_clss'][207]['list']['field']['enabled']=array('title'=>'Состояние') ;
    //$_SESSION['descr_clss'][207]['list']['field']['read_only']=array('title'=>'Запрет изменений') ;
    $_SESSION['descr_clss'][207]['list']['field']['obj_name']=array('title'=>'Наименование') ;
    //$_SESSION['descr_clss'][207]['list']['field']['full_name']=array('title'=>'Полное наименование') ;
    //$_SESSION['descr_clss'][207]['list']['field']['email']=array('title'=>'email') ;
    //$_SESSION['descr_clss'][207]['list']['field']['phone']=array('title'=>'Телефон') ;
    //$_SESSION['descr_clss'][207]['list']['field']['phone2']=array('title'=>'Доп.телефон') ;
    //$_SESSION['descr_clss'][207]['list']['field']['inn']=array('title'=>'ИНН') ;
    //$_SESSION['descr_clss'][207]['list']['field']['kpp']=array('title'=>'КПП') ;
    //$_SESSION['descr_clss'][207]['list']['field']['bik']=array('title'=>'БИК') ;
    //$_SESSION['descr_clss'][207]['list']['field']['bank']=array('title'=>'Банк') ;
    //$_SESSION['descr_clss'][207]['list']['field']['ks']=array('title'=>'Корреспонденский счет') ;
    //$_SESSION['descr_clss'][207]['list']['field']['rs']=array('title'=>'Расчетный счет') ;
    //$_SESSION['descr_clss'][207]['list']['field']['adres1']=array('title'=>'Юр.адрес') ;
    //$_SESSION['descr_clss'][207]['list']['field']['adres2']=array('title'=>'Почт.адрес') ;
    //$_SESSION['descr_clss'][207]['list']['field']['director_fio']=array('title'=>'ФИО директора') ;
    //$_SESSION['descr_clss'][207]['list']['field']['director_working']=array('title'=>'Должность директора') ;
    //$_SESSION['descr_clss'][207]['list']['field']['buh_fio']=array('title'=>'ФИО бухгалтера') ;
    //$_SESSION['descr_clss'][207]['list']['field']['buh_working']=array('title'=>'Должность бухгалтера') ;
    //$_SESSION['descr_clss'][207]['list']['field']['client_id']=array('title'=>'Client ID') ;
    $_SESSION['descr_clss'][207]['list']['field']['demo']=array('title'=>'demo') ;


    $_SESSION['descr_clss'][208]['name']='Подразделение' ;
    $_SESSION['descr_clss'][208]['parent']=1 ;
    $_SESSION['descr_clss'][208]['fields']['obj_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][208]['fields']['read_only']=array('type'=>'int(1)') ;
    $_SESSION['descr_clss'][208]['fields']['HR_ID']=array('type'=>'int(11)') ;


    $_SESSION['descr_clss'][208]['list']['field']['pkey']=array('title'=>'ID') ;
    $_SESSION['descr_clss'][208]['list']['field']['enabled']=array('title'=>'Состояние') ;
    $_SESSION['descr_clss'][208]['list']['field']['obj_name']=array('title'=>'Наименование') ;
    $_SESSION['descr_clss'][208]['list']['field']['read_only']=array('title'=>'Запрет изменений') ;



    //-----------------------------------------------------------------------------------------------------
    $_SESSION['descr_clss'][211]['name']='Физическое лицо' ;
    $_SESSION['descr_clss'][211]['parent']=1 ;
    $_SESSION['descr_clss'][211]['parent_to']=array(3) ;
    $_SESSION['descr_clss'][211]['child_to']=array(207,208) ;
    $_SESSION['descr_clss'][211]['fields']['obj_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][211]['fields']['level']=array('type'=>'int(11)','index'=>'level') ;
    $_SESSION['descr_clss'][211]['fields']['parent1']=array('type'=>'int(11)','index'=>'parent1','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent2']=array('type'=>'int(11)','index'=>'parent2','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent3']=array('type'=>'int(11)','index'=>'parent3','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent4']=array('type'=>'int(11)','index'=>'parent4','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent5']=array('type'=>'int(11)','index'=>'parent5','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent6']=array('type'=>'int(11)','index'=>'parent6','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent7']=array('type'=>'int(11)','index'=>'parent7','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent8']=array('type'=>'int(11)','index'=>'parent8','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['parent9']=array('type'=>'int(11)','index'=>'parent9','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['name1']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][211]['fields']['name2']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][211]['fields']['name3']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][211]['fields']['working']=array('type'=>'indx_select','array'=>'IL_works','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['working2']=array('type'=>'indx_select','array'=>'IL_works','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['status']=array('type'=>'indx_select','array'=>'IL_personal_status','default'=>0) ;
    //$_SESSION['descr_clss'][211]['fields']['working_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][211]['fields']['propusk']=array('type'=>'varchar(32)','index'=>'propusk','default'=>'') ;
    $_SESSION['descr_clss'][211]['fields']['propusk_uptime']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][211]['fields']['propusk_old']=array('type'=>'varchar(32)') ;
    $_SESSION['descr_clss'][211]['fields']['driving']=array('type'=>'varchar(32)') ;
    $_SESSION['descr_clss'][211]['fields']['driving_seria']=array('type'=>'varchar(4)'); // серия ВУ
    $_SESSION['descr_clss'][211]['fields']['driving_date']=array('type'=>'int(11)'); // дата выдачи ВУ
    $_SESSION['descr_clss'][211]['fields']['driving_validity_period']=array('type'=>'int(11)'); // дата выдачи ВУ
    $_SESSION['descr_clss'][211]['fields']['permit']=array('type'=>'varchar(32)') ;
    $_SESSION['descr_clss'][211]['fields']['PersonLicense']=array('type'=>'varchar(32)') ;
    $_SESSION['descr_clss'][211]['fields']['snils']=array('type'=>'varchar(32)','index'=>'snils','default'=>'') ;
    $_SESSION['descr_clss'][211]['fields']['tab_number']=array('type'=>'varchar(32)','index'=>'tab_number','default'=>'') ;
    $_SESSION['descr_clss'][211]['fields']['adres']=array('type'=>'text') ;
    $_SESSION['descr_clss'][211]['fields']['phone']=array('type'=>'varchar(15)') ;
    $_SESSION['descr_clss'][211]['fields']['dr']=array('type'=>'varchar(10)','default'=>'') ;
    $_SESSION['descr_clss'][211]['fields']['age']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['pol']=array('type'=>'int(1)','default'=>0) ;
    $_SESSION['descr_clss'][211]['fields']['s_min']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['s_max']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['d_min']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['d_max']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['t_min']='float(10,1)' ;
    $_SESSION['descr_clss'][211]['fields']['t_max']='float(10,1)' ;
    $_SESSION['descr_clss'][211]['fields']['p_min']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['p_max']='int(11)' ;
    $_SESSION['descr_clss'][211]['fields']['a']='int(11)' ; // 1 - не производить алкотест ; 2 - делать алкотест
    $_SESSION['descr_clss'][211]['fields']['n']='int(11)' ; // 1 - не производить тест ЦНС ; 2 - делать тест ЦНС
    $_SESSION['descr_clss'][211]['fields']['smena_s']='varchar(5)' ; // время начала смены
    $_SESSION['descr_clss'][211]['fields']['smena_e']='varchar(5)' ; // время окончания смены
    $_SESSION['descr_clss'][211]['fields']['full_access']='int(1)' ; // проход всегда
    $_SESSION['descr_clss'][211]['fields']['demo_access']='int(1)' ; // демо-доступ  (неограниченное число МО)
    $_SESSION['descr_clss'][211]['fields']['ext']='int(1)' ; // внесен по доп.спискам
    $_SESSION['descr_clss'][211]['fields']['ext_info']='serialize' ; // внесен по доп.спискам
    $_SESSION['descr_clss'][211]['fields']['uid']=array('type'=>'varchar(128)','index'=>'uid','default'=>'') ; // внесен по доп.спискам
    $_SESSION['descr_clss'][211]['fields']['upl_img']=array('type'=>'serialize') ; // доп.инфо
    $_SESSION['descr_clss'][211]['fields']['s_medspravka']=array('type'=>'timedata') ; // дата выдача медсправки
    $_SESSION['descr_clss'][211]['fields']['status']=array('type'=>'indx_select','array'=>'IL_status') ; // уволен, отпуск, болен
	$_SESSION['descr_clss'][211]['fields']['job_data']=array('type'=>'timedata','index'=>'job_data') ; // дата трудоустройства
    $_SESSION['descr_clss'][211]['fields']['fired_data']=array('type'=>'timedata') ; // дата увольнения
    $_SESSION['descr_clss'][211]['fields']['fired_data_pause']=array('type'=>'timedata','default'=>0) ; // отложенная дата увольнения
    $_SESSION['descr_clss'][211]['fields']['_image_name']=array('type'=>'varchar(255)','default'=>'') ;
    $_SESSION['descr_clss'][211]['fileds']['client_id']='int(11)';
    $_SESSION['descr_clss'][211]['fields']['sign_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][211]['fields']['risk']=array('type'=>'int(1)') ;  // группа риска состоит/не состоит. Причина включения в группу риска
    $_SESSION['descr_clss'][211]['fields']['stazh']=array('type'=>'int(11)','default'=>0) ;  // непрерывный стаж
    $_SESSION['descr_clss'][211]['fields']['stazh_last']=array('type'=>'int(11)','default'=>0) ;  // стаж на последнем месте работы
    $_SESSION['descr_clss'][211]['fields']['mo_block']=array('type'=>'int(1)') ;  // блокировка прохождения МО
    $_SESSION['descr_clss'][211]['fields']['mo_block_comment']=array('type'=>'varchar(255)') ;  // комменарий к блокировка прохождения МО
    $_SESSION['descr_clss'][211]['fields']['person_status']=array('type'=>'int(11)','index'=>'person_status','default'=>0) ;// статус по ФЛ: 1 - осн 2 - осн/совмещение 3 - совме
    $_SESSION['descr_clss'][211]['fields']['workings_count']=array('type'=>'int(11)','index'=>'workings_count','default'=>0) ;// число сотрудников для данного ФЛ
    $_SESSION['descr_clss'][211]['fields']['main_count']=array('type'=>'int(11)','index'=>'main_count','default'=>0) ;// число сотрудников для данного ФЛ
    $_SESSION['descr_clss'][211]['fields']['second_count']=array('type'=>'int(11)','index'=>'second_count','default'=>0) ;// число сотрудников для данного ФЛ
     $_SESSION['descr_clss'][211]['fields']['intro_level']=array('type'=>'int(11)','default'=>0) ;  // группа риска сотрудника
    $_SESSION['descr_clss'][211]['fields']['danger']=array('type'=>'int(1)','default'=>0) ;  // опасная должность. Для домодедово
    $_SESSION['descr_clss'][211]['fields']['email']=array('type'=>'varchar(128)','default'=>'') ;
    //поля для модуля "Печать нарядов" PRINT_ORDER
    $_SESSION['descr_clss'][211]['fields']['print_order_type']=array('type'=>'int(11)','index'=>'print_order_type','default'=>0) ; // тип печатаемого наряда
    $_SESSION['descr_clss'][211]['fields']['print_order_URL']=array('type'=>'varchar(255)','default'=>'') ; // URL для печати наряда
    $_SESSION['descr_clss'][211]['fields']['print_order_time_from']=array('type'=>'timedata') ; // время с которого разрешено печатать наряд
    $_SESSION['descr_clss'][211]['fields']['print_order_time_to']=array('type'=>'timedata') ; // время до которого разрешено печатать наряд

	$_SESSION['descr_clss'][211]['fields']['working2']=array('type'=>'indx_select','index'=>'working2','array'=>'IL_works','default'=>0) ; // должность по совмещению сотрудника


    // поля для стыковки с HR
    //$_SESSION['descr_clss'][211]['fields']['person_id']=array('type'=>'int(11)') ; // person_id по HR
    //$_SESSION['descr_clss'][211]['fields']['iNet_ID']=array('type'=>'int(11)') ;
    //$_SESSION['descr_clss'][211]['fields']['iNet_name']=array('type'=>'varchar(255)') ;
    //$_SESSION['descr_clss'][211]['fields']['HR_ID']=array('type'=>'int(11)') ;
    //$_SESSION['descr_clss'][211]['fields']['ASSIGNMENT_ID']=array('type'=>'int(11)') ;
    //$_SESSION['descr_clss'][211]['fields']['EMP_NUMBER']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][211]['fields']['ASS_NUMBER']=array('type'=>'varchar(32)') ;
    //$_SESSION['descr_clss'][211]['fields']['PROPUSK_NUMBER']=array('type'=>'int(11)') ;
    //$_SESSION['descr_clss'][211]['fields']['snils']=array('type'=>'int(11)') ; // snils по HR
    //$_SESSION['descr_clss'][211]['fields']['table_number']=array('type'=>'int(11)') ; // table_number по HR
    $_SESSION['descr_clss'][211]['index']['ext']='ext' ;


    //$_SESSION['descr_clss'][211]['child_to']=array(1) ;
    //$_SESSION['descr_clss'][211]['parent_to']=array(3) ;
    $_SESSION['descr_clss'][211]['no_show_in_tree']=0 ; // не показывать объекты класса в дереве
    $_SESSION['descr_clss'][211]['icons']=_PATH_TO_BASED_CLSS_IMG.'/98.png' ;
    $_SESSION['descr_clss'][211]['list']['field']['pkey']			=array('title'=>'ID') ;
    //$_SESSION['descr_clss'][211]['list']['field']['HR_ID']			=array('title'=>'HR_ID') ;
    //$_SESSION['descr_clss'][211]['list']['field']['PROPUSK_NUMBER']			=array('title'=>'PROPUSK_NUMBER') ;
    //$_SESSION['descr_clss'][211]['list']['field']['ASSIGNMENT_ID']			=array('title'=>'ASSIGNMENT_ID') ;
    //$_SESSION['descr_clss'][211]['list']['field']['ASS_NUMBER']			=array('title'=>'ASS_NUMBER') ;
    //$_SESSION['descr_clss'][211]['list']['field']['EMP_NUMBER']			=array('title'=>'EMP_NUMBER') ;
    $_SESSION['descr_clss'][211]['list']['field']['uid']			=array('title'=>'UID') ;
    $_SESSION['descr_clss'][211]['list']['field']['enabled']			=array('title'=>'Сост.') ;
    $_SESSION['descr_clss'][211]['list']['field']['obj_name']			=array('title'=>'ФИО','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['working']		=array('title'=>'Должность','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['working2']		=array('title'=>'Должность2','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['dr']			        =array('title'=>'Дата рождения','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['propusk']			=array('title'=>'Номер пропуска','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['tab_number']			=array('title'=>'Табельный номер','td_class'=>'left') ;
    //$_SESSION['descr_clss'][211]['list']['field']['status']			    =array('title'=>'Статус','td_class'=>'left') ;
    $_SESSION['descr_clss'][211]['list']['field']['temp']			    =array('title'=>'temp') ;
    $_SESSION['descr_clss'][211]['details']=$_SESSION['descr_clss'][211]['list'] ;


    $_SESSION['descr_clss'][3]['fields']['faceimg']=array('type'=>'int(11)','default'=>0) ;

    //-----------------------------------------------------------------------------------------------------
    $_SESSION['descr_clss'][212]['name']='Сотрудник компании' ;
    $_SESSION['descr_clss'][212]['parent']=0 ;
    $_SESSION['descr_clss'][212]['fields']['obj_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][212]['fields']['enabled']=array('type'=>'int(1)','index'=>'enabled','default'=>1) ;
    $_SESSION['descr_clss'][212]['fields']['uid']=array('type'=>'varchar(128)','index'=>'uid','default'=>'') ;
    $_SESSION['descr_clss'][212]['fields']['personal_id']=array('type'=>'int(11)','index'=>'personal_id','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['work_id']=array('type'=>'indx_select','array'=>'IL_works','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['person_status']=array('type'=>'int(11)','index'=>'person_status','default'=>0) ;// статус по ФЛ: 1 - осн 2 - осн/совмещение 3 - совме
	$_SESSION['descr_clss'][211]['fields']['work_status']=array('type'=>'indx_select','array'=>'IL_worker_status','default'=>0) ; // работа, отпуск
    $_SESSION['descr_clss'][212]['fields']['status']=array('type'=>'int(11)','index'=>'status','default'=>0) ;      // статус по СО 1 - осн 2 - совмещение
    $_SESSION['descr_clss'][212]['fields']['is_main']=array('type'=>'int(1)','index'=>'is_main','default'=>0) ;     // статус по СО 1 - осн 2 - совмещение
    $_SESSION['descr_clss'][212]['fields']['is_second']=array('type'=>'int(1)','index'=>'is_second','default'=>0) ; // статус по СО 1 - осн 2 - совмещение
    $_SESSION['descr_clss'][212]['fields']['job_data']=array('type'=>'timedata','index'=>'job_data') ; // дата трудоустройства
    $_SESSION['descr_clss'][212]['fields']['fired_data']=array('type'=>'timedata','index'=>'fired_data') ; // дата увольнения
    $_SESSION['descr_clss'][212]['fields']['fired_data_pause']=array('type'=>'timedata','default'=>0) ; // отложенная дата увольнения
    $_SESSION['descr_clss'][212]['fields']['level']=array('type'=>'int(11)','index'=>'level') ;
    $_SESSION['descr_clss'][212]['fields']['parent1']=array('type'=>'int(11)','index'=>'parent1','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent2']=array('type'=>'int(11)','index'=>'parent2','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent3']=array('type'=>'int(11)','index'=>'parent3','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent4']=array('type'=>'int(11)','index'=>'parent4','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent5']=array('type'=>'int(11)','index'=>'parent5','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent6']=array('type'=>'int(11)','index'=>'parent6','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent7']=array('type'=>'int(11)','index'=>'parent7','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent8']=array('type'=>'int(11)','index'=>'parent8','default'=>0) ;
    $_SESSION['descr_clss'][212]['fields']['parent9']=array('type'=>'int(11)','index'=>'parent9','default'=>0) ;
	$_SESSION['descr_clss'][212]['fields']['inrm']=array('type'=>'varchar(32)','index'=>'inrm','default'=>'') ;// ИНРМ

    //-----------------------------------------------------------------------------------------------------
    $_SESSION['descr_clss'][214]['name']='Запись в табеле HR' ;
    $_SESSION['descr_clss'][214]['table_code']='tabel_HR' ;
    $_SESSION['descr_clss'][214]['parent']=0 ;
    $_SESSION['descr_clss'][214]['fields']=array('table_id'=>'int(11)','complex'=>'text') ;
    $_SESSION['descr_clss'][214]['fields']['person_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][214]['fields']['date_start']=array('type'=>'timedata','data_format'=>'d.m.y G:i') ; // время начала смены
    $_SESSION['descr_clss'][214]['fields']['date_end']=array('type'=>'timedata','data_format'=>'d.m.y G:i') ; // время окончания смены
    $_SESSION['descr_clss'][214]['fields']['guests_allowed']=array('type'=>'int(1)') ; // 1 = разрешено проводить гостей
    $_SESSION['descr_clss'][214]['fields']['access_type']=array('type'=>'int(1)') ; // 0 =resticted 1=free

    $_SESSION['descr_clss'][214]['no_show_in_tree']=0 ; // не показывать объекты класса в дереве
    $_SESSION['descr_clss'][214]['icons']=_PATH_TO_BASED_CLSS_IMG.'/98.png' ;



    $_SESSION['descr_clss'][217]['name']='Сообщение сотруднику' ;
    $_SESSION['descr_clss'][217]['parent']=0 ;
    $_SESSION['descr_clss'][217]['fields']['group_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][217]['fields']['account_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][217]['fields']['personal_id']=array('type'=>'int(11)') ;
    // поля более не используются
    //$_SESSION['descr_clss'][217]['fields']['max_cnt']=array('type'=>'int(11)','default'=>0) ;    // максимальное число показаов
    //$_SESSION['descr_clss'][217]['fields']['max_day']=array('type'=>'int(11)','default'=>0) ;   // максимальное число дней показа
    //$_SESSION['descr_clss'][217]['fields']['max_data']=array('type'=>'int(11)','default'=>0) ;   // срок окончания показа сообщения
    $_SESSION['descr_clss'][217]['fields']['view_from']=array('type'=>'int(11)','default'=>0) ;   // срок начала показа сообщения
    $_SESSION['descr_clss'][217]['fields']['view_to']=array('type'=>'int(11)','default'=>0) ;   // срок окончания показа сообщения
    $_SESSION['descr_clss'][217]['fields']['block_from']=array('type'=>'int(11)','default'=>0) ; // срок начала блокировки
    $_SESSION['descr_clss'][217]['fields']['block_to']=array('type'=>'int(11)','default'=>0) ;   // срок окончания блокировки
    $_SESSION['descr_clss'][217]['fields']['auto_close']=array('type'=>'int(11)','default'=>0) ;   // срок автозакрытия сообщения
    $_SESSION['descr_clss'][217]['fields']['close_data']=array('type'=>'int(11)','default'=>0) ;

    $_SESSION['descr_clss'][217]['fields']['status']=array('type'=>'int(11)','index'=>'status') ;
	// поля более не используются
    //$_SESSION['descr_clss'][217]['fields']['view_mode']=array('type'=>'timedata') ;
    //$_SESSION['descr_clss'][217]['fields']['block_mo']=array('type'=>'int(1)') ; // флаг блокировки МО
    $_SESSION['descr_clss'][217]['fields']['view_cnt']=array('type'=>'int(11)') ; // число показов сообщение
    $_SESSION['descr_clss'][217]['fields']['view_data']=array('type'=>'timedata') ; // дата последнего показа
    $_SESSION['descr_clss'][217]['fields']['view_mesto']=array('type'=>'varchar(255)') ; // место последнего показа
    $_SESSION['descr_clss'][217]['fields']['source_pkey']=array('type'=>'int(11)','index'=>'source_pkey') ; //
    $_SESSION['descr_clss'][217]['fields']['source_tkey']=array('type'=>'int(11)') ; //
    $_SESSION['descr_clss'][217]['fields']['source_obj']=array('type'=>'varchar(100)','index'=>'source_obj') ; //

    $_SESSION['descr_clss'][117]['name']='Показ сообщения сотруднику' ;
    $_SESSION['descr_clss'][117]['parent']=0 ;
    $_SESSION['descr_clss'][117]['fields']['mess_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][117]['fields']['pass_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][117]['fields']['personal_id']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][117]['fields']['status']=array('type'=>'int(11)') ;
    $_SESSION['descr_clss'][117]['fields']['view_mesto']=array('type'=>'varchar(255)') ; // место показа

    $_SESSION['descr_clss'][220]['name']='Фильтр по персоналу' ;
    $_SESSION['descr_clss'][220]['parent']=0 ;
    $_SESSION['descr_clss'][220]['fields']['obj_name']=array('type'=>'varchar(32)') ;
    $_SESSION['descr_clss'][220]['fields']['reffer']=array('type'=>'varchar(32)','index'=>'reffer') ;
    $_SESSION['descr_clss'][220]['fields']['ext_info']=array('type'=>'json') ;
    $_SESSION['descr_clss'][220]['fields']['info']=array('type'=>'text') ;

    $_SESSION['descr_clss'][265]['name']='Вьювер персонала' ;
    $_SESSION['descr_clss'][265]['parent']=20 ;
    $_SESSION['descr_clss'][265]['fields']['obj_name']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][265]['fields']['arr_name']=array('type'=>'varchar(255)') ;

    $_SESSION['descr_clss'][265]['list']['field']['id']			=array('title'=>'ID') ;
    $_SESSION['descr_clss'][265]['list']['field']['enabled']			=array('title'=>'Сост.') ;
    $_SESSION['descr_clss'][265]['list']['field']['obj_name']			=array('title'=>'Наименование') ;
    $_SESSION['descr_clss'][265]['list']['field']['arr_name']			=array('title'=>'Название вьювера','td_class'=>'left') ;

    //508 - постоянный пропуск
    $_SESSION['descr_clss'][508]['name']='Постоянный пропуск' ;
    $_SESSION['descr_clss'][508]['parent']=0 ;
    $_SESSION['descr_clss'][508]['fields']['pkey']=array('name'=>'ID','type'=>'int(11)') ; ;
    $_SESSION['descr_clss'][508]['fields']['PROPUSK_NUMBER']=array('name'=>'Номер','type'=>'int(11)','index'=>'PROPUSK_NUMBER') ; ;
    $_SESSION['descr_clss'][508]['fields']['member_id']='int(11)' ; // кто выдал пропуск
    $_SESSION['descr_clss'][508]['fields']['personal_id']=array('name'=>'ID персоны','type'=>'int(11)','index'=>'personal_id') ; ;
    $_SESSION['descr_clss'][508]['fields']['c_data']=array('type'=>'timedata','is_edit'=>1,'datepicker'=>1,'data_format'=>'d.m.y') ;
    $_SESSION['descr_clss'][508]['fields']['obj_name']='varchar(255)' ;
    $_SESSION['descr_clss'][508]['fields']['time_from']='timedata' ;   // срок действия, от
    $_SESSION['descr_clss'][508]['fields']['time_to']='timedata' ;   // срок действия, до
    //$_SESSION['descr_clss'][508]['fields']['TenantNdx']=array('type'=>'int(11)','default'=>0) ;
    //$_SESSION['descr_clss'][508]['fields']['IndivId']=array('type'=>'int(11)','default'=>0) ;
    //$_SESSION['descr_clss'][508]['fields']['bp_id']=array('type'=>'int(11)','default'=>0) ;
    //$_SESSION['descr_clss'][508]['fields']['template_name']=array('type'=>'varchar(32)','default'=>'') ;
    //$_SESSION['descr_clss'][508]['fields']['template_id']=array('type'=>'int(11)','default'=>0) ;
    //$_SESSION['descr_clss'][508]['fields']['doc_id']=array('type'=>'int(11)','default'=>0) ;

    $_SESSION['descr_clss'][362]['name']='Статистика загрузки через шлюз' ;
       $_SESSION['descr_clss'][362]['parent']=0 ;
       $_SESSION['descr_clss'][362]['fields']['client_id']=array('type'=>'int(11)') ;     // IP
       $_SESSION['descr_clss'][362]['fields']['IP']=array('type'=>'varchar(22)') ;     // IP
       $_SESSION['descr_clss'][362]['fields']['result']=array('type'=>'serialize') ;   // res data
    $_SESSION['descr_clss'][362]['fields']['session_uid']=array('type'=>'varchar(128)') ;
    $_SESSION['descr_clss'][362]['fields']['source']=array('type'=>'varchar(255)') ;
    $_SESSION['descr_clss'][362]['fields']['t_exec']=array('type'=>'float(10,2)') ;


	$_SESSION['descr_clss'][277]['name']='Журнал изменений ФЛ' ;
	$_SESSION['descr_clss'][277]['parent']=0 ;
	$_SESSION['descr_clss'][277]['fields']['pkey']=array('name'=>'ID','type'=>'int(11)') ; ;
	$_SESSION['descr_clss'][277]['fields']['account_id']=array('name'=>'account_id','type'=>'int(11)','index'=>'account_id') ; ;
	$_SESSION['descr_clss'][277]['fields']['personal_id']=array('name'=>'personal_id','type'=>'int(11)','index'=>'personal_id') ;
	$_SESSION['descr_clss'][277]['fields']['worker_id']=array('name'=>'worker_id','type'=>'int(11)','index'=>'worker_id') ; ;
	$_SESSION['descr_clss'][277]['fields']['worker_type']=array('name'=>'worker_type','type'=>'int(11)') ; ;
	$_SESSION['descr_clss'][277]['fields']['obj_name']=array('name'=>'код','type'=>'varchar(3)','index'=>'obj_name') ;
	$_SESSION['descr_clss'][277]['fields']['fname']=array('name'=>'Поле','type'=>'varchar(32)') ;
	$_SESSION['descr_clss'][277]['fields']['old_value']=array('name'=>'Старое значение','type'=>'varchar(100)') ;
	$_SESSION['descr_clss'][277]['fields']['new_value']=array('name'=>'Новое значение','type'=>'varchar(100)') ;
	$_SESSION['descr_clss'][277]['fields']['log_id']=array('name'=>'Источник в логе','type'=>'int(11)') ;
	$_SESSION['descr_clss'][277]['fields']['source']=array('name'=>'Источник','type'=>'varchar(128)') ;
	//$_SESSION['descr_clss'][277]['fields']['comment']=array('name'=>'Комментарий','type'=>'varchar(128)') ;

	$_SESSION['descr_clss'][279]['name']='Журнал изменений сообщений' ;
	$_SESSION['descr_clss'][279]['parent']=0 ;
	$_SESSION['descr_clss'][279]['fields']['pkey']=array('name'=>'ID','type'=>'int(11)') ;
	$_SESSION['descr_clss'][279]['fields']['account_id']=array('name'=>'account_id','type'=>'int(11)','index'=>'account_id') ; ;
	$_SESSION['descr_clss'][279]['fields']['personal_id']=array('name'=>'personal_id','type'=>'int(11)','index'=>'personal_id') ; ;
	$_SESSION['descr_clss'][279]['fields']['obj_name']=array('name'=>'код','type'=>'varchar(3)','index'=>'obj_name') ;
	$_SESSION['descr_clss'][279]['fields']['type']=array('name'=>'Тип должности','type'=>'int(11)') ;
	$_SESSION['descr_clss'][279]['fields']['fname']=array('name'=>'Поле','type'=>'varchar(32)') ;
	$_SESSION['descr_clss'][279]['fields']['old_value']=array('name'=>'Старое значение','type'=>'varchar(100)') ;
	$_SESSION['descr_clss'][279]['fields']['new_value']=array('name'=>'Новое значение','type'=>'varchar(100)') ;
	$_SESSION['descr_clss'][279]['fields']['log_id']=array('name'=>'Источник в логе','type'=>'int(11)') ;







}

function _personal_admin_boot($options)
{
  create_system_modul_obj('personal') ;
}


function _personal_install_modul($DOT_root)
{   SETUP()->reg_report('Персонал','personal/report_personals.php') ;         //
    SETUP()->reg_report('Персонал','personal/report_personal_cards.php') ;         //
    SETUP()->reg_report('Персонал','personal/report_personal_blocked.php') ;         //

    // персонал компании
    $pattern=array() ;
    $pattern['table_title']		        = 	'Физические лица' ;
    $pattern['use_clss']		        = 	'1,207,208,211' ;
    $pattern['def_recs'][]		        =	array ('parent'=>0,	'clss'=>1,	'enabled'=>1,	'indx'=>1,	'obj_name'=>'Персонал компании') ;
    $pattern['def_recs'][]		        =	array ('parent'=>1,	'clss'=>207,	'enabled'=>1,	'indx'=>1,	'obj_name'=>'Квазар', 'level'=>2,'parent1'=>1) ;
    $pattern['def_recs'][]		        =	array ('parent'=>2,	'clss'=>208,	'enabled'=>1,	'indx'=>1,	'obj_name'=>'Внедрение', 'level'=>3,'parent1'=>1,'parent2'=>2) ;
    $pattern['def_recs'][]		        =	array ('parent'=>3,	'clss'=>211,	'enabled'=>1,	'indx'=>1,	'obj_name'=>'Техник','propusk'=>'12345','uid'=>'12345','parent1'=>1,'parent2'=>2,'parent3'=>3) ;
    $pattern['table_name']				= 	'obj_site_personals' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    $id_DOT_personal=create_table_by_pattern($pattern) ;

    $pattern=array() ;
    $pattern['table_title']				= 	'Фото' ;
    $pattern['use_clss']				= 	'3' ;
    $pattern['table_name']				= 	'obj_site_personals_image' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$id_DOT_personal;
    $pattern['dir_to_image']			= 	'/public/personals/';
    $pattern['img_pattern']			    = 	'personal';
    $id_image=create_table_by_pattern($pattern) ;

    SETUP()->check_obj_table_image_dir($id_image) ;  // проверяем папки изображений
	SETUP()->check_obj_table_file_dir($id_image) ;   // проверяем папки файлов


    $pattern=array() ;
    $pattern['table_title']		        = 	'Постоянные пропуска' ;
    $pattern['use_clss']		        = 	'508' ;
    $pattern['table_name']				= 	'obj_site_pass_static' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    create_table_by_pattern($pattern) ;

    // персонал компании
   $pattern=array() ;
    $pattern['table_title']		        = 	'Сотрудники' ;
    $pattern['use_clss']		        = 	'212' ;
    $pattern['table_name']				= 	'obj_site_workers' ;
   $pattern['table_clss']				= 	101 ;
   $pattern['table_parent']			= 	$DOT_root;
    $id_DOT_personal=create_table_by_pattern($pattern) ;


    // Сообщения сотрудникам
   $pattern=array() ;
   $pattern['table_title']		        = 	'Сообщения сотрудникам' ;
   $pattern['use_clss']		            = 	'217' ;
   $pattern['table_name']				= 	'obj_site_personal_mess' ;
   $pattern['table_clss']				= 	101 ;
   $pattern['table_parent']			= 	$DOT_root;
   create_table_by_pattern($pattern) ;

    // Сообщения сотрудникам
   $pattern=array() ;
   $pattern['table_title']		  = 	'Показ сообщения сотруднику' ;
   $pattern['use_clss']		      = 	'117' ;
   $pattern['table_name']				= 	'personal_mess_history' ;
   $pattern['table_clss']				= 	101 ;
   $pattern['table_parent']			= 	$DOT_root;
   create_table_by_pattern($pattern) ;

    // Сообщения сотрудникам
   $pattern=array() ;
   $pattern['table_title']		        = 	'Фильтры по сотрудникам' ;
   $pattern['use_clss']		            = 	'220' ;
   $pattern['table_name']				= 	'personals_filter' ;
   $pattern['table_clss']				= 	101 ;
   $pattern['table_parent']			= 	$DOT_root;
   create_table_by_pattern($pattern) ;

    // разграничение доступа пользователей к скриптам
    $pattern=array() ;
    $pattern['table_title']		        = 	'Журнал работы шлюза' ;
    $pattern['use_clss']		        = 	'362' ;
    $pattern['table_name']				= 	'obj_site_post_log' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    create_table_by_pattern($pattern) ;

    $pattern=array() ;
    $pattern['table_title']		        = 	'Журнал изменений ФЛ' ;
    $pattern['use_clss']		        = 	'277' ;
    $pattern['table_name']				= 	'log_personal_changes' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    create_table_by_pattern($pattern) ;

    $id_sect=SETUP_add_section_to_site_setting('Поля по сотруднику') ;
    SETUP_add_rec_to_site_setting($id_sect,"Пропуск",1,'LS_person_use_propusk',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Табельный номер",1,'LS_person_use_tab_number',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Водительское удостоверение",1,'LS_person_use_driving',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Дата рождения",1,'LS_person_use_dr',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Возраст",1,'LS_person_use_age',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Адрес",1,'LS_person_use_adres',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Организация",1,'LS_person_use_org',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Подразделение",1,'LS_person_use_otdel',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Должность",1,'LS_person_use_working',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Email",0,'LS_person_use_email',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Поле в QR-коде",'propusk','LS_person_field_to_qrcode') ;


	// Вьюверы сотрудников используются для отбора сотрудников в группах сотрудников
    $id_list=SETUP_add_list_to_site_list(1,'Вьюверы сотрудников','personals_viewer') ;
    SETUP_add_rec_to_site_list($id_list,265,array('id'=>1,'obj_name'=>'Сотрудник добавлен менее месяца назад','arr_name'=>'view_personals_new')) ;
    SETUP_add_rec_to_site_list($id_list,265,array('id'=>2,'obj_name'=>'Сотрудник ранее имел недостуск по алкоголю','arr_name'=>'view_personals_select_alco')) ;

    $id_list=SETUP_add_list_to_site_list(1,'Группы персонала','groups') ;

    // персонал
    $id_sect=SETUP_add_section_to_site_setting('Персонал') ;
    SETUP_add_rec_to_site_setting($id_sect,"При формировании полный пути подразделения на основе полей parent1,parent2,parent3,parent4,parent5.... показывать органиазцию в пути",1,'LS_view_org_name_in_dep_tree',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Срок отложенного увольнения",0,'LS_fired_pause_day',array('update_current_value'=>0,'human'=>'day')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Ограничение по числу сотрудников в отложенное увольнение",100,'LS_fired_pause_max_count') ;
    SETUP_add_rec_to_site_setting($id_sect,"Поиск сотрудника по пропуску с преобразованием как DEC->HEX",1,'LS_get_personal_propusk_convert_to_hex',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Поиск сотрудника по пропуску с преобразованием как HEX->DEC",1,'LS_get_personal_propusk_convert_to_dec',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Поиск сотрудника по пропуску с преобразованием как HEX->DEC без разделения",0,'LS_get_personal_propusk_convert_to_dec_as_is',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"Поиск сотрудника по пропуску с преобразованием как DEC->HEX без разделения",0,'LS_get_personal_propusk_convert_to_hex_as_is',array('el'=>'checkbox')) ;
    SETUP_add_rec_to_site_setting($id_sect,"При экспорте в csv преобразовывать пропуск в формулу",0,'LS_personal_propusk_convert_to_formula',array('el'=>'checkbox', 'descr' => 'Если пропуск состоит только из чисел и имеет длину более 16 символов. Без этой настройки при импорте в csv будет отображаться разрядностью Е+')) ;

	ENGINE()->reg_cron('Отложенное увольнение','PERSONAL/check_fired_pause_day','0 0 * * *',array('enabled'=>1)) ;
	ENGINE()->reg_cron('Обновление возраста сотрудников','ENGINE/update_personals_age','0 0 * * *',array('enabled'=>1)) ;
    ENGINE()->reg_cron('Обновление статусов сообщений','PERSONAL/update_message_status','*/1 * * * *',array('enabled'=>1)) ;


    // создавем вьюверы
    $sql='create view view_deps as
                select  t1.*
                from obj_site_personals t1
                where t1.clss in (1,207,208) 
                ' ;
    create_viewer('view_deps',$sql) ;

    $sql='create view view_personals as
                select  t1.*,
                        t2.pkey as _otdel_id,
                        t2.obj_name as _otdel_name,
                        t3.pkey as _org_id,
                        t3.obj_name as _org_name,
                        t3.group_id as org_group_id
                from obj_site_personals t1
                left join obj_site_personals t2 on t2.pkey=t1.parent3 
                left join obj_site_personals t3 on t3.pkey=t1.parent2 
                ' ;
    create_viewer('view_personals',$sql) ;

    $sql='create view view_personals_active as
                select  t1.*,
                        t2.pkey as _otdel_id,
                        t2.obj_name as _otdel_name,
                        t3.pkey as _org_id,
                        t3.obj_name as _org_name,
                        t3.group_id as org_group_id
                from obj_site_personals t1
                left join obj_site_personals t2 on t2.pkey=t1.parent3 
                left join obj_site_personals t3 on t3.pkey=t1.parent2 
                where t1.clss=211 and t1.enabled=1
                ' ;
    create_viewer('view_personals_active',$sql) ;

 $sql='create view view_personals_active_all as
                select  t1.*,
                        t2.pkey as _otdel_id,
                        t2.obj_name as _otdel_name,
                        t3.pkey as _org_id,
                        t3.obj_name as _org_name,
                        t3.group_id as org_group_id
                from obj_site_personals t1
                left join obj_site_personals t2 on t2.pkey=t1.parent3 
                left join obj_site_personals t3 on t3.pkey=t1.parent2 
                where t1.clss=211
                ' ;
    create_viewer('view_personals_active_all',$sql) ;

    // создавем вьюверы
	// вьювер по сотрудникам + привязка к группе
    $sql='create view view_personals_org_group as
                select  t1.*,
                        t2.obj_name as org_group_name
                from view_personals t1
                left join obj_site_account t2 on t2.pkey=t1.org_group_id 
                ' ;
    create_viewer('view_personals_org_group',$sql) ;

    $sql='create view view_workers as
                select  t1.*,
                        t2.pkey as _otdel_id,
                        t2.obj_name as _otdel_name,
                        t3.pkey as _org_id,
                        t3.obj_name as _org_name,
                        t3.group_id as org_group_id,
                        t4.obj_name as _work_name
                from obj_site_workers t1
                left join obj_site_personals t2 on t2.pkey=t1.parent3 
                left join obj_site_personals t3 on t3.pkey=t1.parent2 
                left join view_IL_works t4 on t4.id=t1.work_id 
                ' ;
    create_viewer('view_workers',$sql) ;

    if (function_exists('EVENTS'))
    {  $sql='create view view_personals_messages as
                select  t1.*,
                        t_pers.obj_name as _personal_name,
                        t_pers.dr as _personal_dr,
                        t_pers._otdel_id,
                        t_pers._otdel_name,
                        t_pers._org_id,
                        t_pers._org_name,
                        t_pers._image_name,
                        t_pers.parent1 as personal_parent1,
                        t_pers.parent2 as personal_parent2,
                        t_pers.parent3 as personal_parent3,
                        t_pers.parent4 as personal_parent4,
                        t_pers.parent5 as personal_parent5,
                        t_pers.dr,
                        t_pers.propusk,
                        t_pers.group_id as personal_group_id,
                        t_acc.obj_name as account_name,
                        CONCAT("/window/personal/message/",t1.pkey,"/") as __href_window,
                        t_pass.event_id as mess_event_id,
                        t_events.obj_name as mess_event_name
                from obj_site_personal_mess t1
                left join view_personals t_pers on t_pers.pkey=t1.personal_id 
                left join obj_site_account t_acc on t_acc.pkey=t1.account_id
                left join obj_site_events_pass t_pass on t_pass.pkey=t1.source_pkey
                left join obj_site_events_schedule t_events on t_events.pkey=t_pass.event_id
                where t_pers.pkey is not null and t_pers.enabled=1
                ' ;

    }
    else
    {   $sql='create view view_personals_messages as
            select  t1.*,
                    t_pers.obj_name as _personal_name,
                    t_pers.dr as _personal_dr,
                    t_pers._otdel_id,
                    t_pers._otdel_name,
                    t_pers._org_id,
                    t_pers._org_name,
                    t_pers._image_name,
                    t_pers.parent1 as personal_parent1,
                    t_pers.parent2 as personal_parent2,
                    t_pers.parent3 as personal_parent3,
                    t_pers.parent4 as personal_parent4,
                    t_pers.parent5 as personal_parent5,
                    t_pers.dr,
                    t_pers.propusk,
                    t_pers.group_id as personal_group_id,
                    t_acc.obj_name as account_name,
                    CONCAT("/window/personal/message/",t1.pkey,"/") as __href_window
            from obj_site_personal_mess t1
            left join view_personals t_pers on t_pers.pkey=t1.personal_id 
            left join obj_site_account t_acc on t_acc.pkey=t1.account_id
            where t_pers.pkey is not null and t_pers.enabled=1
            ' ;
    }
       create_viewer('view_personals_messages',$sql) ;

     $sql='create view view_personals_new as
                  select  *
                  from view_personals
                  where c_data>=(UNIX_TIMESTAMP()-5184000)
                 ' ;
    create_viewer('view_personals_new',$sql) ;


           $sql='create view view_personals_last_messages as
                 select  t1.*
                        from obj_site_personal_mess t1
                        where t1.source_obj="" or t1.source_obj is NULL
                        group by t1.personal_id 
                        order by t1.pkey desc
                     ' ;
    create_viewer('view_personals_last_messages',$sql) ;


  if ($GLOBALS['install_options']['viewers']) PERSONAL()->update_groups_viewers() ;

	if ($GLOBALS['install_options']['create_default_objects'] and ESMO_STATUS!='SETUP_FIRST')
  { PERSONAL()->full_group_id_to_personal() ;
    PERSONALS_FILTER()->check_old_format_personals_filters();
  }
	//if ($GLOBALS['install_options']['create_default_objects']) PERSONAL()->sync_workers_by_persons() ;

  if (SETUP_LEVEL('db_updates') and ESMO_STATUS!='SETUP_FIRST')
  {
      execSQL_update('ALTER TABLE  log_personal_changes CHANGE  source  source VARCHAR(128)') ;
  }




}




?>
