- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/invoice/compatible/helper.php
- Класс: Bitrix\Crm\Invoice\Compatible\Helper
- Вызов: Helper::statusOrder
static function statusOrder($id, $statusId)
{
global $USER, $APPLICATION;
$id = (int)$id;
$statusId = trim($statusId);
if ($id <= 0)
{
$APPLICATION->ThrowException(Loc::getMessage('CRM_INVOICE_COMPAT_HELPER_NO_INVOICE_ID'));
return false;
}
$arOrder = static::getByID($id);
if (!$arOrder)
{
$APPLICATION->ThrowException(Loc::getMessage('CRM_INVOICE_COMPAT_HELPER_NO_INVOICE', ['#ID#', $id]));
return false;
}
if ($arOrder['STATUS_ID'] == $statusId)
{
$APPLICATION->ThrowException(Loc::getMessage('CRM_INVOICE_COMPAT_HELPER_DUB_STATUS', ['#ID#', $id]));
return false;
}
/** @var Main\DB\Connection $connection */
$connection = Main\Application::getInstance()->getConnectionPool()->getConnection();
$sqlHelper = $connection->getSqlHelper();
$userId = (isset($USER) && $USER instanceof \CUser) ? (int)$USER->GetID() : 0;
$arFields = array(
'STATUS_ID' => $statusId,
'=DATE_STATUS' => $sqlHelper->getCurrentDateTimeFunction(),
'EMP_STATUS_ID' => $userId > 0 ? $userId : false
);
return static::update($id, $arFields);
}