while ($row = $result->Fetch()) { if ($row['GROUP_ID'] > 2) { $saleGroupIds[] = $row['GROUP_ID']; } } if ($saleGroupIds) { $result = GroupTable::getList(array('select' => array('ID', 'NAME'), 'filter' => array('=ID' => $saleGroupIds), 'order' => array('C_SORT' => 'ASC', 'ID' => 'ASC'))); while ($row = $result->fetch()) { $groups[$row['ID']] = $row['NAME']; } } // A D D / U P D A T E ///////////////////////////////////////////////////////////////////////////////////////////////// if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$readOnly && check_bitrix_sessid() && ($_POST['save'] || $_POST['apply'])) { $errors = array(); $statusType = $_REQUEST['TYPE'] == 'O' ? 'O' : 'D'; $lockedStatusList = array("O" => array(\Bitrix\Sale\OrderStatus::getInitialStatus(), \Bitrix\Sale\OrderStatus::getFinalStatus()), "D" => array(\Bitrix\Sale\DeliveryStatus::getInitialStatus(), \Bitrix\Sale\DeliveryStatus::getFinalStatus())); if ($statusId) { foreach ($lockedStatusList as $lockStatusType => $lockStatusIdList) { foreach ($lockStatusIdList as $lockStatusId) { if ($lockStatusId == $statusId && $statusType != $lockStatusType) { $errors[] = Loc::getMessage('SALE_STATUS_WRONG_TYPE', array('#STATUS_ID#' => htmlspecialcharsEx($statusId), '#STATUS_TYPE#' => Loc::getMessage('SSEN_TYPE_' . $statusType))); break; } } } } // prepare & check status $status = array('TYPE' => $statusType, 'SORT' => ($statusSort = intval($_POST['SORT'])) ? $statusSort : 100, 'NOTIFY' => $_POST['NOTIFY'] ? 'Y' : 'N'); $isNew = true; $result = new \Bitrix\Main\Entity\Result(); if ($statusId) {