Пример #1
0
 protected function SetupShipment()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intShipmentId = QApplication::QueryString('intShipmentId');
     if ($intShipmentId) {
         $this->objShipment = Shipment::Load($intShipmentId);
         if (!$this->objShipment) {
             throw new Exception('Could not find a Shipment object with PK arguments: ' . $intShipmentId);
         }
     }
 }
Пример #2
0
 protected function SetupShipment()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intShipmentId = QApplication::QueryString('intShipmentId');
     if ($intShipmentId) {
         $this->objShipment = Shipment::Load($intShipmentId);
         if (!$this->objShipment) {
             throw new Exception('Could not find a Shipment object with PK arguments: ' . $intShipmentId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objShipment = new Shipment();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
Пример #3
0
 /**
  * Load an array of Item objects by ShipmentId
  *
  * @param string $intShipmentId
  * @return Array
  */
 public static function LoadArrayByShipmentId($intShipmentId, $strOrderBy = null, $strLimit = null, $objExpansionMap = null)
 {
     Item::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $objDatabase);
     $objShipment = Shipment::Load($intShipmentId);
     $strQuery = sprintf("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\tasset_model.short_description AS short_description,\r\n\t\t\t\t\tasset.asset_code AS code,\r\n\t\t\t\t\t'1' AS quantity,\r\n\t\t\t\t\t(\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\treceipt.receipt_number \r\n\t\t\t\t\tFROM \r\n\t\t\t\t\t\treceipt,\r\n\t\t\t\t\t\ttransaction,\r\n\t\t\t\t\t\tasset_transaction at\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\treceipt.transaction_id = transaction.transaction_id\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t\tat.transaction_id = transaction.transaction_id\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t\tat.parent_asset_transaction_id = asset_transaction.asset_transaction_id\t\t\t\t\t\r\n\t\t\t\t\t) AS receipt_number\r\n\t\t\t\tFROM \r\n\t\t\t\t\tasset_transaction \r\n\t\t\t\t\tLEFT JOIN asset ON asset_transaction.asset_id = asset.asset_id\r\n\t\t\t\t\tLEFT JOIN asset_model ON asset.asset_model_id = asset_model.asset_model_id\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tasset_transaction.transaction_id = %s\r\n\t\t\t\tUNION\r\n\t\t\t\tSELECT \r\n\t\t\t\t\tinventory_model.short_description AS short_description, \r\n\t\t\t\t\tinventory_model.inventory_model_code AS code, \r\n\t\t\t\t\tinventory_transaction.quantity AS quantity,\r\n\t\t\t\t\t'' AS receipt_number\r\n\t\t\t\tFROM \r\n\t\t\t\t\tinventory_transaction\r\n\t\t\t\t\tLEFT JOIN inventory_location ON inventory_transaction.inventory_location_id = inventory_location.inventory_location_id\r\n\t\t\t\t\tLEFT JOIN inventory_model ON inventory_location.inventory_model_id = inventory_model.inventory_model_id\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tinventory_transaction.transaction_id = %s\r\n\t\t\t", $objShipment->TransactionId, $objShipment->TransactionId);
     $objDbResult = $objDatabase->Query($strQuery);
     return Item::InstantiateDbResult($objDbResult);
 }
 protected function UpdateTransactionFields()
 {
     $this->objTransaction->EntityQtypeId = $this->lstEntityQtype->SelectedValue;
     $this->objTransaction->TransactionTypeId = $this->lstTransactionType->SelectedValue;
     $this->objTransaction->Note = $this->txtNote->Text;
     $this->objTransaction->CreatedBy = $this->lstCreatedByObject->SelectedValue;
     $this->objTransaction->CreationDate = $this->calCreationDate->DateTime;
     $this->objTransaction->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
     $this->objTransaction->Receipt = Receipt::Load($this->lstReceipt->SelectedValue);
     $this->objTransaction->Shipment = Shipment::Load($this->lstShipment->SelectedValue);
 }
Пример #5
0
 protected function btnMassDelete_Click()
 {
     $items = $this->dtgShipment->getSelected('ShipmentId');
     if (count($items) > 0) {
         $this->lblWarning->Text = "";
         $arrToSkip = array();
         // Separating items able to be deleted
         foreach ($items as $item) {
             $shipmentToDelete = Shipment::Load($item);
             if ($shipmentToDelete instanceof Shipment && !$shipmentToDelete->ShippedFlag) {
                 $this->arrToDelete[] = $shipmentToDelete;
                 // objects stored in array!
             } else {
                 $arrToSkip[] = $shipmentToDelete->ShipmentNumber;
             }
         }
         if (count($arrToSkip) > 0) {
             if (count($arrToSkip) == 1) {
                 $toBe = 'is';
                 $ending = '';
             } else {
                 $toBe = 'are';
                 $ending = 's';
             }
             $this->dlgMassDelete->Text = sprintf("There %s %s Shipment%s that %s not able to be deleted.\n                                                         Would you like to continue the deletion process,\n                                                         skipping these item%s?<br />", $toBe, count($arrToSkip), $ending, $toBe, $ending);
             $this->dlgMassDelete->ShowDialogBox();
         } else {
             if (count($this->arrToDelete) > 0) {
                 try {
                     // Get an instance of the database
                     $objDatabase = QApplication::$Database[1];
                     // Begin a MySQL Transaction to be either committed or rolled back
                     $objDatabase->TransactionBegin();
                     foreach ($this->arrToDelete as $shipment) {
                         $objTransaction = Transaction::Load($shipment->TransactionId);
                         $objTransaction->Delete();
                     }
                     $objDatabase->TransactionCommit();
                     $this->arrToDelete = array();
                     QApplication::Redirect('');
                 } catch (QMySqliDatabaseException $objExc) {
                     $objDatabase->TransactionRollback();
                     throw new QDatabaseException();
                 }
             }
         }
     } else {
         $this->lblWarning->Text = "You haven't chosen any Shipment to Delete";
     }
 }
 public function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $strParameterArray = explode(',', $strParameter);
     $objShipment = Shipment::Load($strParameterArray[0]);
     $objEditPanel = new ShipmentEditPanel($this, $this->strCloseEditPanelMethod, $objShipment);
     $strMethodName = $this->strSetEditPanelMethod;
     $this->objForm->{$strMethodName}($objEditPanel);
 }
 /**
  * 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 ShipmentMetaControl
  * @param integer $intShipmentId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing Shipment object creation - defaults to CreateOrEdit
  * @return ShipmentMetaControl
  */
 public static function Create($objParentObject, $intShipmentId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intShipmentId)) {
         $objShipment = Shipment::Load($intShipmentId);
         // Shipment was found -- return it!
         if ($objShipment) {
             return new ShipmentMetaControl($objParentObject, $objShipment);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a Shipment object with PK arguments: ' . $intShipmentId);
             }
         }
         // 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 ShipmentMetaControl($objParentObject, new Shipment());
 }
