protected function SetupInventoryModel()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
     if ($intInventoryModelId) {
         $this->objInventoryModel = InventoryModel::Load($intInventoryModelId);
         if (!$this->objInventoryModel) {
             throw new Exception('Could not find a InventoryModel object with PK arguments: ' . $intInventoryModelId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objInventoryModel = new InventoryModel();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
예제 #2
0
 protected function Form_Create()
 {
     // check rigths for the Inventory to Ship
     $this->blnShowInventory = true;
     $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3);
     if ($objRoleModule->AccessFlag) {
         $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2);
         if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) {
             $this->blnShowInventory = false;
         }
     } else {
         $this->blnShowInventory = false;
     }
     // Call Setup Receipt to either load existing or create new receipt
     $this->SetupReceipt();
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     // Create the Shortcut Menu
     $this->ctlShortcutMenu_Create();
     // Create the labels
     $this->lblHeaderReceipt_Create();
     $this->lblFromCompany_Create();
     $this->lblFromContact_Create();
     $this->lblToContact_Create();
     $this->lblToAddress_Create();
     $this->lblReceiptNumber_Create();
     $this->pnlNote_Create();
     $this->lblDueDate_Create();
     $this->lblReceiptDate_Create();
     // Create the inputs
     $this->lstFromCompany_Create();
     $this->lblNewFromCompany_Create();
     $this->lstFromContact_Create();
     $this->lblNewFromContact_Create();
     $this->lstToContact_Create();
     $this->lblNewToContact_Create();
     $this->lstToAddress_Create();
     $this->lblNewToAddress_Create();
     $this->txtNote_Create();
     // Create all custom asset fields - this must be here for tab ordering
     $this->customFields_Create();
     if ($this->blnShowInventory) {
         $this->txtNewInventoryModelCode_Create();
         $this->ctlInventorySearchTool_Create();
         $this->txtQuantity_Create();
         $this->btnAddInventory_Create();
     }
     $this->txtNewAssetCode_Create();
     $this->rblAssetType_Create();
     $this->lstAssetModel_Create();
     $this->chkAutoGenerateAssetCode_Create();
     $this->calDueDate_Create();
     $this->calDateReceived_Create();
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         $this->txtReceiptNumber_Create();
     }
     // Create the buttons
     $this->btnSave_Create();
     $this->btnEdit_Create();
     $this->btnCancel_Create();
     $this->btnDelete_Create();
     $this->atcAttach_Create();
     $this->pnlAttachments_Create();
     $this->btnAddAsset_Create();
     $this->ctlAssetSearchTool_Create();
     //Set display logic of Built-In Fields
     $this->UpdateBuiltInFields();
     // Set display logic of certain Entities
     $this->UpdateAddressAccess();
     $this->UpdateCompanyAccess();
     $this->UpdateContactAccess();
     // Check prerequisites for scheduling receipts
     $this->CheckPrerequisites();
     // Create the datagrids
     $this->dtgAssetTransact_Create();
     $this->dtgInventoryTransact_Create();
     // New entities Dialog
     $this->dlgNew_Create();
     // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time
     if ($this->blnEditMode) {
         $objClauses = array();
         if ($objClause = $this->dtgAssetTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgAssetTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) {
             array_push($objClauses, $objClause);
         }
         $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $objClauses = null;
         $objClauses = array();
         if ($objClause = $this->dtgInventoryTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgInventoryTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) {
         }
         array_push($objClauses, $objClause);
         $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $this->DisplayLabels();
     } elseif (!$this->blnEditMode) {
         $this->DisplayInputs();
     }
     // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit
     if (!$this->blnEditMode) {
         $intAssetId = QApplication::QueryString('intAssetId');
         // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button
         if ($intAssetId) {
             $objAsset = Asset::Load($intAssetId);
             if ($objAsset) {
                 $this->txtNewAssetCode->Text = $objAsset->AssetCode;
                 $this->btnAddAsset_Click($this, null, null);
             }
         }
         $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
         // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box
         if ($intInventoryModelId) {
             $objInventoryModel = InventoryModel::Load($intInventoryModelId);
             if ($objInventoryModel) {
                 $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode;
                 $this->txtQuantity->Focus();
             }
         }
     }
 }
 public function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $strParameterArray = explode(',', $strParameter);
     $objInventoryModel = InventoryModel::Load($strParameterArray[0]);
     $objEditPanel = new InventoryModelEditPanel($this, $this->strCloseEditPanelMethod, $objInventoryModel);
     $strMethodName = $this->strSetEditPanelMethod;
     $this->objForm->{$strMethodName}($objEditPanel);
 }
