protected function Form_PreRender() { // If an existing InventoryModel is being edited, render the Quantities by Location and Transaction history datagrids if ($this->ctlInventoryEdit->blnEditMode) { // Render the Quantities by Location datagrid $objExpansionMap[InventoryLocation::ExpandLocation] = true; $this->ctlInventoryEdit->dtgInventoryQuantities->TotalItemCount = InventoryLocation::CountByInventoryModelIdLocations($this->ctlInventoryEdit->objInventoryModel->InventoryModelId); // If there are no rows in the datagrid, do not show the header column if ($this->ctlInventoryEdit->dtgInventoryQuantities->TotalItemCount == 0) { $this->ctlInventoryEdit->dtgInventoryQuantities->ShowHeader = false; } else { $this->ctlInventoryEdit->dtgInventoryQuantities->ShowHeader = true; // $this->ctlInventoryEdit->dtgInventoryQuantities->DataSource = InventoryLocation::LoadArrayByInventoryModelId($this->ctlInventoryEdit->objInventoryModel->InventoryModelId, $this->ctlInventoryEdit->dtgInventoryQuantities->SortInfo, $this->ctlInventoryEdit->dtgInventoryQuantities->LimitInfo, $objExpansionMap); $this->ctlInventoryEdit->dtgInventoryQuantities->DataSource = InventoryLocation::LoadArrayByInventoryModelIdLocations($this->ctlInventoryEdit->objInventoryModel->InventoryModelId, $this->ctlInventoryEdit->dtgInventoryQuantities->SortInfo, $this->ctlInventoryEdit->dtgInventoryQuantities->LimitInfo, $objExpansionMap, true); } $objExpansionMap = null; // Specify the local databind method this datagrid will use $this->ctlInventoryEdit->dtgInventoryTransaction->SetDataBinder('dtgInventoryTransaction_Bind'); // Specify the local databind method this datagrid will use $this->ctlInventoryEdit->dtgShipmentReceipt->SetDataBinder('dtgShipmentReceipt_Bind'); } // If InventoryLocations are in the array, finish setting up the datagrid of InventorieLocations prepared for a transaction if ($this->ctlInventoryTransact->objInventoryLocationArray) { // Using the array instead of querying the database again. This means sorting will not work because the db is not being queried each time. $this->ctlInventoryTransact->dtgInventoryTransact->TotalItemCount = count($this->ctlInventoryTransact->objInventoryLocationArray); $this->ctlInventoryTransact->dtgInventoryTransact->DataSource = $this->ctlInventoryTransact->objInventoryLocationArray; $this->ctlInventoryTransact->dtgInventoryTransact->ShowHeader = true; } else { $this->ctlInventoryTransact->dtgInventoryTransact->TotalItemCount = 0; $this->ctlInventoryTransact->dtgInventoryTransact->ShowHeader = false; } }
public function btnLookup_Click($strFormId, $strControlId = null, $strParameter = null) { $this->txtNewInventoryModelCode->Warning = ''; // Assign the value submitted from the form $strInventoryModelCode = $this->txtNewInventoryModelCode->Text; if ($strInventoryModelCode) { // Load the inventory model object based on the inventory_model_code submitted $objInventoryModel = InventoryModel::LoadByInventoryModelCode($strInventoryModelCode); if ($objInventoryModel) { // Load the array of InventoryLocations based on the InventoryModelId of the InventoryModel object $InventorySourceLocationArray = InventoryLocation::LoadArrayByInventoryModelIdLocations($objInventoryModel->InventoryModelId); $this->lstSourceLocation->RemoveAllItems(); $this->lstSourceLocation->AddItem('- Select One -', null); if ($InventorySourceLocationArray) { // Populate the Source Location list box foreach ($InventorySourceLocationArray as $InventoryLocation) { // Do not display locations where the quantity is 0 if ($InventoryLocation->Quantity != 0) { $this->lstSourceLocation->AddItem($InventoryLocation->__toStringWithQuantity(), $InventoryLocation->InventoryLocationId); } } $this->lstSourceLocation->Enabled = true; $this->txtQuantity->Enabled = true; $this->lstSourceLocation->SelectedIndex = $this->lstSourceLocation->ItemCount == 2; } elseif ($this->intTransactionTypeId != 4) { $this->txtNewInventoryModelCode->Warning = 'There is no inventory for that inventory code'; $this->lstSourceLocation->Enabled = false; $this->txtQuantity->Enabled = false; } if ($this->intTransactionTypeId == 1 || $this->intTransactionTypeId == 5) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId(QApplication::$objUserAccount->RoleId, $this->intTransactionTypeId); if ($objRoleTransactionTypeAuthorization) { // If the user has 'None' privileges for this transaction if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $this->txtNewInventoryModelCode->Warning = "You do not have privileges for this transaction."; $this->lstSourceLocation->Enabled = false; $this->txtQuantity->Enabled = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2 && $objInventoryModel->CreatedBy != QApplication::$objUserAccount->UserAccountId) { $this->txtNewInventoryModelCode->Warning = "You are not the owner of this inventory."; $this->lstSourceLocation->Enabled = false; $this->txtQuantity->Enabled = false; } } } } else { $this->txtNewInventoryModelCode->Warning = 'That is not a valid inventory code.'; } } else { $this->txtNewInventoryModelCode->Warning = 'Please enter an inventory code.'; } }
You will also have to change the asset.location_id to the destination location */ $arrInventoryCodeLocationQuantity = array_unique(explode('#', $_POST['result'])); $blnError = false; $arrCheckedInventoryCodeLocationQuantity = array(); foreach ($arrInventoryCodeLocationQuantity as $strInventoryCodeLocationQuantity) { $blnErrorCurrentInventory = false; list($strInventoryModelCode, $strSourceLocation, $intQuantity) = explode('|', $strInventoryCodeLocationQuantity, 3); if ($strInventoryModelCode && $strSourceLocation && $intQuantity) { $intNewInventoryLocationId = 0; // Begin error checking // Load the inventory model object based on the inventory_model_code submitted $objInventoryModel = InventoryModel::LoadByInventoryModelCode($strInventoryModelCode); if ($objInventoryModel) { // Load the array of InventoryLocations based on the InventoryModelId of the InventoryModel object $InventorySourceLocationArray = InventoryLocation::LoadArrayByInventoryModelIdLocations($objInventoryModel->InventoryModelId); if ($InventorySourceLocationArray) { $blnErrorCurrentInventory = true; foreach ($InventorySourceLocationArray as $InventoryLocation) { if ($InventoryLocation->Quantity != 0) { if (strtoupper($InventoryLocation->__toString()) == strtoupper($strSourceLocation)) { $blnErrorCurrentInventory = false; $intNewInventoryLocationId = $InventoryLocation->InventoryLocationId; $objNewInventoryLocation = $InventoryLocation; } } } if ($blnErrorCurrentInventory) { $strWarning .= $strInventoryModelCode . " - There is no source location for that inventory code.<br />"; $blnError = true; }
public function btnLookup_Click($strFormId, $strControlId, $strParameter) { // Clear if warning from previous attempt exists $this->txtNewInventoryModelCode->Warning = ''; // Assign the value submitted from the form $strInventoryModelCode = $this->txtNewInventoryModelCode->Text; if ($strInventoryModelCode) { // Load the inventory model object based on the inventory_model_code submitted $objInventoryModel = InventoryModel::LoadByInventoryModelCode($strInventoryModelCode); if ($objInventoryModel) { // Load the array of InventoryLocations based on the InventoryModelId of the InventoryModel object $InventorySourceLocationArray = InventoryLocation::LoadArrayByInventoryModelIdLocations($objInventoryModel->InventoryModelId); $this->lstSourceLocation->RemoveAllItems(); $this->lstSourceLocation->AddItem('- Select One -', null); if ($InventorySourceLocationArray) { // Populate the Source Location list box foreach ($InventorySourceLocationArray as $InventoryLocation) { // Do not display locations where the quantity is 0 if ($InventoryLocation->Quantity != 0) { $this->lstSourceLocation->AddItem($InventoryLocation->__toStringWithQuantity(), $InventoryLocation->InventoryLocationId); } } $this->lstSourceLocation->Enabled = true; $this->txtQuantity->Enabled = true; } else { $this->txtNewInventoryModelCode->Warning = 'There is no inventory for that inventory code'; $this->lstSourceLocation->Enabled = false; $this->txtQuantity->Enabled = false; } } else { $this->txtNewInventoryModelCode->Warning = 'That is not a valid inventory code.'; } } else { $this->txtNewInventoryModelCode->Warning = 'Please enter an inventory code.'; } }