- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/lib/controller/shiftplan.php
- Класс: BitrixTimemanControllerShiftPlan
- Вызов: ShiftPlan::addAction
public function addAction()
{
$shiftPlanForm = new ShiftPlanForm();
if ($shiftPlanForm->load($this->getRequest()) && $shiftPlanForm->validate())
{
$forced = $this->getRequest()->getPost('createShiftPlanForced') === 'Y';
$result = (new ShiftPlanHandlerCreateHandler())->handle($shiftPlanForm, $forced);
if ($result->isSuccess())
{
$res = ['shiftPlan' => $this->makeResult($result)];
return $res;
}
elseif ($result->getFirstError()->getCode() === ShiftPlanServiceResult::ERROR_CODE_OVERLAPPING_SHIFT_PLAN)
{
/** @var ShiftPlanServiceResult $result */
$shiftWithDate = $result->getShiftWithDate();
if ($shiftWithDate)
{
$this->addError(new Error(
Loc::getMessage('TM_SHIFTPLAN_SERVICE_OVERLAPPING_SHIFT_PLANS_EXIST',
[
'#SHIFT_NAME#' => $shiftWithDate->getShift()->getName(),
'#SCHEDULE_NAME#' => $shiftWithDate->getSchedule()->getName(),
'#SHIFT_DATE#' => TimeHelper::getInstance()->formatDateTime(
$shiftWithDate->getDateTimeStart(),
Context::getCurrent()->getCulture()->getShortDateFormat()
),
'#SHIFT_START_TIME#' => TimeHelper::getInstance()->formatDateTime(
$shiftWithDate->getDateTimeStart(),
Context::getCurrent()->getCulture()->getShortTimeFormat()
),
'#SHIFT_END_TIME#' => TimeHelper::getInstance()->formatDateTime(
$shiftWithDate->getDateTimeEnd(),
Context::getCurrent()->getCulture()->getShortTimeFormat()
),
]
),
ShiftPlanServiceResult::ERROR_CODE_OVERLAPPING_SHIFT_PLAN
));
return [];
}
}
$this->addErrors($result->getErrors());
return [];
}
$this->addError($shiftPlanForm->getFirstError());
}