Пример #8
0
 /**
  * Reload this Shipment 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 Shipment object.');
     }
     // Reload the Object
     $objReloaded = Shipment::Load($this->intShipmentId);
     // Update $this's local variables to match
     $this->strShipmentNumber = $objReloaded->strShipmentNumber;
     $this->TransactionId = $objReloaded->TransactionId;
     $this->FromCompanyId = $objReloaded->FromCompanyId;
     $this->FromContactId = $objReloaded->FromContactId;
     $this->FromAddressId = $objReloaded->FromAddressId;
     $this->ToCompanyId = $objReloaded->ToCompanyId;
     $this->ToContactId = $objReloaded->ToContactId;
     $this->ToAddressId = $objReloaded->ToAddressId;
     $this->CourierId = $objReloaded->CourierId;
     $this->strTrackingNumber = $objReloaded->strTrackingNumber;
     $this->dttShipDate = $objReloaded->dttShipDate;
     $this->blnShippedFlag = $objReloaded->blnShippedFlag;
     $this->CreatedBy = $objReloaded->CreatedBy;
     $this->dttCreationDate = $objReloaded->dttCreationDate;
     $this->ModifiedBy = $objReloaded->ModifiedBy;
     $this->strModifiedDate = $objReloaded->strModifiedDate;
 }
Пример #9
0
 /**
  * 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 'FedexShipmentId':
             /**
              * Gets the value for intFedexShipmentId (Read-Only PK)
              * @return integer
              */
             return $this->intFedexShipmentId;
         case 'ShipmentId':
             /**
              * Gets the value for intShipmentId (Not Null)
              * @return integer
              */
             return $this->intShipmentId;
         case 'PackageTypeId':
             /**
              * Gets the value for intPackageTypeId 
              * @return integer
              */
             return $this->intPackageTypeId;
         case 'ShippingAccountId':
             /**
              * Gets the value for intShippingAccountId 
              * @return integer
              */
             return $this->intShippingAccountId;
         case 'FedexServiceTypeId':
             /**
              * Gets the value for intFedexServiceTypeId 
              * @return integer
              */
             return $this->intFedexServiceTypeId;
         case 'CurrencyUnitId':
             /**
              * Gets the value for intCurrencyUnitId 
              * @return integer
              */
             return $this->intCurrencyUnitId;
         case 'WeightUnitId':
             /**
              * Gets the value for intWeightUnitId 
              * @return integer
              */
             return $this->intWeightUnitId;
         case 'LengthUnitId':
             /**
              * Gets the value for intLengthUnitId 
              * @return integer
              */
             return $this->intLengthUnitId;
         case 'ToPhone':
             /**
              * Gets the value for strToPhone 
              * @return string
              */
             return $this->strToPhone;
         case 'PayType':
             /**
              * Gets the value for intPayType 
              * @return integer
              */
             return $this->intPayType;
         case 'PayerAccountNumber':
             /**
              * Gets the value for strPayerAccountNumber 
              * @return string
              */
             return $this->strPayerAccountNumber;
         case 'PackageWeight':
             /**
              * Gets the value for fltPackageWeight 
              * @return double
              */
             return $this->fltPackageWeight;
         case 'PackageLength':
             /**
              * Gets the value for fltPackageLength 
              * @return double
              */
             return $this->fltPackageLength;
         case 'PackageWidth':
             /**
              * Gets the value for fltPackageWidth 
              * @return double
              */
             return $this->fltPackageWidth;
         case 'PackageHeight':
             /**
              * Gets the value for fltPackageHeight 
              * @return double
              */
             return $this->fltPackageHeight;
         case 'DeclaredValue':
             /**
              * Gets the value for fltDeclaredValue 
              * @return double
              */
             return $this->fltDeclaredValue;
         case 'Reference':
             /**
              * Gets the value for strReference 
              * @return string
              */
             return $this->strReference;
         case 'SaturdayDeliveryFlag':
             /**
              * Gets the value for blnSaturdayDeliveryFlag 
              * @return boolean
              */
             return $this->blnSaturdayDeliveryFlag;
         case 'NotifySenderEmail':
             /**
              * Gets the value for strNotifySenderEmail 
              * @return string
              */
             return $this->strNotifySenderEmail;
         case 'NotifySenderShipFlag':
             /**
              * Gets the value for blnNotifySenderShipFlag 
              * @return boolean
              */
             return $this->blnNotifySenderShipFlag;
         case 'NotifySenderExceptionFlag':
             /**
              * Gets the value for blnNotifySenderExceptionFlag 
              * @return boolean
              */
             return $this->blnNotifySenderExceptionFlag;
         case 'NotifySenderDeliveryFlag':
             /**
              * Gets the value for blnNotifySenderDeliveryFlag 
              * @return boolean
              */
             return $this->blnNotifySenderDeliveryFlag;
         case 'NotifyRecipientEmail':
             /**
              * Gets the value for strNotifyRecipientEmail 
              * @return string
              */
             return $this->strNotifyRecipientEmail;
         case 'NotifyRecipientShipFlag':
             /**
              * Gets the value for blnNotifyRecipientShipFlag 
              * @return boolean
              */
             return $this->blnNotifyRecipientShipFlag;
         case 'NotifyRecipientExceptionFlag':
             /**
              * Gets the value for blnNotifyRecipientExceptionFlag 
              * @return boolean
              */
             return $this->blnNotifyRecipientExceptionFlag;
         case 'NotifyRecipientDeliveryFlag':
             /**
              * Gets the value for blnNotifyRecipientDeliveryFlag 
              * @return boolean
              */
             return $this->blnNotifyRecipientDeliveryFlag;
         case 'NotifyOtherEmail':
             /**
              * Gets the value for strNotifyOtherEmail 
              * @return string
              */
             return $this->strNotifyOtherEmail;
         case 'NotifyOtherShipFlag':
             /**
              * Gets the value for blnNotifyOtherShipFlag 
              * @return boolean
              */
             return $this->blnNotifyOtherShipFlag;
         case 'NotifyOtherExceptionFlag':
             /**
              * Gets the value for blnNotifyOtherExceptionFlag 
              * @return boolean
              */
             return $this->blnNotifyOtherExceptionFlag;
         case 'NotifyOtherDeliveryFlag':
             /**
              * Gets the value for blnNotifyOtherDeliveryFlag 
              * @return boolean
              */
             return $this->blnNotifyOtherDeliveryFlag;
         case 'HoldAtLocationFlag':
             /**
              * Gets the value for blnHoldAtLocationFlag 
              * @return boolean
              */
             return $this->blnHoldAtLocationFlag;
         case 'HoldAtLocationAddress':
             /**
              * Gets the value for strHoldAtLocationAddress 
              * @return string
              */
             return $this->strHoldAtLocationAddress;
         case 'HoldAtLocationCity':
             /**
              * Gets the value for strHoldAtLocationCity 
              * @return string
              */
             return $this->strHoldAtLocationCity;
         case 'HoldAtLocationState':
             /**
              * Gets the value for intHoldAtLocationState 
              * @return integer
              */
             return $this->intHoldAtLocationState;
         case 'HoldAtLocationPostalCode':
             /**
              * Gets the value for strHoldAtLocationPostalCode 
              * @return string
              */
             return $this->strHoldAtLocationPostalCode;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Shipment':
             /**
              * Gets the value for the Shipment object referenced by intShipmentId (Not Null)
              * @return Shipment
              */
             try {
                 if (!$this->objShipment && !is_null($this->intShipmentId)) {
                     $this->objShipment = Shipment::Load($this->intShipmentId);
                 }
                 return $this->objShipment;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'PackageType':
             /**
              * Gets the value for the PackageType object referenced by intPackageTypeId 
              * @return PackageType
              */
             try {
                 if (!$this->objPackageType && !is_null($this->intPackageTypeId)) {
                     $this->objPackageType = PackageType::Load($this->intPackageTypeId);
                 }
                 return $this->objPackageType;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ShippingAccount':
             /**
              * Gets the value for the ShippingAccount object referenced by intShippingAccountId 
              * @return ShippingAccount
              */
             try {
                 if (!$this->objShippingAccount && !is_null($this->intShippingAccountId)) {
                     $this->objShippingAccount = ShippingAccount::Load($this->intShippingAccountId);
                 }
                 return $this->objShippingAccount;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'FedexServiceType':
             /**
              * Gets the value for the FedexServiceType object referenced by intFedexServiceTypeId 
              * @return FedexServiceType
              */
             try {
                 if (!$this->objFedexServiceType && !is_null($this->intFedexServiceTypeId)) {
                     $this->objFedexServiceType = FedexServiceType::Load($this->intFedexServiceTypeId);
                 }
                 return $this->objFedexServiceType;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'CurrencyUnit':
             /**
              * Gets the value for the CurrencyUnit object referenced by intCurrencyUnitId 
              * @return CurrencyUnit
              */
             try {
                 if (!$this->objCurrencyUnit && !is_null($this->intCurrencyUnitId)) {
                     $this->objCurrencyUnit = CurrencyUnit::Load($this->intCurrencyUnitId);
                 }
                 return $this->objCurrencyUnit;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'WeightUnit':
             /**
              * Gets the value for the WeightUnit object referenced by intWeightUnitId 
              * @return WeightUnit
              */
             try {
                 if (!$this->objWeightUnit && !is_null($this->intWeightUnitId)) {
                     $this->objWeightUnit = WeightUnit::Load($this->intWeightUnitId);
                 }
                 return $this->objWeightUnit;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'LengthUnit':
             /**
              * Gets the value for the LengthUnit object referenced by intLengthUnitId 
              * @return LengthUnit
              */
             try {
                 if (!$this->objLengthUnit && !is_null($this->intLengthUnitId)) {
                     $this->objLengthUnit = LengthUnit::Load($this->intLengthUnitId);
                 }
                 return $this->objLengthUnit;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'HoldAtLocationStateObject':
             /**
              * Gets the value for the StateProvince object referenced by intHoldAtLocationState 
              * @return StateProvince
              */
             try {
                 if (!$this->objHoldAtLocationStateObject && !is_null($this->intHoldAtLocationState)) {
                     $this->objHoldAtLocationStateObject = StateProvince::Load($this->intHoldAtLocationState);
                 }
                 return $this->objHoldAtLocationStateObject;
             } 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;
             }
     }
 }
 /**
  * This will save this object's Transaction instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveTransaction()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->lstEntityQtype) {
             $this->objTransaction->EntityQtypeId = $this->lstEntityQtype->SelectedValue;
         }
         if ($this->lstTransactionType) {
             $this->objTransaction->TransactionTypeId = $this->lstTransactionType->SelectedValue;
         }
         if ($this->txtNote) {
             $this->objTransaction->Note = $this->txtNote->Text;
         }
         if ($this->lstCreatedByObject) {
             $this->objTransaction->CreatedBy = $this->lstCreatedByObject->SelectedValue;
         }
         if ($this->calCreationDate) {
             $this->objTransaction->CreationDate = $this->calCreationDate->DateTime;
         }
         if ($this->lstModifiedByObject) {
             $this->objTransaction->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstReceipt) {
             $this->objTransaction->Receipt = Receipt::Load($this->lstReceipt->SelectedValue);
         }
         if ($this->lstShipment) {
             $this->objTransaction->Shipment = Shipment::Load($this->lstShipment->SelectedValue);
         }
         // Save the Transaction object
         $this->objTransaction->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 public function btnApply_Click($strFormId, $strControlId, $strParameter)
 {
     $this->clearWarnings();
     $blnError = false;
     $objDatabase = QApplication::$Database[1];
     // Begin a MySQL Transaction to be either committed or rolled back
     $objDatabase->TransactionBegin();
     // Check "Contact To", "Contact From", "Coutrier" wasn't changed for shipped items
     if (Shipment::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Shipment()->ShippedFlag, 1), QQ::In(QQN::Shipment()->ShipmentId, $this->arrShipmentToEdit))) > 0 && ($this->chkToCompany->Checked || $this->chkFromCompany->Checked || $this->chkCourier->Checked)) {
         $this->lblWarning->Text = '"To Company", "From Company", "Courier" shouldn\'t be changed for already
                                     Shipped items';
         $blnError = true;
     }
     if (!$blnError) {
         // Apply checked main_table fields
         $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
         if ($this->chkToCompany->Checked) {
             if ($this->lstToCompany->SelectedValue) {
                 $set[] = sprintf('`to_company_id`="%s"', $this->lstToCompany->SelectedValue);
             } else {
                 $this->lstToCompany->Warning = 'Company name must be chosen';
                 $blnError = true;
             }
             if ($this->lstToContact->SelectedValue) {
                 $set[] = sprintf('`to_contact_id`="%s"', $this->lstToContact->SelectedValue);
             } else {
                 $this->lstToContact->Warning = 'Contact name must be chosen';
                 $blnError = true;
             }
             if ($this->lstToAddress->SelectedValue) {
                 $set[] = sprintf('`to_address_id`="%s"', $this->lstToAddress->SelectedValue);
             } else {
                 $this->lstToContact->Warning = 'Address name must be chosen';
                 $blnError = true;
             }
         }
         if ($this->chkFromCompany->Checked) {
             if ($this->lstFromCompany->SelectedValue) {
                 $set[] = sprintf('`from_company_id`="%s"', $this->lstFromCompany->SelectedValue);
             } else {
                 $this->lstFromCompany->Warning = 'Company name must be chosen';
                 $blnError = true;
             }
             if ($this->lstFromContact->SelectedValue) {
                 $set[] = sprintf('`from_contact_id`="%s"', $this->lstFromContact->SelectedValue);
             } else {
                 $this->lstFromContact->Warning = 'Contact name must be chosen';
                 $blnError = true;
             }
             if ($this->lstFromAddress->SelectedValue) {
                 $set[] = sprintf('`from_address_id`="%s"', $this->lstFromAddress->SelectedValue);
             } else {
                 $this->lstFromAddress->Warning = 'Address name must be chosen';
                 $blnError = true;
             }
         }
         if ($this->chkCourier->Checked) {
             $set[] = sprintf('`courier_id`="%s"', $this->lstCourier->SelectedValue);
         }
         if ($this->chkShipDate->Checked && $this->calShipDate->DateTime) {
             $set[] = sprintf('`ship_date`="%s"', $this->calShipDate->DateTime->__toString('YYYY-MM-DD'));
         }
     }
     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);
                 }
             }
         }
     }
     // Apdate main table
     if (!$blnError) {
         try {
             // Edit Transactions
             foreach ($this->arrShipmentToEdit as $intShipmetId) {
                 $objTransaction = Transaction::Load(Shipment::Load($intShipmetId)->Transaction->TransactionId);
                 $objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId;
                 if ($this->chkNote->Checked) {
                     $objTransaction->Note = $this->txtNote->Text;
                 }
                 $objTransaction->Save();
             }
             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->arrShipmentToEdit as $intShipmentId) {
                     $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Shipment, false);
                     $selectedCustomFieldsArray = array();
                     foreach ($objCustomFieldsArray as $objCustomField) {
                         if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
                             $selectedCustomFieldsArray[] = $objCustomField;
                         }
                     }
                     CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intShipmentId, EntityQtype::Shipment);
                 }
             }
             $strQuery = sprintf("UPDATE `shipment`\n                                     SET " . implode(",", $set) . "\n                                     WHERE `shipment_id` IN (%s)", implode(",", $this->arrShipmentToEdit));
             $objDatabase->NonQuery($strQuery);
             $objDatabase->TransactionCommit();
             $this->ParentControl->HideDialogBox();
             QApplication::Redirect('');
         } catch (QMySqliDatabaseException $objExc) {
             $objDatabase->TransactionRollback();
             throw new QDatabaseException();
         }
     } else {
         $objDatabase->TransactionRollback();
         $this->arrCustomFieldsToEdit = array();
         $this->uncheck();
     }
 }
 /**
  * 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 'ShipmentId':
             // Gets the value for intShipmentId (PK)
             // @return integer
             return $this->intShipmentId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Shipment':
             // Gets the value for the Shipment object referenced by intShipmentId (PK)
             // @return Shipment
             try {
                 if (!$this->objShipment && !is_null($this->intShipmentId)) {
                     $this->objShipment = Shipment::Load($this->intShipmentId);
                 }
                 return $this->objShipment;
             } 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;
             }
     }
 }