protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgLocation_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colLocationId = new QDataGridColumn(QApplication::Translate('Location Id'), '<?= $_ITEM->LocationId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->LocationId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->LocationId, false))); $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription, false))); $this->colLongDescription = new QDataGridColumn(QApplication::Translate('Long Description'), '<?= QString::Truncate($_ITEM->LongDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgLocation_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgLocation_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgLocation_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->ModifiedDate, false))); // Setup DataGrid $this->dtgLocation = new QDataGrid($this); $this->dtgLocation->CellSpacing = 0; $this->dtgLocation->CellPadding = 4; $this->dtgLocation->BorderStyle = QBorderStyle::Solid; $this->dtgLocation->BorderWidth = 1; $this->dtgLocation->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgLocation->Paginator = new QPaginator($this->dtgLocation); $this->dtgLocation->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgLocation->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgLocation->SetDataBinder('dtgLocation_Bind'); $this->dtgLocation->AddColumn($this->colEditLinkColumn); $this->dtgLocation->AddColumn($this->colLocationId); $this->dtgLocation->AddColumn($this->colShortDescription); $this->dtgLocation->AddColumn($this->colLongDescription); $this->dtgLocation->AddColumn($this->colCreatedBy); $this->dtgLocation->AddColumn($this->colCreationDate); $this->dtgLocation->AddColumn($this->colModifiedBy); $this->dtgLocation->AddColumn($this->colModifiedDate); }
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->dtgLocation_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colLocationId = new QDataGridColumn(QApplication::Translate('Location Id'), '<?= $_ITEM->LocationId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->LocationId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->LocationId, false))); $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription, false))); $this->colLongDescription = new QDataGridColumn(QApplication::Translate('Long Description'), '<?= QString::Truncate($_ITEM->LongDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgLocation_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgLocation_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgLocation_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->ModifiedDate, false))); // Setup DataGrid $this->dtgLocation = new QDataGrid($this); $this->dtgLocation->CellSpacing = 0; $this->dtgLocation->CellPadding = 4; $this->dtgLocation->BorderStyle = QBorderStyle::Solid; $this->dtgLocation->BorderWidth = 1; $this->dtgLocation->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgLocation->Paginator = new QPaginator($this->dtgLocation); $this->dtgLocation->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgLocation->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgLocation->SetDataBinder('dtgLocation_Bind', $this); $this->dtgLocation->AddColumn($this->colEditLinkColumn); $this->dtgLocation->AddColumn($this->colLocationId); $this->dtgLocation->AddColumn($this->colShortDescription); $this->dtgLocation->AddColumn($this->colLongDescription); $this->dtgLocation->AddColumn($this->colCreatedBy); $this->dtgLocation->AddColumn($this->colCreationDate); $this->dtgLocation->AddColumn($this->colModifiedBy); $this->dtgLocation->AddColumn($this->colModifiedDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Location'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a Location-based QQNode. * It will also verify that it is a proper Location-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 == '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 "location".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'LocationId': return QQN::Location()->LocationId; case 'ShortDescription': return QQN::Location()->ShortDescription; case 'LongDescription': return QQN::Location()->LongDescription; case 'EnabledFlag': return QQN::Location()->EnabledFlag; case 'AssetFlag': return QQN::Location()->AssetFlag; case 'InventoryFlag': return QQN::Location()->InventoryFlag; case 'CreatedBy': return QQN::Location()->CreatedBy; case 'CreatedByObject': return QQN::Location()->CreatedByObject; case 'CreationDate': return QQN::Location()->CreationDate; case 'ModifiedBy': return QQN::Location()->ModifiedBy; case 'ModifiedByObject': return QQN::Location()->ModifiedByObject; case 'ModifiedDate': return QQN::Location()->ModifiedDate; default: throw new QCallerException('Simple Property not found in LocationDataGrid 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'); } } } }
/** * Count Locations * by ModifiedBy Index(es) * @param integer $intModifiedBy * @return int */ public static function CountByModifiedBy($intModifiedBy, $objOptionalClauses = null) { // Call Location::QueryCount to perform the CountByModifiedBy query return Location::QueryCount(QQ::Equal(QQN::Location()->ModifiedBy, $intModifiedBy), $objOptionalClauses); }
protected function btnQuickAdd_Click($strFormId, $strControlId, $strParameter) { $blnError = false; $this->btnQuickAdd->Warning = ''; if (strlen(trim($this->txtQuickAdd->Text)) == 0) { $blnError = true; $this->btnQuickAdd->Warning = 'You must enter a Location name'; } // Check for dupes $objLocationDuplicate = Location::QuerySingle(QQ::Equal(QQN::Location()->ShortDescription, $this->txtQuickAdd->Text)); if ($objLocationDuplicate) { $blnError = true; $this->btnQuickAdd->Warning = 'This Location Name is already in use. Please try another.'; } if (!$blnError) { $objLocation = new Location(); $objLocation->ShortDescription = $this->txtQuickAdd->Text; $objLocation->EnabledFlag = '1'; $objLocation->AssetFlag = '1'; $objLocation->InventoryFlag = '1'; $objLocation->CreatedBy = QApplication::$objUserAccount->UserAccountId; $objLocation->CreationDate = QDateTime::Now(); $objLocation->Save(); $this->dtgLocation->Refresh(); $this->txtQuickAdd->Text = ''; } $this->txtQuickAdd->Focus(); $this->txtQuickAdd->Select(); }
protected function btnPrintLabels_Click() { //if ($this->blnPrintLabels) { $this->strBarCodeArray = array(); $this->strTablesBufferArray = array(); $this->intCurrentBarCodeLabel = 0; // Set start value for PDF generation progress bar $_SESSION["intGeneratingStatus"] = 0; set_time_limit(0); $blnError = false; // Array[0] - DataGrid Object name; array[1] - Id; array[2] - used for Bar Code Label Generation $arrDataGridObjectNameId = $this->ctlSearchMenu->GetDataGridObjectNameId(); $this->intObjectIdArray = $this->ctlSearchMenu->{$arrDataGridObjectNameId}[0]->GetSelected($arrDataGridObjectNameId[1]); $objCheckedArray = array(); if (count($this->intObjectIdArray)) { // Switch statement for all four entity types switch ($this->lstLabelTypeControl->SelectedValue) { case 1: // Load an array of Assets by AssetId $objCheckedArray = Asset::QueryArray(QQ::In(QQN::Asset()->AssetId, $this->intObjectIdArray)); break; case 2: // Load an array of Inventories by InventoryModelId $objCheckedArray = InventoryModel::QueryArray(QQ::In(QQN::InventoryModel()->InventoryModelId, $this->intObjectIdArray)); break; case 3: // Load an array of Locations by LocationId $objCheckedArray = Location::QueryArray(QQ::In(QQN::Location()->LocationId, $this->intObjectIdArray)); break; case 4: $objCheckedArray = UserAccount::QueryArray(QQ::In(QQN::UserAccount()->UserAccountId, $this->intObjectIdArray)); break; default: $this->btnPrintLabels->Warning = "Please select Label Type.<br/>"; $this->intObjectIdArray = array(); $blnError = true; break; } $objArrayById = array(); // Create array of objects where the key is Id foreach ($objCheckedArray as $objChecked) { $objArrayById[$objChecked->{$arrDataGridObjectNameId}[1]] = $objChecked; } // Fill the BarCodeArray in the order items sorted in the datagrid foreach ($this->intObjectIdArray as $intObjectId) { $this->strBarCodeArray[] = $objArrayById[$intObjectId]->{$arrDataGridObjectNameId}[2]; } } else { $blnError = true; } if (!$blnError) { $this->btnPrintLabels->Warning = ""; $this->lstLabelStock->SelectedValue = 0; $this->lstLabelOffset->RemoveAllItems(); $this->lstLabelOffset->AddItem(new QListItem('None', 0, 1)); $this->lstLabelStock->Enabled = true; $this->lstLabelOffset->Enabled = true; $this->dlgPrintLabels->ShowDialogBox(); } else { // If we have no checked items $this->btnPrintLabels->Warning .= "You must check at least one item."; } // Enable Print Labels button $this->btnPrintLabels->Enabled = true; //$this->blnPrintLabels = false; /*} else { $this->btnPrintLabels->Warning = "Please wait... loading."; $this->blnPrintLabels = true; QApplication::ExecuteJavaScript("document.getElementById('".$this->btnPrintLabels->ControlId."').click(); document.getElementById('warning_loading').innerHTML = '';"); }*/ QApplication::ExecuteJavaScript("document.getElementById('warning_loading').innerHTML = '';"); }
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); } } }
/** * Count Locations * by ModifiedBy Index(es) * @param integer $intModifiedBy * @return int */ public static function CountByModifiedBy($intModifiedBy) { // Call Location::QueryCount to perform the CountByModifiedBy query return Location::QueryCount(QQ::Equal(QQN::Location()->ModifiedBy, $intModifiedBy)); }
public function dtgLocation_Bind() { $objClauses = array(); if ($objClause = $this->dtgLocation->OrderByClause) { array_push($objClauses, $objClause); } $objClause = QQ::Expand(QQN::Location()->CreatedByObject); array_push($objClauses, $objClause); $this->strLocation = $this->txtLocation->Text; if ($this->strLocation) { $this->dtgLocation->TotalItemCount = Location::QueryCount(QQ::AndCondition(QQ::Like(QQN::Location()->ShortDescription, '%' . $this->strLocation . '%'), QQ::GreaterThan(QQN::Location()->LocationId, 6)), $objClauses); if ($this->dtgLocation->TotalItemCount > 0) { $this->dtgLocation->ShowHeader = true; // Add the LimitClause information, as well if ($objClause = $this->dtgLocation->LimitClause) { array_push($objClauses, $objClause); } $this->dtgLocation->DataSource = Location::QueryArray(QQ::AndCondition(QQ::Like(QQN::Location()->ShortDescription, '%' . $this->strLocation . '%'), QQ::GreaterThan(QQN::Location()->LocationId, 6)), $objClauses); } else { $this->dtgLocation->ShowHeader = false; } } else { $objExpansionMap[Location::ExpandCreatedByObject] = true; // Get Total Count b/c of Pagination $this->dtgLocation->TotalItemCount = Location::QueryCount(QQ::GreaterThan(QQN::Location()->LocationId, 6), $objClauses); if ($this->dtgLocation->TotalItemCount == 0) { $this->dtgLocation->ShowHeader = false; } else { if ($objClause = $this->dtgLocation->LimitClause) { array_push($objClauses, $objClause); } $this->dtgLocation->DataSource = Location::QueryArray(QQ::GreaterThan(QQN::Location()->LocationId, 6), $objClauses); $this->dtgLocation->ShowHeader = true; } } $this->blnSearch = false; }