public function GetReportData($force = false)
 {
     $arResult = array("REPORT_INFO" => array(), "REPORT_DATA" => array());
     $date = $arResult["REPORT_INFO"] = $this->GetReportInfo();
     if ($date["IS_REPORT_DAY"] == "N") {
         return $arResult;
     } elseif ($date["IS_REPORT_DAY"] == "Y") {
         if ($date["IS_DELAY"] == "Y" && MakeTimeStamp($date["DELAY_TIME"], TM_FULL_FORMAT) < time()) {
             $date["IS_DELAY"] = "N";
         }
         if (($date["IS_DELAY"] == "Y" || $date["SHOW_REPORT_FORM"] == "N") && !$force) {
             return $arResult;
         }
     }
     $datefomat = CSite::GetDateFormat("SHORT", SITE_ID);
     $USER_ID = $this->USER_ID;
     $arManagers = CTimeMan::GetUserManagers($USER_ID);
     $arManagers[] = $USER_ID;
     $user_url = COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', SITE_ID);
     $dbManagers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', $arManagers)));
     $arCurrentUserManagers = array();
     $arCurrentUser = array();
     while ($manager = $dbManagers->GetNext()) {
         $manager['PHOTO'] = $manager['PERSONAL_PHOTO'] > 0 ? CIntranetUtils::InitImage($manager['PERSONAL_PHOTO'], 32, 0, BX_RESIZE_IMAGE_EXACT) : array();
         $userData = array('ID' => $manager['ID'], 'LOGIN' => $manager['LOGIN'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $manager, true, false), 'URL' => str_replace(array('#ID#', '#USER_ID#'), $manager['ID'], $user_url), 'WORK_POSITION' => $manager['WORK_POSITION'], 'PHOTO' => $manager['PHOTO']['CACHE']['src']);
         if ($userData["ID"] == $this->USER_ID) {
             $arCurrentUser = $userData;
         } else {
             $arCurrentUserManagers[] = $userData;
         }
     }
     if (count($arCurrentUserManagers) == 0) {
         $arCurrentUserManagers[] = $arCurrentUser;
     }
     $arInfo = CTimeMan::GetRuntimeInfo(true);
     $dbReports = CTimeManReport::GetList(array('ID' => 'ASC'), array('ENTRY_ID' => $arInfo["ID"], 'REPORT_TYPE' => 'REPORT'));
     if ($Report = $dbReports->Fetch()) {
         $RTReport = $Report["REPORT"];
     }
     $dbReport = CTimeManReportFull::GetList(array("DATE_FROM" => "DESC"), array("USER_ID" => $USER_ID, "ACTIVE" => "N"), array(), array("nTopCount" => 1));
     if ($arReport = $dbReport->Fetch()) {
         $arInfo["REPORT_DATE_FROM"] = MakeTimeStamp($arReport["DATE_FROM"], $datefomat);
         $arInfo["REPORT_DATE_TO"] = MakeTimeStamp($arReport["DATE_TO"], $datefomat);
         //$arInfo["TASKS"] = unserialize($arReport["TASKS"]);
         $arInfo["REPORT"] = $arReport["REPORT"];
         $arInfo["PLANS"] = $arReport["PLANS"];
         if ($arReport["FILES"]) {
             $arInfo["FILES"] = unserialize($arReport["FILES"]);
         }
         $arInfo["REPORT_ID"] = $arReport["ID"];
         if ($arInfo["REPORT_DATE_FROM"] != $arInfo["REPORT_DATE_TO"]) {
             $arInfo['DATE_TEXT'] = FormatDate('j F', $arInfo["REPORT_DATE_FROM"]) . " - " . FormatDate('j F', $arInfo["REPORT_DATE_TO"]);
         } else {
             $arInfo['DATE_TEXT'] = FormatDate('j F', $arInfo["REPORT_DATE_TO"]);
         }
     } else {
         if (isset($_SESSION['report_files']) && is_array($_SESSION['report_files'])) {
             $arInfo["FILES"] = $_SESSION['report_files'];
         }
         $arInfo["REPORT_DATE_FROM"] = MakeTimeStamp($date["DATE_FROM"], TM_SHORT_FORMAT);
         $arInfo["REPORT_DATE_TO"] = MakeTimeStamp($date["DATE_TO"], TM_SHORT_FORMAT);
     }
     $date_to = $date["DATE_TO"] ? $date["DATE_TO"] : $arReport["DATE_TO"];
     $date_to = MakeTimeStamp($date_to, CSite::GetDateFormat("SHORT", SITE_ID));
     $today = CTimeMan::RemoveHoursTS(time());
     if ($date_to < $today) {
         $arInfo["TASKS"] = array();
         $arInfo["EVENTS"] = array();
     }
     $arLastTasks = array();
     $arFilter = array(">=REPORT_DATE" => $date["DATE_FROM"] ? $date["DATE_FROM"] : $arReport["DATE_FROM"], "<=REPORT_DATE" => $date["DATE_TO"] ? $date["DATE_TO"] : $arReport["DATE_TO"], "USER_ID" => $USER_ID);
     $arTaskIDs = array();
     $arEventIDs = array();
     if (is_array($arInfo['PLANNER'])) {
         $arInfo = array_merge($arInfo, $arInfo['PLANNER']['DATA']);
         unset($arInfo['PLANNER']);
     }
     if (is_array($arInfo["TASKS"])) {
         foreach ($arInfo["TASKS"] as $task) {
             $arTaskIDs[] = $task["ID"];
         }
     }
     if (is_array($arInfo["EVENTS"])) {
         foreach ($arInfo["EVENTS"] as $event) {
             $arEventIDs[] = $event["ID"];
         }
     }
     $res = CTimeManReportDaily::GetList(array(), $arFilter);
     while ($day = $res->Fetch()) {
         $arDayTasks = unserialize($day["TASKS"]);
         $arDayEvents = unserialize($day["EVENTS"]);
         if (is_array($arDayTasks)) {
             foreach ($arDayTasks as $task) {
                 if (!in_array($task["ID"], $arTaskIDs)) {
                     $arInfo["TASKS"][] = $task;
                     $arTaskIDs[] = $task["ID"];
                 } else {
                     foreach ($arInfo["TASKS"] as $key => $cur_task) {
                         if ($cur_task["ID"] == $task["ID"]) {
                             $arInfo["TASKS"][$key]["TIME"] += $task["TIME"];
                         }
                     }
                 }
             }
         }
         if (is_array($arDayEvents)) {
             foreach ($arDayEvents as $event) {
                 if (!in_array($event["ID"], $arEventIDs)) {
                     $arInfo["EVENTS"][] = $event;
                     $arEventIDs[] = $event["ID"];
                 }
             }
         }
         if (strlen($day["REPORT"]) > 0 && !$arInfo["REPORT_ID"]) {
             $day["REPORT"] = nl2br($day["REPORT"]);
             $arInfo["REPORT"] .= "<b>" . $day["REPORT_DATE"] . "</b><br>" . $day["REPORT"] . "<br>";
         }
     }
     if ($RTReport && !$arInfo["REPORT_ID"]) {
         $arInfo["REPORT"] .= "<b>" . ConvertTimeStamp(time(), "SHORT") . "</b><br>" . nl2br($RTReport);
     }
     if (is_array($arInfo['EVENTS'])) {
         foreach ($arInfo['EVENTS'] as $key => $arEvent) {
             if ($arEvent['STATUS'] && $arEvent['STATUS'] != 'Y') {
                 unset($arInfo['EVENTS'][$key]);
             }
         }
         $arInfo['EVENTS'] = array_values($arInfo['EVENTS']);
     }
     if (!$arInfo["REPORT_ID"]) {
         if ($arInfo["REPORT_DATE_FROM"] != $arInfo["REPORT_DATE_TO"]) {
             $arInfo['DATE_TEXT'] = FormatDate('j F', $arInfo["REPORT_DATE_FROM"]) . " - " . FormatDate('j F', $arInfo["REPORT_DATE_TO"]);
         } else {
             $arInfo['DATE_TEXT'] = FormatDate('j F', $arInfo["REPORT_DATE_TO"]);
         }
     }
     $arResult["REPORT_DATA"] = array('FROM' => $arCurrentUser, 'TO' => array_values($arCurrentUserManagers), 'INFO' => $arInfo, 'REPORT' => $arInfo["REPORT"], 'PLANS' => $arInfo["PLANS"], 'REPORT_ID' => $arInfo["REPORT_ID"] ? $arInfo["REPORT_ID"] : "");
     return $arResult;
 }
