- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/classes/general/timeman_user.php
- Класс: CTimeManUser
- Вызов: CTimeManUser::closeDay
public function closeDay($timestamp = false, $report = '', $bFieldsOnly = false, $extraInformation = [])
{
global $APPLICATION;
if ($this->State() == 'EXPIRED' && !$timestamp)
{
$GLOBALS['APPLICATION']->ThrowException('Workday is expired', 'WD_EXPIRED');
return false;
}
$recordForm = $this->buildStopForm($timestamp, $report, $extraInformation);
if ($this->State() == 'EXPIRED')
{
$recordForm->editedBy = $this->USER_ID;
}
if ($recordForm->validate())
{
$result = (new ManageStopHandler())->handle($recordForm);
if ($result->isSuccess())
{
CUser::SetLastActivityDate($this->USER_ID);
$recordFields = WorktimeRecordTable::convertFieldsCompatible($result->getWorktimeRecord()->collectRawValues());
if (isset($arFields['ACTIVE']) && $recordFields['ACTIVE'] == 'N')
{
CTimeManNotify::SendMessage($recordFields['ID']);
}
static::clearFullReportCache();
$e = GetModuleEvents('timeman', 'OnAfterTMDayEnd');
while ($a = $e->Fetch())
{
ExecuteModuleEventEx($a, [$recordFields]);
}
return $recordFields;
}
else
{
foreach ($result->getErrors() as $error)
{
if ($error->getCode() === WorktimeServiceResult::ERROR_REASON_NEEDED
|| $error->getCode() === WorktimeServiceResult::ERROR_EXPIRED_REASON_NEEDED)
{
$APPLICATION->ThrowException($error->getMessage(), 'REPORT_NEEDED');
}
}
if ($result->getErrors()[0]->getCode() === WorktimeServiceResult::ERROR_FOR_USER)
{
$APPLICATION->ThrowException($result->getErrors()[0]->getMessage(), 'ALERT_WARNING');
}
}
}
return false;
}