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


PHP Receipt::Save方法代码示例

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


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

示例1: btnCompleteShipment_Click

 protected function btnCompleteShipment_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     if ($this->objAssetTransactionArray && $this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::AssetInventory;
     } elseif ($this->objAssetTransactionArray) {
         $intEntityQtypeId = EntityQtype::Asset;
     } elseif ($this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::Inventory;
     } else {
         $blnError = true;
         $this->btnCompleteShipment->Warning = 'There are no assets or inventory in this shipment.';
     }
     if ($this->objAssetTransactionArray) {
         foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
             if ($objAssetTransaction->Asset instanceof Asset) {
                 $arrAssetTransactions = AssetTransaction::LoadArrayByAssetId($objAssetTransaction->Asset->AssetId, array(QQ::OrderBy(QQN::AssetTransaction()->CreationDate, false)));
                 if (count($arrAssetTransactions) > 0) {
                     $intLastTransactionId = $arrAssetTransactions[0]->TransactionId;
                     $transaction = Transaction::load($intLastTransactionId);
                     if ($transaction->TransactionTypeId == 6 && $transaction->Shipment->ShippedFlag) {
                         $blnError = true;
                         $this->btnCompleteShipment->Warning = $objAssetTransaction->Asset->__toStringWithLink() . ' already shipped.';
                     }
                 }
             }
         }
     }
     if (!$blnError) {
         try {
             // Get an instance of the database
             $objDatabase = QApplication::$Database[1];
             // Begin a MySQL Transaction to be either committed or rolled back
             $objDatabase->TransactionBegin();
             if (!$this->blnEditMode) {
                 // this is a new shipment so save the transaction & shipment before completing
                 // Create the new transaction object and save it
                 $this->objTransaction = new Transaction();
                 $this->objTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->objTransaction->TransactionTypeId = 6;
                 $this->objTransaction->Note = $this->txtNote->Text;
                 $this->objTransaction->Save();
                 $this->UpdateShipmentFields();
                 $this->objShipment->Save(true);
                 if ($this->arrCustomFields) {
                     // Save the values from all of the custom field controls to save the shipment
                     CustomField::SaveControls($this->objShipment->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objShipment->ShipmentId, 10);
                 }
             }
             // Create receipt transaction for internal shipment
             if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId) {
                 $this->receiveInternalShipmentTransaction = new Transaction();
                 $this->receiveInternalShipmentTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->receiveInternalShipmentTransaction->TransactionTypeId = 7;
                 $note = sprintf('This receipt was automatically created when creating internal shipment Number %s. ', $this->objShipment->ShipmentNumber);
                 $this->receiveInternalShipmentTransaction->Note = $note . $this->txtNote->Text;
                 $this->receiveInternalShipmentTransaction->Save();
                 // Create a new receipt
                 $objInternalReceipt = new Receipt();
                 $objInternalReceipt->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId;
                 // The receipt will mimic the shipment information
                 $objInternalReceipt->FromCompanyId = $this->objShipment->FromCompanyId;
                 $objInternalReceipt->FromContactId = $this->objShipment->FromContactId;
                 $objInternalReceipt->ToContactId = $this->objShipment->ToContactId;
                 $objInternalReceipt->ToAddressId = $this->objShipment->ToAddressId;
                 $objInternalReceipt->ReceivedFlag = 0;
                 $objInternalReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber();
                 $objInternalReceipt->Save();
             }
             if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) {
                 $objTransaction = '';
                 $objReceipt = '';
                 $objNewAssetTransactionArray = array();
                 foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                     $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode] = $objAssetTransaction;
                 }
                 // Assign a destinationLocation to the AssetTransaction, and change the Location of the asset
                 foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                     if ($objAssetTransaction->Asset instanceof Asset) {
                         // LocationId #2 == Shipped
                         $DestinationLocationId = 2;
                         if ($objAssetTransaction->ScheduleReceiptFlag && $objAssetTransaction->Asset->LinkedFlag) {
                             $objAssetTransaction = $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode];
                         }
                         $objAssetTransaction->Asset->LocationId = $DestinationLocationId;
                         $objAssetTransaction->Asset->Save();
                         if (!$this->blnEditMode) {
                             // Assign the TransactionId
                             $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId;
                         }
                         $objAssetTransaction->DestinationLocationId = $DestinationLocationId;
                         // No any actions with linked items (LinkedFlag = 1) which have been scheduled for receipt
                         if ($objAssetTransaction->ScheduleReceiptFlag && !$objAssetTransaction->Asset->LinkedFlag) {
                             if ($objAssetTransaction->NewAsset && $objAssetTransaction->NewAsset instanceof Asset && $objAssetTransaction->NewAsset->AssetId == null) {
                                 // We have to create the new asset before we can
                                 $objReceiptAsset = new Asset();
                                 $objReceiptAsset->AssetModelId = $objAssetTransaction->NewAsset->AssetModelId;
                                 $objReceiptAsset->LocationId = $objAssetTransaction->NewAsset->LocationId;
                                 if ($objAssetTransaction->NewAsset->AssetCode == '') {
                                     $objReceiptAsset->AssetCode = Asset::GenerateAssetCode();
//.........这里部分代码省略.........
开发者ID:proxymoron,项目名称:tracmor,代码行数:101,代码来源:shipment_edit.php

示例2: btnCompleteShipment_Click

 protected function btnCompleteShipment_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     if ($this->objAssetTransactionArray && $this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::AssetInventory;
     } elseif ($this->objAssetTransactionArray) {
         $intEntityQtypeId = EntityQtype::Asset;
     } elseif ($this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::Inventory;
     } else {
         $blnError = true;
         $this->btnCompleteShipment->Warning = 'There are no assets or inventory in this shipment.';
     }
     // If Courier is Fedex, validate Fedex inputs
     if ($this->objShipment->CourierId === 1) {
         if (!$this->lstPackageType->SelectedValue) {
             $blnError = true;
             $this->lblPackageType->Warning = "Please select a package type.";
             $this->lstPackageType->Warning = "Please select a package type.";
         }
         if (!$this->txtPackageWeight->Text) {
             $blnError = true;
             $this->lblPackageWeight->Warning = "Please enter a weight for this package.";
             $this->txtPackageWeight->Warning = "Please enter a weight for this package.";
         }
         //if (!$this->lstWeightUnit->SelectedValue) {
         //	$blnError = true;
         //	$this->lstWeightUnit->Warning = "Please select a weight unit.";
         //}
         //if (!$this->txtValue->Text) {
         //	$blnError = true;
         //	$this->txtValue->Warning = "Please enter a value.";
         //}
         //if (!$this->lstCurrencyUnit->SelectedValue) {
         //	$blnError = true;
         //	$this->lstCurrencyUnit->Warning = "Please select a currency type.";
         //}
     }
     if (!$blnError) {
         try {
             // Get an instance of the database
             $objDatabase = QApplication::$Database[1];
             // Begin a MySQL Transaction to be either committed or rolled back
             $objDatabase->TransactionBegin();
             if (!$this->blnEditMode) {
                 // this is a new shipment so save the transaction & shipment before completing
                 // Create the new transaction object and save it
                 $this->objTransaction = new Transaction();
                 $this->objTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->objTransaction->TransactionTypeId = 6;
                 $this->objTransaction->Note = $this->txtNote->Text;
                 $this->objTransaction->Save();
                 $this->UpdateShipmentFields();
                 $this->objShipment->Save(true);
                 if ($this->arrCustomFields) {
                     // Save the values from all of the custom field controls to save the shipment
                     CustomField::SaveControls($this->objShipment->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objShipment->ShipmentId, 10);
                 }
                 // If the courier is FedEx, create new fedexShipment
                 if ($this->lstCourier->SelectedValue === 1) {
                     if (!$this->objFedexShipment instanceof FedexShipment) {
                         $this->objFedexShipment = new FedexShipment();
                     }
                     $this->objFedexShipment->ShipmentId = $this->objShipment->ShipmentId;
                     $this->UpdateFedexFields();
                     $this->objFedexShipment->Save(true);
                 }
             }
             // If courier is FedEx, initiate communication with FedEx
             if (!$blnError && $this->objShipment->CourierId == 1) {
                 if (!$this->FedEx()) {
                     $blnError = true;
                     $objDatabase->TransactionRollback();
                     return;
                 }
             }
             if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) {
                 $objTransaction = '';
                 $objReceipt = '';
                 $objNewAssetTransactionArray = array();
                 foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                     $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode] = $objAssetTransaction;
                 }
                 // Assign a destinationLocation to the AssetTransaction, and change the Location of the asset
                 foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                     if ($objAssetTransaction->Asset instanceof Asset) {
                         // LocationId #2 == Shipped
                         $DestinationLocationId = 2;
                         if ($objAssetTransaction->ScheduleReceiptFlag && $objAssetTransaction->Asset->LinkedFlag) {
                             $objAssetTransaction = $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode];
                         }
                         $objAssetTransaction->Asset->LocationId = $DestinationLocationId;
                         $objAssetTransaction->Asset->Save();
                         if (!$this->blnEditMode) {
                             // Assign the TransactionId
                             $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId;
                         }
                         $objAssetTransaction->DestinationLocationId = $DestinationLocationId;
                         // No any actions with linked items (LinkedFlag = 1) which have been scheduled for receipt
                         if ($objAssetTransaction->ScheduleReceiptFlag && !$objAssetTransaction->Asset->LinkedFlag) {
//.........这里部分代码省略.........
开发者ID:brustj,项目名称:tracmor,代码行数:101,代码来源:shipment_edit.php


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