示例#2
0
 $arRes['DATE_START'] = MakeTimeStamp($arRes['DATE_START']) - CTimeZone::GetOffset();
 $arRes['DATE_FINISH'] = MakeTimeStamp($arRes['DATE_FINISH']) - CTimeZone::GetOffset();
 $arInfo = array('INFO' => $arRes, 'DATE_TEXT' => FormatDate('j F Y', $arRes['DATE_START']), 'CALENDAR_ENABLED' => CBXFeatures::IsFeatureEnabled('Calendar'), 'TASKS_ENABLED' => CBXFeatures::IsFeatureEnabled('Tasks') && IsModuleInstalled('tasks'));
 $cur_info = $obUser->GetCurrentInfo();
 if ($cur_info['ID'] == $ID) {
     $arInfo['STATE'] = $obUser->State();
     $arInfo['EXPIRED_DATE'] = $obUser->GetExpiredRecommendedDate();
 } else {
     $arInfo['STATE'] = 'CLOSED';
 }
 $res = array('FROM' => array('ID' => $arCurrentUser['ID'], 'LOGIN' => $arCurrentUser['LOGIN'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $arCurrentUser, true, false), 'URL' => str_replace(array('#ID#', '#USER_ID#'), $arCurrentUser['ID'], $user_url), 'WORK_POSITION' => $arCurrentUser['WORK_POSITION'], 'PHOTO' => $arCurrentUser['PHOTO']['CACHE']['src']), 'TO' => array_values($arCurrentUserManagers), 'INFO' => $arInfo, 'REPORT' => '', 'CAN_EDIT' => $bCanEdit ? 'Y' : 'N', 'REPORTS' => array());
 if (count($res['TO']) <= 0) {
     $res['TO'] = array($res['FROM']);
 }
 $arUserIDs = array();
 $dbReports = CTimeManReport::GetList(array('ID' => 'ASC'), array('ENTRY_ID' => $arInfo['INFO']['ID']));
 while ($arReport = $dbReports->Fetch()) {
     switch ($arReport['REPORT_TYPE']) {
         case 'ERR_OPEN':
         case 'ERR_CLOSE':
         case 'ERR_DURATION':
             $arUserIDs[] = $arReport['USER_ID'];
             $key = $arReport['REPORT_TYPE'] == 'ERR_OPEN' ? 'TIME_START' : ($arReport['REPORT_TYPE'] == 'ERR_CLOSE' ? 'TIME_FINISH' : 'DURATION');
             $arReportData = explode(';', $arReport['REPORT']);
             if (!$res['REPORTS'][$key]) {
                 $res['REPORTS'][$key] = array();
             }
             $report_ts = strtotime($arReportData[1]) + CTimeZone::GetOffset();
             $res['REPORTS'][$key][0] = array('TYPE' => $arReportData[0], 'TYPE_TEXT' => $arReportData[0], 'TIME' => $report_ts + date('Z'), 'DATE_TIME' => FormatDate(str_replace(':s', '', $DB->DateFormatToPHP(FORMAT_DATETIME)), MakeTimeStamp($arReport['TIMESTAMP_X'])), 'ACTIVE' => $arReport['ACTIVE'] == 'Y', 'USER_ID' => $arReport['USER_ID']);
             break;
         case 'REPORT_OPEN':
示例#3
0
 protected function _ReopenGetActivity($entry_id)
 {
     $dbRes = CTimeManReport::GetList(array('ID' => 'ASC'), array('ENTRY_ID' => $entry_id, 'REPORT_TYPE' => 'ERR_OPEN', 'ACTIVE' => 'Y'));
     if ($arRes = $dbRes->Fetch()) {
         return false;
     } else {
         return true;
     }
 }