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->dtgInventoryLocation_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colInventoryLocationId = new QDataGridColumn(QApplication::Translate('Inventory Location Id'), '<?= $_ITEM->InventoryLocationId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->InventoryLocationId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->InventoryLocationId, false))); $this->colInventoryModelId = new QDataGridColumn(QApplication::Translate('Inventory Model Id'), '<?= $_CONTROL->ParentControl->dtgInventoryLocation_InventoryModel_Render($_ITEM); ?>'); $this->colLocationId = new QDataGridColumn(QApplication::Translate('Location Id'), '<?= $_CONTROL->ParentControl->dtgInventoryLocation_Location_Render($_ITEM); ?>'); $this->colQuantity = new QDataGridColumn(QApplication::Translate('Quantity'), '<?= $_ITEM->Quantity; ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->Quantity), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->Quantity, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgInventoryLocation_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgInventoryLocation_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgInventoryLocation_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->ModifiedDate, false))); // Setup DataGrid $this->dtgInventoryLocation = new QDataGrid($this); $this->dtgInventoryLocation->CellSpacing = 0; $this->dtgInventoryLocation->CellPadding = 4; $this->dtgInventoryLocation->BorderStyle = QBorderStyle::Solid; $this->dtgInventoryLocation->BorderWidth = 1; $this->dtgInventoryLocation->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgInventoryLocation->Paginator = new QPaginator($this->dtgInventoryLocation); $this->dtgInventoryLocation->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgInventoryLocation->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgInventoryLocation->SetDataBinder('dtgInventoryLocation_Bind', $this); $this->dtgInventoryLocation->AddColumn($this->colEditLinkColumn); $this->dtgInventoryLocation->AddColumn($this->colInventoryLocationId); $this->dtgInventoryLocation->AddColumn($this->colInventoryModelId); $this->dtgInventoryLocation->AddColumn($this->colLocationId); $this->dtgInventoryLocation->AddColumn($this->colQuantity); $this->dtgInventoryLocation->AddColumn($this->colCreatedBy); $this->dtgInventoryLocation->AddColumn($this->colCreationDate); $this->dtgInventoryLocation->AddColumn($this->colModifiedBy); $this->dtgInventoryLocation->AddColumn($this->colModifiedDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('InventoryLocation'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgInventoryLocation_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colInventoryLocationId = new QDataGridColumn(QApplication::Translate('Inventory Location Id'), '<?= $_ITEM->InventoryLocationId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->InventoryLocationId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->InventoryLocationId, false))); $this->colInventoryModelId = new QDataGridColumn(QApplication::Translate('Inventory Model Id'), '<?= $_FORM->dtgInventoryLocation_InventoryModel_Render($_ITEM); ?>'); $this->colLocationId = new QDataGridColumn(QApplication::Translate('Location Id'), '<?= $_FORM->dtgInventoryLocation_Location_Render($_ITEM); ?>'); $this->colQuantity = new QDataGridColumn(QApplication::Translate('Quantity'), '<?= $_ITEM->Quantity; ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->Quantity), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->Quantity, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgInventoryLocation_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgInventoryLocation_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgInventoryLocation_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::InventoryLocation()->ModifiedDate, false))); // Setup DataGrid $this->dtgInventoryLocation = new QDataGrid($this); $this->dtgInventoryLocation->CellSpacing = 0; $this->dtgInventoryLocation->CellPadding = 4; $this->dtgInventoryLocation->BorderStyle = QBorderStyle::Solid; $this->dtgInventoryLocation->BorderWidth = 1; $this->dtgInventoryLocation->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgInventoryLocation->Paginator = new QPaginator($this->dtgInventoryLocation); $this->dtgInventoryLocation->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgInventoryLocation->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgInventoryLocation->SetDataBinder('dtgInventoryLocation_Bind'); $this->dtgInventoryLocation->AddColumn($this->colEditLinkColumn); $this->dtgInventoryLocation->AddColumn($this->colInventoryLocationId); $this->dtgInventoryLocation->AddColumn($this->colInventoryModelId); $this->dtgInventoryLocation->AddColumn($this->colLocationId); $this->dtgInventoryLocation->AddColumn($this->colQuantity); $this->dtgInventoryLocation->AddColumn($this->colCreatedBy); $this->dtgInventoryLocation->AddColumn($this->colCreationDate); $this->dtgInventoryLocation->AddColumn($this->colModifiedBy); $this->dtgInventoryLocation->AddColumn($this->colModifiedDate); }
/** * Count InventoryLocations * by CreatedBy Index(es) * @param integer $intCreatedBy * @return int */ public static function CountByCreatedBy($intCreatedBy, $objOptionalClauses = null) { // Call InventoryLocation::QueryCount to perform the CountByCreatedBy query return InventoryLocation::QueryCount(QQ::Equal(QQN::InventoryLocation()->CreatedBy, $intCreatedBy), $objOptionalClauses); }
protected function GetOrderByClause() { $objOrderByClause = QQ::Clause(QQ::OrderBy(QQN::InventoryLocation()->Location->ShortDescription, QQN::InventoryLocation()->InventoryModel->ShortDescription)); return $objOrderByClause; }
protected function btnSave_Click($strFormId, $strControlId, $strParameter) { $blnError = false; // Do not allow duplicate Location names if ($this->blnEditMode) { $objLocationDuplicate = Location::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::Location()->ShortDescription, $this->txtShortDescription->Text), QQ::NotEqual(QQN::Location()->LocationId, $this->objLocation->LocationId))); } else { $objLocationDuplicate = Location::QuerySingle(QQ::Equal(QQN::Location()->ShortDescription, $this->txtShortDescription->Text)); } if ($objLocationDuplicate) { $blnError = true; $this->txtShortDescription->Warning = 'This Location Name is already in use. Please try another.'; $this->txtShortDescription->Focus(); } // Check if there is any inventory at this location $objInventoryLocation = InventoryLocation::QuerySingle(QQ::Equal(QQN::InventoryLocation()->LocationId, $this->objLocation->LocationId), QQ::Clause(QQ::Sum(QQN::InventoryLocation()->Quantity, 'QuantityTotal'))); $intInventoryAtLocation = $objInventoryLocation->GetVirtualAttribute('QuantityTotal'); // Don't allow disabling of locations with assets or inventory quantities if ($this->blnEditMode && $this->objLocation->EnabledFlag && !$this->chkEnabled->Checked && (Asset::CountByLocationId($this->objLocation->LocationId) > 0 || $intInventoryAtLocation > 0)) { $blnError = true; $this->chkEnabled->Warning = 'Location must be empty before disabling.'; $this->chkEnabled->Focus(); } if (!$blnError) { try { $this->UpdateLocationFields(); $this->objLocation->Save(); $this->RedirectToListPage(); } catch (QExtendedOptimisticLockingException $objExc) { $this->btnCancel->Warning = sprintf('This location has been updated by another user. You must <a href="location_edit.php?intLocationId=%s">Refresh</a> to edit this location.', $this->objLocation->LocationId); } } }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a InventoryLocation-based QQNode. * It will also verify that it is a proper InventoryLocation-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 == 'inventory_location') { 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 "inventory_location".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'InventoryLocationId': return QQN::InventoryLocation()->InventoryLocationId; case 'InventoryModelId': return QQN::InventoryLocation()->InventoryModelId; case 'InventoryModel': return QQN::InventoryLocation()->InventoryModel; case 'LocationId': return QQN::InventoryLocation()->LocationId; case 'Location': return QQN::InventoryLocation()->Location; case 'Quantity': return QQN::InventoryLocation()->Quantity; case 'CreatedBy': return QQN::InventoryLocation()->CreatedBy; case 'CreatedByObject': return QQN::InventoryLocation()->CreatedByObject; case 'CreationDate': return QQN::InventoryLocation()->CreationDate; case 'ModifiedBy': return QQN::InventoryLocation()->ModifiedBy; case 'ModifiedByObject': return QQN::InventoryLocation()->ModifiedByObject; case 'ModifiedDate': return QQN::InventoryLocation()->ModifiedDate; default: throw new QCallerException('Simple Property not found in InventoryLocationDataGrid 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'); } } } }