- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/classes/general/timeman_report_full.php
- Класс: CUserReportFull
- Вызов: CUserReportFull::GetLastDate
public function GetLastDate()
{
global $DB,$USER;
$arSettings=$this->GetSettings();
$shortFormat = CSite::getDateFormat("SHORT", SITE_ID);
$fullFormat = CSite::getDateFormat("FULL", SITE_ID);
if (!$arSettings["UF_LAST_REPORT_DATE"])
{
$dbres = CTimeManReportFull::GetList(
Array("DATE_TO"=>"desc"),
Array("USER_ID"=>$this->USER_ID,"ACTIVE"=>"Y"),
Array("DATE_TO"),
Array("nTopCount"=>1)
);
$last_report = $dbres->Fetch();
$last_date_report = MakeTimeStamp($last_report["DATE_TO"] ?? null, $this->TimeShort);
}
else
{
$last_date_report = MakeTimeStamp($arSettings["UF_LAST_REPORT_DATE"], $shortFormat);
if (!$last_date_report)
{
// id=140000
$last_date_report = MakeTimeStamp($arSettings["UF_LAST_REPORT_DATE"], TM_SHORT_FORMAT);
}
}
$last_settings = MakeTimeStamp($arSettings["UF_SETTING_DATE"], $fullFormat);
$last_date_report = max($last_date_report, $last_settings);
switch ($arSettings["UF_REPORT_PERIOD"])
{
case "WEEK":
if($arSettings["UF_TM_DAY"]<=4)
$arLastDate = strtotime("last sun -1 week");
else
$arLastDate = strtotime("last sun");
if ($last_date_report)
$arLastDate = $last_date_report;
break;
case "DAY":
$arLastDate = strtotime("-1 day");
if ($last_date_report)
$arLastDate = $last_date_report;
break;
case "MONTH";
if($arSettings["UF_TM_REPORT_DATE"]<=20)
$arLastDate = strtotime("last day of last month -1 month");
else
$arLastDate = strtotime("last day of last month");
if ($last_date_report)
$arLastDate = $last_date_report;
break;
}
return $arLastDate;
}