• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/service/schedule/shiftplanservice.php
  • Класс: BitrixTimemanServiceScheduleShiftPlanService
  • Вызов: ShiftPlanService::delete
public function delete(ShiftPlanForm $shiftPlanForm)
{
	$shiftPlan = $this->shiftPlanRepository->findActiveById($shiftPlanForm->id, ['*']);
	if (!$shiftPlan)
	{
		return (new ShiftPlanServiceResult())->addShiftPlanNotFoundError();
	}
	$shiftPlan->markDeleted();
	$agentId = 0;
	/** @var ShiftPlan $shiftPlan */
	if ($shiftPlan->getMissedShiftAgentId() > 0)
	{
		$agentId = $shiftPlan->getMissedShiftAgentId();
	}
	$shiftPlan->setMissedShiftAgentId(0);
	$res = $this->shiftPlanRepository->save($shiftPlan);
	if (!$res->isSuccess())
	{
		return ShiftPlanServiceResult::createByResult($res);
	}
	if ($agentId > 0)
	{
		$this->worktimeAgentManager->deleteAgentById($agentId);
	}
	return (new ShiftPlanServiceResult())
		->setShift($shift = $this->shiftRepository->findByIdWithSchedule($shiftPlanForm->shiftId))
		->setSchedule($shift ? $shift->obtainSchedule() : null)
		->setShiftPlan($shiftPlan);
}