Esempio n. 1
0
 /**
  * deleteItem
  *
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  *
  */
 public function deleteItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->id) || !($recievingItem = ReceivingItem::get(trim($param->CallbackParameter->id))) instanceof ReceivingItem) {
             throw new Exception('System Error: invalid item provided');
         }
         $recievingItem->setActive(false)->save();
         $results['item'] = $recievingItem->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Esempio n. 2
0
 public function preSave()
 {
     $this->setProduct($this->getProductQtyLog()->getproduct())->setLastPurchaseTime($this->getProductQtyLog()->getCreated());
     switch ($this->getProductQtyLog()->getEntityName()) {
         case 'ReceivingItem':
             if (($receivingItem = ReceivingItem::get($this->getProductQtyLog()->getEntityId())) instanceof ReceivingItem) {
                 $this->setReceivingItem($receivingItem);
             }
             break;
         case 'PurchaseOrderItem':
             if (($purchaseOrderItem = PurchaseOrderItem::get($this->getProductQtyLog()->getEntityId())) instanceof PurchaseOrderItem) {
                 $this->setPurchaseOrderItem($purchaseOrderItem);
             }
             break;
         case 'OrderItem':
             if (($orderItem = OrderItem::get($this->getProductQtyLog()->getEntityId())) instanceof OrderItem) {
                 $this->setOrderItem($orderItem);
             }
             break;
         case 'CreditNoteItem':
             if (($creditNoteItem = CreditNoteItem::get($this->getProductQtyLog()->getEntityId())) instanceof CreditNoteItem) {
                 $this->setCreditNoteItem($creditNoteItem);
             }
             break;
     }
 }