当前位置: 首页>>代码示例>>PHP>>正文


PHP Dao::commitTransaction方法代码示例

本文整理汇总了PHP中Dao::commitTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Dao::commitTransaction方法的具体用法?PHP Dao::commitTransaction怎么用?PHP Dao::commitTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dao的用法示例。


在下文中一共展示了Dao::commitTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->id)) {
             throw new Exception('Invalid supplier ID passed in!');
         }
         $supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id);
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid supplier passed in!');
         }
         $contactName = trim($param->CallbackParameter->address->contactName);
         $contactNo = trim($param->CallbackParameter->address->contactNo);
         $street = trim($param->CallbackParameter->address->street);
         $city = trim($param->CallbackParameter->address->city);
         $region = trim($param->CallbackParameter->address->region);
         $postCode = trim($param->CallbackParameter->address->postCode);
         $country = trim($param->CallbackParameter->address->country);
         $address = $supplier->getAddress();
         $supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save();
         $results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : '');
         $results['item'] = $supplier->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . $ex->getTraceAsString();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:34,代码来源:DetailsController.php

示例2: sendEmail

 /**
  * Sending the email out
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  */
 public function sendEmail($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) {
             throw new Exception('System Error: invalid order provided!');
         }
         if (!isset($param->CallbackParameter->emailAddress) || ($emailAddress = trim($param->CallbackParameter->emailAddress)) === '') {
             throw new Exception('System Error: invalid emaill address provided!');
         }
         $emailBody = '';
         if (isset($param->CallbackParameter->emailBody) && ($emailBody = trim($param->CallbackParameter->emailBody)) !== '') {
             $emailBody = str_replace("\n", "<br />", $emailBody);
         }
         $pdfFile = EntityToPDF::getPDF($order);
         $asset = Asset::registerAsset($order->getOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
         $type = $order->getType();
         EmailSender::addEmail('sales@budgetpc.com.au', $emailAddress, 'BudgetPC ' . $type . ':' . $order->getOrderNo(), (trim($emailBody) === '' ? '' : $emailBody . "<br /><br />") . 'Please find attached ' . $type . ' (' . $order->getOrderNo() . '.pdf) from Budget PC Pty Ltd.', array($asset));
         $order->addComment('An email sent to "' . $emailAddress . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         $results['item'] = $order->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:36,代码来源:OrderBtns.php

示例3: addComments

 /**
  *
  * @param unknown $sender
  * @param unknown $params
  */
 public function addComments($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->entityName) || ($entityName = trim($params->CallbackParameter->entityName)) === '') {
             throw new Exception('System Error: EntityName is not provided!');
         }
         if (!isset($params->CallbackParameter->entityId) || ($entityId = trim($params->CallbackParameter->entityId)) === '') {
             throw new Exception('System Error: entityId is not provided!');
         }
         if (!($entity = $entityName::get($entityId)) instanceof $entityName) {
             throw new Exception('System Error: no such a entity exisits!');
         }
         if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') {
             throw new Exception('System Error: invalid comments passed in!');
         }
         $comment = Comments::addComments($entity, $comments, Comments::TYPE_NORMAL);
         $results['item'] = $comment->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:31,代码来源:CommentsDiv.php

