本文整理汇总了PHP中CustomField::LoadObjCustomFieldArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::LoadObjCustomFieldArray方法的具体用法?PHP CustomField::LoadObjCustomFieldArray怎么用?PHP CustomField::LoadObjCustomFieldArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomField
的用法示例。
在下文中一共展示了CustomField::LoadObjCustomFieldArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($objParentObject, $strControlId = null, $blnShowCheckboxes = false)
{
// First, call the parent to do most of the basic setup
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->objParentObject = $objParentObject;
$this->dtgLocation = new QDataGrid($this);
$this->dtgLocation->Name = 'location_list';
$this->dtgLocation->CellPadding = 5;
$this->dtgLocation->CellSpacing = 0;
$this->dtgLocation->CssClass = "datagrid";
// Disable AJAX for the datagrid
$this->dtgLocation->UseAjax = false;
// Allow for column toggling
$this->dtgLocation->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgLocation->ShowExportCsv = true;
// Enable Pagination, and set to 20 items per page
$objPaginator = new QPaginator($this->dtgLocation);
$this->dtgLocation->Paginator = $objPaginator;
$this->dtgLocation->ItemsPerPage = 20;
// If the user wants the checkboxes column
if ($blnShowCheckboxes) {
// This will render all of the necessary controls and actions. chkSelected_Render expects a unique ID for each row of the database.
$this->dtgLocation->AddColumn(new QDataGridColumnExt('<?=$_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->LocationId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
}
$this->dtgLocation->AddColumn(new QDataGridColumnExt('Location', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->ShortDescription, false)), 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgLocation->AddColumn(new QDataGridColumnExt('Description', '<?= $_ITEM->LongDescription ?>', 'Width=200', array('OrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->LongDescription, false)), 'CssClass="dtg_column"'));
$this->dtgLocation->AddColumn(new QDataGridColumnExt('Created By', '<?= $_ITEM->CreatedByObject->__toStringFullName() ?>', array('OrderByClause' => QQ::OrderBy(QQN::Location()->CreatedByObject->LastName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Location()->CreatedByObject->LastName, false)), 'CssClass="dtg_column"'));
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(2, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgLocation->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
$this->dtgLocation->SortColumnIndex = 1;
$this->dtgLocation->SortDirection = 0;
$objStyle = $this->dtgLocation->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgLocation->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgLocation->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgLocation->SetDataBinder('dtgLocation_Bind', $this);
$this->txtLocation_Create();
$this->btnSearch_Create();
$this->btnClear_Create();
}
示例2: __construct
public function __construct($objParentObject, $intEntityQtypeId = null, $strControlId = null)
{
// First, call the parent to do most of the basic setup
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->objParentObject = $objParentObject;
$this->intEntityQtypeId = $intEntityQtypeId;
$this->chkEntityView = new QCheckBox($this);
$this->chkEntityEdit = new QCheckBox($this);
$this->chkBuiltInView = new QCheckBox($this);
$this->chkBuiltInView->Enabled = false;
$this->chkBuiltInView->Checked = true;
$intRoleId = QApplication::QueryString('intRoleId');
if ($intRoleId) {
$objBuiltInViewAuth = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, $intEntityQtypeId, 1);
}
if (isset($objBuiltInViewAuth)) {
$this->chkBuiltInView->Checked = $objBuiltInViewAuth->AuthorizedFlag;
}
$this->chkBuiltInEdit = new QCheckBox($this);
if ($intRoleId) {
$objBuiltInEditAuth = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, $intEntityQtypeId, 2);
}
if (isset($objBuiltInEditAuth)) {
$this->chkBuiltInEdit->Checked = $objBuiltInEditAuth->AuthorizedFlag;
}
// Load all custom fields and their values into an array arrCustomChecks
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray($intEntityQtypeId, false, null);
foreach ($objCustomFieldArray as $objCustomField) {
$chkCustomView = new QCheckBox($this);
$chkCustomEdit = new QCheckBox($this);
$objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($intEntityQtypeId, $objCustomField->CustomFieldId);
if ($objEntityQtypeCustomField) {
$objCustomAuthView = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 1);
if ($objCustomAuthView) {
$chkCustomView->Checked = $objCustomAuthView->AuthorizedFlag;
}
$objCustomAuthEdit = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 2);
if ($objCustomAuthEdit) {
$chkCustomEdit->Checked = $objCustomAuthEdit->AuthorizedFlag;
}
}
$this->arrCustomChecks[] = array('name' => $objCustomField->ShortDescription . ':', 'view' => $chkCustomView, 'edit' => $chkCustomEdit);
}
}
示例3: dtgContact_Create
protected function dtgContact_Create()
{
$this->dtgContact = new QDataGrid($this);
$this->dtgContact->Name = 'contact_list';
$this->dtgContact->CellPadding = 5;
$this->dtgContact->CellSpacing = 0;
$this->dtgContact->CssClass = "datagrid";
// Disable AJAX for the datagrid
$this->dtgContact->UseAjax = false;
// Allow for column toggling
$this->dtgContact->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgContact->ShowExportCsv = true;
// Enable Pagination, and set to 20 items per page
$objPaginator = new QPaginator($this->dtgContact);
$this->dtgContact->Paginator = $objPaginator;
$this->dtgContact->ItemsPerPage = 20;
$this->dtgContact->AddColumn(new QDataGridColumnExt('<img src=../images/icons/attachment_gray.gif border=0 title=Attachments alt=Attachments>', '<?= Attachment::toStringIcon($_ITEM->GetVirtualAttribute(\'attachment_count\')); ?>', 'SortByCommand="__attachment_count ASC"', 'ReverseSortByCommand="__attachment_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgContact->AddColumn(new QDataGridColumnExt(QApplication::Translate('Name'), '<?= $_ITEM->__toStringWithLink("bluelink") ?>', 'SortByCommand="last_name ASC, first_name DESC"', 'ReverseSortByCommand="last_name DESC, first_name DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgContact->AddColumn(new QDataGridColumnExt(QApplication::Translate('Title'), '<?= $_ITEM->Title ?>', 'Width=200', 'SortByCommand="title ASC"', 'ReverseSortByCommand="title DESC"', 'CssClass="dtg_column"'));
$this->dtgContact->AddColumn(new QDataGridColumnExt(QApplication::Translate('Company'), '<?= $_ITEM->Company->__toStringWithLink("bluelink") ?>', 'SortByCommand="contact__company_id__short_description ASC"', 'ReverseSortByCommand="contact__company_id__short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgContact->AddColumn(new QDataGridColumnExt(QApplication::Translate('Email'), '<?= $_ITEM->Email ?>', 'SortByCommand="email ASC"', 'ReverseSortByCommand="email DESC"', 'CssClass="dtg_column"'));
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(8, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgContact->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
$this->dtgContact->SortColumnIndex = 1;
$this->dtgContact->SortDirection = 0;
$objStyle = $this->dtgContact->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgContact->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgContact->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgContact->SetDataBinder('dtgContact_Bind');
}
示例4: btnSave_Click
public function btnSave_Click($strFormId, $strControlId, $strParameter)
{
$this->EnableSelectedControls();
$this->ClearWarnings();
$blnError = false;
// Make sure at least one checkbox is checked
if (!$this->chkCategory->Checked && !$this->chkManufacturer->Checked && !$this->chkLongDescription->Checked) {
$blnChecked = false;
foreach ($this->arrCheckboxes as $objCheckBox) {
if ($objCheckBox->Checked) {
$blnChecked = true;
break;
}
}
if (!$blnChecked) {
$blnError = true;
$this->btnCancel->Warning = 'You must select at least one field to edit.';
return;
}
}
// Get an instance of the database
$objDatabase = QApplication::$Database[1];
// Begin a MySQL Transaction to be either committed or rolled back
$objDatabase->TransactionBegin();
if (count($this->arrCustomFields) > 0) {
$customFieldIdArray = array();
foreach ($this->arrCustomFields as $field) {
if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) {
if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) {
$blnError = true;
$field['input']->Warning = "Required.";
} else {
$this->arrCustomFieldsToEdit[] = $field;
$customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId);
}
}
}
}
$set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
// Force modified_date timestamp update
$set[] = '`modified_date` = NOW()';
if ($this->chkLongDescription->Checked) {
$set[] = sprintf('`long_description`="%s"', $this->txtLongDescription->Text);
}
if ($this->chkManufacturer->Checked) {
if ($this->lstManufacturer->SelectedValue !== null) {
$set[] = sprintf('`manufacturer_id`=%s', $this->lstManufacturer->SelectedValue);
} else {
$blnError = true;
$this->lstManufacturer->Warning = 'Manufacturer is required.';
}
}
if ($this->chkCategory->Checked) {
if ($this->lstCategory->SelectedValue !== null) {
$set[] = sprintf('`category_id`= %s', $this->lstCategory->SelectedValue);
} else {
$blnError = true;
$this->lstCategory->Warning = 'Category is required.';
}
}
// First check that the user is authorized to edit these models
foreach ($this->arrModelsToEdit as $intModelId) {
$objAssetModel = AssetModel::Load($intModelId);
if (!QApplication::AuthorizeEntityBoolean($objAssetModel, 2)) {
$blnError = true;
$this->btnCancel->Warning = 'You are not authorized to edit one or more of the selected models.';
break;
}
}
if (!$blnError) {
try {
if (count($this->arrCustomFieldsToEdit) > 0) {
// preparing data to edit
// Save the values from all of the custom field controls to save the asset
foreach ($this->arrModelsToEdit as $intModelId) {
$objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::AssetModel, false);
$selectedCustomFieldsArray = array();
foreach ($objCustomFieldsArray as $objCustomField) {
if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
$selectedCustomFieldsArray[] = $objCustomField;
}
}
CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intModelId, EntityQtype::AssetModel);
}
}
$strQuery = sprintf("UPDATE `asset_model`\n\t\t\t\t\t\t\t\t\t SET " . implode(",", $set) . "\n\t\t\t\t\t\t\t\t\t WHERE `asset_model_id` IN (%s)", implode(",", $this->arrModelsToEdit));
// print $strQuery; exit;
$objDatabase->NonQuery($strQuery);
$objDatabase->TransactionCommit();
QApplication::Redirect('');
} catch (QMySqliDatabaseException $objExc) {
$objDatabase->TransactionRollback();
throw new QDatabaseException();
}
} else {
$objDatabase->TransactionRollback();
$this->arrCustomFieldsToEdit = array();
}
}
示例5: btnSave_Click
public function btnSave_Click($strFormId, $strControlId, $strParameter)
{
$this->clearWarnings();
$blnError = false;
// Get an instance of the database
$objDatabase = QApplication::$Database[1];
// Begin a MySQL Transaction to be either committed or rolled back
$objDatabase->TransactionBegin();
$strQuery = sprintf("\n\t\t\tUPDATE `company`\n\t\t\tSET `long_description`='%s'\n\t\t\tWHERE `company_id` IN (%s)\n\t\t\t", $this->txtLongDescription->Text, implode(",", $this->arrCompaniesToEdit));
try {
if (count($this->arrCustomFields) > 0) {
$customFieldIdArray = array();
foreach ($this->arrCustomFields as $field) {
if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) {
if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) {
$blnError = true;
$field['input']->Warning = "Required.";
} else {
$this->arrCustomFieldsToEdit[] = $field;
$customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId);
}
}
}
if (count($this->arrCustomFieldsToEdit) > 0 && !$blnError) {
// preparing data to edit
// Save the values from all of the custom field controls to save the asset
foreach ($this->arrCompaniesToEdit as $intCompanyId) {
$objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Company, false);
$selectedCustomFieldsArray = array();
foreach ($objCustomFieldsArray as $objCustomField) {
if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
$selectedCustomFieldsArray[] = $objCustomField;
}
}
CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intCompanyId, EntityQtype::Company);
}
}
if ($this->chkLongDescription->Checked && !$blnError) {
$objDatabase->NonQuery($strQuery);
}
} else {
$objDatabase->NonQuery($strQuery);
}
$objDatabase->TransactionCommit();
} catch (QMySqliDatabaseException $objExc) {
$objDatabase->TransactionRollback();
throw new QDatabaseException();
}
if (!$blnError) {
$this->ParentControl->RemoveChildControls(true);
$this->CloseSelf(true);
QApplication::Redirect('');
} else {
$objDatabase->TransactionRollback();
$this->arrCustomFieldsToEdit = array();
$this->uncheck();
}
}
示例6: dtgShipment_Create
protected function dtgShipment_Create()
{
$this->dtgShipment = new QDataGrid($this);
$this->dtgShipment->Name = 'shipment_list';
$this->dtgShipment->CellPadding = 5;
$this->dtgShipment->CellSpacing = 0;
$this->dtgShipment->CssClass = "datagrid";
// Allow for column toggling
$this->dtgShipment->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgShipment->ShowExportCsv = true;
// Disable AJAX on the datagrid
$this->dtgShipment->UseAjax = false;
// Enable Pagination
$objPaginator = new QPaginator($this->dtgShipment);
$this->dtgShipment->Paginator = $objPaginator;
$this->dtgShipment->ItemsPerPage = QApplication::$TracmorSettings->SearchResultsPerPage;
$this->dtgShipment->AddColumn(new QDataGridColumnExt('<?= $_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->ShipmentId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('<img src=../images/icons/attachment_gray.gif border=0 title=Attachments alt=Attachments>', '<?= Attachment::toStringIcon($_ITEM->GetVirtualAttribute(\'attachment_count\')); ?>', 'SortByCommand="__attachment_count ASC"', 'ReverseSortByCommand="__attachment_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Shipment Number', '<?= $_ITEM->__toStringWithLink("bluelink") ?> <?= $_ITEM->__toStringHoverTips($_CONTROL) ?>', 'SortByCommand="shipment_number * 1 ASC"', 'ReverseSortByCommand="shipment_number * 1 DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Ship Date', '<?= $_ITEM->ShipDate->__toString(); ?>', 'SortByCommand="ship_date ASC"', 'ReverseSortByCommand="ship_date DESC"', 'CssClass="dtg_column"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Recipient Company', '<?= $_ITEM->ToCompany->__toString() ?>', 'Width=200', 'SortByCommand="shipment__to_company_id__short_description ASC"', 'ReverseSortByCommand="shipment__to_company_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Recipient Contact', '<?= $_ITEM->ToContact->__toString() ?>', 'SortByCommand="shipment__to_contact_id__last_name ASC"', 'ReverseSortByCommand="shipment__to_contact_id__last_name DESC"', 'CssClass="dtg_column"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Recipient Address', '<?= $_ITEM->ToAddress->__toString() ?>', 'SortByCommand="shipment__to_address_id__short_description ASC"', 'ReverseSortByCommand="shipment__to_address_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Sender Company', '<?= $_ITEM->FromCompany->__toString() ?>', 'Width=200', 'SortByCommand="shipment__from_company_id__short_description ASC"', 'ReverseSortByCommand="shipment__from_company_id__short_description DESC"', 'CssClass="dtg_column"', 'Display="false"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Sender Contact', '<?= $_ITEM->FromContact->__toString() ?>', 'SortByCommand="shipment__from_contact_id__last_name ASC"', 'ReverseSortByCommand="shipment__from_contact_id__last_name DESC"', 'CssClass="dtg_column"', 'Display="false"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Sender Address', '<?= $_ITEM->FromAddress->__toString() ?>', 'SortByCommand="shipment__from_address_id__short_description ASC"', 'ReverseSortByCommand="shipment__from_address_id__short_description DESC"', 'CssClass="dtg_column"', 'Display="false"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Scheduled By', '<?= $_ITEM->CreatedByObject->__toString() ?>', 'SortByCommand="shipment__created_by__last_name ASC"', 'ReverseSortByCommand="shipment__created_by__last_name DESC"', 'CssClass="dtg_column"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Status', '<?= $_ITEM->__toStringStatusStyled() ?>', 'SortByCommand="shipped_flag ASC"', 'ReverseSortByCommand="shipped_flag DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Tracking', '<?= $_ITEM->__toStringTrackingNumber() ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Courier', '<?= $_ITEM->__toStringCourier() ?>', 'SortByCommand="shipment__courier_id__short_description ASC"', 'ReverseSortByCommand="shipment__courier_id__short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"', 'Display="false"'));
$this->dtgShipment->AddColumn(new QDataGridColumnExt('Note', '<?= $_ITEM->Transaction->Note ?>', 'SortByCommand="shipment__transaction_id__note ASC"', 'ReverseSortByCommand="shipment__transaction_id__note DESC"', 'CssClass="dtg_column"', 'Width="160"', 'HtmlEntities="false"', 'Display="false"'));
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(10, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgShipment->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
$this->dtgShipment->SortColumnIndex = 2;
$this->dtgShipment->SortDirection = 1;
$objStyle = $this->dtgShipment->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgShipment->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgShipment->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgShipment->SetDataBinder('dtgShipment_Bind');
}
示例7: Form_Create
protected function Form_Create()
{
$this->ctlHeaderMenu_Create();
$this->ctlShortcutMenu_Create();
$this->dtgInventoryModel = new QDataGrid($this);
$this->dtgInventoryModel->Name = 'inventory_model_list';
$this->dtgInventoryModel->CellPadding = 5;
$this->dtgInventoryModel->CellSpacing = 0;
$this->dtgInventoryModel->CssClass = "datagrid";
// Disable AJAX for the datagrid
$this->dtgInventoryModel->UseAjax = false;
// Allow for column toggling
$this->dtgInventoryModel->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgInventoryModel->ShowExportCsv = true;
// Enable Pagination, and set to 20 items per page
$objPaginator = new QPaginator($this->dtgInventoryModel);
$this->dtgInventoryModel->Paginator = $objPaginator;
$this->dtgInventoryModel->ItemsPerPage = 20;
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt('<img src=../images/icons/attachment_gray.gif border=0 title=Attachments alt=Attachments>', '<?= Attachment::toStringIcon($_ITEM->GetVirtualAttribute(\'attachment_count\')); ?>', 'SortByCommand="__attachment_count ASC"', 'ReverseSortByCommand="__attachment_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Inventory Code'), '<?= $_ITEM->__toStringWithLink("bluelink"); ?>', 'SortByCommand="inventory_model_code ASC"', 'ReverseSortByCommand="inventory_model_code DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Model'), '<?= $_ITEM->ShortDescription ?>', 'Width=200', 'SortByCommand="short_description ASC"', 'ReverseSortByCommand="short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Long Description'), '<?= $_ITEM->LongDescription ?>', 'Width=200', 'SortByCommand="long_description ASC"', 'ReverseSortByCommand="long_description DESC"', 'CssClass="dtg_column"'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Category'), '<?= $_ITEM->Category->__toString(); ?>', 'SortByCommand="inventory_model__category_id__short_description ASC"', 'ReverseSortByCommand="inventory_model__category_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Manufacturer'), '<?= $_ITEM->Manufacturer->__toString(); ?>', 'SortByCommand="inventory_model__manufacturer_id__short_description ASC"', 'ReverseSortByCommand="inventory_model__manufacturer_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate('Quantity'), '<?= $_ITEM->__toStringQuantity(); ?>', 'SortByCommand="inventory_model_quantity ASC"', 'ReverseSortByCommand="inventory_model_quantity DESC"', 'CssClass="dtg_column"'));
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(2, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgInventoryModel->AddColumn(new QDataGridColumnExt(QApplication::Translate($objCustomField->ShortDescription), '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
$this->dtgInventoryModel->SortColumnIndex = 2;
$this->dtgInventoryModel->SortDirection = 0;
$objStyle = $this->dtgInventoryModel->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgInventoryModel->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgInventoryModel->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgInventoryModel->SetDataBinder('dtgInventoryModel_Bind');
$this->lstCategory_Create();
$this->lstManufacturer_Create();
$this->lstLocation_Create();
$this->txtShortDescription_Create();
$this->txtInventoryModelCode_Create();
$this->btnSearch_Create();
$this->btnClear_Create();
$this->ctlAdvanced_Create();
$this->lblAdvanced_Create();
}
示例8: customFields_Create
protected function customFields_Create()
{
// Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
$this->objAssetModel->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(4, $this->blnEditMode, $this->objAssetModel->AssetModelId);
// Create the Custom Field Controls - labels and inputs (text or list) for each
$this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objAssetModel->objCustomFieldArray, $this->blnEditMode, $this, false, true, false);
}
示例9: dtgCategory_Create
protected function dtgCategory_Create()
{
$this->dtgCategory = new QDataGrid($this);
$this->dtgCategory->Name = 'category_list';
$this->dtgCategory->CellPadding = 5;
$this->dtgCategory->CellSpacing = 0;
$this->dtgCategory->CssClass = "datagrid";
$this->dtgCategory->SortColumnIndex = 0;
// Enable AJAX - this won't work while using the DB profiler
$this->dtgCategory->UseAjax = true;
// Allow for column toggling
$this->dtgCategory->ShowColumnToggle = true;
// Enable Pagination, and set to 20 items per page
$objPaginator = new QPaginator($this->dtgCategory);
$this->dtgCategory->Paginator = $objPaginator;
$this->dtgCategory->ItemsPerPage = 20;
$this->dtgCategory->ShowExportCsv = true;
$this->dtgCategory->AddColumn(new QDataGridColumnExt('ID', '<?= $_ITEM->CategoryId ?>', array('OrderByClause' => QQ::OrderBy(QQN::Category()->CategoryId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Category()->CategoryId, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
$this->dtgCategory->AddColumn(new QDataGridColumnExt('Category', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', array('OrderByClause' => QQ::OrderBy(QQN::Category()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Category()->ShortDescription, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
$this->dtgCategory->AddColumn(new QDataGridColumnExt('Description', '<?= $_ITEM->LongDescription ?>', array('Width' => "200", 'OrderByClause' => QQ::OrderBy(QQN::Category()->LongDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Category()->LongDescription, false), 'CssClass' => "dtg_column")));
/* $this->dtgCategory->AddColumn(new QDataGridColumnExt('Created By', '<?= $_ITEM->CreatedByObject->__toStringFullName() ?>', array('OrderByClause' => QQ::OrderBy(QQN::Category()->CreatedByObject->LastName, false, QQN::Category()->CreatedByObject->FirstName, false), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Category()->CreatedByObject->LastName, QQN::Category()->CreatedByObject->FirstName), 'CssClass' => "dtg_column")));*/
$this->dtgCategory->AddColumn(new QDataGridColumnExt('Created By', '<?= $_ITEM->CreatedByObject->__toStringFullName() ?>', array('SortByCommand' => 'category__created_by__last_name DESC, category__created_by__first_name DESC', 'ReverseSortByCommand' => 'category__created_by__last_name ASC, category__created_by__first_name ASC', 'CssClass' => "dtg_column")));
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(6, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
$this->dtgCategory->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
$this->dtgCategory->SortColumnIndex = 1;
$this->dtgCategory->SortDirection = 0;
$objStyle = $this->dtgCategory->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgCategory->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgCategory->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgCategory->SetDataBinder('dtgCategory_Bind');
}
示例10: reloadCustomFields
public function reloadCustomFields($intAssetModelId)
{
// Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
$this->objAsset->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(1, $this->blnEditMode, $this->objAsset->AssetId, false, $intAssetModelId);
foreach ($this->arrCustomFields as $objCustomField) {
$objCustomField['input']->Form->RemoveControl($objCustomField['input']->ControlId);
}
// Create the Custom Field Controls - labels and inputs (text or list) for each
$this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objAsset->objCustomFieldArray, $this->blnEditMode, $this, true, true, false);
// Add TabIndex for all txt custom fields
$this->blnEditMode ? $this->intNextTabIndex = 2 : ($this->intNextTabIndex = 3);
foreach ($this->arrCustomFields as $arrCustomField) {
if (array_key_exists('input', $arrCustomField)) {
$arrCustomField['input']->TabIndex = $this->GetNextTabIndex();
$this->txtParentAssetCode->TabIndex = $arrCustomField['input']->TabIndex + 1;
$this->chkLockToParent->TabIndex = $this->txtParentAssetCode->TabIndex + 1;
$arrCustomField['lbl']->Display = false;
}
}
//Setup Custom Fields
$this->UpdateCustomFields();
}
示例11: btnApply_Click
public function btnApply_Click($strFormId, $strControlId, $strParameter)
{
$this->clearWarnings();
$blnError = false;
$objDatabase = QApplication::$Database[1];
// Begin a MySQL Transaction to be either committed or rolled back
$objDatabase->TransactionBegin();
// Check "Contact To", "Contact From", "Coutrier" wasn't changed for shipped items
if (Shipment::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Shipment()->ShippedFlag, 1), QQ::In(QQN::Shipment()->ShipmentId, $this->arrShipmentToEdit))) > 0 && ($this->chkToCompany->Checked || $this->chkFromCompany->Checked || $this->chkCourier->Checked)) {
$this->lblWarning->Text = '"To Company", "From Company", "Courier" shouldn\'t be changed for already
Shipped items';
$blnError = true;
}
if (!$blnError) {
// Apply checked main_table fields
$set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
if ($this->chkToCompany->Checked) {
if ($this->lstToCompany->SelectedValue) {
$set[] = sprintf('`to_company_id`="%s"', $this->lstToCompany->SelectedValue);
} else {
$this->lstToCompany->Warning = 'Company name must be chosen';
$blnError = true;
}
if ($this->lstToContact->SelectedValue) {
$set[] = sprintf('`to_contact_id`="%s"', $this->lstToContact->SelectedValue);
} else {
$this->lstToContact->Warning = 'Contact name must be chosen';
$blnError = true;
}
if ($this->lstToAddress->SelectedValue) {
$set[] = sprintf('`to_address_id`="%s"', $this->lstToAddress->SelectedValue);
} else {
$this->lstToContact->Warning = 'Address name must be chosen';
$blnError = true;
}
}
if ($this->chkFromCompany->Checked) {
if ($this->lstFromCompany->SelectedValue) {
$set[] = sprintf('`from_company_id`="%s"', $this->lstFromCompany->SelectedValue);
} else {
$this->lstFromCompany->Warning = 'Company name must be chosen';
$blnError = true;
}
if ($this->lstFromContact->SelectedValue) {
$set[] = sprintf('`from_contact_id`="%s"', $this->lstFromContact->SelectedValue);
} else {
$this->lstFromContact->Warning = 'Contact name must be chosen';
$blnError = true;
}
if ($this->lstFromAddress->SelectedValue) {
$set[] = sprintf('`from_address_id`="%s"', $this->lstFromAddress->SelectedValue);
} else {
$this->lstFromAddress->Warning = 'Address name must be chosen';
$blnError = true;
}
}
if ($this->chkCourier->Checked) {
$set[] = sprintf('`courier_id`="%s"', $this->lstCourier->SelectedValue);
}
if ($this->chkShipDate->Checked && $this->calShipDate->DateTime) {
$set[] = sprintf('`ship_date`="%s"', $this->calShipDate->DateTime->__toString('YYYY-MM-DD'));
}
}
if (count($this->arrCustomFields) > 0) {
$customFieldIdArray = array();
foreach ($this->arrCustomFields as $field) {
if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) {
if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) {
$blnError = true;
$field['input']->Warning = "Required.";
} else {
$this->arrCustomFieldsToEdit[] = $field;
$customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId);
}
}
}
}
// Apdate main table
if (!$blnError) {
try {
// Edit Transactions
foreach ($this->arrShipmentToEdit as $intShipmetId) {
$objTransaction = Transaction::Load(Shipment::Load($intShipmetId)->Transaction->TransactionId);
$objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId;
if ($this->chkNote->Checked) {
$objTransaction->Note = $this->txtNote->Text;
}
$objTransaction->Save();
}
if (count($this->arrCustomFieldsToEdit) > 0) {
// preparing data to edit
// Save the values from all of the custom field controls to save the asset
foreach ($this->arrShipmentToEdit as $intShipmentId) {
$objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Shipment, false);
$selectedCustomFieldsArray = array();
foreach ($objCustomFieldsArray as $objCustomField) {
if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
$selectedCustomFieldsArray[] = $objCustomField;
}
}
//.........这里部分代码省略.........
示例12: __construct
public function __construct($objParentObject, $strControlId = null, $blnShowCheckboxes = false, $blnUseAjax = false, $blnRemoveAllLinks = false)
{
// First, call the parent to do most of the basic setup
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->objParentObject = $objParentObject;
$this->blnUseAjax = $blnUseAjax;
$this->blnRemoveAllLinks = $blnRemoveAllLinks;
$this->dtgAsset = new QDataGrid($this);
$this->dtgAsset->Name = 'asset_list';
$this->dtgAsset->CellPadding = 5;
$this->dtgAsset->CellSpacing = 0;
$this->dtgAsset->CssClass = "datagrid";
// Enable/Disable AJAX for the datagrid
$this->dtgAsset->UseAjax = $this->blnUseAjax;
$this->dtgAsset->ShowColumnToggle = true;
$this->dtgAsset->ShowExportCsv = true;
/*if (!$blnRemoveAllLinks) {
// Allow for column toggling
$this->dtgAsset->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgAsset->ShowExportCsv = true;
}
else {
// Disallow for column toggling
$this->dtgAsset->ShowColumnToggle = false;
// Disallow for CSV Export
$this->dtgAsset->ShowExportCsv = false;
}*/
// Add a 'Select All' checkbox
$this->dtgAsset->ShowCheckboxes = false;
// Enable Pagination
$objPaginator = new QPaginator($this->dtgAsset);
$this->dtgAsset->Paginator = $objPaginator;
$this->dtgAsset->ItemsPerPage = QApplication::$TracmorSettings->SearchResultsPerPage;
// If the user wants the checkboxes column
if ($blnShowCheckboxes) {
// This will render all of the necessary controls and actions. chkSelected_Render expects a unique ID for each row of the database.
$this->dtgAsset->AddColumn(new QDataGridColumnExt('<?= $_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->AssetId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
}
$this->dtgAsset->AddColumn(new QDataGridColumnExt('ID', '<?= $_ITEM->AssetId ?>', array('OrderByClause' => QQ::OrderBy(QQN::Asset()->AssetId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Asset()->AssetId, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('<img src=../images/icons/attachment_gray.gif border=0 title=Attachments alt=Attachments>', '<?= Attachment::toStringIcon($_ITEM->GetVirtualAttribute(\'attachment_count\')); ?>', 'SortByCommand="__attachment_count ASC"', 'ReverseSortByCommand="__attachment_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
// Removing any links in the column data
if ($this->blnRemoveAllLinks) {
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Asset Tag', '<?= $_ITEM->AssetCode ?> <?= $_ITEM->ToStringHoverTips($_CONTROL) ?>', 'SortByCommand="asset_code ASC"', 'ReverseSortByCommand="asset_code DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Model', '<?= $_ITEM->AssetModel->ShortDescription ?>', 'SortByCommand="asset__asset_model_id__short_description ASC"', 'ReverseSortByCommand="asset__asset_model_id__short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
} else {
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Asset Tag', '<?= $_ITEM->__toStringWithLink("bluelink") ?> <?= $_ITEM->ToStringHoverTips($_CONTROL) ?>', 'SortByCommand="asset_code ASC"', 'ReverseSortByCommand="asset_code DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Model', '<?= $_ITEM->AssetModel->__toStringWithLink("bluelink") ?>', 'SortByCommand="asset__asset_model_id__short_description ASC"', 'ReverseSortByCommand="asset__asset_model_id__short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
}
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Category', '<?= $_ITEM->AssetModel->Category->__toString() ?>', 'SortByCommand="asset__asset_model_id__category_id__short_description ASC"', 'ReverseSortByCommand="asset__asset_model_id__category_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Manufacturer', '<?= $_ITEM->AssetModel->Manufacturer->__toString() ?>', 'SortByCommand="asset__asset_model_id__manufacturer_id__short_description ASC"', 'ReverseSortByCommand="asset__asset_model_id__manufacturer_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Location', '<?= $_ITEM->GetLocation() ?>', 'SortByCommand="asset__location_id__short_description ASC"', 'ReverseSortByCommand="asset__location_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Model Number', '<?= $_ITEM->AssetModel->AssetModelCode ?>', 'SortByCommand="asset__asset_model_id__asset_model_code"', 'ReverseSortByCommand="asset__asset_model_id__asset_model_code DESC"', 'CssClass="dtg_column"', 'Display="false"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Parent Asset Tag', '<?= $_CONTROL->objParentControl->ParentAsset__toString($_ITEM) ?>', 'SortByCommand="asset__parent_asset_id__asset_code ASC"', 'ReverseSortByCommand="asset__parent_asset_id__asset_code DESC"', 'CssClass="dtg_column"', 'Display="false"', 'HtmlEntities="false"'));
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Check In Due', '<?= $_ITEM->CheckoutDueDate() ?>', 'CssClass="dtg_column"', 'Display="false"', 'HtmlEntities="false"'));
// Add Asset Model Depreciation class if Enabled within application
if (QApplication::$TracmorSettings->DepreciationFlag == '1') {
$this->dtgAsset->AddColumn(new QDataGridColumnExt('Depreciation Class', '<?= $_ITEM->AssetModel->DepreciationClass ?>', 'SortByCommand="asset__asset_model_id__depreciation_class_id__short_description ASC"', 'ReverseSortByCommand="asset__asset_model_id__depreciation_class_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->addColumn(new QDataGridColumnExt('Purchase Cost', '<?= $_ITEM->getPurchaseCost() ?>', 'SortByCommand="purchase_cost ASC"', 'ReverseSortByCommand="purchase_cost DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->addColumn(new QDataGridColumnExt('Purchase Date', '<?= $_ITEM->PurchaseDate ?>', 'SortByCommand="purchase_date ASC"', 'ReverseSortByCommand="purchase_date DESC"', 'CssClass="dtg_column"'));
$this->dtgAsset->addColumn(new QDataGridColumnExt('Book Value', '<?= $_ITEM->getBookValue() ?>', 'CssClass="dtg_column"'));
}
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(1, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgAsset->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
// Column to originally sort by (Asset Model)
$this->dtgAsset->SortColumnIndex = $blnShowCheckboxes ? 4 : 3;
$this->dtgAsset->SortDirection = 0;
$objStyle = $this->dtgAsset->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgAsset->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgAsset->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgAsset->SetDataBinder('dtgAsset_Bind', $this);
$this->lstCategory_Create();
$this->lstManufacturer_Create();
$this->lstLocation_Create();
$this->txtShortDescription_Create();
$this->txtAssetCode_Create();
$this->lblAssetModelId_Create();
$this->btnSearch_Create();
//.........这里部分代码省略.........
示例13: btnApply_Click
//.........这里部分代码省略.........
if ($this->txtParentAssetCode->Text != $objAsset->AssetCode) {
$objParentAsset = Asset::LoadByAssetCode($this->txtParentAssetCode->Text);
if (!$objParentAsset) {
$blnError = true;
$this->txtParentAssetCode->Warning = "That asset tag does not exist.";
break;
} else {
if ($this->chkLockToParent->Checked && !($objAsset->ParentAssetId == $objParentAsset->AssetId && $objAsset->LinkedFlag == 1) && $objParentAsset->LocationId != $objAsset->LocationId) {
// If locking child to parent, make sure assets are at the same location
$blnError = true;
$this->chkLockToParent->Warning = 'Cannot lock to parent asset at another location.';
break;
} else {
if ($this->chkLockToParent->Checked && !($objAsset->ParentAssetId == $objParentAsset->AssetId && $objAsset->LinkedFlag == 1) && ($objParentAsset->CheckedOutFlag || $objParentAsset->ReservedFlag || $objParentAsset->ArchivedFlag || $objParentAsset->LocationId == 2 || $objParentAsset->LocationId == 5 || AssetTransaction::PendingTransaction($objParentAsset->AssetId))) {
$blnError = true;
$this->chkLockToParent->Warning = "Parent asset tag (" . $objParentAsset->AssetCode . ") must not be currently Archived, Checked Out, Pending Shipment, Shipped/TBR, or Reserved.";
break;
} else {
if ($this->chkLockToParent->Checked && !($objAsset->ParentAssetId == $objParentAsset->AssetId && $objAsset->LinkedFlag == 1) && ($objAsset->CheckedOutFlag || $objAsset->ReservedFlag || $objAsset->ArchivedFlag || $objAsset->LocationId == 2 || $objAsset->LocationId == 5 || AssetTransaction::PendingTransaction($objAsset->AssetId))) {
$blnError = true;
$this->chkLockToParent->Warning .= "Child asset must not be currently Archived, Checked Out, Pending Shipment, Shipped/TBR, or Reserved.";
break;
} else {
$objAsset->ParentAssetId = $objParentAsset->AssetId;
if ($this->chkLockToParent->Checked) {
$objAsset->LinkedFlag = 1;
} else {
$objAsset->LinkedFlag = 0;
}
}
}
}
}
} else {
$blnError = true;
$this->txtParentAssetCode->Warning = "Asset cannot be assigned as its own parent.";
break;
}
} else {
if ($this->chkChkLockToParent->Checked && $this->chkLockToParent->Checked) {
// Make sure assets have a parent to lock to if lock is checked and no parent being assigned
$objAsset = Asset::Load($intAssetToEditId);
if (!$objAsset->ParentAssetId) {
$blnError = true;
$this->chkLockToParent->Warning = 'Asset cannot be locked without a parent assigned.';
break;
}
}
}
}
// Apply checked main_table fields
if ($this->chkModel->Checked) {
$set[] = sprintf('`asset_model_id`="%s"', $this->lstModel->SelectedValue);
}
if ($this->chkChkLockToParent->Checked) {
$set[] = sprintf('`linked_flag`=%s', $this->chkLockToParent->Checked ? 1 : "NULL");
}
if ($this->chkParentAssetCode->Checked) {
$parent_asset = Asset::LoadByAssetCode($this->txtParentAssetCode->Text);
if ($parent_asset instanceof Asset) {
$parent_asset_id = $parent_asset->AssetId;
} else {
$parent_asset_id = "NULL";
$set[] = sprintf('`linked_flag`=%s', "NULL");
}
$set[] = sprintf('`parent_asset_id`=%s', $parent_asset_id);
}
// Force modified_date timestamp update
$set[] = '`modified_date` = NOW()';
if (!$blnError) {
try {
if (count($this->arrCustomFieldsToEdit) > 0) {
// preparing data to edit
// Save the values from all of the custom field controls to save the asset
foreach ($this->arrAssetToEdit as $intAssetId) {
$objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Asset, false, null, false, 'all');
$selectedCustomFieldsArray = array();
foreach ($objCustomFieldsArray as $objCustomField) {
if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
$selectedCustomFieldsArray[] = $objCustomField;
}
}
CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intAssetId, EntityQtype::Asset);
}
}
// Edit TransAction
// Update main table
$strQuery = sprintf("UPDATE `asset`\n\t\t\t\t\t\t\tSET " . implode(",", $set) . " WHERE `asset_id` IN (%s)", implode(",", $this->arrAssetToEdit));
//print $strQuery; exit;
$objDatabase->NonQuery($strQuery);
$objDatabase->TransactionCommit();
QApplication::Redirect('');
} catch (QMySqliDatabaseException $objExc) {
$objDatabase->TransactionRollback();
throw new QDatabaseException();
}
} else {
$objDatabase->TransactionRollback();
}
}
示例14: GenerateHelperSql
/**
* Generate the SQL for a list page to include custom fields as virtual attributes (add __ before an alias to make a virutal attribute)
* The virtual attributes can then be accessed by $objAsset->GetVirtualAttribute('name_of_attribute') where the name doesn't include the __
* This method was added so that custom fields can be added to the customizable datagrids as hidden columns
*
* @param integer $intEntityQtypeId
* @return array $arrCustomFieldSql - with two elements: strSelect and strFrom which are to be included in a SQL statement
*/
public static function GenerateHelperSql($intEntityQtypeId)
{
$arrCustomFieldSql = array();
$arrCustomFieldSql['strSelect'] = '';
$arrCustomFieldSql['strFrom'] = '';
$objCustomFields = CustomField::LoadObjCustomFieldArray($intEntityQtypeId, false);
// This could be better. This will have to be updated if we want to add custom fields.
// IMPORTANT - LOOK CAREFULLY BELOW - SOME ARE BACKTICKS AND SOME ARE SINGLE QUOTES
switch ($intEntityQtypeId) {
case 1:
$strPrimaryKey = 'asset_id';
$strId = 'asset`.`asset_id';
$strHelperTable = '`asset_custom_field_helper`';
break;
case 2:
$strPrimaryKey = 'inventory_model_id';
$strId = 'inventory_model`.`inventory_model_id';
$strHelperTable = '`inventory_model_custom_field_helper`';
break;
case 4:
$strPrimaryKey = 'asset_model_id';
$strId = 'asset_model`.`asset_model_id';
$strHelperTable = '`asset_model_custom_field_helper`';
break;
case 5:
$strPrimaryKey = 'manufacturer_id';
$strId = 'manufacturer`.`manufacturer_id';
$strHelperTable = '`manufacturer_custom_field_helper`';
break;
case 6:
$strPrimaryKey = 'category_id';
$strId = 'category`.`category_id';
$strHelperTable = '`category_custom_field_helper`';
break;
case 7:
$strPrimaryKey = 'company_id';
$strId = 'company`.`company_id';
$strHelperTable = '`company_custom_field_helper`';
break;
case 8:
$strPrimaryKey = 'contact_id';
$strId = 'contact`.`contact_id';
$strHelperTable = '`contact_custom_field_helper`';
break;
case 9:
$strPrimaryKey = 'address_id';
$strId = 'address`.`address_id';
$strHelperTable = '`address_custom_field_helper`';
break;
case 10:
$strPrimaryKey = 'shipment_id';
$strId = 'shipment`.`shipment_id';
$strHelperTable = '`shipment_custom_field_helper`';
break;
case 11:
$strPrimaryKey = 'receipt_id';
$strId = 'receipt`.`receipt_id';
$strHelperTable = '`receipt_custom_field_helper`';
break;
default:
throw new Exception('Not a valid EntityQtypeId.');
}
if ($objCustomFields) {
foreach ($objCustomFields as $objCustomField) {
$strAlias = $objCustomField->CustomFieldId;
$arrCustomFieldSql['strSelect'] .= sprintf(', %s.`cfv_%s` AS `%s`', $strHelperTable, $strAlias, '__' . $strAlias);
}
$arrCustomFieldSql['strFrom'] .= sprintf('LEFT JOIN %s ON `%s` = %s.`%s`', $strHelperTable, $strId, $strHelperTable, $strPrimaryKey);
}
return $arrCustomFieldSql;
}
示例15: Form_Create
protected function Form_Create()
{
$this->ctlHeaderMenu_Create();
$this->ctlShortcutMenu_Create();
$this->dtgAssetModel = new QDataGrid($this);
$this->dtgAssetModel->Name = 'asset_model_list';
$this->dtgAssetModel->CellPadding = 5;
$this->dtgAssetModel->CellSpacing = 0;
$this->dtgAssetModel->CssClass = "datagrid";
// Disable AJAX for the datagrid
$this->dtgAssetModel->UseAjax = false;
// Allow for column toggling
$this->dtgAssetModel->ShowColumnToggle = true;
// Allow for CSV Export
$this->dtgAssetModel->ShowExportCsv = true;
// Enable Pagination
$objPaginator = new QPaginator($this->dtgAssetModel);
$this->dtgAssetModel->Paginator = $objPaginator;
$this->dtgAssetModel->ItemsPerPage = QApplication::$TracmorSettings->SearchResultsPerPage;
// Add column with checkBoxes to perform MassActions
$blnShowCheckboxes = QApplication::AuthorizeEntityTypeBoolean(2);
if ($blnShowCheckboxes) {
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('<?= $_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->AssetModelId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
}
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('ID', '<?= $_ITEM->AssetModelId ?>', array('OrderByClause' => QQ::OrderBy(QQN::AssetModel()->AssetModelId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AssetModel()->AssetModelId, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('<img src=../images/icons/attachment_gray.gif border=0 title=Attachments alt=Attachments>', '<?= Attachment::toStringIcon($_ITEM->GetVirtualAttribute(\'attachment_count\')); ?>', 'SortByCommand="__attachment_count ASC"', 'ReverseSortByCommand="__attachment_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Assets', '<?= $_ITEM->__toStringWithAssetCountLink($_ITEM,"bluelink"); ?>', 'SortByCommand="asset_count ASC"', 'ReverseSortByCommand="asset_count DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Short Description', '<?= $_ITEM->__toStringWithLink($_ITEM,"bluelink"); ?>', 'SortByCommand="short_description ASC"', 'ReverseSortByCommand="short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Category', '<?= $_FORM->dtgAssetModel_Category_Render($_ITEM); ?>', 'SortByCommand="asset_model__category_id__short_description ASC"', 'ReverseSortByCommand="asset_model__category_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Manufacturer', '<?= $_FORM->dtgAssetModel_Manufacturer_Render($_ITEM); ?>', 'SortByCommand="asset_model__manufacturer_id__short_description ASC"', 'ReverseSortByCommand="asset_model__manufacturer_id__short_description DESC"', 'CssClass="dtg_column"'));
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Model Number', '<?= (QString::Truncate($_ITEM->AssetModelCode, 200)); ?>', 'FontBold=true', 'SortByCommand="asset_model_code ASC"', 'ReverseSortByCommand="asset_model_code DESC"', 'CssClass="dtg_column"'));
// Add Asset Model Depreciation class if Enabled within application
if (QApplication::$TracmorSettings->DepreciationFlag == '1') {
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt('Depreciation Class', '<?= $_FORM->dtgAssetModel_Depreciation_Render($_ITEM); ?>', 'SortByCommand="asset_model__depreciation_class_id__short_description ASC"', 'ReverseSortByCommand="asset_model__depreciation_class_id__short_description DESC"', 'CssClass="dtg_column"'));
}
// Add the custom field columns with Display set to false. These can be shown by using the column toggle menu.
$objCustomFieldArray = CustomField::LoadObjCustomFieldArray(EntityQtype::AssetModel, false);
if ($objCustomFieldArray) {
foreach ($objCustomFieldArray as $objCustomField) {
//Only add the custom field column if the role has authorization to view it.
if ($objCustomField->objRoleAuthView && $objCustomField->objRoleAuthView->AuthorizedFlag) {
$this->dtgAssetModel->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'SortByCommand="__' . $objCustomField->CustomFieldId . ' ASC"', 'ReverseSortByCommand="__' . $objCustomField->CustomFieldId . ' DESC"', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
}
}
}
$this->dtgAssetModel->SortColumnIndex = $blnShowCheckboxes ? 4 : 3;
$this->dtgAssetModel->SortDirection = 0;
$objStyle = $this->dtgAssetModel->RowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#FFFFFF';
$objStyle->FontSize = 12;
$objStyle = $this->dtgAssetModel->AlternateRowStyle;
$objStyle->BackColor = '#EFEFEF';
$objStyle = $this->dtgAssetModel->HeaderRowStyle;
$objStyle->ForeColor = '#000000';
$objStyle->BackColor = '#EFEFEF';
$objStyle->CssClass = 'dtg_header';
$this->dtgAssetModel->SetDataBinder('dtgAssetModel_Bind');
$this->lstCategory_Create();
$this->lstManufacturer_Create();
$this->txtDescription_Create();
$this->txtAssetModelCode_Create();
$this->btnSearch_Create();
$this->btnClear_Create();
$this->ctlAdvanced_Create();
$this->lblAdvanced_Create();
// Mass Actions controls create
$this->lblWarning_Create();
$this->dlgMassDelete_Create();
$this->btnMassDeleteConfirm_Create();
$this->btnMassDeleteConfirmSkip_Create();
$this->btnMassDeleteCancel_Create();
$this->dlgMassEdit_Create();
$this->btnMassDelete_Create();
$this->btnMassEdit_Create();
$this->AddMassButtonActions();
}