/** * Load a single AssetTransactionCheckout object, * by AssetId * @param integer $intAssetId * @return object $objAssetTransactionCheckout */ public function LoadAssetTransactionCheckoutByAssetId($intAssetId = null) { // Loads objAssetTransaction $objClauses = array(); $objOrderByClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false); $objLimitClause = QQ::LimitInfo(1, 0); array_push($objClauses, $objOrderByClause); array_push($objClauses, $objLimitClause); $AssetTransactionArray = AssetTransaction::LoadArrayByAssetId($this->AssetId, $objClauses); $intLastAssetTransactionId = $AssetTransactionArray[0]->AssetTransactionId; $objAssetTransactionCheckout = AssetTransactionCheckout::LoadByAssetTransactionId($intAssetLastTransactionId); return $objAssetTransactionCheckout; }
protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgAssetTransaction_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colAssetTransactionId = new QDataGridColumn(QApplication::Translate('Asset Transaction Id'), '<?= $_ITEM->AssetTransactionId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->AssetTransactionId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->AssetTransactionId, false))); $this->colAssetId = new QDataGridColumn(QApplication::Translate('Asset Id'), '<?= $_FORM->dtgAssetTransaction_Asset_Render($_ITEM); ?>'); $this->colTransactionId = new QDataGridColumn(QApplication::Translate('Transaction Id'), '<?= $_FORM->dtgAssetTransaction_Transaction_Render($_ITEM); ?>'); $this->colParentAssetTransactionId = new QDataGridColumn(QApplication::Translate('Parent Asset Transaction Id'), '<?= $_FORM->dtgAssetTransaction_ParentAssetTransaction_Render($_ITEM); ?>'); $this->colSourceLocationId = new QDataGridColumn(QApplication::Translate('Source Location Id'), '<?= $_FORM->dtgAssetTransaction_SourceLocation_Render($_ITEM); ?>'); $this->colDestinationLocationId = new QDataGridColumn(QApplication::Translate('Destination Location Id'), '<?= $_FORM->dtgAssetTransaction_DestinationLocation_Render($_ITEM); ?>'); $this->colNewAssetFlag = new QDataGridColumn(QApplication::Translate('New Asset Flag'), '<?= ($_ITEM->NewAssetFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->NewAssetFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->NewAssetFlag, false))); $this->colNewAssetId = new QDataGridColumn(QApplication::Translate('New Asset Id'), '<?= $_FORM->dtgAssetTransaction_NewAsset_Render($_ITEM); ?>'); $this->colScheduleReceiptFlag = new QDataGridColumn(QApplication::Translate('Schedule Receipt Flag'), '<?= ($_ITEM->ScheduleReceiptFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptFlag, false))); $this->colScheduleReceiptDueDate = new QDataGridColumn(QApplication::Translate('Schedule Receipt Due Date'), '<?= $_FORM->dtgAssetTransaction_ScheduleReceiptDueDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptDueDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptDueDate, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgAssetTransaction_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgAssetTransaction_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgAssetTransaction_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ModifiedDate, false))); // Setup DataGrid $this->dtgAssetTransaction = new QDataGrid($this); $this->dtgAssetTransaction->CellSpacing = 0; $this->dtgAssetTransaction->CellPadding = 4; $this->dtgAssetTransaction->BorderStyle = QBorderStyle::Solid; $this->dtgAssetTransaction->BorderWidth = 1; $this->dtgAssetTransaction->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgAssetTransaction->Paginator = new QPaginator($this->dtgAssetTransaction); $this->dtgAssetTransaction->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgAssetTransaction->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgAssetTransaction->SetDataBinder('dtgAssetTransaction_Bind'); $this->dtgAssetTransaction->AddColumn($this->colEditLinkColumn); $this->dtgAssetTransaction->AddColumn($this->colAssetTransactionId); $this->dtgAssetTransaction->AddColumn($this->colAssetId); $this->dtgAssetTransaction->AddColumn($this->colTransactionId); $this->dtgAssetTransaction->AddColumn($this->colParentAssetTransactionId); $this->dtgAssetTransaction->AddColumn($this->colSourceLocationId); $this->dtgAssetTransaction->AddColumn($this->colDestinationLocationId); $this->dtgAssetTransaction->AddColumn($this->colNewAssetFlag); $this->dtgAssetTransaction->AddColumn($this->colNewAssetId); $this->dtgAssetTransaction->AddColumn($this->colScheduleReceiptFlag); $this->dtgAssetTransaction->AddColumn($this->colScheduleReceiptDueDate); $this->dtgAssetTransaction->AddColumn($this->colCreatedBy); $this->dtgAssetTransaction->AddColumn($this->colCreationDate); $this->dtgAssetTransaction->AddColumn($this->colModifiedBy); $this->dtgAssetTransaction->AddColumn($this->colModifiedDate); }
public function btnAddAsset_Click($strFormId, $strControlId, $strParameter) { if ($this->rblAssetType->SelectedValue == 'new') { $blnError = false; // Do not allow creation of an asset if asset limit will be exceeded $intAssetLimit = is_numeric(QApplication::$TracmorSettings->AssetLimit) ? QApplication::$TracmorSettings->AssetLimit : false; if ($intAssetLimit && Asset::CountActive() >= $intAssetLimit) { $blnError = true; $this->txtNewAssetCode->Warning = "Your asset limit has been reached."; } // Assign an empty string to the asset code for now (NULL won't work to render properly in the datagrid if ($this->chkAutoGenerateAssetCode->Checked == true) { $strAssetCode = ''; } else { $strAssetCode = $this->txtNewAssetCode->Text; if (!$strAssetCode) { $blnError = true; $this->txtNewAssetCode->Warning = 'You must enter an asset tag.'; } } // Generate an error if that asset code already exists if ($objDuplicate = Asset::LoadByAssetCode($strAssetCode)) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset tag already exists. Choose another.'; } elseif (!$this->lstAssetModel->SelectedValue) { $blnError = true; $this->txtNewAssetCode->Warning = 'You must select one model.'; } if (!$blnError) { $objNewAsset = new Asset(); $objNewAsset->AssetModelId = $this->lstAssetModel->SelectedValue; $objNewAsset->LocationId = 5; // To Be Received $objNewAsset->AssetCode = $strAssetCode; // Set the AssetId to 0. This is so that it can be assigned to an AssetTransaction object without being saved to the db // We don't want to save this until btnSave_Click, because we don't want to create new assets that could get orphaned $objNewAsset->AssetId = 0; // This can be combined with the code below it $this->txtNewAssetCode->Text = null; $this->txtNewAssetCode->Enabled = true; $this->chkAutoGenerateAssetCode->Checked = false; $this->lstAssetModel->SelectedValue = null; $objNewAssetTransaction = new AssetTransaction(); // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objNewAsset->LocationId; // $objNewAssetTransaction->AssetId = $objNewAsset->AssetId; $objNewAssetTransaction->Asset = $objNewAsset; $this->objAssetTransactionArray[] = $objNewAssetTransaction; // Set this boolean to true so that the datagrid updates $this->blnModifyAssets = true; } } elseif ($this->rblAssetType->SelectedValue == 'existing') { $strAssetCode = $this->txtNewAssetCode->Text; $blnDuplicate = false; $blnError = false; if ($strAssetCode) { // Begin error checking if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction && $objAssetTransaction->Asset->AssetCode == $strAssetCode) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset has already been added."; } } } if (!$blnError) { $objNewAsset = Asset::LoadByAssetCode($this->txtNewAssetCode->Text); if (!$objNewAsset instanceof Asset) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset tag does not exist."; } elseif ($objNewAsset->LinkedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is locked to a parent asset."; } elseif ($objNewAsset->ArchivedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is archived."; } elseif ($objNewAsset->CheckedOutFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is checked out."; } elseif ($objNewAsset->ReservedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is reserved."; } elseif (!($objNewAsset->LocationId == 5 || $objNewAsset->LocationId == 2)) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset has already been received."; } elseif (!QApplication::AuthorizeEntityBoolean($objNewAsset, 2)) { $blnError = true; $this->txtNewAssetCode->Warning = "You do not have authorization to perform a transaction on this asset."; } elseif ($objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objNewAsset->AssetId)) { $strAssetCodeArray = array(); $objCheckedLinkedAssetArray = array(); foreach ($objLinkedAssetArray as $objLinkedAsset) { if (!QApplication::AuthorizeEntityBoolean($objLinkedAsset, 2)) { $blnError = true; $this->txtNewAssetCode->Warning = sprintf("You do not have authorization to perform a transaction on locked asset %s.", $objLinkedAsset->AssetCode); break; } else { $objCheckedLinkedAssetArray[] = $objLinkedAsset; $strAssetCodeArray[] = $objLinkedAsset->AssetCode; } if (!$blnError) { $this->txtNewAssetCode->Warning = sprintf("The following asset(s) have been added to the transaction because they are locked to asset (%s):<br />%s", $objNewAsset->AssetCode, implode('<br />', $strAssetCodeArray)); } } if (!$blnError) { foreach ($objCheckedLinkedAssetArray as $objCheckedLinkedAsset) { $objNewAssetTransaction = new AssetTransaction(); // We can assign the AssetId for existing assets because they have already been saved to the db $objNewAssetTransaction->AssetId = $objCheckedLinkedAsset->AssetId; // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objCheckedLinkedAsset->LocationId; $this->objAssetTransactionArray[] = $objNewAssetTransaction; } } } if (!$blnError) { // Check that the asset isn't already in another pending receipt $arrPendingReceipts = AssetTransaction::QueryArray(QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $objNewAsset->AssetId), QQ::In(QQN::AssetTransaction()->SourceLocationId, array(5, 2)), QQ::IsNull(QQN::AssetTransaction()->DestinationLocationId), QQ::NotEqual(QQN::AssetTransaction()->TransactionId, $this->objReceipt->TransactionId))); if (!$blnError && count($arrPendingReceipts) != 0) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset is already pending receipt.'; } elseif (!$blnError && ($objPendingShipment = AssetTransaction::PendingShipment($objNewAsset->AssetId))) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset is in a pending shipment.'; } } // Create a new, but incomplete AssetTransaction if (!$blnError) { $this->txtNewAssetCode->Text = null; $this->txtNewAssetCode->Enabled = true; $this->chkAutoGenerateAssetCode->Checked = false; $this->lstAssetModel->SelectedValue = null; $objNewAssetTransaction = new AssetTransaction(); // We can assign the AssetId for existing assets because they have already been saved to the db $objNewAssetTransaction->AssetId = $objNewAsset->AssetId; // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objNewAsset->LocationId; $this->objAssetTransactionArray[] = $objNewAssetTransaction; // Set this boolean to true so that the datagrid updates $this->blnModifyAssets = true; } } } } $this->dtgAssetTransact->Refresh(); $this->txtNewAssetCode->Focus(); }
protected function dtrAssetHistory_Bind() { // Get Total Count for Pagination $this->dtrAssetHistory->TotalItemCount = AssetTransaction::CountAssetTransaction($this->ctlAssetEdit->objAsset->AssetId); $objClauses = array(); $objClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false); array_push($objClauses, $objClause); $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->ctlAssetEdit->objAsset->AssetId), QQ::OrCondition(QQ::In(QQN::AssetTransaction()->Transaction->TransactionTypeId, array(1, 2, 3, 6, 7, 8, 9, 10, 11)))); $intItemsPerPage = $this->dtrAssetHistory->ItemsPerPage; $intItemOffset = ($this->dtrAssetHistory->PageNumber - 1) * $intItemsPerPage; $arrDataSource = array_slice(AssetTransaction::QueryArray($objCondition, $objClauses), $intItemOffset, $intItemsPerPage); $this->dtrAssetHistory->DataSource = $arrDataSource; }
/** * Returns a Location object from the most recent shipment transaction for this asset * * @return Object Location */ public function GetLastShippedFromLocation() { $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->AssetId), QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6)); $objClauses = array(); $objExpansionClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation); $objOrderByClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false); $objLimitClause = QQ::LimitInfo(1, 0); array_push($objClauses, $objExpansionClause); array_push($objClauses, $objOrderByClause); array_push($objClauses, $objLimitClause); $AssetTransactionArray = AssetTransaction::QueryArray($objCondition, $objClauses); if (count($AssetTransactionArray) > 0) { $Location = $AssetTransactionArray[0]->SourceLocation; } else { $Location = null; } return $Location; }
protected function dtgAssetTransaction_Create() { $this->dtgAssetTransaction = new QDataGrid($this); $this->dtgAssetTransaction->Name = 'Transactions'; $this->dtgAssetTransaction->CellPadding = 5; $this->dtgAssetTransaction->CellSpacing = 0; $this->dtgAssetTransaction->CssClass = "datagrid"; // Enable AJAX - this won't work while using the DB profiler $this->dtgAssetTransaction->UseAjax = true; // Enable Pagination, and set to 20 items per page $objPaginator = new QPaginator($this->dtgAssetTransaction); $this->dtgAssetTransaction->Paginator = $objPaginator; $this->dtgAssetTransaction->ItemsPerPage = 20; $this->dtgAssetTransaction->AddColumn(new QDataGridColumn('Transaction Type', '<?= $_ITEM->Transaction->__toStringWithLink() ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Transaction->TransactionType->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Transaction->TransactionType->ShortDescription, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false))); $this->dtgAssetTransaction->AddColumn(new QDataGridColumn('From', '<?= $_ITEM->__toStringSourceLocation() ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->SourceLocation->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->SourceLocation->ShortDescription, false), 'CssClass' => "dtg_column"))); $this->dtgAssetTransaction->AddColumn(new QDataGridColumn('To', '<?= $_ITEM->__toStringDestinationLocation() ?>', array('OrderByClause' => QQ::Orderby(QQN::AssetTransaction()->DestinationLocation->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->DestinationLocation->ShortDescription, false), 'CssClass' => "dtg_column"))); $this->dtgAssetTransaction->AddColumn(new QDataGridColumn('User', '<?= $_ITEM->Transaction->CreatedByObject->__toStringFullName() ?>', array('OrderByClause' => QQ::Orderby(QQN::AssetTransaction()->CreatedByObject->LastName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->CreatedByObject->LastName, false), 'CssClass' => "dtg_column"))); $this->dtgAssetTransaction->AddColumn(new QDataGridColumn('Date', '<?= $_ITEM->Transaction->CreationDate->PHPDate("Y-m-d H:i:s"); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false), 'CssClass' => "dtg_column"))); $this->dtgAssetTransaction->SortColumnIndex = 4; $this->dtgAssetTransaction->SortDirection = 1; $objStyle = $this->dtgAssetTransaction->RowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#FFFFFF'; $objStyle->FontSize = 12; $objStyle = $this->dtgAssetTransaction->AlternateRowStyle; $objStyle->BackColor = '#EFEFEF'; $objStyle = $this->dtgAssetTransaction->HeaderRowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#EFEFEF'; $objStyle->CssClass = 'dtg_header'; }
protected function dtgShipmentReceipt_Bind() { // Get Total Count for Pagination $objClauses = array(); $this->ctlAssetEdit->dtgShipmentReceipt->TotalItemCount = AssetTransaction::CountShipmentReceiptByAssetId($this->ctlAssetEdit->objAsset->AssetId); if ($this->ctlAssetEdit->dtgShipmentReceipt->TotalItemCount === 0) { $this->ctlAssetEdit->lblShipmentReceipt->Display = false; $this->ctlAssetEdit->dtgShipmentReceipt->ShowHeader = false; } else { $objClauses = array(); if ($objClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false)) { array_push($objClauses, $objClause); } if ($objClause = $this->ctlAssetEdit->dtgShipmentReceipt->LimitClause) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->Transaction->Shipment)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->Transaction->Receipt)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->DestinationLocation)) { array_push($objClauses, $objClause); } $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->ctlAssetEdit->objAsset->AssetId), QQ::OrCondition(QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6), QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 7))); $this->ctlAssetEdit->dtgShipmentReceipt->DataSource = AssetTransaction::QueryArray($objCondition, $objClauses); } }
protected function btnCompleteShipment_Click($strFormId, $strControlId, $strParameter) { $blnError = false; if ($this->objAssetTransactionArray && $this->objInventoryTransactionArray) { $intEntityQtypeId = EntityQtype::AssetInventory; } elseif ($this->objAssetTransactionArray) { $intEntityQtypeId = EntityQtype::Asset; } elseif ($this->objInventoryTransactionArray) { $intEntityQtypeId = EntityQtype::Inventory; } else { $blnError = true; $this->btnCompleteShipment->Warning = 'There are no assets or inventory in this shipment.'; } if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction->Asset instanceof Asset) { $arrAssetTransactions = AssetTransaction::LoadArrayByAssetId($objAssetTransaction->Asset->AssetId, array(QQ::OrderBy(QQN::AssetTransaction()->CreationDate, false))); if (count($arrAssetTransactions) > 0) { $intLastTransactionId = $arrAssetTransactions[0]->TransactionId; $transaction = Transaction::load($intLastTransactionId); if ($transaction->TransactionTypeId == 6 && $transaction->Shipment->ShippedFlag) { $blnError = true; $this->btnCompleteShipment->Warning = $objAssetTransaction->Asset->__toStringWithLink() . ' already shipped.'; } } } } } if (!$blnError) { try { // Get an instance of the database $objDatabase = QApplication::$Database[1]; // Begin a MySQL Transaction to be either committed or rolled back $objDatabase->TransactionBegin(); if (!$this->blnEditMode) { // this is a new shipment so save the transaction & shipment before completing // Create the new transaction object and save it $this->objTransaction = new Transaction(); $this->objTransaction->EntityQtypeId = $intEntityQtypeId; $this->objTransaction->TransactionTypeId = 6; $this->objTransaction->Note = $this->txtNote->Text; $this->objTransaction->Save(); $this->UpdateShipmentFields(); $this->objShipment->Save(true); if ($this->arrCustomFields) { // Save the values from all of the custom field controls to save the shipment CustomField::SaveControls($this->objShipment->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objShipment->ShipmentId, 10); } } // Create receipt transaction for internal shipment if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId) { $this->receiveInternalShipmentTransaction = new Transaction(); $this->receiveInternalShipmentTransaction->EntityQtypeId = $intEntityQtypeId; $this->receiveInternalShipmentTransaction->TransactionTypeId = 7; $note = sprintf('This receipt was automatically created when creating internal shipment Number %s. ', $this->objShipment->ShipmentNumber); $this->receiveInternalShipmentTransaction->Note = $note . $this->txtNote->Text; $this->receiveInternalShipmentTransaction->Save(); // Create a new receipt $objInternalReceipt = new Receipt(); $objInternalReceipt->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; // The receipt will mimic the shipment information $objInternalReceipt->FromCompanyId = $this->objShipment->FromCompanyId; $objInternalReceipt->FromContactId = $this->objShipment->FromContactId; $objInternalReceipt->ToContactId = $this->objShipment->ToContactId; $objInternalReceipt->ToAddressId = $this->objShipment->ToAddressId; $objInternalReceipt->ReceivedFlag = 0; $objInternalReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber(); $objInternalReceipt->Save(); } if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) { $objTransaction = ''; $objReceipt = ''; $objNewAssetTransactionArray = array(); foreach ($this->objAssetTransactionArray as $objAssetTransaction) { $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode] = $objAssetTransaction; } // Assign a destinationLocation to the AssetTransaction, and change the Location of the asset foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction->Asset instanceof Asset) { // LocationId #2 == Shipped $DestinationLocationId = 2; if ($objAssetTransaction->ScheduleReceiptFlag && $objAssetTransaction->Asset->LinkedFlag) { $objAssetTransaction = $objNewAssetTransactionArray[$objAssetTransaction->Asset->AssetCode]; } $objAssetTransaction->Asset->LocationId = $DestinationLocationId; $objAssetTransaction->Asset->Save(); if (!$this->blnEditMode) { // Assign the TransactionId $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId; } $objAssetTransaction->DestinationLocationId = $DestinationLocationId; // No any actions with linked items (LinkedFlag = 1) which have been scheduled for receipt if ($objAssetTransaction->ScheduleReceiptFlag && !$objAssetTransaction->Asset->LinkedFlag) { if ($objAssetTransaction->NewAsset && $objAssetTransaction->NewAsset instanceof Asset && $objAssetTransaction->NewAsset->AssetId == null) { // We have to create the new asset before we can $objReceiptAsset = new Asset(); $objReceiptAsset->AssetModelId = $objAssetTransaction->NewAsset->AssetModelId; $objReceiptAsset->LocationId = $objAssetTransaction->NewAsset->LocationId; if ($objAssetTransaction->NewAsset->AssetCode == '') { $objReceiptAsset->AssetCode = Asset::GenerateAssetCode(); } else { $objReceiptAsset->AssetCode = $objAssetTransaction->NewAsset->AssetCode; } $objReceiptAsset->Save(); // Assign any default custom field values CustomField::AssignNewEntityDefaultValues(1, $objReceiptAsset->AssetId); // Associate the new Asset with the AssetTransaction $objAssetTransaction->NewAsset = $objReceiptAsset; } // If it doesn't exist, create a new transaction object and receipt object if (!$objTransaction instanceof Transaction && !$objReceipt instanceof Receipt) { $objTransaction = new Transaction(); // Transaction is asset only $objTransaction->EntityQtypeId = 1; // Transaction is a receipt $objTransaction->TransactionTypeId = 7; // Set a note showing how this receipt was created if (!$objAssetTransaction->NewAssetId) { $strTransactionType = 'return'; } else { $strTransactionType = 'exchange'; } $objTransaction->Note = sprintf('This %s receipt was automatically created when creating Shipment Number %s.', $strTransactionType, $this->objShipment->ShipmentNumber); // Save the transaction $objTransaction->Save(); // Create a new receipt $objReceipt = new Receipt(); $objReceipt->TransactionId = $objTransaction->TransactionId; // The receipt will be coming from the company that was shipped to $objReceipt->FromCompanyId = $this->objShipment->ToCompanyId; $objReceipt->FromContactId = $this->objShipment->ToContactId; $objReceipt->ToContactId = $this->objShipment->FromContactId; $objReceipt->ToAddressId = $this->objShipment->FromAddressId; $objReceipt->ReceivedFlag = 0; $objReceipt->ReceiptNumber = Receipt::LoadNewReceiptNumber(); if ($objAssetTransaction->ScheduleReceiptDueDate) { $objReceipt->DueDate = $objAssetTransaction->ScheduleReceiptDueDate; } $objReceipt->Save(); } $objReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objReceiptAssetTransaction->AssetId = $objAssetTransaction->AssetId; } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; $objReceiptAssetTransaction->NewAssetFlag = true; $objAssetTransaction->NewAssetFlag = true; $objAssetTransaction->Save(); } $objReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; // This is not right. NewAssetFlag should be set only if a new asset was created when creating this AssetTransaction // It should not be true on the new AssetTransaction, but only on the AssetTransaction that caused the new asset to be created. // $objReceiptAssetTransaction->NewAssetFlag = true; $objReceiptAssetTransaction->Save(); // Load all child assets if ($objLinkedAssetCodeArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId)) { foreach ($objLinkedAssetCodeArray as $objLinkedAssetCode) { $objLinkedAssetTransaction = $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode]; $objLinkedReceiptAssetTransaction = new AssetTransaction(); // If this is a return if (!$objAssetTransaction->NewAssetId) { $objLinkedReceiptAssetTransaction->AssetId = $objLinkedAssetTransaction->AssetId; $objLinkedReceiptAssetTransaction->TransactionId = $objTransaction->TransactionId; $objLinkedReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->DestinationLocationId; $objLinkedReceiptAssetTransaction->Save(); } else { // Both the shipmentAssetTranscation (objAssetTransaction and the objReceiptAssetTransaction were involved in creating a new asset // Asset Transactions where NewAssetFlag = true but AssetId is NULL are receipt asset transactions for exchanges. $objLinkedReceiptAssetTransaction->AssetId = $objAssetTransaction->NewAssetId; } $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode] = $objLinkedAssetTransaction; } } } $objAssetTransaction->Save(); if ($objAssetTransaction->ScheduleReceiptFlag) { // Set the Receipt Asset Transaction as child of the Shipment Asset Transaction $objAssetTransaction->AssociateChildAssetTransaction($objReceiptAssetTransaction); } if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId && !$objAssetTransaction->Asset->LinkedFlag) { $objReceiptAssetTransaction = new AssetTransaction(); $objReceiptAssetTransaction->AssetId = $objAssetTransaction->AssetId; $objReceiptAssetTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->SourceLocationId; $objReceiptAssetTransaction->Save(); // Load all child assets if ($objLinkedAssetCodeArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId)) { foreach ($objLinkedAssetCodeArray as $objLinkedAssetCode) { $objLinkedAssetTransaction = $objNewAssetTransactionArray[$objLinkedAssetCode->AssetCode]; $objLinkedReceiptAssetTransaction = new AssetTransaction(); // add data to linked asset $objLinkedReceiptAssetTransaction->AssetId = $objLinkedAssetTransaction->AssetId; $objLinkedReceiptAssetTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objLinkedReceiptAssetTransaction->SourceLocationId = $objAssetTransaction->SourceLocationId; $objLinkedReceiptAssetTransaction->Save(); } } } $objReceipt = null; $objTransaction = null; } } } if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) { // Assign different source and destinations depending on transaction type foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { // LocationId #2 == Shipped $DestinationLocationId = 2; if (!$this->blnEditMode) { $objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId; } // Remove the inventory quantity from the source $objInventoryTransaction->InventoryLocation->Quantity = $objInventoryTransaction->InventoryLocation->Quantity - $objInventoryTransaction->Quantity; $objInventoryTransaction->InventoryLocation->Save(); // Finish the InventoryTransaction and save it $objInventoryTransaction->DestinationLocationId = $DestinationLocationId; $objInventoryTransaction->Save(); // Add Inventory to receipt if this is an internal shipment if ($this->objShipment->ToCompanyId == $this->objShipment->FromCompanyId) { $objReceiptInventoryLocation = InventoryLocation::LoadByLocationIdInventoryModelId(5, $objInventoryTransaction->InventoryLocation->InventoryModelId); if (!$objReceiptInventoryLocation) { // First create the inventory location if it doesn't exist $objReceiptInventoryLocation = new InventoryLocation(); $objReceiptInventoryLocation->InventoryModelId = $objInventoryTransaction->InventoryLocation->InventoryModelId; $objReceiptInventoryLocation->LocationId = 5; $objReceiptInventoryLocation->Quantity = 0; } // Set the To Be Received quantity $objReceiptInventoryLocation->Quantity += $objInventoryTransaction->Quantity; $objReceiptInventoryLocation->Save(); // Create the inventory transaction $objReceiptInventoryTransaction = new InventoryTransaction(); $objReceiptInventoryTransaction->TransactionId = $this->receiveInternalShipmentTransaction->TransactionId; $objReceiptInventoryTransaction->InventoryLocationId = $objReceiptInventoryLocation->InventoryLocationId; $objReceiptInventoryTransaction->Quantity = $objInventoryTransaction->Quantity; $objReceiptInventoryTransaction->SourceLocationId = 5; $objReceiptInventoryTransaction->Save(); } } } if ($this->blnEditMode) { $this->UpdateShipmentFields(); } $this->objShipment->ShippedFlag = true; // $this->objShipment->Save(false, true); $this->objShipment->Save(); $objDatabase->TransactionCommit(); QApplication::Redirect(sprintf('../shipping/shipment_edit.php?intShipmentId=%s', $this->objShipment->ShipmentId)); } catch (QExtendedOptimisticLockingException $objExc) { $objDatabase->TransactionRollback(); if ($objExc->Class == 'Shipment') { $this->btnCancelShipment->Warning = sprintf('This shipment has been modified by another user. You must <a href="shipment_edit.php?intShipmentId=%s">Refresh</a> to complete this shipment.', $this->objShipment->ShipmentId); } else { throw new QOptimisticLockingException($objExc->Class); } } } }
/** * Count AssetTransactions * by ParentAssetTransactionId Index(es) * @param integer $intParentAssetTransactionId * @return int */ public static function CountByParentAssetTransactionId($intParentAssetTransactionId, $objOptionalClauses = null) { // Call AssetTransaction::QueryCount to perform the CountByParentAssetTransactionId query return AssetTransaction::QueryCount(QQ::Equal(QQN::AssetTransaction()->ParentAssetTransactionId, $intParentAssetTransactionId), $objOptionalClauses); }
/** * Returns the HTML needed for a receipt 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__ . '/receiving/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__ . '/receiving/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; }
/** * Count AssetTransactions * by AssetId Index(es), but only those transactions that are Shipments or Receipts * @param integer $intAssetId * @param boolean $blnInclude - include only shipments and receipts or all other transactions * @return int */ public static function CountShipmentReceiptByAssetId($intAssetId, $blnInclude = true) { // Call AssetTransaction::QueryCount to perform the CountByAssetId query if ($blnInclude) { $arrToReturn = AssetTransaction::QueryCount(QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $intAssetId), QQ::OrCondition(QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6), QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 7)))); } else { $arrToReturn = AssetTransaction::QueryCount(QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $intAssetId), QQ::NotEqual(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6), QQ::NotEqual(QQN::AssetTransaction()->Transaction->TransactionTypeId, 7))); } return $arrToReturn; }
/** * Count AssetTransactions (excluding transactions for linked assets) * by TransactionId Index(es) * @param integer $intTransactionId * @return int */ public static function CountByTransactionIdLinkedFlag($intTransactionId) { // Call AssetTransaction::QueryCount to perform the CountByTransactionId query return AssetTransaction::QueryCount(QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->TransactionId, $intTransactionId), QQ::NotEqual(QQN::AssetTransaction()->Asset->LinkedFlag, true))); }
public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Record Method Callbacks $this->strSetEditPanelMethod = $strSetEditPanelMethod; $this->strCloseEditPanelMethod = $strCloseEditPanelMethod; // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colAssetTransactionId = new QDataGridColumn(QApplication::Translate('Asset Transaction Id'), '<?= $_ITEM->AssetTransactionId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->AssetTransactionId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->AssetTransactionId, false))); $this->colAssetId = new QDataGridColumn(QApplication::Translate('Asset Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_Asset_Render($_ITEM); ?>'); $this->colTransactionId = new QDataGridColumn(QApplication::Translate('Transaction Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_Transaction_Render($_ITEM); ?>'); $this->colParentAssetTransactionId = new QDataGridColumn(QApplication::Translate('Parent Asset Transaction Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_ParentAssetTransaction_Render($_ITEM); ?>'); $this->colSourceLocationId = new QDataGridColumn(QApplication::Translate('Source Location Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_SourceLocation_Render($_ITEM); ?>'); $this->colDestinationLocationId = new QDataGridColumn(QApplication::Translate('Destination Location Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_DestinationLocation_Render($_ITEM); ?>'); $this->colNewAssetFlag = new QDataGridColumn(QApplication::Translate('New Asset Flag'), '<?= ($_ITEM->NewAssetFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->NewAssetFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->NewAssetFlag, false))); $this->colNewAssetId = new QDataGridColumn(QApplication::Translate('New Asset Id'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_NewAsset_Render($_ITEM); ?>'); $this->colScheduleReceiptFlag = new QDataGridColumn(QApplication::Translate('Schedule Receipt Flag'), '<?= ($_ITEM->ScheduleReceiptFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptFlag, false))); $this->colScheduleReceiptDueDate = new QDataGridColumn(QApplication::Translate('Schedule Receipt Due Date'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_ScheduleReceiptDueDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptDueDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ScheduleReceiptDueDate, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgAssetTransaction_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->ModifiedDate, false))); // Setup DataGrid $this->dtgAssetTransaction = new QDataGrid($this); $this->dtgAssetTransaction->CellSpacing = 0; $this->dtgAssetTransaction->CellPadding = 4; $this->dtgAssetTransaction->BorderStyle = QBorderStyle::Solid; $this->dtgAssetTransaction->BorderWidth = 1; $this->dtgAssetTransaction->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgAssetTransaction->Paginator = new QPaginator($this->dtgAssetTransaction); $this->dtgAssetTransaction->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgAssetTransaction->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgAssetTransaction->SetDataBinder('dtgAssetTransaction_Bind', $this); $this->dtgAssetTransaction->AddColumn($this->colEditLinkColumn); $this->dtgAssetTransaction->AddColumn($this->colAssetTransactionId); $this->dtgAssetTransaction->AddColumn($this->colAssetId); $this->dtgAssetTransaction->AddColumn($this->colTransactionId); $this->dtgAssetTransaction->AddColumn($this->colParentAssetTransactionId); $this->dtgAssetTransaction->AddColumn($this->colSourceLocationId); $this->dtgAssetTransaction->AddColumn($this->colDestinationLocationId); $this->dtgAssetTransaction->AddColumn($this->colNewAssetFlag); $this->dtgAssetTransaction->AddColumn($this->colNewAssetId); $this->dtgAssetTransaction->AddColumn($this->colScheduleReceiptFlag); $this->dtgAssetTransaction->AddColumn($this->colScheduleReceiptDueDate); $this->dtgAssetTransaction->AddColumn($this->colCreatedBy); $this->dtgAssetTransaction->AddColumn($this->colCreationDate); $this->dtgAssetTransaction->AddColumn($this->colModifiedBy); $this->dtgAssetTransaction->AddColumn($this->colModifiedDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('AssetTransaction'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
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(); // 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->lblFedexLabelPrinterType_Create(); $this->lblFedexLabelFormatType_Create(); $this->lblFedexThermalPrinterPort_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->lstFedexLabelPrinterType_Create(); $this->lstFedexLabelFormatType_Create(); $this->txtFedexThermalPrinterPort_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_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 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)); } } } }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a AssetTransaction-based QQNode. * It will also verify that it is a proper AssetTransaction-based QQNode, and will throw an exception otherwise. * * @param mixed $mixContent * @return QQNode */ protected function ResolveContentItem($mixContent) { if ($mixContent instanceof QQNode) { if (!$mixContent->_ParentNode) { throw new QCallerException('Content QQNode cannot be a Top Level Node'); } if ($mixContent->_RootTableName == 'asset_transaction') { if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } $objCurrentNode = $mixContent; while ($objCurrentNode = $objCurrentNode->_ParentNode) { if (!$objCurrentNode instanceof QQNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } } return $mixContent; } else { throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "asset_transaction".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'AssetTransactionId': return QQN::AssetTransaction()->AssetTransactionId; case 'AssetId': return QQN::AssetTransaction()->AssetId; case 'Asset': return QQN::AssetTransaction()->Asset; case 'TransactionId': return QQN::AssetTransaction()->TransactionId; case 'Transaction': return QQN::AssetTransaction()->Transaction; case 'ParentAssetTransactionId': return QQN::AssetTransaction()->ParentAssetTransactionId; case 'ParentAssetTransaction': return QQN::AssetTransaction()->ParentAssetTransaction; case 'SourceLocationId': return QQN::AssetTransaction()->SourceLocationId; case 'SourceLocation': return QQN::AssetTransaction()->SourceLocation; case 'DestinationLocationId': return QQN::AssetTransaction()->DestinationLocationId; case 'DestinationLocation': return QQN::AssetTransaction()->DestinationLocation; case 'NewAssetFlag': return QQN::AssetTransaction()->NewAssetFlag; case 'NewAssetId': return QQN::AssetTransaction()->NewAssetId; case 'NewAsset': return QQN::AssetTransaction()->NewAsset; case 'ScheduleReceiptFlag': return QQN::AssetTransaction()->ScheduleReceiptFlag; case 'ScheduleReceiptDueDate': return QQN::AssetTransaction()->ScheduleReceiptDueDate; case 'CreatedBy': return QQN::AssetTransaction()->CreatedBy; case 'CreatedByObject': return QQN::AssetTransaction()->CreatedByObject; case 'CreationDate': return QQN::AssetTransaction()->CreationDate; case 'ModifiedBy': return QQN::AssetTransaction()->ModifiedBy; case 'ModifiedByObject': return QQN::AssetTransaction()->ModifiedByObject; case 'ModifiedDate': return QQN::AssetTransaction()->ModifiedDate; case 'AssetTransactionCheckout': return QQN::AssetTransaction()->AssetTransactionCheckout; default: throw new QCallerException('Simple Property not found in AssetTransactionDataGrid content: ' . $mixContent); } } else { if ($mixContent instanceof QQAssociationNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } else { throw new QCallerException('Invalid Content type'); } } } }
protected function dtgAssetTransact_Create() { $this->dtgAssetTransact = new QDataGrid($this); $this->dtgAssetTransact->CellPadding = 5; $this->dtgAssetTransact->CellSpacing = 0; $this->dtgAssetTransact->CssClass = "datagrid"; // Enable AJAX - this won't work while using the DB profiler $this->dtgAssetTransact->UseAjax = true; // Enable Pagination, and set to 20 items per page $objPaginator = new QPaginator($this->dtgAssetTransact); $this->dtgAssetTransact->Paginator = $objPaginator; $this->dtgAssetTransact->ItemsPerPage = 20; $this->dtgAssetTransact->AddColumn(new QDataGridColumn('Asset Code', '<?= $_ITEM->Asset->__toStringWithLink("bluelink") ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Asset->AssetCode), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Asset->AssetCode, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false))); $this->dtgAssetTransact->AddColumn(new QDataGridColumn('Model', '<?= $_ITEM->Asset->AssetModel->__toStringWithLink("bluelink") ?>', array('Width' => "200", 'OrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Asset->AssetModel->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetTransaction()->Asset->AssetModel->ShortDescription, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false))); $this->dtgAssetTransact->AddColumn(new QDataGridColumn('Status', '<?= $_ITEM->__toStringStatus() ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false))); $objStyle = $this->dtgAssetTransact->RowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#FFFFFF'; $objStyle->FontSize = 12; $objStyle = $this->dtgAssetTransact->AlternateRowStyle; $objStyle->BackColor = '#EFEFEF'; $objStyle = $this->dtgAssetTransact->HeaderRowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#EFEFEF'; $objStyle->CssClass = 'dtg_header'; $this->dtgAssetTransact->ShowHeader = false; }