示例4: updateSetting

 public function updateSetting($sender, $param)
 {
     $result = $errors = array();
     try {
         $result = $products = array();
         $systemSetting = SystemSettings::getByType(SystemSettings::TYPE_SYSTEM_BUILD_PRODUCTS_ID);
         foreach ($param->CallbackParameter as $type => $ids) {
             $result[$type] = array();
             $products[$type] = array();
             foreach ($ids as $index => $id) {
                 $id = intval(trim($id));
                 if (($product = Product::get($id)) instanceof Product) {
                     $result[$type][] = $id;
                     $products[$type][] = $product->getJson();
                 }
             }
         }
         Dao::beginTransaction();
         $systemSetting->setValue(json_encode($result))->save();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         // 			Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($products, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:26,代码来源:BuildController.php

示例5: run

 public static function run()
 {
     try {
         Dao::beginTransaction();
         $start = self::_logMsg("== START: processing Product Ageing ==", __CLASS__, __FUNCTION__);
         self::_emptyProductAgeingLog();
         $productCount = 0;
         $products = self::_getProducts();
         if (self::DEBUG === true) {
             self::_logMsg('ProductCount: ' . count($products), __CLASS__, __FUNCTION__);
         }
         foreach ($products as $product) {
             $productCount++;
             if (self::DEBUG === true) {
                 self::_logMsg('ProductId: ' . $product->getId(), __CLASS__, __FUNCTION__);
             }
             $lastPurchase = self::_getLastPurchase($product);
             if ($lastPurchase instanceof ProductQtyLog) {
                 self::_recordProductAgeingLog($lastPurchase);
             }
         }
         $end = new UDate();
         self::_logMsg("== FINISHED: process product ageing, (productCount: " . $productCount . ", ProductAgeingLogCount: " . ProductAgeingLog::countByCriteria('active = 1') . ")", __CLASS__, __FUNCTION__);
         Dao::commitTransaction();
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         echo "\n" . $e->getMessage() . "\n" . $e->getTraceAsString();
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:ProductAgeingReport.php

示例6: updateProduct

function updateProduct($pro, $fileName, $line)
{
    $clientScript = CatelogConnector::getConnector(B2BConnector::CONNECTOR_TYPE_CATELOG, getWSDL(), 'B2BUser', 'B2BUser');
    try {
        $transStarted = false;
        try {
            Dao::beginTransaction();
        } catch (Exception $e) {
            $transStarted = true;
        }
        $sku = trim($pro['sku']);
        $product = Product::getBySku($pro['sku']);
        $mageId = trim($pro['product_id']);
        $name = trim($pro['name']);
        $short_description = trim($pro['short_description']);
        $description = trim($pro['description']);
        $weight = trim($pro['weight']);
        $statusId = trim($pro['status']);
        $price = trim($pro['price']);
        $specialPrice = trim($pro['special_price']);
        $specialPrice_From = trim($pro['special_from_date']) === '' ? trim($pro['special_from_date']) : null;
        $specialPrice_To = trim($pro['special_to_date']) === '' ? trim($pro['special_to_date']) : null;
        $supplierName = trim($pro['supplier']);
        $attributeSet = ProductAttributeSet::get(trim($pro['attributeSetId']));
        if (!$product instanceof Product) {
            $product = Product::create($sku, $name);
        }
        $asset = ($assetId = trim($product->getFullDescAssetId())) === '' || !($asset = Asset::getAsset($assetId)) instanceof Asset ? Asset::registerAsset('full_desc_' . $sku, $description, Asset::TYPE_PRODUCT_DEC) : $asset;
        $product->setName($name)->setMageId($mageId)->setAttributeSet($attributeSet)->setShortDescription($short_description)->setFullDescAssetId(trim($asset->getAssetId()))->setIsFromB2B(true)->setStatus(ProductStatus::get($statusId))->setSellOnWeb(true)->setManufacturer($clientScript->getManufacturerName(trim($pro['manufacturer'])))->save()->clearAllPrice()->addPrice(ProductPriceType::get(ProductPriceType::ID_RRP), $price)->addInfo(ProductInfoType::ID_WEIGHT, $weight);
        if ($specialPrice !== '') {
            $product->addPrice(ProductPriceType::get(ProductPriceType::ID_CASUAL_SPECIAL), $specialPrice, $specialPrice_From, $specialPrice_To);
        }
        if ($supplierName !== '') {
            $product->addSupplier(Supplier::create($supplierName, $supplierName, true));
        }
        if (isset($pro['categories']) && count($pro['categories']) > 0) {
            $product->clearAllCategory();
            foreach ($pro['categories'] as $cateMageId) {
                if (!($category = ProductCategory::getByMageId($cateMageId)) instanceof ProductCategory) {
                    continue;
                }
                $product->addCategory($category);
            }
        }
        if ($transStarted === false) {
            Dao::commitTransaction();
        }
        //TODO remove the file
        removeLineFromFile($fileName, $line);
        echo $product->getId() . " => done! \n";
    } catch (Exception $ex) {
        if ($transStarted === false) {
            Dao::rollbackTransaction();
        }
        throw $ex;
    }
}
开发者ID:larryu,项目名称:magento-b2b,代码行数:57,代码来源:test.php

示例7: run

 /**
  * runner
  * @param string $debug
  */
 public static function run($debug = false)
 {
     try {
         self::$_debug = $debug;
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         $start = self::_debug("Start to run " . __CLASS__ . ' =================== ');
         $assetIds = self::_findAllOverdueAssets();
         $assetIds = array_merge($assetIds, self::_findAllZombieAssets());
         self::_deleteAssets($assetIds);
         self::_debug("Finished to run " . __CLASS__ . ' =================== ', self::NEW_LINE, "", $start);
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         self::_debug("***** ERROR: " . $ex->getMessage());
         self::_debug($ex->getTraceAsString());
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:22,代码来源:AssetCleaner.php

示例8: createProduct

 /**
  * create product
  *
  * @param string $sku			The sku of product
  * @param string $name			The name of product
  * @param array $categoryPaths	The category paths of product (e.g. $categories = array(array('cate2', 'cate3'), array('cate4', 'cate5', 'cate6'));
  * @param string $mageProductId //TODO
  * @param string $isFromB2B
  * @param string $shortDescr
  * @param string $fullDescr
  * @param string $brandName
  *
  * @throws Exception
  * @return string
  * @soapmethod
  */
 public function createProduct($sku, $name, $categoryPaths = array(), $mageProductId = '', $isFromB2B = false, $shortDescr = '', $fullDescr = '', $brandName = '')
 {
     $response = $this->_getResponse(UDate::now());
     try {
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         //TODO
         if (Product::getBySku(trim($sku)) instanceof Product) {
             throw new Exception('sku "' . $sku . '" already exists');
         }
         $categories = array();
         if (is_array($categoryPaths)) {
             foreach ($categoryPaths as $categoryPath) {
                 $parentCategory = null;
                 foreach ($categoryPath as $categoryName) {
                     if (count($i = ProductCategory::getAllByCriteria('name = ?', array(trim($categoryName)), true, 1, 1)) > 0) {
                         $categories[$i[0]->getId()] = $category = $i[0];
                     } else {
                         $category = ProductCategory::create(trim($categoryName), trim($categoryName), $parentCategory);
                         $categories[$category->getId()] = $category;
                     }
                     $parentCategory = $category;
                 }
             }
         }
         // create product
         $product = Product::create(trim($sku), trim($name));
         // TODO
         foreach ($categories as $category) {
             $product->addCategory($category);
         }
         $response['status'] = self::RESULT_CODE_SUCC;
         $this->addCData('product', json_encode($product->getJson()), $response);
         Dao::commitTransaction();
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         $response['status'] = self::RESULT_CODE_FAIL;
         $this->addCData('error', $e->getMessage(), $response);
     }
     return trim($response->asXML());
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:57,代码来源:APIProduct.php

示例9: addMemo

 /**
  * Creating a new Memo
  *
  * @param unknown $sender
  * @param unknown $params
  *
  * @throws Exception
  */
 public function addMemo($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->entity) || !isset($param->CallbackParameter->entityId) || ($entityName = trim($param->CallbackParameter->entity)) === '' || !($entity = $entityName::get(trim($param->CallbackParameter->entityId))) instanceof $entityName) {
             throw new Exception('System Error: no entity provided for the Memo');
         }
         if (!isset($param->CallbackParameter->data) || !isset($param->CallbackParameter->data->comments) || ($comments = trim($param->CallbackParameter->data->comments)) === '') {
             throw new Exception('You can NOT create a Memo with a blank message.');
         }
         $newComments = null;
         $entity->addComment($comments, Comments::TYPE_MEMO, '', $newComments);
         $results['item'] = $newComments->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:LastMemoPanel.php

示例10: run

 public static function run()
 {
     $start = self::_logMsg("== START: processing Messages ==", __CLASS__, __FUNCTION__);
     $messages = self::_getAndMarkMessages();
     self::_logMsg("GOT " . count($messages) . ' Message(s): ', __CLASS__, __FUNCTION__);
     foreach ($messages as $message) {
         self::_logMsg("    Looping message(ID=" . $message->getId() . ': ', __CLASS__, __FUNCTION__);
         try {
             Dao::beginTransaction();
             EmailSender::sendEmail($message->getFrom(), $message->getTo(), $message->getSubject(), $message->getBody(), $message->getAttachmentAssetIdArray());
             $message->setStatus(Message::STATUS_SENT)->save();
             Dao::commitTransaction();
             self::_logMsg("    SUCCESS sending message(ID=" . $message->getId() . ').', __CLASS__, __FUNCTION__);
         } catch (Exception $ex) {
             Dao::rollbackTransaction();
             $message->setStatus(Message::STATUS_FAILED)->save();
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getMessage(), __CLASS__, __FUNCTION__);
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getTraceAsString(), __CLASS__, __FUNCTION__);
         }
     }
     $end = new UDate();
     self::_logMsg("== FINISHED: " . count($messages) . " Message(s) == ", __CLASS__, __FUNCTION__);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:23,代码来源:MessageSender.php

示例11: addComments

 /**
  *
  * @param unknown $sender
  * @param unknown $params
  */
 public function addComments($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->creditNote) || !($creditNote = CreditNote::get($params->CallbackParameter->creditNote->id)) instanceof CreditNote) {
             throw new Exception('System Error: invalid CreditNote passed in!');
         }
         if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') {
             throw new Exception('System Error: invalid comments passed in!');
         }
         $comment = Comments::addComments($creditNote, $comments, Comments::TYPE_NORMAL);
         $results = $comment->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:25,代码来源:DetailsController.php

示例12: saveOrder

 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     $daoStart = false;
     try {
         Dao::beginTransaction();
         $daoStart = true;
         $supplier = Supplier::get(trim($param->CallbackParameter->supplier->id));
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid Supplier passed in!');
         }
         $supplierContactName = trim($param->CallbackParameter->supplier->contactName);
         $supplierContactNo = trim($param->CallbackParameter->supplier->contactNo);
         $supplierEmail = trim($param->CallbackParameter->supplier->email);
         if (!empty($supplierContactName) && $supplierContactName !== $supplier->getContactName()) {
             $supplier->setContactName($supplierContactName);
         }
         if (!empty($supplierContactNo) && $supplierContactNo !== $supplier->getContactNo()) {
             $supplier->setContactNo($supplierContactNo);
         }
         if (!empty($supplierEmail) && $supplierEmail !== $supplier->getEmail()) {
             $supplier->setEmail($supplierEmail);
         }
         $supplier->save();
         $purchaseOrder = PurchaseOrder::create($supplier, trim($param->CallbackParameter->supplierRefNum), $supplierContactName, $supplierContactNo, StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->shippingCost)), StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->handlingCost)))->setTotalAmount(StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalPaymentDue)))->setEta(trim($param->CallbackParameter->eta))->setStatus(PurchaseOrder::STATUS_NEW)->save()->addComment(trim($param->CallbackParameter->comments), Comments::TYPE_PURCHASING);
         foreach ($param->CallbackParameter->items as $item) {
             if (!($product = Product::get(trim($item->productId))) instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             $purchaseOrder->addItem($product, StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice)), intval(trim($item->qtyOrdered)));
         }
         if ($param->CallbackParameter->submitToSupplier === true) {
             $purchaseOrder->setStatus(PurchaseOrder::STATUS_ORDERED)->save();
         }
         $daoStart = false;
         Dao::commitTransaction();
         $results['item'] = $purchaseOrder->getJson();
         if (isset($param->CallbackParameter->confirmEmail) && trim($confirmEmail = trim($param->CallbackParameter->confirmEmail)) !== '') {
             $pdfFile = EntityToPDF::getPDF($purchaseOrder);
             $asset = Asset::registerAsset($purchaseOrder->getPurchaseOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
             EmailSender::addEmail('purchasing@budgetpc.com.au', $confirmEmail, 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             EmailSender::addEmail('purchasing@budgetpc.com.au', 'purchasing@budgetpc.com.au', 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             $purchaseOrder->addComment('An email sent to "' . $confirmEmail . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         }
     } catch (Exception $ex) {
         if ($daoStart === true) {
             Dao::rollbackTransaction();
         }
         $errors[] = $ex->getMessage() . "<pre>" . $ex->getTraceAsString() . "</pre>";
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:61,代码来源:POController.php

示例13: importProductManufacturers

 public function importProductManufacturers()
 {
     $productAttributes = ProductAttribute::getAllByCriteria('code = ? and isFromB2B = 1 and mageId <> 0', array('manufacturer'), true, 1, 1, array("id" => "desc"));
     if (count($productAttributes) === 0) {
         return;
     }
     $productAttribute = $productAttributes[0];
     try {
         $transStarted = false;
         try {
             Dao::beginTransaction();
         } catch (Exception $e) {
             $transStarted = true;
         }
         foreach ($this->getProductAttributeOptions($productAttribute->getMageId()) as $productAttributeOption) {
             $label = isset($productAttributeOption->label) ? trim($productAttributeOption->label) : '';
             $value = isset($productAttributeOption->value) ? trim($productAttributeOption->value) : '';
             // mageId
             if ($label === '' || $value === '') {
                 echo "ingore product manufacturer options due to empty label or value (" . 'label="' . $label . '", value="' . $value . '")' . "\n";
                 continue;
             }
             $manufacturer = Manufacturer::create($label, '', true, $value);
             echo 'Imported manufacture (name="' . $label . '", mageId=' . $value . ')' . "\n";
         }
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
     } catch (Exception $e) {
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
         throw $e;
     }
     return $this;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:36,代码来源:CatelogConnector.php

示例14: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $perchaseorder = !isset($param->CallbackParameter->id) ? new PurchaseOrder() : PurchaseOrder::get(trim($param->CallbackParameter->id));
         if (!$perchaseorder instanceof PurchaseOrder) {
             throw new Exception('Invalid Purchase Order passed in!');
         }
         $purchaseOrderNo = trim($param->CallbackParameter->purchaseOrderNo);
         $supplierId = trim($param->CallbackParameter->supplierId);
         $supplier = Supplier::get($supplierId);
         $orderDate = trim($param->CallbackParameter->orderDate);
         $totalAmount = trim($param->CallbackParameter->totalAmount);
         $totalPaid = trim($param->CallbackParameter->totalPaid);
         if (isset($param->CallbackParameter->id)) {
             $perchaseorder->setPurchaseOrderNo($purchaseOrderNo)->setSupplier($supplier)->setSupplierRefNo($supplierId)->setOrderDate($orderDate)->setTotalAmount($totalAmount)->setTotalPaid($totalPaid)->save();
         } else {
             // 				PurchaseOrder::
         }
         $results['url'] = '/purchase/' . $perchaseorder->getId() . '.html';
         $results['item'] = $perchaseorder->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . $ex->getTraceAsString();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:33,代码来源:DetailsController.php

示例15: delPayment

 /**
  * deleting a payment
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  */
 public function delPayment($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->paymentId) || !($payment = Payment::get($param->CallbackParameter->paymentId)) instanceof Payment) {
             throw new Exception('System Error: invalid payment provided!');
         }
         if (!isset($param->CallbackParameter->reason) || ($reason = trim($param->CallbackParameter->reason)) === '') {
             throw new Exception('The reason for the deletion is needed!');
         }
         $comments = 'A payment [Value: ' . StringUtilsAbstract::getCurrency($payment->getValue()) . ', Method: ' . $payment->getMethod()->getName() . '] is DELETED: ' . $reason;
         $payment->setActive(false)->addComment($comments, Comments::TYPE_ACCOUNTING)->save();
         $entityFor = $payment->getOrder() instanceof Order ? $payment->getOrder() : $payment->getCreditNote();
         if ($entityFor instanceof Order || $entityFor instanceof CreditNote) {
             $entityFor->addComment($comments, Comments::TYPE_ACCOUNTING);
         }
         $results['item'] = $payment->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:33,代码来源:PaymentListPanel.php


注:本文中的Dao::commitTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。