- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/classes/general/timeman_report_full.php
- Класс: CUserReportFull
- Вызов: CUserReportFull::FixDateByHoliday
private function FixDateByHoliday($DATE_FROM = false, $DATE_TO = false)
{
$arResult = Array(
"NEED_TO_RECALC"=>false,
"DO_NOT_SHOW_THE_FORM"=>false
);
//$DATE_TO_INC = ConvertTimeStampForReport(strtotime('+1 day', MakeTimeStamp($DATE_TO,$this->TimeShort)),"SHORT");
// $DATE_TO_INC = ConvertTimeStampForReport(strtotime('+1 day', MakeTimeStamp($DATE_TO,TM_SHORT_FORMAT)),"SHORT");
// $DATE_FROM = ConvertTimeStampForReport(MakeTimeStamp($DATE_FROM, TM_SHORT_FORMAT),"SHORT");
$shortFormat = CSite::getDateFormat("SHORT", SITE_ID);
$fullFormat = CSite::getDateFormat("FULL", SITE_ID);
$DATE_TO_INC = ConvertTimeStamp(strtotime('+1 day', MakeTimeStamp($DATE_TO, $shortFormat)),"SHORT");
$DATE_FROM = ConvertTimeStamp(MakeTimeStamp($DATE_FROM, $shortFormat),"SHORT");
// if($DATE_TO_INC == $DATE_FROM)
// {
// $DATE_TO_INC = ConvertTimeStamp(strtotime('+2 day', $ts_from),"SHORT");
// }
//was the work day is open between $DATE_FROM and $DATE_TO?
$dbRes = CTimeManEntry::GetList(
array('ID' => 'ASC'),
array(
'USER_ID' => $this->USER_ID,
'>=DATE_START'=>$DATE_FROM,
'$DATE_TO_INC,
),
false,false,Array("ID")
);
if (!$dbRes->Fetch())//it's all right, we found work between $DATE_FROM and $DATE_TO
{
//the work day was NOT open between $DATE_FROM and $DATE_TO...hmm, holidays?
//let's try to find first open work day after holidays
$dbRes = CTimeManEntry::GetList(
array('ID' => 'ASC'),
array(
'USER_ID' => $this->USER_ID,
'>DATE_START'=>$DATE_FROM,
),
false,false,Array("ID", "DATE_START")
);
if ($res = $dbRes->Fetch())
{
//we've found first open work day after holidays, now we should rewrite last report date
$FWorkDayDateTS = MakeTimeStamp($res['DATE_START'],$this->TimeFull);
$LastDate = ConvertTimeStampForReport(strtotime('-1 day',$FWorkDayDateTS),"SHORT");
//if we set the same value we will fall into the endless recursion
if($LastDate != ConvertTimeStampForReport($this->GetLastDate(),"SHORT"))
{
$this->SetLastDate($this->USER_ID,$LastDate);
$arResult["NEED_TO_RECALC"] = true;
}
}
else
{
//we not found the first open workday after holidays, it's mean that the holidays are not over yet and we can't show the report form
$arResult["DO_NOT_SHOW_THE_FORM"] = true;
}
}
return $arResult;
}