protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgRole_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colRoleId = new QDataGridColumn(QApplication::Translate('Role Id'), '<?= $_ITEM->RoleId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->RoleId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->RoleId, false))); $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription, false))); $this->colLongDescription = new QDataGridColumn(QApplication::Translate('Long Description'), '<?= QString::Truncate($_ITEM->LongDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgRole_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgRole_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgRole_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->ModifiedDate, false))); // Setup DataGrid $this->dtgRole = new QDataGrid($this); $this->dtgRole->CellSpacing = 0; $this->dtgRole->CellPadding = 4; $this->dtgRole->BorderStyle = QBorderStyle::Solid; $this->dtgRole->BorderWidth = 1; $this->dtgRole->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgRole->Paginator = new QPaginator($this->dtgRole); $this->dtgRole->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgRole->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgRole->SetDataBinder('dtgRole_Bind'); $this->dtgRole->AddColumn($this->colEditLinkColumn); $this->dtgRole->AddColumn($this->colRoleId); $this->dtgRole->AddColumn($this->colShortDescription); $this->dtgRole->AddColumn($this->colLongDescription); $this->dtgRole->AddColumn($this->colCreatedBy); $this->dtgRole->AddColumn($this->colCreationDate); $this->dtgRole->AddColumn($this->colModifiedBy); $this->dtgRole->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->dtgRole_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colRoleId = new QDataGridColumn(QApplication::Translate('Role Id'), '<?= $_ITEM->RoleId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->RoleId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->RoleId, false))); $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription, false))); $this->colLongDescription = new QDataGridColumn(QApplication::Translate('Long Description'), '<?= QString::Truncate($_ITEM->LongDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgRole_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgRole_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgRole_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->ModifiedDate, false))); // Setup DataGrid $this->dtgRole = new QDataGrid($this); $this->dtgRole->CellSpacing = 0; $this->dtgRole->CellPadding = 4; $this->dtgRole->BorderStyle = QBorderStyle::Solid; $this->dtgRole->BorderWidth = 1; $this->dtgRole->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgRole->Paginator = new QPaginator($this->dtgRole); $this->dtgRole->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgRole->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgRole->SetDataBinder('dtgRole_Bind', $this); $this->dtgRole->AddColumn($this->colEditLinkColumn); $this->dtgRole->AddColumn($this->colRoleId); $this->dtgRole->AddColumn($this->colShortDescription); $this->dtgRole->AddColumn($this->colLongDescription); $this->dtgRole->AddColumn($this->colCreatedBy); $this->dtgRole->AddColumn($this->colCreationDate); $this->dtgRole->AddColumn($this->colModifiedBy); $this->dtgRole->AddColumn($this->colModifiedDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Role'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
/** * Count Roles * by ModifiedBy Index(es) * @param integer $intModifiedBy * @return int */ public static function CountByModifiedBy($intModifiedBy, $objOptionalClauses = null) { // Call Role::QueryCount to perform the CountByModifiedBy query return Role::QueryCount(QQ::Equal(QQN::Role()->ModifiedBy, $intModifiedBy), $objOptionalClauses); }
protected function btnSave_Click($strFormId, $strControlId, $strParameter) { $blnError = false; // Do not allow empty/whitespace for role name if (!trim($this->txtShortDescription->Text)) { $blnError = true; $this->txtShortDescription->Warning = QApplication::Translate('You must enter a Role Name.'); } // Role Duplicate checks if ($this->blnEditMode) { $objRoleDuplicate = Role::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::Role()->ShortDescription, trim($this->txtShortDescription->Text)), QQ::NotEqual(QQN::Role()->RoleId, $this->objRole->RoleId))); } else { $objRoleDuplicate = Role::QuerySingle(QQ::Equal(QQN::Role()->ShortDescription, trim($this->txtShortDescription->Text))); } if ($objRoleDuplicate) { $blnError = true; $this->txtShortDescription->Warning = QApplication::Translate('That Role Name is already in use.'); } 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(); // Update the role fields $this->UpdateRoleFields(); // Save the role $this->objRole->Save(); // Update the authorizations for this role // This must be done after saving the Role. If it is new, we need a RoleId first. $this->UpdateAuthorizations(); // Update the Role Field Authorization for this role $this->UpdateFieldLevelAuthorizations(); // Update the Role Transaction Level Authorization for this role $this->UpdateTransactionLevelAuthorizations(); // Commit the transaction to the database $objDatabase->TransactionCommit(); QApplication::Redirect('role_list.php'); } catch (QExtendedOptimisticLockingException $objExc) { // Roll back the transaction from the database $objDatabase->TransactionRollback(); $this->btnCancel->Warning = sprintf('This role has been updated by another user. You must <a href="role_edit.php?intRoleId=%s">Refresh</a> to edit this role.', $this->objRole->RoleId); } } }
/** * Count Roles * by ModifiedBy Index(es) * @param integer $intModifiedBy * @return int */ public static function CountByModifiedBy($intModifiedBy) { // Call Role::QueryCount to perform the CountByModifiedBy query return Role::QueryCount(QQ::Equal(QQN::Role()->ModifiedBy, $intModifiedBy)); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a Role-based QQNode. * It will also verify that it is a proper Role-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 == 'role') { 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 "role".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'RoleId': return QQN::Role()->RoleId; case 'ShortDescription': return QQN::Role()->ShortDescription; case 'LongDescription': return QQN::Role()->LongDescription; case 'CreatedBy': return QQN::Role()->CreatedBy; case 'CreatedByObject': return QQN::Role()->CreatedByObject; case 'CreationDate': return QQN::Role()->CreationDate; case 'ModifiedBy': return QQN::Role()->ModifiedBy; case 'ModifiedByObject': return QQN::Role()->ModifiedByObject; case 'ModifiedDate': return QQN::Role()->ModifiedDate; default: throw new QCallerException('Simple Property not found in RoleDataGrid 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 dtgRole_Create() { $this->dtgRole = new QDataGrid($this); $this->dtgRole->CellPadding = 5; $this->dtgRole->CellSpacing = 0; $this->dtgRole->CssClass = "datagrid"; $this->dtgRole->SortColumnIndex = 0; // Enable AJAX - this won't work while using the DB profiler $this->dtgRole->UseAjax = true; // Enable Pagination, and set to 20 items per page $objPaginator = new QPaginator($this->dtgRole); $this->dtgRole->Paginator = $objPaginator; $this->dtgRole->ItemsPerPage = 20; $this->dtgRole->AddColumn(new QDataGridColumn('Role', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->ShortDescription, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false))); $this->dtgRole->AddColumn(new QDataGridColumn('Description', '<?= $_ITEM->LongDescription ?>', array('Width' => "200", 'OrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->LongDescription, false), 'CssClass' => "dtg_column"))); $this->dtgRole->AddColumn(new QDataGridColumn('Created By', '<?= $_ITEM->CreatedByObject->__toStringFullName() ?>', array('OrderByClause' => QQ::OrderBy(QQN::Role()->CreatedByObject->LastName, false, QQN::Role()->CreatedByObject->FirstName, false), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Role()->CreatedByObject->LastName, QQN::Role()->CreatedByObject->FirstName), 'CssClass' => "dtg_column"))); $this->dtgRole->SortColumnIndex = 0; $this->dtgRole->SortDirection = 0; $objStyle = $this->dtgRole->RowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#FFFFFF'; $objStyle->FontSize = 12; $objStyle = $this->dtgRole->AlternateRowStyle; $objStyle->BackColor = '#EFEFEF'; $objStyle = $this->dtgRole->HeaderRowStyle; $objStyle->ForeColor = '#000000'; $objStyle->BackColor = '#EFEFEF'; $objStyle->CssClass = 'dtg_header'; }