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(); } else { $objReceiptAsset->AssetCode = $objAssetTransaction->NewAsset->AssetCode; } $objReceiptAsset->Save(); // Assign any default custom field values CustomField::AssignNewEntityDefaultValues(1, $objReceiptAsset->AssetId); // Associate the new Asset with the AssetTransaction $objAssetTransaction->NewAsset = $objReceiptAsset; } // If it doesn't exist, create a new transaction object and receipt object if (!$objTransaction instanceof Transaction && !$objReceipt instanceof Receipt) { $objTransaction = new Transaction(); // Transaction is asset only $objTransaction->EntityQtypeId = 1; // Transaction is a receipt $objTransaction->TransactionTypeId = 7; // Set a note showing how this receipt was created if (!$objAssetTransaction->NewAssetId) { $strTransactionType = 'return'; } else { $strTransactionType = 'exchange'; } $objTransaction->Note = sprintf('This %s receipt was automatically created when creating Shipment Number %s.', $strTransactionType, $this->objShipment->ShipmentNumber); // Save the transaction $objTransaction->Save(); // Create a new receipt $objReceipt = new Receipt(); $objReceipt->TransactionId = $objTransaction->TransactionId; // The receipt will be coming from the company that was shipped to $objReceipt->FromCompanyId = $this->objShipment->ToCompanyId; $objReceipt->FromContactId = $this->objShipment->ToContactId; $objReceipt->ToContactId = $this->objShipment->FromContactId; $objReceipt->ToAddressId = $this->objShipment->FromAddressId; $objReceipt->ReceivedFlag = 0; $objReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber(); if ($objAssetTransaction->ScheduleReceiptDueDate) { $objReceipt->DueDate = $objAssetTransaction->ScheduleReceiptDueDate; } $objReceipt->Save(); } $objReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objReceiptAssetTransaction->AssetId = $objAssetTransaction->AssetId; } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; $objReceiptAssetTransaction->NewAssetFlag = true; $objAssetTransaction->NewAssetFlag = true; $objAssetTransaction->Save(); } $objReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; // This is not right. NewAssetFlag should be set only if a new asset was created when creating this AssetTransaction // It should not be true on the new AssetTransaction, but only on the AssetTransaction that caused the new asset to be created. // $objReceiptAssetTransaction->NewAssetFlag = true; $objReceiptAssetTransaction->Save(); // Load all child assets if ($objLinkedAssetCodeArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId)) { foreach ($objLinkedAssetCodeArray as $objLinkedAssetCode) { $objLinkedAssetTransaction = $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode]; $objLinkedReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objLinkedReceiptAssetTransaction->AssetId = $objLinkedAssetTransaction->AssetId; $objLinkedReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objLinkedReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; $objLinkedReceiptAssetTransaction->Save(); } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objLinkedReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; } $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode] = $objLinkedAssetTransaction; } } } $objAssetTransaction->Save(); if ($objAssetTransaction->ScheduleReceiptFlag) { // Set the Receipt Asset Transaction as child of the Shipment Asset Transaction $objAssetTransaction->AssociateChildAssetTransaction($objReceiptAssetTransaction); } if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId && !$objAssetTransaction->Asset->LinkedFlag) { $objReceiptAssetTransaction = new AssetTransaction(); $objReceiptAssetTransaction->AssetId = $objAssetTransaction->AssetId; $objReceiptAssetTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->SourceLocationId; $objReceiptAssetTransaction->Save(); // Load all child assets if ($objLinkedAssetCodeArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId)) { foreach ($objLinkedAssetCodeArray as $objLinkedAssetCode) { $objLinkedAssetTransaction = $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode]; $objLinkedReceiptAssetTransaction = new AssetTransaction(); // add data to linked asset $objLinkedReceiptAssetTransaction->AssetId = $objLinkedAssetTransaction->AssetId; $objLinkedReceiptAssetTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objLinkedReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->SourceLocationId; $objLinkedReceiptAssetTransaction->Save(); } } } $objReceipt = null; $objTransaction = null; } } } if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) { // Assign different source and destinations depending on transaction type foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { // LocationId #2 == Shipped $DestinationLocationId = 2; if (!$this->blnEditMode) { $objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId; } // Remove the inventory quantity from the source $objInventoryTransaction->InventoryLocation->Quantity = $objInventoryTransaction->InventoryLocation->Quantity - $objInventoryTransaction->Quantity; $objInventoryTransaction->InventoryLocation->Save(); // Finish the InventoryTransaction and save it $objInventoryTransaction->DestinationLocationId = $DestinationLocationId; $objInventoryTransaction->Save(); // Add Inventory to receipt if this is an internal shipment if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId) { $objReceiptInventoryLocation = InventoryLocation::LoadByLocationIdInventoryModelId(5, $objInventoryTransaction->InventoryLocation->InventoryModelId); if (!$objReceiptInventoryLocation) { // First create the inventory location if it doesn't exist $objReceiptInventoryLocation = new InventoryLocation(); $objReceiptInventoryLocation->InventoryModelId = $objInventoryTransaction->InventoryLocation->InventoryModelId; $objReceiptInventoryLocation->LocationId = 5; $objReceiptInventoryLocation->Quantity = 0; } // Set the To Be Received quantity $objReceiptInventoryLocation->Quantity += $objInventoryTransaction->Quantity; $objReceiptInventoryLocation->Save(); // Create the inventory transaction $objReceiptInventoryTransaction = new InventoryTransaction(); $objReceiptInventoryTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objReceiptInventoryTransaction->InventoryLocationId = $objReceiptInventoryLocation->InventoryLocationId; $objReceiptInventoryTransaction->Quantity = $objInventoryTransaction->Quantity; $objReceiptInventoryTransaction->SourceLocationId = 5; $objReceiptInventoryTransaction->Save(); } } } if ($this->blnEditMode) { $this->UpdateShipmentFields(); } $this->objShipment->ShippedFlag = true; // $this->objShipment->Save(false, true); $this->objShipment->Save(); $objDatabase->TransactionCommit(); QApplication::Redirect(sprintf('../shipping/shipment_edit.php?intShipmentId=%s', $this->objShipment->ShipmentId)); } catch (QExtendedOptimisticLockingException $objExc) { $objDatabase->TransactionRollback(); if ($objExc->Class == 'Shipment') { $this->btnCancelShipment->Warning = sprintf('This shipment has been modified by another user. You must <a href="shipment_edit.php?intShipmentId=%s">Refresh</a> to complete this shipment.', $this->objShipment->ShipmentId); } else { throw new QOptimisticLockingException($objExc->Class); } } } }
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) { 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(); } else { $objReceiptAsset->AssetCode = $objAssetTransaction->NewAsset->AssetCode; } $objReceiptAsset->Save(); // Assign any default custom field values CustomField::AssignNewEntityDefaultValues(1, $objReceiptAsset->AssetId); // Associate the new Asset with the AssetTransaction $objAssetTransaction->NewAsset = $objReceiptAsset; } // If it doesn't exist, create a new transaction object and receipt object if (!$objTransaction instanceof Transaction && !$objReceipt instanceof Receipt) { $objTransaction = new Transaction(); // Transaction is asset only $objTransaction->EntityQtypeId = 1; // Transaction is a receipt $objTransaction->TransactionTypeId = 7; // Set a note showing how this receipt was created if (!$objAssetTransaction->NewAssetId) { $strTransactionType = 'return'; } else { $strTransactionType = 'exchange'; } $objTransaction->Note = sprintf('This %s receipt was automatically created when creating Shipment Number %s.', $strTransactionType, $this->objShipment->ShipmentNumber); // Save the transaction $objTransaction->Save(); // Create a new receipt $objReceipt = new Receipt(); $objReceipt->TransactionId = $objTransaction->TransactionId; // The receipt will be coming from the company that was shipped to $objReceipt->FromCompanyId = $this->objShipment->ToCompanyId; $objReceipt->FromContactId = $this->objShipment->ToContactId; $objReceipt->ToContactId = $this->objShipment->FromContactId; $objReceipt->ToAddressId = $this->objShipment->FromAddressId; $objReceipt->ReceivedFlag = 0; $objReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber(); if ($objAssetTransaction->ScheduleReceiptDueDate) { $objReceipt->DueDate = $objAssetTransaction->ScheduleReceiptDueDate; } $objReceipt->Save(); } $objReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objReceiptAssetTransaction->AssetId = $objAssetTransaction->AssetId; } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; $objReceiptAssetTransaction->NewAssetFlag = true; $objAssetTransaction->NewAssetFlag = true; $objAssetTransaction->Save(); } $objReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; // This is not right. NewAssetFlag should be set only if a new asset was created when creating this AssetTransaction // It should not be true on the new AssetTransaction, but only on the AssetTransaction that caused the new asset to be created. // $objReceiptAssetTransaction->NewAssetFlag = true; $objReceiptAssetTransaction->Save(); // Load all child assets if ($objLinkedAssetCodeArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId)) { foreach ($objLinkedAssetCodeArray as $objLinkedAssetCode) { $objLinkedAssetTransaction = $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode]; $objLinkedReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objLinkedReceiptAssetTransaction->AssetId = $objLinkedAssetTransaction->AssetId; $objLinkedReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objLinkedReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; $objLinkedReceiptAssetTransaction->Save(); } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objLinkedReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; } $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode] = $objLinkedAssetTransaction; } } } $objAssetTransaction->Save(); if ($objAssetTransaction->ScheduleReceiptFlag) { // Set the Receipt Asset Transaction as child of the Shipment Asset Transaction $objAssetTransaction->AssociateChildAssetTransaction($objReceiptAssetTransaction); } $objReceipt = null; $objTransaction = null; } } } if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) { // Assign different source and destinations depending on transaction type foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { // LocationId #2 == Shipped $DestinationLocationId = 2; if (!$this->blnEditMode) { $objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId; } // Remove the inventory quantity from the source $objInventoryTransaction->InventoryLocation->Quantity = $objInventoryTransaction->InventoryLocation->Quantity - $objInventoryTransaction->Quantity; $objInventoryTransaction->InventoryLocation->Save(); // Finish the InventoryTransaction and save it $objInventoryTransaction->DestinationLocationId = $DestinationLocationId; $objInventoryTransaction->Save(); } } if ($this->blnEditMode) { $this->UpdateShipmentFields(); if ($this->objShipment->CourierId === 1) { $this->UpdateFedexFields(); } } elseif ($this->objShipment->CourierId === 1) { // Update $this->objShipment with FedEx tracking number $this->objShipment->TrackingNumber = $this->txtTrackingNumber->Text; } $this->objShipment->ShippedFlag = true; // $this->objShipment->Save(false, true); $this->objShipment->Save(); $objDatabase->TransactionCommit(); QApplication::Redirect(sprintf('../shipping/shipment_edit.php?intShipmentId=%s', $this->objShipment->ShipmentId)); } catch (QExtendedOptimisticLockingException $objExc) { $objDatabase->TransactionRollback(); if ($objExc->Class == 'Shipment') { $this->btnCancelShipment->Warning = sprintf('This shipment has been modified by another user. You must <a href="shipment_edit.php?intShipmentId=%s">Refresh</a> to complete this shipment.', $this->objShipment->ShipmentId); } else { throw new QOptimisticLockingException($objExc->Class); } } } }