/** * Returns the HTML needed for the asset list datagrid to show reserved and checked out by icons, with hovertips with the username. * If the asset is neither reserved nor checked out, it returns an empty string. * * @param QDatagrid Object $objControl * @return string */ public function ToStringHoverTips($objControl) { if ($this->blnReservedFlag) { $lblReservedImage = new QLabelExt($objControl); $lblReservedImage->HtmlEntities = false; $lblReservedImage->Text = sprintf('<img src="%s/icons/reserved_datagrid.png" style="vertical-align:middle;">', __IMAGE_ASSETS__); $objHoverTip = new QHoverTip($lblReservedImage); $objHoverTip->Text = 'Reserved by ' . $this->GetLastTransactionUser()->__toString(); $lblReservedImage->HoverTip = $objHoverTip; $strToReturn = $lblReservedImage->Render(false); } elseif ($this->blnCheckedOutFlag) { $lblCheckedOutImage = new QLabelExt($objControl); $lblCheckedOutImage->HtmlEntities = false; $lblCheckedOutImage->Text = sprintf('<img src="%s/icons/checked_out_datagrid.png" style="vertical-align:middle;">', __IMAGE_ASSETS__); $objHoverTip = new QHoverTip($lblCheckedOutImage); //$objHoverTip->Text = 'Checked Out by ' . $this->GetLastTransactionUser()->__toString(); $arrObjects = $this->GetLastTransactionCheckoutObjectArray(); $objAccount = $arrObjects['objAccount']; $objAssetTransactionCheckout = $arrObjects['objAssetTransactionCheckout']; $strReason = $arrObjects['strNote']; if (!$objAssetTransactionCheckout) { $objHoverTip->Text = 'Checked Out by ' . $objAccount->__toString(); } else { $objHoverTip->Text = 'Checked Out to '; if ($objAssetTransactionCheckout->ToContactId) { $objHoverTip->Text .= $objAssetTransactionCheckout->ToContact->__toString(); } else { $objHoverTip->Text .= $objAssetTransactionCheckout->ToUser->__toString(); } $objHoverTip->Text .= ' by ' . $objAccount->__toString(); if (QApplication::$TracmorSettings->ReasonRequired == "1" || $strReason) { $objHoverTip->Text .= "<br />Reason: " . $strReason; } if (QApplication::$TracmorSettings->DueDateRequired == "1" || $objAssetTransactionCheckout->DueDate) { $objHoverTip->Text .= sprintf("<br />Due Date: %s", $objAssetTransactionCheckout->DueDate ? $objAssetTransactionCheckout->DueDate->format('m/d/Y g:i A') : ""); } } $lblCheckedOutImage->HoverTip = $objHoverTip; $strToReturn = $lblCheckedOutImage->Render(false); } elseif ($this->blnArchivedFlag) { $lblArchivedImage = new QLabelExt($objControl); $lblArchivedImage->HtmlEntities = false; $lblArchivedImage->Text = sprintf('<img src="%s/icons/archived_datagrid.png" style="vertical-align:middle;">', __IMAGE_ASSETS__); $objHoverTip = new QHoverTip($lblArchivedImage); $objHoverTip->Text = 'Archived by ' . $this->GetLastTransactionUser()->__toString(); $lblArchivedImage->HoverTip = $objHoverTip; $strToReturn = $lblArchivedImage->Render(false); } elseif ($objPendingShipment = AssetTransaction::PendingShipment($this->AssetId)) { $lblShipmentImage = new QLabelExt($objControl); $lblShipmentImage->HtmlEntities = false; $lblShipmentImage->Text = sprintf('<img src="%s/icons/shipment_datagrid.png" style="Vertical-align:middle;">', __IMAGE_ASSETS__); $objHoverTip = new QHoverTip($lblShipmentImage); $objHoverTip->Text = 'Scheduled for Shipment by ' . $this->GetLastTransactionUser()->__toString(); $lblShipmentImage->HoverTip = $objHoverTip; $strToReturn = $lblShipmentImage->Render(false); } elseif ($objPendingReceipt = AssetTransaction::PendingReceipt($this->AssetId)) { $lblReceiptImage = new QLabelExt($objControl); $lblReceiptImage->HtmlEntities = false; $lblReceiptImage->Text = sprintf('<img src="%s/icons/receipt_datagrid.png" style="Vertical-align:middle;">', __IMAGE_ASSETS__); $objHoverTip = new QHoverTip($lblReceiptImage); $objHoverTip->Text = 'Scheduled for Receipt by ' . $this->GetLastTransactionUser()->__toString(); $lblReceiptImage->HoverTip = $objHoverTip; $strToReturn = $lblReceiptImage->Render(false); } else { $strToReturn = ''; } return $strToReturn; }
if (!$blnError) { $arrPendingReceiptId = array_unique($arrPendingReceiptId); foreach ($objAssetArray as $objAsset) { $objDestinationLocation = $arrLocation[$objAsset->AssetId]; $intDestinationLocationId = $objDestinationLocation->LocationId; // Set the DestinationLocation of the AssetTransaction $objAssetTransaction = $objAssetTransactionArray[$objAsset->AssetId]; $objAssetTransaction->DestinationLocationId = $intDestinationLocationId; $objAssetTransaction->Save(); $objAsset->LocationId = $intDestinationLocationId; $objAsset->Save(); if ($objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objAsset->AssetId)) { foreach ($objLinkedAssetArray as $objLinkedAsset) { $objLinkedAsset->LocationId = $intDestinationLocationId; $objLinkedAsset->Save(); if ($objChildPendingReceipt = AssetTransaction::PendingReceipt($objLinkedAsset->AssetId)) { $objChildPendingReceipt->DestinationLocationId = $intDestinationLocationId; $objChildPendingReceipt->Save(); } } } } foreach ($arrPendingReceiptId as $intReceiptId) { Receipt::ReceiptComplete($intReceiptId); } $strWarning .= "Your transaction has successfully completed<br /><a href='index.php'>Main Menu</a> | <a href='asset_menu.php'>Manage Assets</a><br />"; //Remove that flag when transaction is compelete or exists some errors unset($_SESSION['intUserAccountId']); $blnTransactionComplete = true; $arrCheckedAssetCodeLocation = ""; } else {
public function btnAddAsset_Click($strFormId, $strControlId, $strParameter) { if ($this->rblAssetType->SelectedValue == 'new') { $blnError = false; // 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 code.'; } } // Generate an error if that asset code already exists if ($objDuplicate = Asset::LoadByAssetCode($strAssetCode)) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset code already exists. Choose another.'; } 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 code does not exist."; } 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 ($objNewAsset && ($objPendingReceipt = AssetTransaction::PendingReceipt($objNewAsset->AssetId))) { if ($this->blnEditMode && $objPendingReceipt->TransactionId != $this->objReceipt->TransactionId || !$this->blnEditMode) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset is already pending receipt.'; } else { if ($this->arrAssetTransactionToDelete) { foreach ($this->arrAssetTransactionToDelete as $key => $value) { if ($value) { $objOffendingAssetTransaction = AssetTransaction::Load($value); if ($objOffendingAssetTransaction->AssetId == $objNewAsset->AssetId) { $objOffendingAssetTransaction->Delete(); unset($this->arrAssetTransactionToDelete[$key]); } } } } } } elseif ($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; } } } } }
/** * Return a boolean if there is a pending transaction * @param integer $intAssetId * @return bool */ public static function PendingTransaction($intAssetId) { if ($objPendingShipment = AssetTransaction::PendingShipment($intAssetId) || ($objPendingReceipt = AssetTransaction::PendingReceipt($intAssetId))) { return true; } else { return false; } }
$blnError = false; $arrCheckedAssetCodeLocation = array(); $arrLocation = array(); foreach ($arrAssetCodeLocation as $strAssetCodeLocation) { list($strAssetCode, $strLocation) = split('[|]', $strAssetCodeLocation, 2); if ($strAssetCode && $strLocation) { // Begin error checking // Asset Code must match an existing asset in the system $objNewAsset = Asset::LoadByAssetCode($strAssetCode); if (!$objNewAsset instanceof Asset) { $blnError = true; $strWarning .= $strAssetCode . " - That asset code does not exist.<br />"; } elseif (!($objNewAsset->LocationId == 5 || $objNewAsset->LocationId == 2)) { $blnError = true; $strWarning .= $strAssetCode . " - That asset has already been received.<br />"; } elseif (!($objPendingReceipt = AssetTransaction::PendingReceipt($objNewAsset->AssetId))) { $blnError = true; $strWarning .= $strAssetCode . " - That asset must be in a pending receipt.<br />"; } elseif ($objNewAsset->CheckedOutFlag) { $blnError = true; $strWarning .= $strAssetCode . " - That asset is checked out.<br />"; } elseif ($objNewAsset->ReservedFlag) { $blnError = true; $strWarning .= $strAssetCode . " - That asset is reserved.<br />"; } elseif (!($objDestinationLocation = Location::LoadByShortDescription($strLocation))) { $blnError = true; $strWarning .= $strLocation . " - Destination Location does not exist.<br />"; } else { if (!array_key_exists($objNewAsset->AssetId, $arrLocation)) { $arrLocation[$objNewAsset->AssetId] = $objDestinationLocation; $arrCheckedAssetCodeLocation[] = $strAssetCodeLocation;