Пример #1
0
         if ($source == 'department') {
             $obSection = new CIBlockSection();
             $obSection->Update($ID, $arFields);
             $CACHE_MANAGER->CleanDir("timeman_structure_" . COption::GetOptionInt('intranet', 'iblock_structure'));
             $res = array('ID' => $ID, 'SETTINGS' => CTimeMan::GetSectionPersonalSettings($ID, true, $arNeededSettings), 'SETTINGS_ALL' => CTimeMan::GetSectionSettings($ID, $arNeededSettings));
         } else {
             $obUser = new CUser();
             $obUser->Update($ID, $arFields);
             $CACHE_MANAGER->CleanDir("timeman_structure_" . COption::GetOptionInt('intranet', 'iblock_structure'));
             $TMUSER = new CTimeManUser($ID);
             $res = array('ID' => $ID, 'SETTINGS' => $TMUSER->GetPersonalSettings($arNeededSettings), 'SETTINGS_ALL' => $TMUSER->GetSettings($arNeededSettings));
         }
     } else {
         $res = array('DEFAULTS' => CTimeMan::GetModuleSettings($arNeededSettings), 'DEPARTMENTS' => array(), 'USERS' => array());
         foreach ($_REQUEST['DEPARTMENTS'] as $dpt) {
             $res['DEPARTMENTS'][] = array('ID' => $dpt, 'SETTINGS' => CTimeMan::GetSectionPersonalSettings($dpt, true, $arNeededSettings), 'SETTINGS_ALL' => CTimeMan::GetSectionSettings($dpt, $arNeededSettings));
         }
         foreach ($_REQUEST['USERS'] as $user) {
             $TMUSER = new CTimeManUser($user);
             $res['USERS'][] = array('ID' => $user, 'SETTINGS' => $TMUSER->GetPersonalSettings($arNeededSettings), 'SETTINGS_ALL' => $TMUSER->GetSettings($arNeededSettings));
         }
     }
     break;
 case 'admin_data':
     $obReport = new CTimeManAdminReport(array('show_all' => $_REQUEST['show_all'] == 'Y', 'ts' => $_REQUEST['ts'], 'page' => $_REQUEST['page'], 'amount' => 30, 'department' => $_REQUEST['department'], 'path_user' => COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $site_id), 'nav_handler' => 'window.BXTMREPORT.Page'));
     $bReturnRes = true;
     $res = $obReport->GetData();
     \Bitrix\Main\Type\Collection::sortByColumn($res['USERS'], array('HEAD' => SORT_DESC, 'NAME' => SORT_ASC));
     $res['DEPARTMENTS'] = array_values($res['DEPARTMENTS']);
     break;
 case 'admin_save':
