Ejemplo n.º 1
0
 public static function onBeforeDelete(Entity\Event $event)
 {
     $result = new Entity\EventResult();
     $primary = $event->getParameter("primary");
     if (intval($primary['ID']) > 0) {
         $dbRes = \Bitrix\Sale\Internals\ShipmentExtraServiceTable::getList(array('filter' => array('=EXTRA_SERVICE_ID' => $primary['ID'])));
         if ($row = $dbRes->fetch()) {
             $result->addError(new Entity\EntityError(str_replace('#ID#', $primary['ID'], Loc::getMessage('DELIVERY_EXTRA_SERVICES_ENTITY_ERROR_DELETE'))));
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Function formats delivery system info in arResult
  * @return void
  */
 protected function formatResultDeliverySystem()
 {
     $arResult =& $this->arResult;
     foreach ($arResult['SHIPMENT'] as &$shipment) {
         if (!empty($shipment["DELIVERY_ID"])) {
             $shipment["DELIVERY"]["NAME"] = htmlspecialcharsEx($shipment["DELIVERY"]["NAME"]);
         }
         $res = \Bitrix\Sale\Delivery\ExtraServices\Table::getList(array('filter' => array("=DELIVERY_ID" => $shipment['DELIVERY_ID'], "=CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store', "=CODE" => 'BITRIX_STORE_PICKUP')));
         $store = $res->fetch();
         if ($store) {
             $dbRes = \Bitrix\Sale\Internals\ShipmentExtraServiceTable::getList(array('filter' => array('=SHIPMENT_ID' => $shipment['ID'], '=EXTRA_SERVICE_ID' => $store['ID'])));
             if ($row = $dbRes->fetch()) {
                 $shipment['STORE_ID'] = $row["VALUE"];
             }
         }
     }
     unset($shipment);
     if (!empty($arResult["DELIVERY"])) {
         if (!empty($arResult['DELIVERY_STORE_LIST'])) {
             $arResult["DELIVERY"]['STORE_LIST'] = $arResult['DELIVERY_STORE_LIST'];
             unset($arResult['DELIVERY_STORE_LIST']);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Deletes shipment
  *
  * @return Result
  * @throws Main\NotSupportedException
  * @throws Main\ObjectNotFoundException
  */
 public function delete()
 {
     $result = new Result();
     if ($this->isShipped()) {
         $result->addError(new ResultError(Loc::getMessage('SALE_SHIPMENT_EXIST_SHIPPED'), 'SALE_SHIPMENT_EXIST_SHIPPED'));
         return $result;
     }
     if ($this->isAllowDelivery()) {
         $this->disallowDelivery();
     }
     if (!$this->isSystem()) {
         $this->setField('BASE_PRICE_DELIVERY', 0);
     }
     $this->getShipmentItemCollection()->clearCollection();
     $id = $this->getId();
     $result = parent::delete();
     if ($result->isSuccess()) {
         Internals\ShipmentExtraServiceTable::deleteByShipmentId($id);
     }
     return $result;
 }
Ejemplo n.º 4
0
 public static function saveStoreIdForShipment($shipmentId, $deliveryId, $storeId)
 {
     if (intval($shipmentId) <= 0) {
         throw new ArgumentNullException("shipmentId");
     }
     $result = new Result();
     if (intval($deliveryId) <= 0) {
         return $result;
     }
     $storeFields = self::getStoresFields($deliveryId);
     if (isset($storeFields['ID'])) {
         $dbRes = ShipmentExtraServiceTable::getList(array('filter' => array('=SHIPMENT_ID' => $shipmentId, '=EXTRA_SERVICE_ID' => $storeFields['ID'])));
         $storeRowId = 0;
         if ($row = $dbRes->fetch()) {
             $storeRowId = $row["ID"];
         }
         if ($storeRowId > 0) {
             $res = ShipmentExtraServiceTable::update($storeRowId, array("VALUE" => $storeId));
         } else {
             $res = ShipmentExtraServiceTable::add(array("EXTRA_SERVICE_ID" => $storeFields['ID'], "SHIPMENT_ID" => $shipmentId, "VALUE" => $storeId));
         }
         if (!$res->isSuccess()) {
             foreach ($res->getErrors() as $error) {
                 $result->addError($error);
             }
         }
     }
     return $result;
 }