protected function SetupInventoryLocation() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intInventoryLocationId = QApplication::QueryString('intInventoryLocationId'); if ($intInventoryLocationId) { $this->objInventoryLocation = InventoryLocation::Load($intInventoryLocationId); if (!$this->objInventoryLocation) { throw new Exception('Could not find a InventoryLocation object with PK arguments: ' . $intInventoryLocationId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objInventoryLocation = new InventoryLocation(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
protected function UpdateReceiptFields() { $this->objReceipt->TransactionId = $this->objTransaction->TransactionId; if (QApplication::$TracmorSettings->CustomReceiptNumbers) { $this->objReceipt->ReceiptNumber = $this->txtReceiptNumber->Text; } elseif (!$this->blnEditMode) { $this->objReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber(); } $this->objReceipt->FromCompanyId = $this->lstFromCompany->SelectedValue; $this->objReceipt->FromContactId = $this->lstFromContact->SelectedValue; $this->objReceipt->ToContactId = $this->lstToContact->SelectedValue; $this->objReceipt->ToAddressId = $this->lstToAddress->SelectedValue; $this->objReceipt->DueDate = $this->calDueDate->DateTime; $this->objReceipt->ReceiptDate = $this->calDateReceived->DateTime; //! $this->objTransaction->Note = $this->txtNote->Text; // Reload the Assets and inventory locations so that they don't trigger an OLE if edit/save adding assets or inventory multiple times if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { $objAssetTransaction->Asset = Asset::Load($objAssetTransaction->AssetId); } } if ($this->objInventoryTransactionArray) { foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { $objInventoryTransaction->InventoryLocation = InventoryLocation::Load($objInventoryTransaction->InventoryLocationId); } } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { if ($this->objInventoryLocationArray) { $blnError = false; // If it is a move or a restock, lstDestinationLocation cannot be null if (($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) && !$this->lstDestinationLocation->SelectedValue) { $this->lstDestinationLocation->Warning = 'You must select a destination location.'; $blnError = true; } foreach ($this->objInventoryLocationArray as $objInventoryLocation) { // TransactionTypeId = 1 is for moves if ($this->intTransactionTypeId == 1) { if ($objInventoryLocation->LocationId == $this->lstDestinationLocation->SelectedValue) { $this->dtgInventoryTransact->Warning = 'Cannot move inventory from a location to the same location.'; $blnError = true; } } } 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(); // Create the new transaction object and save it $this->objTransaction = new Transaction(); $this->objTransaction->EntityQtypeId = EntityQtype::Inventory; $this->objTransaction->TransactionTypeId = $this->intTransactionTypeId; $this->objTransaction->Note = $this->txtNote->Text; $this->objTransaction->Save(); // Assign different source and destinations depending on transaction type foreach ($this->objInventoryLocationArray as $objInventoryLocation) { // Move if ($this->intTransactionTypeId == 1) { $SourceLocationId = $objInventoryLocation->LocationId; $DestinationLocationId = $this->lstDestinationLocation->SelectedValue; } elseif ($this->intTransactionTypeId == 4) { // LocationId = 4 - 'New Inventory' $SourceLocationId = 4; $DestinationLocationId = $this->lstDestinationLocation->SelectedValue; } elseif ($this->intTransactionTypeId == 5) { $SourceLocationId = $objInventoryLocation->LocationId; // LocationId = 3 - 'Taken Out' $DestinationLocationId = 3; } // Remove the inventory quantity from the source for moves and take outs if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 5) { //$objInventoryLocation->Quantity = $objInventoryLocation->Quantity - $objInventoryLocation->intTransactionQuantity; $objInventoryLocation->Quantity = $objInventoryLocation->GetVirtualAttribute('actual_quantity') - $objInventoryLocation->intTransactionQuantity; $objInventoryLocation->Save(); } // Add the new quantity where it belongs for moves and restocks if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) { $objNewInventoryLocation = InventoryLocation::LoadByLocationIdInventoryModelId($DestinationLocationId, $objInventoryLocation->InventoryModelId); if ($objNewInventoryLocation) { //$objNewInventoryLocation->Quantity = $objNewInventoryLocation->GetVirtualAttribute('actual_quantity') + $objInventoryLocation->intTransactionQuantity; $objNewInventoryLocation->Quantity = $objNewInventoryLocation->Quantity + $objInventoryLocation->intTransactionQuantity; } else { $objNewInventoryLocation = new InventoryLocation(); $objNewInventoryLocation->InventoryModelId = $objInventoryLocation->InventoryModelId; $objNewInventoryLocation->Quantity = $objInventoryLocation->intTransactionQuantity; } $objNewInventoryLocation->LocationId = $DestinationLocationId; $objNewInventoryLocation->Save(); } // Create the new InventoryTransaction object and save it $this->objInventoryTransaction = new InventoryTransaction(); if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) { $this->objInventoryTransaction->InventoryLocationId = $objNewInventoryLocation->InventoryLocationId; } elseif ($this->intTransactionTypeId == 5) { $this->objInventoryTransaction->InventoryLocationId = $objInventoryLocation->InventoryLocationId; } $this->objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId; $this->objInventoryTransaction->Quantity = $objInventoryLocation->intTransactionQuantity; $this->objInventoryTransaction->SourceLocationId = $SourceLocationId; $this->objInventoryTransaction->DestinationLocationId = $DestinationLocationId; $this->objInventoryTransaction->Save(); } // Commit the above transactions to the database $objDatabase->TransactionCommit(); QApplication::Redirect('../common/transaction_edit.php?intTransactionId=' . $this->objTransaction->TransactionId); } catch (QOptimisticLockingException $objExc) { // Rollback the database $objDatabase->TransactionRollback(); $objInventoryLocation = InventoryLocation::Load($objExc->EntityId); $this->objParentObject->btnRemove_Click($this->objParentObject->FormId, 'btnRemove' . $objExc->EntityId, $objExc->EntityId); // Lock Exception Thrown, Report the Error $this->btnCancel->Warning = sprintf('The Inventory %s at %s has been altered by another user and removed from the transaction. You may add the inventory again or save the transaction without it.', $objInventoryLocation->InventoryModel->InventoryModelCode, $objInventoryLocation->Location->__toString()); } } } }
protected function UpdateShipmentFields() { if (!$this->blnEditMode) { //$this->objShipment->TransactionId = $this->objTransaction->TransactionId; $this->objShipment->Transaction = $this->objTransaction; } if ($this->blnEditMode) { if (!$this->objTransaction) { $this->objTransaction = Transaction::Load($this->objShipment->TransactionId); } $this->objShipment->Transaction = $this->objTransaction; $this->objShipment->ShipmentNumber = $this->lblShipmentNumber->Text; } elseif (QApplication::$TracmorSettings->CustomShipmentNumbers) { $this->objShipment->ShipmentNumber = $this->txtShipmentNumber->Text; } else { $this->objShipment->ShipmentNumber = Shipment::LoadNewShipmentNumber(); } $this->objShipment->ToContactId = $this->lstToContact->SelectedValue; $this->objShipment->FromCompanyId = $this->lstFromCompany->SelectedValue; $this->objShipment->FromContactId = $this->lstFromContact->SelectedValue; $this->objShipment->ShipDate = $this->calShipDate->DateTime; $this->objShipment->FromAddressId = $this->lstFromAddress->SelectedValue; $this->objShipment->ToCompanyId = $this->lstToCompany->SelectedValue; $this->objShipment->ToAddressId = $this->lstToAddress->SelectedValue; $this->objShipment->CourierId = $this->lstCourier->SelectedValue; //if (!$this->lstCourier->SelectedValue) { $this->objShipment->TrackingNumber = $this->txtTrackingNumber->Text; //} // Reload the Assets and inventory locations so that they don't trigger an OLE if completing the shipment without reloading after adding an asset or inventory. if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { $objAssetTransaction->Asset = Asset::Load($objAssetTransaction->AssetId); } } if ($this->objInventoryTransactionArray) { foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { $objInventoryTransaction->InventoryLocation = InventoryLocation::Load($objInventoryTransaction->InventoryLocationId); } } }
/** * Reload this InventoryLocation from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved InventoryLocation object.'); } // Reload the Object $objReloaded = InventoryLocation::Load($this->intInventoryLocationId); // Update $this's local variables to match $this->InventoryModelId = $objReloaded->InventoryModelId; $this->LocationId = $objReloaded->LocationId; $this->intQuantity = $objReloaded->intQuantity; $this->CreatedBy = $objReloaded->CreatedBy; $this->dttCreationDate = $objReloaded->dttCreationDate; $this->ModifiedBy = $objReloaded->ModifiedBy; $this->strModifiedDate = $objReloaded->strModifiedDate; }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'InventoryTransactionId': /** * Gets the value for intInventoryTransactionId (Read-Only PK) * @return integer */ return $this->intInventoryTransactionId; case 'InventoryLocationId': /** * Gets the value for intInventoryLocationId (Not Null) * @return integer */ return $this->intInventoryLocationId; case 'TransactionId': /** * Gets the value for intTransactionId (Not Null) * @return integer */ return $this->intTransactionId; case 'Quantity': /** * Gets the value for intQuantity (Not Null) * @return integer */ return $this->intQuantity; case 'SourceLocationId': /** * Gets the value for intSourceLocationId * @return integer */ return $this->intSourceLocationId; case 'DestinationLocationId': /** * Gets the value for intDestinationLocationId * @return integer */ return $this->intDestinationLocationId; case 'CreatedBy': /** * Gets the value for intCreatedBy * @return integer */ return $this->intCreatedBy; case 'CreationDate': /** * Gets the value for dttCreationDate * @return QDateTime */ return $this->dttCreationDate; case 'ModifiedBy': /** * Gets the value for intModifiedBy * @return integer */ return $this->intModifiedBy; case 'ModifiedDate': /** * Gets the value for strModifiedDate (Read-Only Timestamp) * @return string */ return $this->strModifiedDate; case 'LocalWarehouseStock': /** * Gets the value for Local_warehouse_stock * @return integer */ return $this->intLocalWarehouseStock; case 'BadProductsWarehouseStock': /** * Gets the value for bad_products_warehouse_stock * @return integer */ return $this->intBadProductsWarehouseStock; case 'SampleWarehouseStock': /** * Gets the value for sample_warehouse_stock * @return integer */ return $this->intSampleWarehouseStock; case 'RepairWarehouseStock': /** * Gets the value for repair_warehouse_stock * @return integer */ return $this->intRepairWarehouseStock; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'InventoryLocation': /** * Gets the value for the InventoryLocation object referenced by intInventoryLocationId (Not Null) * @return InventoryLocation */ try { if (!$this->objInventoryLocation && !is_null($this->intInventoryLocationId)) { $this->objInventoryLocation = InventoryLocation::Load($this->intInventoryLocationId); } return $this->objInventoryLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Transaction': /** * Gets the value for the Transaction object referenced by intTransactionId (Not Null) * @return Transaction */ try { if (!$this->objTransaction && !is_null($this->intTransactionId)) { $this->objTransaction = Transaction::Load($this->intTransactionId); } return $this->objTransaction; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'SourceLocation': /** * Gets the value for the Location object referenced by intSourceLocationId * @return Location */ try { if (!$this->objSourceLocation && !is_null($this->intSourceLocationId)) { $this->objSourceLocation = Location::Load($this->intSourceLocationId); } return $this->objSourceLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'DestinationLocation': /** * Gets the value for the Location object referenced by intDestinationLocationId * @return Location */ try { if (!$this->objDestinationLocation && !is_null($this->intDestinationLocationId)) { $this->objDestinationLocation = Location::Load($this->intDestinationLocationId); } return $this->objDestinationLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'CreatedByObject': /** * Gets the value for the UserAccount object referenced by intCreatedBy * @return UserAccount */ try { if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) { $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy); } return $this->objCreatedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ModifiedByObject': /** * Gets the value for the UserAccount object referenced by intModifiedBy * @return UserAccount */ try { if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) { $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy); } return $this->objModifiedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'InventoryTransactionId': // Gets the value for intInventoryTransactionId (Read-Only PK) // @return integer return $this->intInventoryTransactionId; case 'InventoryLocationId': // Gets the value for intInventoryLocationId (Not Null) // @return integer return $this->intInventoryLocationId; case 'TransactionId': // Gets the value for intTransactionId (Not Null) // @return integer return $this->intTransactionId; case 'Quantity': // Gets the value for intQuantity (Not Null) // @return integer return $this->intQuantity; case 'SourceLocationId': // Gets the value for intSourceLocationId // @return integer return $this->intSourceLocationId; case 'DestinationLocationId': // Gets the value for intDestinationLocationId // @return integer return $this->intDestinationLocationId; case 'CreatedBy': // Gets the value for intCreatedBy // @return integer return $this->intCreatedBy; case 'CreationDate': // Gets the value for dttCreationDate // @return QDateTime return $this->dttCreationDate; case 'ModifiedBy': // Gets the value for intModifiedBy // @return integer return $this->intModifiedBy; case 'ModifiedDate': // Gets the value for strModifiedDate (Read-Only Timestamp) // @return string return $this->strModifiedDate; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'InventoryLocation': // Gets the value for the InventoryLocation object referenced by intInventoryLocationId (Not Null) // @return InventoryLocation try { if (!$this->objInventoryLocation && !is_null($this->intInventoryLocationId)) { $this->objInventoryLocation = InventoryLocation::Load($this->intInventoryLocationId); } return $this->objInventoryLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Transaction': // Gets the value for the Transaction object referenced by intTransactionId (Not Null) // @return Transaction try { if (!$this->objTransaction && !is_null($this->intTransactionId)) { $this->objTransaction = Transaction::Load($this->intTransactionId); } return $this->objTransaction; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'SourceLocation': // Gets the value for the Location object referenced by intSourceLocationId // @return Location try { if (!$this->objSourceLocation && !is_null($this->intSourceLocationId)) { $this->objSourceLocation = Location::Load($this->intSourceLocationId); } return $this->objSourceLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'DestinationLocation': // Gets the value for the Location object referenced by intDestinationLocationId // @return Location try { if (!$this->objDestinationLocation && !is_null($this->intDestinationLocationId)) { $this->objDestinationLocation = Location::Load($this->intDestinationLocationId); } return $this->objDestinationLocation; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'CreatedByObject': // Gets the value for the UserAccount object referenced by intCreatedBy // @return UserAccount try { if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) { $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy); } return $this->objCreatedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ModifiedByObject': // Gets the value for the UserAccount object referenced by intModifiedBy // @return UserAccount try { if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) { $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy); } return $this->objModifiedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { if ($this->objInventoryLocationArray) { $blnError = false; // If it is a move or a restock, lstDestinationLocation cannot be null if (($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) && !$this->lstDestinationLocation->SelectedValue) { $this->lstDestinationLocation->Warning = 'You must select a destination location.'; $blnError = true; } foreach ($this->objInventoryLocationArray as $objInventoryLocation) { // TransactionTypeId = 1 is for moves if ($this->intTransactionTypeId == 1) { if ($objInventoryLocation->LocationId == $this->lstDestinationLocation->SelectedValue) { $this->dtgInventoryTransact->Warning = 'Cannot move inventory from a location to the same location.'; $blnError = true; } } } 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(); // Create the new transaction object and save it $this->objTransaction = new Transaction(); $this->objTransaction->EntityQtypeId = EntityQtype::Inventory; $this->objTransaction->TransactionTypeId = $this->intTransactionTypeId; $this->objTransaction->Note = $this->txtNote->Text; $this->objTransaction->Save(); // Assign different source and destinations depending on transaction type foreach ($this->objInventoryLocationArray as $objInventoryLocation) { $xx = InventoryLocation::LoadByLocationIdInventoryModelId(6, $objInventoryLocation->InventoryModelId); if ($xx) { $local_warehouse_stock = $xx->Quantity; } else { $local_warehouse_stock = 0; } $xx = InventoryLocation::LoadByLocationIdInventoryModelId(7, $objInventoryLocation->InventoryModelId); if ($xx) { $bad_products_warehouse_stock = $xx->Quantity; } else { $bad_products_warehouse_stock = 0; } $xx = InventoryLocation::LoadByLocationIdInventoryModelId(8, $objInventoryLocation->InventoryModelId); if ($xx) { $sample_warehouse_stock = $xx->Quantity; } else { $sample_warehouse_stock = 0; } $xx = InventoryLocation::LoadByLocationIdInventoryModelId(9, $objInventoryLocation->InventoryModelId); if ($xx) { $repair_warehouse_stock = $xx->Quantity; } else { $repair_warehouse_stock = 0; } // Move if ($this->intTransactionTypeId == 1) { $SourceLocationId = $objInventoryLocation->LocationId; $DestinationLocationId = $this->lstDestinationLocation->SelectedValue; } elseif ($this->intTransactionTypeId == 4) { // LocationId = 4 - 'New Inventory' $SourceLocationId = 4; $DestinationLocationId = $this->lstDestinationLocation->SelectedValue; } elseif ($this->intTransactionTypeId == 5) { $SourceLocationId = $objInventoryLocation->LocationId; // LocationId = 3 - 'Taken Out' $DestinationLocationId = 3; } // Remove the inventory quantity from the source for moves and take outs if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 5) { $objInventoryLocation->Quantity = $objInventoryLocation->Quantity - $objInventoryLocation->intTransactionQuantity; $objInventoryLocation->Save(); } // Add the new quantity where it belongs for moves and restocks if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) { $objNewInventoryLocation = InventoryLocation::LoadByLocationIdInventoryModelId($DestinationLocationId, $objInventoryLocation->InventoryModelId); if ($objNewInventoryLocation) { $objNewInventoryLocation->Quantity = $objNewInventoryLocation->Quantity + $objInventoryLocation->intTransactionQuantity; } else { $objNewInventoryLocation = new InventoryLocation(); $objNewInventoryLocation->InventoryModelId = $objInventoryLocation->InventoryModelId; $objNewInventoryLocation->Quantity = $objInventoryLocation->intTransactionQuantity; } $objNewInventoryLocation->LocationId = $DestinationLocationId; $objNewInventoryLocation->Save(); } // Create the new InventoryTransaction object and save it $this->objInventoryTransaction = new InventoryTransaction(); if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 4) { $this->objInventoryTransaction->InventoryLocationId = $objNewInventoryLocation->InventoryLocationId; } elseif ($this->intTransactionTypeId == 5) { $this->objInventoryTransaction->InventoryLocationId = $objInventoryLocation->InventoryLocationId; } $this->objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId; $this->objInventoryTransaction->Quantity = $objInventoryLocation->intTransactionQuantity; $this->objInventoryTransaction->SourceLocationId = $SourceLocationId; $this->objInventoryTransaction->DestinationLocationId = $DestinationLocationId; $this->objInventoryTransaction->LocalWarehouseStock = $local_warehouse_stock; $this->objInventoryTransaction->BadProductsWarehouseStock = $bad_products_warehouse_stock; $this->objInventoryTransaction->SampleWarehouseStock = $sample_warehouse_stock; $this->objInventoryTransaction->RepairWarehouseStock = $repair_warehouse_stock; $this->objInventoryTransaction->Save(); /* $this->http_post("http://127.0.0.1:8080/inventory/service.php", 'updateVirtualStock', array( //'byName' => '', 'inventory_model_id' => $objInventoryLocation->InventoryModelId, 'virtualStock' => $objInventoryLocation->intTransactionQuantity, 'operate' => '+' ) ); */ } // Commit the above transactions to the database $objDatabase->TransactionCommit(); QApplication::Redirect('../common/transaction_edit.php?intTransactionId=' . $this->objTransaction->TransactionId); } catch (QOptimisticLockingException $objExc) { // Rollback the database $objDatabase->TransactionRollback(); $objInventoryLocation = InventoryLocation::Load($objExc->EntityId); $this->objParentObject->btnRemove_Click($this->objParentObject->FormId, 'btnRemove' . $objExc->EntityId, $objExc->EntityId); // Lock Exception Thrown, Report the Error $this->btnCancel->Warning = sprintf('The Inventory %s at %s has been altered by another user and removed from the transaction. You may add the inventory again or save the transaction without it.', $objInventoryLocation->InventoryModel->InventoryModelCode, $objInventoryLocation->Location->__toString()); } } } }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this InventoryLocationMetaControl * @param integer $intInventoryLocationId primary key value * @param QMetaControlCreateType $intCreateType rules governing InventoryLocation object creation - defaults to CreateOrEdit * @return InventoryLocationMetaControl */ public static function Create($objParentObject, $intInventoryLocationId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intInventoryLocationId)) { $objInventoryLocation = InventoryLocation::Load($intInventoryLocationId); // InventoryLocation was found -- return it! if ($objInventoryLocation) { return new InventoryLocationMetaControl($objParentObject, $objInventoryLocation); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a InventoryLocation object with PK arguments: ' . $intInventoryLocationId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new InventoryLocationMetaControl($objParentObject, new InventoryLocation()); }
public function btnEdit_Click($strFormId, $strControlId, $strParameter) { $strParameterArray = explode(',', $strParameter); $objInventoryLocation = InventoryLocation::Load($strParameterArray[0]); $objEditPanel = new InventoryLocationEditPanel($this, $this->strCloseEditPanelMethod, $objInventoryLocation); $strMethodName = $this->strSetEditPanelMethod; $this->objForm->{$strMethodName}($objEditPanel); }