Пример #2
0
 protected function _GetSettings()
 {
     global $USER_FIELD_MANAGER;
     $arRes = array();
     $arRes = $this->_GetPersonalSettings();
     if ($arRes) {
         if ($arRes['UF_TIMEMAN'] === 'N') {
             return array('UF_TIMEMAN' => false);
         }
         $cnt = 0;
         if ($arRes['UF_TIMEMAN'] !== 'Y') {
             $cnt++;
         }
         foreach ($arRes as $fld => $value) {
             if (!$arRes[$fld] || $arRes[$fld] == '00:00') {
                 $cnt++;
             }
         }
         if ($cnt > 0) {
             if (is_array($this->UF_DEPARTMENT) && count($this->UF_DEPARTMENT) > 0) {
                 $allSet = array('UF_TIMEMAN' => $arRes['UF_TIMEMAN'] ? $arRes['UF_TIMEMAN'] : false, 'UF_TM_MAX_START' => 86401, 'UF_TM_MIN_FINISH' => false, 'UF_TM_MIN_DURATION' => false, 'UF_TM_REPORT_REQ' => false, 'UF_REPORT_PERIOD' => $arRes['UF_REPORT_PERIOD'], 'UF_TM_REPORT_DATE' => $arRes['UF_TM_REPORT_DATE'], 'UF_TM_TIME' => $arRes['UF_TM_TIME'], 'UF_TM_DAY' => $arRes['UF_TM_DAY'], 'UF_TM_REPORT_TPL' => array(), 'UF_TM_FREE' => false, 'UF_TM_ALLOWED_DELTA' => -1);
                 foreach ($this->UF_DEPARTMENT as $dpt) {
                     $dptSet = CTimeMan::GetSectionSettings($dpt);
                     if ($allSet['UF_TIMEMAN'] !== 'Y' && $dptSet['UF_TIMEMAN']) {
                         $allSet['UF_TIMEMAN'] = $dptSet['UF_TIMEMAN'];
                     }
                     if ($dptSet['UF_TM_MAX_START']) {
                         $allSet['UF_TM_MAX_START'] = min($dptSet['UF_TM_MAX_START'], $allSet['UF_TM_MAX_START']);
                     }
                     $allSet['UF_TM_MAX_START'] = min($dptSet['UF_TM_MAX_START'], $allSet['UF_TM_MAX_START']);
                     $allSet['UF_TM_MIN_FINISH'] = max($dptSet['UF_TM_MIN_FINISH'], $allSet['UF_TM_MIN_FINISH']);
                     $allSet['UF_TM_MIN_DURATION'] = max($dptSet['UF_TM_MIN_DURATION'], $allSet['UF_TM_MIN_DURATION']);
                     if ($dptSet['UF_TM_REPORT_REQ']) {
                         $allSet['UF_TM_REPORT_REQ'] = $dptSet['UF_TM_REPORT_REQ'];
                     }
                     if ((!is_array($allSet['UF_TM_REPORT_TPL']) || count($allSet['UF_TM_REPORT_TPL']) <= 0) && $dptSet['UF_TM_REPORT_TPL']) {
                         $allSet['UF_TM_REPORT_TPL'] = $dptSet['UF_TM_REPORT_TPL'];
                     }
                     if ($dptSet['UF_TM_FREE']) {
                         $allSet['UF_TM_FREE'] = $dptSet['UF_TM_FREE'];
                     }
                     if ($dptSet['UF_TM_ALLOWED_DELTA']) {
                         if ($allSet['UF_TM_ALLOWED_DELTA'] == -1 || $dptSet['UF_TM_ALLOWED_DELTA'] < $allSet['UF_TM_ALLOWED_DELTA']) {
                             $allSet['UF_TM_ALLOWED_DELTA'] = $dptSet['UF_TM_ALLOWED_DELTA'];
                         }
                     }
                 }
                 //report fields
                 $allSet["UF_REPORT_PERIOD"] = !$allSet["UF_REPORT_PERIOD"] && $dptSet["UF_REPORT_PERIOD"] ? $dptSet["UF_REPORT_PERIOD"] : $allSet["UF_REPORT_PERIOD"];
                 $allSet["UF_TM_TIME"] = !$allSet["UF_TM_TIME"] && $dptSet["UF_TM_TIME"] ? $dptSet["UF_TM_TIME"] : $allSet["UF_TM_TIME"];
                 $allSet["UF_TM_DAY"] = !$allSet["UF_TM_DAY"] && $dptSet["UF_TM_DAY"] ? $dptSet["UF_TM_DAY"] : $allSet["UF_TM_DAY"];
                 $allSet["UF_TM_REPORT_DATE"] = !$allSet["UF_TM_REPORT_DATE"] && $dptSet["UF_TM_REPORT_DATE"] ? $dptSet["UF_TM_REPORT_DATE"] : $allSet["UF_TM_REPORT_DATE"];
                 if ($arRes['UF_TM_ALLOWED_DELTA'] === '0') {
                     unset($allSet['UF_TM_ALLOWED_DELTA']);
                 }
                 foreach ($allSet as $key => $value) {
                     if (!$arRes[$key] || $arRes[$key] === '00:00') {
                         $arRes[$key] = $value;
                     }
                 }
                 if ($arRes['UF_TIMEMAN'] === 'N') {
                     return $arRes = array('UF_TIMEMAN' => false);
                 }
             } elseif ($arRes['UF_TIMEMAN'] !== 'Y') {
                 // if user is not attached to company structure tm can be allowed only in his own profile
                 return $arRes = array('UF_TIMEMAN' => false);
             }
         }
         //if ($cnt > 0)
         $arRes['UF_TIMEMAN'] = true;
         // it can be only Y|null at this moment
         $arRes['UF_TM_MAX_START'] = $arRes['UF_TM_MAX_START'];
         $arRes['UF_TM_MAX_START'] = $arRes['UF_TM_MAX_START'] > 0 ? $arRes['UF_TM_MAX_START'] : COption::GetOptionInt('timeman', 'workday_max_start', 33300);
         $arRes['UF_TM_MIN_FINISH'] = $arRes['UF_TM_MIN_FINISH'];
         $arRes['UF_TM_MIN_FINISH'] = $arRes['UF_TM_MIN_FINISH'] > 0 ? $arRes['UF_TM_MIN_FINISH'] : COption::GetOptionInt('timeman', 'workday_min_finish', 63900);
         $arRes['UF_TM_MIN_DURATION'] = $arRes['UF_TM_MIN_DURATION'];
         $arRes['UF_TM_MIN_DURATION'] = $arRes['UF_TM_MIN_DURATION'] > 0 ? $arRes['UF_TM_MIN_DURATION'] : COption::GetOptionInt('timeman', 'workday_min_duration', 28800);
         $arRes['UF_TM_REPORT_REQ'] = $arRes['UF_TM_REPORT_REQ'] ? $arRes['UF_TM_REPORT_REQ'] : COption::GetOptionInt('timeman', 'workday_report_required', 'A');
         $arRes['UF_TM_REPORT_TPL'] = $arRes['UF_TM_REPORT_TPL'] ? $arRes['UF_TM_REPORT_TPL'] : array();
         $arRes['UF_TM_FREE'] = $arRes['UF_TM_FREE'] ? $arRes['UF_TM_FREE'] == 'Y' : false;
         $arRes['UF_TM_ALLOWED_DELTA'] = $arRes['UF_TM_ALLOWED_DELTA'] > -1 ? $arRes['UF_TM_ALLOWED_DELTA'] : COption::GetOptionInt('timeman', 'workday_allowed_delta', '900');
     } else {
         return array('UF_TIMEMAN' => false);
     }
     return $arRes;
 }