/** * Deletes all associated InventoryTransactions * @return void */ public function DeleteAllInventoryTransactions() { if (is_null($this->intTransactionId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateInventoryTransaction on this unsaved Transaction.'); } // Get the Database Object for this Class $objDatabase = Transaction::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (InventoryTransaction::LoadArrayByTransactionId($this->intTransactionId) as $objInventoryTransaction) { $objInventoryTransaction->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `inventory_transaction` WHERE `transaction_id` = ' . $objDatabase->SqlVariable($this->intTransactionId) . ' '); }
protected function btnCancel_Click($strFormId, $strControlId, $strParameter) { if ($this->blnEditMode) { $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId); $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId); $this->DisplayLabels(); $this->UpdateReceiptControls(); } else { QApplication::Redirect('receipt_list.php'); } }
/** * Load an Reciept Object * The method should check for assets or inventory in reciept that is still 'To Be Received' (TBR) * * @param int $intReceiptId * @return Receipt */ public function ReceiptComplete($intReceiptId) { $objClauses = null; $blnAllAssetsReceived = true; $blnAllInventoryReceived = true; $objReceipt = Receipt::Load($intReceiptId); if ($objReceipt) { if (!$objReceipt->ReceivedFlag) { $objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($objReceipt->TransactionId, $objClauses); $objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($objReceipt->TransactionId, $objClauses); foreach ($objAssetTransactionArray as &$objAssetTransaction) { if (!$objAssetTransaction->DestinationLocationId) { $blnAllAssetsReceived = false; } } if ($blnAllAssetsReceived) { if ($objInventoryTransactionArray) { foreach ($objInventoryTransactionArray as $objInventoryTransaction) { if (!$objInventoryTransaction->DestinationLocationId) { $blnAllInventoryReceived = false; } } } // Set the entire receipt as received if assets and inventory have all been received if ($blnAllInventoryReceived) { $objReceipt->ReceivedFlag = true; $objReceipt->ReceiptDate = new QDateTime(QDateTime::Now); $objReceipt->Save(); } } } return $objReceipt; } else { return false; } }
public function receiptDelete(Receipt $receipt) { $objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($receipt->TransactionId); $objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($receipt->TransactionId); // Take out the inventory from the TBR InventoryLocation if ($objInventoryTransactionArray) { foreach ($objInventoryTransactionArray as $objInventoryTransaction) { $objInventoryTransaction->InventoryLocation->Quantity -= $objInventoryTransaction->Quantity; $objInventoryTransaction->InventoryLocation->Save(); } } // Delete any assets that were created while scheduling this receipt if ($objAssetTransactionArray) { foreach ($objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction->NewAssetFlag) { $objAssetTransaction->Asset->Delete(); } } } // Load the Transaction $objTransaction = Transaction::Load($receipt->TransactionId); // Delete the Transaction Object and let it MySQL CASCADE down to asset_transaction, inventory_transaction, and receipt $objTransaction->Delete(); }
/** * Gets all associated InventoryTransactions as an array of InventoryTransaction objects * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return InventoryTransaction[] */ public function GetInventoryTransactionArray($objOptionalClauses = null) { if (is_null($this->intTransactionId)) { return array(); } try { return InventoryTransaction::LoadArrayByTransactionId($this->intTransactionId, $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * Returns a bool that determines whether or not this transaction has any AssetTransactions or InventoryTransactions associated with it * * @return bool */ public function IsEmpty() { $objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->TransactionId); if (empty($objAssetTransactionArray)) { $objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->TransactionId); if (empty($objInventoryTransactionArray)) { return true; } else { return false; } } else { return false; } }
/** * Returns the HTML needed for a shipment datagrid to show asset and inventory icons, with hovertips. * * @param QDatagrid Object $objControl * @return string */ public function __toStringHoverTips($objControl) { // Create the Asset Image label, with corresponding assets hovertip if ($this->Transaction->EntityQtypeId == EntityQtype::AssetInventory || $this->Transaction->EntityQtypeId == EntityQtype::Asset) { $lblAssetImage = new QLabelExt($objControl); $lblAssetImage->HtmlEntities = false; $lblAssetImage->Text = sprintf('<img src="%s/icons/asset_datagrid.png" style="vertical-align:middle;">', __IMAGE_ASSETS__); // create $objHoverTip = new QHoverTip($lblAssetImage); $objHoverTip->Template = __DOCROOT__ . __SUBDIRECTORY__ . '/shipping/hovertip_assets.tpl.php'; $lblAssetImage->HoverTip = $objHoverTip; // Load the AssetTransaction Array on the form so that it can be used by the hovertip panel $objClauses = array(); if ($objClause = QQ::LimitInfo(11, 0)) { 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); $objControl->Form->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->TransactionId, $objClauses); $objClauses = null; } // Create the Inventory Image label with corresponding inventory hovertip if ($this->Transaction->EntityQtypeId == EntityQtype::AssetInventory || $this->Transaction->EntityQtypeId == EntityQtype::Inventory) { $lblInventoryImage = new QLabelExt($objControl); $lblInventoryImage->HtmlEntities = false; $lblInventoryImage->Text = sprintf('<img src="%s/icons/inventory_datagrid.png" style="vertical-align:middle;"', __IMAGE_ASSETS__); // Create the inventory hovertip $objHoverTip = new QHoverTip($lblInventoryImage); $objHoverTip->Template = __DOCROOT__ . __SUBDIRECTORY__ . '/shipping/hovertip_inventory.tpl.php'; $lblInventoryImage->HoverTip = $objHoverTip; // Load the InventoryTransaction Array on the form so that it can be used by the hovertip panel $objClauses = array(); if ($objClause = QQ::LimitInfo(11, 0)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) { } array_push($objClauses, $objClause); $objControl->Form->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->TransactionId, $objClauses); $objClauses = null; } // Display the appropriate images if ($this->Transaction->EntityQtypeId == EntityQtype::AssetInventory) { $strToReturn = $lblAssetImage->Render(false) . ' ' . $lblInventoryImage->Render(false); } elseif ($this->Transaction->EntityQtypeId == EntityQtype::Asset) { $strToReturn = $lblAssetImage->Render(false); } elseif ($this->Transaction->EntityQtypeId == EntityQtype::Inventory) { $strToReturn = $lblInventoryImage->Render(false); } return $strToReturn; }