예제 #4
0
 protected function Form_Create()
 {
     // check rigths for the Inventory to Ship
     $this->blnShowInventory = true;
     $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3);
     if ($objRoleModule->AccessFlag) {
         $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2);
         if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) {
             $this->blnShowInventory = false;
         }
     } else {
         $this->blnShowInventory = false;
     }
     // Call SetupShipment to either Load/Edit Existing or Create New
     $this->SetupShipment();
     $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription)));
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     // Create the Shortcut Menu
     $this->ctlShortcutMenu_Create();
     // Packing List Link
     $this->lblPackingListLink_Create();
     // Shipping Labels
     $this->lblShipmentNumber_Create();
     $this->lblHeaderShipment_Create();
     $this->lblShipDate_Create();
     $this->lblFromCompany_Create();
     $this->lblFromContact_Create();
     $this->lblFromAddress_Create();
     $this->lstToCompany_Create();
     $this->lblNewToCompany_Create();
     $this->lstToContact_Create();
     $this->lblNewToContact_Create();
     $this->lstToAddress_Create();
     $this->lblNewToAddress_Create();
     $this->lblFromAddressFull_Create();
     $this->lblToCompany_Create();
     $this->lblToContact_Create();
     $this->lblToAddress_Create();
     $this->lblToAddressFull_Create();
     $this->lblCourier_Create();
     $this->pnlNote_Create();
     $this->lblTrackingNumber_Create();
     // Shipping Inputs
     $this->dlgExchange_Create();
     $this->dlgDueDate_Create();
     $this->calShipDate_Create();
     $this->lstFromCompany_Create();
     $this->lblNewFromCompany_Create();
     $this->lstFromContact_Create();
     $this->lblNewFromContact_Create();
     $this->lstFromAddress_Create();
     $this->lblNewFromAddress_Create();
     if (QApplication::$TracmorSettings->CustomShipmentNumbers) {
         $this->txtShipmentNumber_Create();
     }
     $this->lstCourier_Create();
     $this->txtNote_Create();
     $this->txtNewAssetCode_Create();
     if ($this->blnShowInventory) {
         $this->txtNewInventoryModelCode_Create();
         $this->btnLookup_Create();
         $this->ctlInventorySearchTool_Create();
         $this->lstSourceLocation_Create();
         $this->txtQuantity_Create();
         $this->btnAddInventory_Create();
     }
     $this->txtTrackingNumber_Create();
     //$this->lblAdvanced_Create();
     $this->txtReceiptAssetCode_Create();
     $this->chkAutoGenerateAssetCode_Create();
     $this->dtpScheduleReceiptDueDate_Create();
     $this->rblAssetType_Create();
     $this->chkScheduleReceipt_Create();
     $this->btnAddAsset_Create();
     $this->ctlAssetSearchTool_Create();
     $this->btnSaveExchange_Create();
     $this->btnCancelExchange_Create();
     $this->btnSaveDueDate_Create();
     $this->btnCancelDueDate_Create();
     $this->pnlAttachments_Create();
     // Create all custom asset fields
     $this->customFields_Create();
     //Set display logic of Built-In Fields
     $this->UpdateBuiltInFields();
     $this->UpdateAddressAccess();
     $this->UpdateCompanyAccess();
     $this->UpdateContactAccess();
     // New entities Dialog
     $this->dlgNew_Create();
     if (!$this->objShipment->ShippedFlag) {
         // Shipping Buttons
         $this->btnDelete_Create();
     }
     $this->btnSave_Create();
     $this->btnCancel_Create();
     $this->btnEdit_Create();
     $this->atcAttach_Create();
     // Complete Shipment Buttons
     $this->btnCompleteShipment_Create();
     $this->btnCancelShipment_Create();
     $this->btnCancelCompleteShipment_Create();
     // Shipping Datagrids
     $this->dtgAssetTransact_Create();
     $this->dtgInventoryTransact_Create();
     // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time
     if ($this->blnEditMode) {
         $objClauses = array();
         if ($objClause = $this->dtgAssetTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgAssetTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) {
         }
         array_push($objClauses, $objClause);
         $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses);
         $objClauses = null;
         $objClauses = array();
         if ($objClause = $this->dtgInventoryTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgInventoryTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) {
         }
         array_push($objClauses, $objClause);
         $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses);
         // If shipped, display labels. Otherwise, we don't need to call DisplayLabels because only labels are on the QPanel.
         $this->DisplayLabels();
     } elseif (!$this->blnEditMode) {
         $this->DisplayInputs();
     }
     // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit
     if (!$this->blnEditMode) {
         $intAssetId = QApplication::QueryString('intAssetId');
         // If an Asset was passed in the query string, load the txt in the Asset Tag text box and click the add button
         if ($intAssetId) {
             $objAsset = Asset::Load($intAssetId);
             if ($objAsset) {
                 $this->txtNewAssetCode->Text = $objAsset->AssetCode;
                 $this->btnAddAsset_Click($this, null, null);
             }
         }
         $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
         // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box
         if ($intInventoryModelId) {
             $objInventoryModel = InventoryModel::Load($intInventoryModelId);
             if ($objInventoryModel) {
                 $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode;
                 $this->btnLookup_Click($this, null, null);
                 QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstSourceLocation->ControlId));
             }
         }
     }
 }
 public function btnApply_Click($strFormId, $strControlId, $strParameter)
 {
     $this->EnableSelectedControls();
     $this->ClearWarnings();
     $blnError = false;
     // Make sure at least one checkbox is checked
     if (!$this->chkCategory->Checked && !$this->chkManufacturer->Checked && !$this->chkLongDescription->Checked) {
         $blnChecked = false;
         foreach ($this->arrCheckboxes as $objCheckBox) {
             if ($objCheckBox->Checked) {
                 $blnChecked = true;
                 break;
             }
         }
         if (!$blnChecked) {
             $blnError = true;
             $this->btnCancel->Warning = 'You must select at least one field to edit.';
             return;
         }
     }
     // Get an instance of the database
     $objDatabase = QApplication::$Database[1];
     // Begin a MySQL Transaction to be either committed or rolled back
     $objDatabase->TransactionBegin();
     if (count($this->arrCustomFields) > 0) {
         $customFieldIdArray = array();
         foreach ($this->arrCustomFields as $field) {
             if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) {
                 if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) {
                     $blnError = true;
                     $field['input']->Warning = "Required.";
                 } else {
                     $this->arrCustomFieldsToEdit[] = $field;
                     $customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId);
                 }
             }
         }
     }
     // Apply checked main_table fields
     $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
     // Force modified_date timestamp update
     $set[] = '`modified_date` = NOW()';
     if ($this->chkLongDescription->Checked) {
         $set[] = sprintf('`long_description`="%s"', $this->txtLongDescription->Text);
     }
     if ($this->chkManufacturer->Checked) {
         if ($this->lstManufacturer->SelectedValue !== null) {
             $set[] = sprintf('`manufacturer_id`=%s', $this->lstManufacturer->SelectedValue);
         } else {
             $blnError = true;
             $this->lstManufacturer->Warning = 'You must select a Manufacturer.';
         }
     }
     if ($this->chkCategory->Checked) {
         if ($this->lstCategory->SelectedValue !== null) {
             $set[] = sprintf('`category_id`= %s', $this->lstCategory->SelectedValue);
         } else {
             $blnError = true;
             $this->lstCategory->Warning = 'You must select a Category.';
         }
     }
     // First check that the user is authorized to edit this inventory
     foreach ($this->arrInventoryToEdit as $intInventoryId) {
         $objInventoryModel = InventoryModel::Load($intInventoryId);
         if (!QApplication::AuthorizeEntityBoolean($objInventoryModel, 2)) {
             $blnError = true;
             $this->btnCancel->Warning = 'You are not authorized to edit one or more of the selected inventory models.';
             break;
         }
     }
     // Save
     if (!$blnError) {
         try {
             if (count($this->arrCustomFieldsToEdit) > 0) {
                 // preparing data to edit
                 // Save the values from all of the custom field controls to save the asset
                 foreach ($this->arrInventoryToEdit as $intInventoryId) {
                     $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Inventory, false);
                     $selectedCustomFieldsArray = array();
                     foreach ($objCustomFieldsArray as $objCustomField) {
                         if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
                             $selectedCustomFieldsArray[] = $objCustomField;
                         }
                     }
                     CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intInventoryId, EntityQtype::Inventory);
                 }
             }
             $strQuery = sprintf("UPDATE `inventory_model`\n\t\t\t\t\t\t\t\t\t SET " . implode(",", $set) . "\n\t\t\t\t\t\t\t\t\t WHERE `inventory_model_id` IN (%s)", implode(",", $this->arrInventoryToEdit));
             $objDatabase = QApplication::$Database[1];
             $objDatabase->NonQuery($strQuery);
             $objDatabase->TransactionCommit();
             QApplication::Redirect('');
         } catch (QMySqliDatabaseException $objExc) {
             $objDatabase->TransactionRollback();
             throw new QDatabaseException();
         }
     } else {
         $objDatabase->TransactionRollback();
     }
 }
