コード例 #1
0
ファイル: shipmentitem.php プロジェクト: Satariall/izurit
 /**
  * @param $id
  * @return Main\Entity\DeleteResult
  * @throws Main\ArgumentException
  */
 public static function deleteWithItems($id)
 {
     $id = intval($id);
     if ($id <= 0) {
         throw new Main\ArgumentNullException("id");
     }
     $itemsFromDbList = ShipmentItemStoreTable::getList(array("filter" => array('ORDER_DELIVERY_BASKET_ID' => $id), "select" => array("ID")));
     while ($itemsFromDbItem = $itemsFromDbList->fetch()) {
         ShipmentItemStoreTable::delete($itemsFromDbItem['ID']);
     }
     return ShipmentItemTable::delete($id);
 }
コード例 #2
0
 /**
  * @param $id
  * @return array
  * @throws Main\ArgumentException
  * @throws Main\ArgumentNullException
  */
 public static function loadForShipmentItem($id)
 {
     if (intval($id) <= 0) {
         throw new Main\ArgumentNullException("id");
     }
     $items = array();
     $itemDataList = Internals\ShipmentItemStoreTable::getList(array('filter' => array('ORDER_DELIVERY_BASKET_ID' => $id), 'order' => array('DATE_CREATE' => 'ASC', 'ID' => 'ASC')));
     while ($itemData = $itemDataList->fetch()) {
         $items[] = new static($itemData);
     }
     return $items;
 }
コード例 #3
0
 /**
  * @return Main\Entity\Result
  */
 public function save()
 {
     $result = new Main\Entity\Result();
     $oldBarcodeList = array();
     $itemsFromDb = array();
     if ($this->getShipmentItem() && $this->getShipmentItem()->getId() > 0) {
         $itemsFromDbList = Internals\ShipmentItemStoreTable::getList(array("filter" => array("ORDER_DELIVERY_BASKET_ID" => $this->getShipmentItem()->getId()), "select" => array("*")));
         while ($itemsFromDbItem = $itemsFromDbList->fetch()) {
             $itemsFromDb[$itemsFromDbItem["ID"]] = true;
         }
     }
     /** @var ShipmentItemStore $shipmentItemStore */
     foreach ($this->collection as $shipmentItemStore) {
         $r = $shipmentItemStore->save();
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
         if (isset($itemsFromDb[$shipmentItemStore->getId()])) {
             unset($itemsFromDb[$shipmentItemStore->getId()]);
         }
     }
     foreach ($itemsFromDb as $k => $v) {
         Internals\ShipmentItemStoreTable::delete($k);
     }
     return $result;
 }