public function __toStringWithLink() { // Shipment if ($this->TransactionTypeId == 6) { $objShipment = Shipment::LoadByTransactionId($this->TransactionId); if ($objShipment) { $strToReturn = sprintf('<a href="../shipping/shipment_edit.php?intShipmentId=%s">Ship</a>', $objShipment->ShipmentId); } else { $strToReturn = ''; } } elseif ($this->TransactionTypeId == 7) { $objReceipt = Receipt::LoadByTransactionId($this->TransactionId); if ($objReceipt) { $strToReturn = sprintf('<a href="../receiving/receipt_edit.php?intReceiptId=%s">Receipt</a>', $objReceipt->ReceiptId); } else { $strToReturn = ''; } } else { $strToReturn = sprintf('<a href="../common/transaction_edit.php?intTransactionId=%s">%s</a>', $this->TransactionId, $this->TransactionType->__toString()); } return $strToReturn; }
/** * 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 'TransactionId': // Gets the value for intTransactionId (Read-Only PK) // @return integer return $this->intTransactionId; case 'EntityQtypeId': // Gets the value for intEntityQtypeId (Not Null) // @return integer return $this->intEntityQtypeId; case 'TransactionTypeId': // Gets the value for intTransactionTypeId (Not Null) // @return integer return $this->intTransactionTypeId; case 'Note': // Gets the value for strNote // @return string return $this->strNote; 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 'TransactionType': // Gets the value for the TransactionType object referenced by intTransactionTypeId (Not Null) // @return TransactionType try { if (!$this->objTransactionType && !is_null($this->intTransactionTypeId)) { $this->objTransactionType = TransactionType::Load($this->intTransactionTypeId); } return $this->objTransactionType; } 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; } case 'Receipt': // Gets the value for the Receipt object that uniquely references this Transaction // by objReceipt (Unique) // @return Receipt try { if ($this->objReceipt === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objReceipt) { $this->objReceipt = Receipt::LoadByTransactionId($this->intTransactionId); } return $this->objReceipt; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Shipment': // Gets the value for the Shipment object that uniquely references this Transaction // by objShipment (Unique) // @return Shipment try { if ($this->objShipment === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objShipment) { $this->objShipment = Shipment::LoadByTransactionId($this->intTransactionId); } 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 '_AssetTransaction': // Gets the value for the private _objAssetTransaction (Read-Only) // if set due to an expansion on the asset_transaction.transaction_id reverse relationship // @return AssetTransaction return $this->_objAssetTransaction; case '_AssetTransactionArray': // Gets the value for the private _objAssetTransactionArray (Read-Only) // if set due to an ExpandAsArray on the asset_transaction.transaction_id reverse relationship // @return AssetTransaction[] return (array) $this->_objAssetTransactionArray; case '_InventoryTransaction': // Gets the value for the private _objInventoryTransaction (Read-Only) // if set due to an expansion on the inventory_transaction.transaction_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.transaction_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; } } }
public function __toStringVerbWithLink() { if ($this->TransactionTypeId == 6) { $objShipment = Shipment::LoadByTransactionId($this->TransactionId); if ($objShipment) { if ($objShipment->ShippedFlag) { $verb = 'shipped'; } else { $verb = 'scheduled shipment'; } $strToReturn = sprintf('<a href="../shipping/shipment_edit.php?intShipmentId=%s">%s</a>', $objShipment->ShipmentId, $verb); } else { $strToReturn = ''; } } elseif ($this->TransactionTypeId == 7) { $objReceipt = Receipt::LoadByTransactionId($this->TransactionId); if ($objReceipt) { if ($objReceipt->ReceivedFlag) { $verb = 'received'; } else { $verb = 'scheduled receipt'; } $strToReturn = sprintf('<a href="../receiving/receipt_edit.php?intReceiptId=%s">%s</a>', $objReceipt->ReceiptId, $verb); } else { $strToReturn = ''; } } else { $verb = strtolower($this->TransactionType->__toString()); if (str_word_count($verb) > 1) { $verb = explode(" ", $verb); $verb = $verb[0] . 'ed ' . $verb[1]; } else { $verb = $verb . 'd'; } $strToReturn = sprintf('<a href="../common/transaction_edit.php?intTransactionId=%s">%s</a>', $this->TransactionId, $verb); } return $strToReturn; return ''; }
public function __toStringData() { switch ($this->Transaction->TransactionTypeId) { case 1: return sprintf('from %s to %s', $this->__toStringSourceLocation(), $this->__toStringDestinationLocation()); break; case 2: if ($this->Transaction->ModifiedByObject instanceof UserAccount) { $user = $this->Transaction->ModifiedByObject->__toStringFullName(); } else { $user = $this->Transaction->CreatedByObject->__toStringFullName(); } return sprintf('from %s to %s', $user, $this->__toStringDestinationLocation()); break; case 3: if ($this->AssetTransactionCheckout) { if ($this->AssetTransactionCheckout->ToContactId) { $strToReturn = $this->AssetTransactionCheckout->ToContact->__toStringWithLink(); } else { $strToReturn = $this->AssetTransactionCheckout->ToUser->__toStringFullName(); } } else { $strToReturn = $this->Transaction->CreatedByObject->__toStringFullName(); } return sprintf('from %s to %s', $this->__toStringSourceLocation(), $strToReturn); break; case 6: $this->Transaction->Shipment = Shipment::LoadByTransactionId($this->TransactionId); return sprintf('from %s to %s', $this->__toStringSourceLocation(), $this->Transaction->ToStringCompanyWithLink()); break; case 7: $this->Transaction->Receipt = Receipt::LoadByTransactionId($this->TransactionId); if ($this->Transaction->Receipt->ReceivedFlag) { return sprintf('from %s to %s', $this->Transaction->ToStringCompanyWithLink(), $this->__toStringDestinationLocation()); } else { return sprintf('from %s', $this->Transaction->ToStringCompanyWithLink()); } break; default: return ''; break; } }
public function btnAddInventory_Click($strFormId, $strControlId, $strParameter) { $blnError = false; // Assign the values from the user submitted form input $intNewInventoryLocationId = $this->lstSourceLocation->SelectedValue; $intTransactionQuantity = $this->txtQuantity->Text; if ($intNewInventoryLocationId) { // Begin error checking if ($this->objInventoryTransactionArray) { foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { if ($objInventoryTransaction && $objInventoryTransaction->InventoryLocation->InventoryLocationId == $intNewInventoryLocationId) { $blnError = true; $this->txtNewInventoryModelCode->Warning = "That Inventory has already been added."; } } } if (!$blnError) { $objNewInventoryLocation = InventoryLocation::LoadLocations($intNewInventoryLocationId); // This should not be possible because the list is populated with existing InventoryLocations if (!$objNewInventoryLocation instanceof InventoryLocation) { $this->txtNewInventoryModelCode->Warning = "That Inventory location does not exist."; $blnError = true; } elseif (!$intTransactionQuantity || !ctype_digit($intTransactionQuantity) || $intTransactionQuantity <= 0) { $this->txtQuantity->Warning = "That is not a valid quantity."; $blnError = true; } elseif ($objNewInventoryLocation->Quantity < $intTransactionQuantity) { $this->txtQuantity->Warning = "Quantity shipped cannot exceed quantity available."; $blnError = true; } elseif (!QApplication::AuthorizeEntityBoolean($objNewInventoryLocation->InventoryModel, 2)) { $blnError = true; $this->txtQuantity->Warning = "You do not have authorization to perform a transaction on this inventory model."; } else { $objExpansionMap[InventoryTransaction::ExpandTransaction] = true; $objInventoryTransactionArray = InventoryTransaction::LoadArrayByInventoryLocationId($objNewInventoryLocation->InventoryLocationId, null, null, $objExpansionMap); if ($objInventoryTransactionArray) { $intQuantityScheduled = 0; foreach ($objInventoryTransactionArray as $objInventoryTransaction) { // If there is a pending shipment if ($objInventoryTransaction->Transaction->TransactionTypeId == 6) { /* QCodo Beta3 is not generating a LoadArrayByTransactionId method anymore. Instead, it generates LoadByTransactionId. That is actually better, so we will use that from now on. $objShipmentArray = Shipment::LoadArrayByTransactionId($objInventoryTransaction->TransactionId); if ($objShipmentArray) { foreach ($objShipmentArray as $objShipment) { if (!$objShipment->ShippedFlag) { $intQuantityScheduled += $objInventoryTransaction->Quantity; } } }*/ $objShipment = Shipment::LoadByTransactionId($objInventoryTransaction->TransactionId); if ($objShipment && !$objShipment->ShippedFlag) { $intQuantityScheduled += $objInventoryTransaction->Quantity; } } } if ($intTransactionQuantity > $objNewInventoryLocation->Quantity - $intQuantityScheduled) { $blnError = true; $this->txtNewInventoryModelCode->Warning = sprintf("That inventory has %s units already scheduled for shipment. Not enough available inventory.", $intQuantityScheduled); } } } $this->dtgInventoryTransact->Refresh(); } } else { $this->txtNewInventoryModelCode->Warning = "Please select a source location."; $blnError = true; } if (!$blnError && $objNewInventoryLocation instanceof InventoryLocation) { $objInventoryTransaction = new InventoryTransaction(); $objInventoryTransaction->InventoryLocationId = $objNewInventoryLocation->InventoryLocationId; // $objInventoryTransaction->InventoryLocation = $objNewInventoryLocation; $objInventoryTransaction->Quantity = $intTransactionQuantity; $objInventoryTransaction->SourceLocationId = $objNewInventoryLocation->LocationId; $this->objInventoryTransactionArray[] = $objInventoryTransaction; $this->txtNewInventoryModelCode->Text = null; $this->lstSourceLocation->SelectedIndex = 0; $this->txtQuantity->Text = null; $this->lstSourceLocation->Enabled = false; $this->txtQuantity->Enabled = false; $this->blnModifyInventory = true; } }