} if (count($arUserIDs) > 0) { $arUserIDs = array_unique($arUserIDs); $dbUsers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', $arUserIDs), 'ACTIVE' => 'Y')); while ($arUser = $dbUsers->Fetch()) { $name = CUser::FormatName(CSite::GetNameFormat(false), $arUser); foreach ($res['REPORTS'] as &$rep) { foreach ($rep as &$arReport) { if ($arReport['USER_ID'] == $arUser['ID']) { $arReport['USER_NAME'] = $name; } } } } } $dbRes = CTimeManReportDaily::GetList(array('ID' => 'DESC'), array('ENTRY_ID' => $arInfo['INFO']['ID'])); if ($arRes = $dbRes->Fetch()) { // $arRes['ACTIVE'], $arRes['MARK']; $res['REPORT'] = nl2br(htmlspecialcharsEx($arRes['REPORT'])); if ($res['INFO']['TASKS_ENABLED']) { $res['INFO']['TASKS'] = unserialize($arRes['TASKS']); } else { unset($res['INFO']['TASKS']); } if ($res['INFO']['CALENDAR_ENABLED']) { $res['INFO']['EVENTS'] = unserialize($arRes['EVENTS']); } else { unset($res['INFO']['EVENTS']); } } $res['NEIGHBOURS'] = CTimeManEntry::GetNeighbours($arInfo['INFO']['ID'], $arInfo['INFO']['USER_ID'], !!$_REQUEST['slider_type']);
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; }