- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/lib/rest.php
- Класс: BitrixTimemanRest
- Вызов: Rest::openDay
static function openDay($query, $n, CRestServer $server)
{
$query = static::prepareQuery($query);
$tmUser = static::getUserInstance($query);
$openAction = $tmUser->OpenAction();
$result = false;
if($openAction)
{
if($openAction === 'OPEN')
{
if(isset($query['TIME']))
{
$timeInfo = static::convertTimeFromISO($query['TIME']);
static::setCurrentTimezoneOffset($timeInfo['OFFSET']);
if(!static::checkDate($timeInfo, ConvertTimeStamp()))
{
throw new DateTimeException('Day open date should correspond to the current date', DateTimeException::ERROR_WRONG_DATETIME);
}
$result = $tmUser->openDay($timeInfo['TIME'], $query['REPORT']);
}
else
{
$result = $tmUser->openDay();
}
if($result !== false)
{
static::setDayGeoPosition($result['ID'], $query, 'open');
}
}
elseif($openAction === 'REOPEN')
{
if(isset($query['TIME']))
{
throw new ArgumentException('Unable to set time, work day is paused', 'TIME');
}
$currentInfo = $tmUser->getCurrentInfo();
$userOffset = $tmUser->getDayStartOffset($currentInfo) + date('Z');
static::setCurrentTimezoneOffset($userOffset);
$result = $tmUser->ReopenDay();
}
}
if(!$result)
{
global $APPLICATION;
$ex = $APPLICATION->GetException();
if($ex)
{
throw new RestException($ex->GetString(), $ex->GetID());
}
}
return static::getStatus($query, $n, $server);
}