예제 #6
0
 public function SetupInventoryModel($objCaller = null)
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     // Overridden from InventoryModelEditForm to add the $objCaller parameter
     $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
     if ($intInventoryModelId) {
         $objCaller->objInventoryModel = InventoryModel::Load($intInventoryModelId);
         if (!$objCaller->objInventoryModel) {
             throw new Exception('Could not find a InventoryModel object with PK arguments: ' . $intInventoryModelId);
         }
         $objCaller->strTitleVerb = QApplication::Translate('Edit');
         $objCaller->blnEditMode = true;
     } else {
         $objCaller->objInventoryModel = new InventoryModel();
         $objCaller->strTitleVerb = QApplication::Translate('Create');
         $objCaller->blnEditMode = false;
     }
     QApplication::AuthorizeEntity($objCaller->objInventoryModel, $objCaller->blnEditMode);
 }
 /**
  * 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 'InventoryLocationId':
             // Gets the value for intInventoryLocationId (Read-Only PK)
             // @return integer
             return $this->intInventoryLocationId;
         case 'InventoryModelId':
             // Gets the value for intInventoryModelId (Not Null)
             // @return integer
             return $this->intInventoryModelId;
         case 'LocationId':
             // Gets the value for intLocationId (Not Null)
             // @return integer
             return $this->intLocationId;
         case 'Quantity':
             // Gets the value for intQuantity (Not Null)
             // @return integer
             return $this->intQuantity;
         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 'InventoryModel':
             // Gets the value for the InventoryModel object referenced by intInventoryModelId (Not Null)
             // @return InventoryModel
             try {
                 if (!$this->objInventoryModel && !is_null($this->intInventoryModelId)) {
                     $this->objInventoryModel = InventoryModel::Load($this->intInventoryModelId);
                 }
                 return $this->objInventoryModel;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Location':
             // Gets the value for the Location object referenced by intLocationId (Not Null)
             // @return Location
             try {
                 if (!$this->objLocation && !is_null($this->intLocationId)) {
                     $this->objLocation = Location::Load($this->intLocationId);
                 }
                 return $this->objLocation;
             } 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 '_InventoryTransaction':
             // Gets the value for the private _objInventoryTransaction (Read-Only)
             // if set due to an expansion on the inventory_transaction.inventory_location_id reverse relationship
             // @return InventoryTransaction
             return $this->_objInventoryTransaction;
         case '_InventoryTransactionArray':
             // Gets the value for the private _objInventoryTransactionArray (Read-Only)
             // if set due to an ExpandAsArray on the inventory_transaction.inventory_location_id reverse relationship
             // @return InventoryTransaction[]
             return (array) $this->_objInventoryTransactionArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * 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 InventoryModelMetaControl
  * @param integer $intInventoryModelId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing InventoryModel object creation - defaults to CreateOrEdit
  * @return InventoryModelMetaControl
  */
 public static function Create($objParentObject, $intInventoryModelId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intInventoryModelId)) {
         $objInventoryModel = InventoryModel::Load($intInventoryModelId);
         // InventoryModel was found -- return it!
         if ($objInventoryModel) {
             return new InventoryModelMetaControl($objParentObject, $objInventoryModel);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a InventoryModel object with PK arguments: ' . $intInventoryModelId);
             }
         }
         // 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 InventoryModelMetaControl($objParentObject, new InventoryModel());
 }
 /**
  * Reload this InventoryModel 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 InventoryModel object.');
     }
     // Reload the Object
     $objReloaded = InventoryModel::Load($this->intInventoryModelId);
     // Update $this's local variables to match
     $this->CategoryId = $objReloaded->CategoryId;
     $this->ManufacturerId = $objReloaded->ManufacturerId;
     $this->strInventoryModelCode = $objReloaded->strInventoryModelCode;
     $this->strShortDescription = $objReloaded->strShortDescription;
     $this->strLongDescription = $objReloaded->strLongDescription;
     $this->strImagePath = $objReloaded->strImagePath;
     $this->fltPrice = $objReloaded->fltPrice;
     $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 'InventoryModelId':
             // Gets the value for intInventoryModelId (PK)
             // @return integer
             return $this->intInventoryModelId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'InventoryModel':
             // Gets the value for the InventoryModel object referenced by intInventoryModelId (PK)
             // @return InventoryModel
             try {
                 if (!$this->objInventoryModel && !is_null($this->intInventoryModelId)) {
                     $this->objInventoryModel = InventoryModel::Load($this->intInventoryModelId);
                 }
                 return $this->objInventoryModel;
             } 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;
             }
     }
 }
예제 #11
0
 protected function Form_Create()
 {
     // Call Setup Receipt to either load existing or create new receipt
     $this->SetupReceipt();
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     // Create the Shortcut Menu
     $this->ctlShortcutMenu_Create();
     // Create the labels
     $this->lblHeaderReceipt_Create();
     $this->lblFromCompany_Create();
     $this->lblFromContact_Create();
     $this->lblToContact_Create();
     $this->lblToAddress_Create();
     $this->lblReceiptNumber_Create();
     $this->pnlNote_Create();
     $this->lblDueDate_Create();
     $this->lblReceiptDate_Create();
     // Create the inputs
     $this->lstFromCompany_Create();
     $this->lblNewFromCompany_Create();
     $this->lstFromContact_Create();
     $this->lblNewFromContact_Create();
     $this->lstToContact_Create();
     $this->lblNewToContact_Create();
     $this->lstToAddress_Create();
     $this->lblNewToAddress_Create();
     $this->txtNote_Create();
     // Create all custom asset fields - this must be here for tab ordering
     $this->customFields_Create();
     $this->txtNewAssetCode_Create();
     $this->txtNewInventoryModelCode_Create();
     $this->txtQuantity_Create();
     $this->rblAssetType_Create();
     $this->lstAssetModel_Create();
     $this->chkAutoGenerateAssetCode_Create();
     $this->calDueDate_Create();
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         $this->txtReceiptNumber_Create();
     }
     // Create the buttons
     $this->btnSave_Create();
     $this->btnEdit_Create();
     $this->btnCancel_Create();
     $this->btnDelete_Create();
     $this->atcAttach_Create();
     $this->pnlAttachments_Create();
     $this->btnAddAsset_Create();
     $this->btnAddInventory_Create();
     //Set display logic of Built-In Fields
     $this->UpdateBuiltInFields();
     // Set display logic of certain Entities
     $this->UpdateAddressAccess();
     $this->UpdateCompanyAccess();
     $this->UpdateContactAccess();
     // Create the datagrids
     $this->dtgAssetTransact_Create();
     $this->dtgInventoryTransact_Create();
     // New entities Dialog
     $this->dlgNew_Create();
     // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time
     if ($this->blnEditMode) {
         $objClauses = array();
         if ($objClause = $this->dtgAssetTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgAssetTransact->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) {
             array_push($objClauses, $objClause);
         }
         $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $objClauses = null;
         $objClauses = array();
         if ($objClause = $this->dtgInventoryTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgInventoryTransact->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) {
         }
         array_push($objClauses, $objClause);
         $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $this->DisplayLabels();
     } elseif (!$this->blnEditMode) {
         $this->DisplayInputs();
     }
     // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit
     if (!$this->blnEditMode) {
         $intAssetId = QApplication::QueryString('intAssetId');
         // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button
         if ($intAssetId) {
             $objAsset = Asset::Load($intAssetId);
             if ($objAsset) {
                 $this->txtNewAssetCode->Text = $objAsset->AssetCode;
                 $this->btnAddAsset_Click($this, null, null);
             }
         }
         $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
         // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box
         if ($intInventoryModelId) {
             $objInventoryModel = InventoryModel::Load($intInventoryModelId);
             if ($objInventoryModel) {
                 $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode;
                 QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->txtQuantity->ControlId));
             }
         }
     }
 }
예제 #12
0
 protected function btnMassDeleteConfirm_Click()
 {
     $items = $this->ctlSearchMenu->dtgInventoryModel->getSelected('InventoryModelId');
     foreach ($items as $item) {
         // First check that the user is authorized to delete this inventory
         $objInventoryModel = InventoryModel::Load($item);
         if (!QApplication::AuthorizeEntityBoolean($objInventoryModel, 3)) {
             $blnError = true;
             $this->lblWarning->Text = 'You are not authorized to delete one or more of the selected inventory models.';
             $this->dlgMassDelete->HideDialogBox();
             return;
         }
     }
     if (count($items) > 0) {
         $this->lblWarning->Text = "";
         // TODO perform validate
         foreach ($items as $item) {
             try {
                 // Get an instance of the database
                 $objDatabase = QApplication::$Database[1];
                 // Begin a MySQL Transaction to be either committed or rolled back
                 $objDatabase->TransactionBegin();
                 InventoryModel::Load($item)->Delete();
                 $objDatabase->TransactionCommit();
                 $this->UncheckAllItems($this);
                 // Hide the dialog
                 $this->dlgMassDelete->HideDialogBox();
             } catch (QDatabaseExceptionBase $objExc) {
                 // Roll back the transaction from the database
                 $objDatabase->TransactionRollback();
                 if ($objExc->ErrorNumber == 1451) {
                     $this->lblWarning->Text .= 'Inventory model ' . $item . 'cannot be deleted because it is associated with one or more transactions.';
                 } else {
                     throw new QDatabaseExceptionBase();
                 }
             }
         }
     } else {
         $this->lblWarning->Text = "You haven't chosen any Inventory to Delete";
     }
 }
예제 #13
0
 protected function Form_Create()
 {
     // Call SetupShipment to either Load/Edit Existing or Create New
     $this->SetupShipment();
     // If the courier is FedEx, load the FedexShipment object
     if ($this->blnEditMode) {
         if ($this->objShipment->CourierId === 1) {
             $this->objFedexShipment = FedexShipment::LoadByShipmentId($this->objShipment->ShipmentId);
         }
     }
     $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription)));
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     // Create the Shortcut Menu
     $this->ctlShortcutMenu_Create();
     // FedEx Shipment Panel
     $this->pnlFedExShipment_Create();
     // Packing List Link
     $this->lblPackingListLink_Create();
     $this->lblFedexShippingLabelLink_Create();
     // Shipping Labels
     $this->lblShipmentNumber_Create();
     $this->lblHeaderShipment_Create();
     // $this->lblHeaderCompleteShipment_Create();
     $this->lblShipDate_Create();
     $this->lblFromCompany_Create();
     $this->lblFromContact_Create();
     $this->lblFromAddress_Create();
     $this->lblFromAddressFull_Create();
     $this->lblToCompany_Create();
     $this->lblToContact_Create();
     $this->lblToAddress_Create();
     $this->lblToAddressFull_Create();
     $this->lblCourier_Create();
     $this->lblToPhone_Create();
     $this->lblBillTransportationTo_Create();
     $this->lblReference_Create();
     $this->lblFedexNotifySenderEmail_Create();
     $this->lblFedexNotifyRecipientEmail_Create();
     $this->lblFedexNotifyOtherEmail_Create();
     $this->lblHoldAtLocationAddress_Create();
     $this->lblHoldAtLocationCity_Create();
     $this->lblHoldAtLocationState_Create();
     $this->lblHoldAtLocationPostalCode_Create();
     $this->pnlNote_Create();
     $this->lblTrackingNumber_Create();
     $this->lblSenderLabel_Create();
     $this->lblPayerAccount_Create();
     $this->lblFxServiceType_Create();
     $this->lblPackageType_Create();
     $this->lblPackageWeight_Create();
     $this->lblPackageLength_Create();
     $this->lblPackageWidth_Create();
     $this->lblPackageHeight_Create();
     $this->lblValue_Create();
     $this->lblWeightUnit_Create();
     $this->lblLengthUnit_Create();
     $this->lblCurrencyUnit_Create();
     // Shipping Inputs
     $this->dlgExchange_Create();
     $this->dlgDueDate_Create();
     $this->calShipDate_Create();
     $this->lstFromCompany_Create();
     $this->lblNewFromCompany_Create();
     $this->lstFromContact_Create();
     $this->lblNewFromContact_Create();
     $this->lstFromAddress_Create();
     $this->lblNewFromAddress_Create();
     $this->lstToCompany_Create();
     $this->lblNewToCompany_Create();
     $this->lstToContact_Create();
     $this->lblNewToContact_Create();
     $this->txtToPhone_Create();
     $this->lstBillTransportationTo_Create();
     $this->lstShippingAccount_Create();
     $this->txtReference_Create();
     $this->txtFedexNotifySenderEmail_Create();
     $this->txtFedexNotifyRecipientEmail_Create();
     $this->txtFedexNotifyOtherEmail_Create();
     $this->chkFedexNotifySenderShipFlag_Create();
     $this->chkFedexNotifySenderExceptionFlag_Create();
     $this->chkFedexNotifySenderDeliveryFlag_Create();
     $this->chkFedexNotifyRecipientShipFlag_Create();
     $this->chkFedexNotifyRecipientExceptionFlag_Create();
     $this->chkFedexNotifyRecipientDeliveryFlag_Create();
     $this->chkFedexNotifyOtherShipFlag_Create();
     $this->chkFedexNotifyOtherExceptionFlag_Create();
     $this->chkFedexNotifyOtherDeliveryFlag_Create();
     $this->lstFxServiceType_Create();
     $this->txtRecipientThirdPartyAccount_Create();
     $this->lstPackageType_Create();
     $this->txtPackageWeight_Create();
     $this->lstWeightUnit_Create();
     $this->txtPackageLength_Create();
     $this->txtPackageWidth_Create();
     $this->txtPackageHeight_Create();
     $this->lstLengthUnit_Create();
     $this->txtValue_Create();
     $this->lstCurrencyUnit_Create();
     $this->chkSaturdayDeliveryFlag_Create();
     $this->chkHoldAtLocationFlag_Create();
     $this->txtHoldAtLocationAddress_Create();
     $this->txtHoldAtLocationCity_Create();
     $this->lstHoldAtLocationState_Create();
     $this->txtHoldAtLocationPostalCode_Create();
     $this->lstToAddress_Create();
     $this->lblNewToAddress_Create();
     if (QApplication::$TracmorSettings->CustomShipmentNumbers) {
         $this->txtShipmentNumber_Create();
     }
     $this->lstCourier_Create();
     $this->txtNote_Create();
     $this->txtNewAssetCode_Create();
     $this->txtNewInventoryModelCode_Create();
     $this->lstSourceLocation_Create();
     $this->txtQuantity_Create();
     $this->txtTrackingNumber_Create();
     //$this->lblAdvanced_Create();
     $this->txtReceiptAssetCode_Create();
     $this->chkAutoGenerateAssetCode_Create();
     $this->dtpScheduleReceiptDueDate_Create();
     $this->rblAssetType_Create();
     $this->chkScheduleReceipt_Create();
     $this->btnAddAsset_Create();
     $this->btnLookup_Create();
     $this->btnAddInventory_Create();
     $this->btnSaveExchange_Create();
     $this->btnCancelExchange_Create();
     $this->btnSaveDueDate_Create();
     $this->btnCancelDueDate_Create();
     $this->pnlAttachments_Create();
     // Create all custom asset fields
     $this->customFields_Create();
     //Set display logic of Built-In Fields
     $this->UpdateBuiltInFields();
     $this->UpdateAddressAccess();
     $this->UpdateCompanyAccess();
     $this->UpdateContactAccess();
     // New entities Dialog
     $this->dlgNew_Create();
     if (!$this->objShipment->ShippedFlag) {
         // Shipping Buttons
         $this->btnSave_Create();
         $this->btnCancel_Create();
         $this->btnEdit_Create();
         $this->btnDelete_Create();
     }
     $this->atcAttach_Create();
     // Complete Shipment Buttons
     $this->btnCompleteShipment_Create();
     $this->btnCancelShipment_Create();
     $this->btnCancelCompleteShipment_Create();
     // Shipping Datagrids
     $this->dtgAssetTransact_Create();
     $this->dtgInventoryTransact_Create();
     // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time
     if ($this->blnEditMode) {
         $objClauses = array();
         if ($objClause = $this->dtgAssetTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgAssetTransact->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) {
         }
         array_push($objClauses, $objClause);
         $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses);
         $objClauses = null;
         $objClauses = array();
         if ($objClause = $this->dtgInventoryTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgInventoryTransact->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) {
         }
         array_push($objClauses, $objClause);
         $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses);
         // If shipped, display labels. Otherwise, we don't need to call DisplayLabels because only labels are on the QPanel.
         $this->DisplayLabels();
     } elseif (!$this->blnEditMode) {
         $this->DisplayInputs();
     }
     // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit
     if (!$this->blnEditMode) {
         $intAssetId = QApplication::QueryString('intAssetId');
         // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button
         if ($intAssetId) {
             $objAsset = Asset::Load($intAssetId);
             if ($objAsset) {
                 $this->txtNewAssetCode->Text = $objAsset->AssetCode;
                 $this->btnAddAsset_Click($this, null, null);
             }
         }
         $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
         // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box
         if ($intInventoryModelId) {
             $objInventoryModel = InventoryModel::Load($intInventoryModelId);
             if ($objInventoryModel) {
                 $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode;
                 $this->btnLookup_Click($this, null, null);
                 QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstSourceLocation->ControlId));
             }
         }
     }
 }