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
0
 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
0
 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');
 }
 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();
     }
 }
 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
0
 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
0
 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
0
 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
0
 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');
 }
 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();
 }
 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;
                         }
                     }
                     CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intShipmentId, EntityQtype::Shipment);
                 }
             }
             $strQuery = sprintf("UPDATE `shipment`\n                                     SET " . implode(",", $set) . "\n                                     WHERE `shipment_id` IN (%s)", implode(",", $this->arrShipmentToEdit));
             $objDatabase->NonQuery($strQuery);
             $objDatabase->TransactionCommit();
             $this->ParentControl->HideDialogBox();
             QApplication::Redirect('');
         } catch (QMySqliDatabaseException $objExc) {
             $objDatabase->TransactionRollback();
             throw new QDatabaseException();
         }
     } else {
         $objDatabase->TransactionRollback();
         $this->arrCustomFieldsToEdit = array();
         $this->uncheck();
     }
 }
 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();
     $this->btnClear_Create();
     $this->ctlAdvanced_Create();
     $this->lblAdvanced_Create();
 }
 public function btnApply_Click($strFormId, $strControlId, $strParameter)
 {
     $this->EnableSelectedControls();
     $this->ClearWarnings();
     $blnError = false;
     // Make sure at least one checkbox is checked
     if (!$this->chkModel->Checked && !$this->chkParentAssetCode->Checked && !$this->chkChkLockToParent->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;
         }
     }
     // If Model is checked, make sure a model is selected
     if ($this->chkModel->Checked && $this->lstModel->SelectedValue == null) {
         $blnError = true;
         $this->lstModel->Warning = 'You must select a Model.';
         return;
     }
     // Get an instance of the database
     $objDatabase = QApplication::$Database[1];
     // Begin a MySQL Transaction to be either committed or rolled back
     $objDatabase->TransactionBegin();
     $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
     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);
                 }
             }
         }
     }
     foreach ($this->arrAssetToEdit as $intAssetToEditId) {
         $objAsset = Asset::Load($intAssetToEditId);
         // First check that the user is authorized to edit this asset
         if (!QApplication::AuthorizeEntityBoolean($objAsset, 2)) {
             $blnError = true;
             $this->btnCancel->Warning = 'You are not authorized to edit one or more of the selected assets.';
             break;
         }
         if ($this->chkParentAssetCode->Checked && $this->txtParentAssetCode->Text) {
             // Check if the parent asset tag is already a child asset of this asset
             $arrChildAsset = Asset::LoadArrayByParentAssetId($intAssetToEditId);
             foreach ($arrChildAsset as $objChildAsset) {
                 if ($objChildAsset->AssetCode == $this->txtParentAssetCode->Text) {
                     $blnError = true;
                     $this->txtParentAssetCode->Warning = "Parent asset tag is already a child of this asset.";
                     break 2;
                 }
             }
             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
0
 /**
  * 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
0
 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();
 }
예제 #16
0
 protected function customFields_Create()
 {
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->objManufacturer->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(5, $this->blnEditMode, $this->objManufacturer->ManufacturerId);
     // Create the Custom Field Controls - labels and inputs (text or list) for each
     $this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objManufacturer->objCustomFieldArray, $this->blnEditMode, $this, true, true);
     foreach ($this->arrCustomFields as $objCustomField) {
         $objCustomField['input']->TabIndex = $this->GetNextTabIndex();
     }
 }
예제 #17
0
 protected function arrAddressCustomFields_Create()
 {
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->objAddress = new Address();
     $this->objAddress->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(9, $this->blnEditMode);
     if ($this->objAddress->objCustomFieldArray) {
         $this->arrAddressCustomFields = CustomField::CustomFieldControlsCreate($this->objAddress->objCustomFieldArray, $this->blnEditMode, $this, false, true);
         if ($this->arrAddressCustomFields) {
             foreach ($this->arrAddressCustomFields as $field) {
                 $field['input']->TabIndex = $this->intTabIndex++;
             }
         }
     }
     $this->UpdateAddressCustomFields();
 }
 public function btnApply_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();
     if (count($this->arrCustomFields) > 0) {
         $customFieldIdArray = array();
         // preparing data to edit
         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);
                 }
             }
         }
     }
     // Apply checked main_table fields
     $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
     if ($this->chkToCompany->Checked) {
         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->lstToAddress->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->chkDateReceived->Checked && $this->calDateReceived->DateTime) {
         // Check all receipts are completed
         if (Receipt::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Receipt()->ReceivedFlag, 0), QQ::In(QQN::Receipt()->ReceiptId, $this->arrReceiptToEdit))) > 0) {
             $this->calDateReceived->Warning = 'Can be set only for completed receipts';
             $blnError = true;
         } else {
             $set[] = sprintf('`receipt_date`="%s"', $this->calDateReceived->DateTime->__toString('YYYY-MM-DD'));
         }
     }
     if ($this->chkDateDue->Checked && $this->calDateDue->DateTime) {
         $set[] = sprintf('`due_date`="%s"', $this->calDateDue->DateTime->__toString('YYYY-MM-DD'));
     }
     if (!$blnError) {
         try {
             // Modifying transactions
             foreach ($this->arrReceiptToEdit as $intReceiptId) {
                 $objTransaction = Transaction::Load(Receipt::Load($intReceiptId)->Transaction->TransactionId);
                 $objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId;
                 if ($this->chkNote->Checked) {
                     $objTransaction->Note = $this->txtNote->Text;
                 }
                 $objTransaction->Save();
             }
             if (count($this->arrCustomFieldsToEdit) > 0) {
                 // Save the values from all of the custom field controls to save the asset
                 foreach ($this->arrReceiptToEdit as $intReceiptId) {
                     $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Receipt, false);
                     $selectedCustomFieldsArray = array();
                     foreach ($objCustomFieldsArray as $objCustomField) {
                         if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
                             $selectedCustomFieldsArray[] = $objCustomField;
                         }
                     }
                     CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intReceiptId, EntityQtype::Receipt);
                 }
                 $this->arrCustomFieldsToEdit = array();
             }
             // Update Transaction
             // Update main table
             $strQuery = sprintf("UPDATE `receipt`\n                                     SET " . implode(",", $set) . "\n                                     WHERE `receipt_id` IN (%s)", implode(",", $this->arrReceiptToEdit));
             $objDatabase->NonQuery($strQuery);
             $objDatabase->TransactionCommit();
             QApplication::Redirect('');
         } catch (QMySqliDatabaseException $objExc) {
             $objDatabase->TransactionRollback();
             throw new QDatabaseException();
         }
     } else {
         $objDatabase->TransactionRollback();
         $this->arrCustomFieldsToEdit = array();
         $this->uncheck();
     }
 }
예제 #19
0
 public function btnClone_Click($strFormId, $strControlId, $strParameter)
 {
     // Creating a new asset
     $this->blnEditMode = false;
     // Create the asset model and location fields
     $this->lstAssetModel_Create();
     $this->lstAssetModel->SelectedValue = $this->objAsset->AssetModelId;
     $this->lstLocation_Create();
     $this->lstLocation->SelectedValue = $this->objAsset->LocationId;
     $objAssetToClone = $this->objAsset;
     // Instantiate new Asset object
     $this->objAsset = new Asset();
     // Load custom fields for asset with values from original asset
     $this->objAsset->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(1, true, $objAssetToClone->AssetId);
     // Set the asset_code to null because they are unique
     $this->lblHeaderAssetCode->Text = 'New Asset';
     $this->txtAssetCode->Text = '';
     $this->dtgAssetTransaction->MarkAsModified();
     $this->dtgShipmentReceipt->MarkAsModified();
     // Set the creation and modification fields to null because it hasn't been created or modified yet.
     $this->lblModifiedDate->Text = '';
     $this->lblCreationDate->Text = '';
     // Show the inputs so the user can change any information and add the asset code
     $this->displayInputs();
 }
 protected function customFields_Create()
 {
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->objCustomFieldArray = CustomField::LoadObjCustomFieldArray($this->intEntityQtypeId, false, null);
     // Create the Custom Field Controls - labels and inputs (text or list) for each
     $this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objCustomFieldArray, false, $this->objParentObject, false, true, true);
 }
예제 #21
0
 protected function customFields_Create()
 {
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->objContact->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Contact, $this->blnEditMode, $this->objContact->ContactId);
     // Create the Custom Field Controls - labels and inputs (text or list) for each
     $this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objContact->objCustomFieldArray, $this->blnEditMode, $this, false, true, false);
     // Set Display logic of the Custom Fields
     $this->UpdateCustomFields();
 }
예제 #22
0
 protected function customFields_Create()
 {
     // Create QPanel with AutoRenderChildren to add cutom fields dynamically
     $this->pnlCustomFields = new QPanel($this);
     $this->pnlCustomFields->AutoRenderChildren = true;
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->arrCustomFields = CustomField::LoadObjCustomFieldArray(1, false, null);
     $i = 0;
     foreach ($this->arrCustomFields as $objCustomField) {
         $this->chkCustomFieldArray[$i] = new QCheckBox($this->pnlCustomFields);
         $this->chkCustomFieldArray[$i]->Text = $objCustomField->ShortDescription;
         $this->chkCustomFieldArray[$i]->ActionParameter = $objCustomField->CustomFieldId;
         $i++;
     }
 }
 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->dtgInventoryModel = new QDataGrid($this);
     $this->dtgInventoryModel->Name = 'inventory_model_list';
     $this->dtgInventoryModel->CellPadding = 5;
     $this->dtgInventoryModel->CellSpacing = 0;
     $this->dtgInventoryModel->CssClass = "datagrid";
     // Enable/Disable AJAX for the datagrid
     $this->dtgInventoryModel->UseAjax = $this->blnUseAjax;
     // Allow for column toggling
     $this->dtgInventoryModel->ShowColumnToggle = true;
     // Allow for CSV Export
     $this->dtgInventoryModel->ShowExportCsv = true;
     // Enable Pagination
     $objPaginator = new QPaginator($this->dtgInventoryModel);
     $this->dtgInventoryModel->Paginator = $objPaginator;
     $this->dtgInventoryModel->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->dtgInventoryModel->AddColumn(new QDataGridColumnExt('<?=$_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->InventoryModelId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));
     }
     $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"'));
     // Removing any links in the column data
     if ($this->blnRemoveAllLinks) {
         $this->dtgInventoryModel->AddColumn(new QDataGridColumnExt('Inventory Code', '<?= $_ITEM->InventoryModelCode; ?>', 'SortByCommand="inventory_model_code ASC"', 'ReverseSortByCommand="inventory_model_code DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
     } else {
         $this->dtgInventoryModel->AddColumn(new QDataGridColumnExt('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('Model', '<?= $_ITEM->ShortDescription ?>', 'Width=200', 'SortByCommand="short_description ASC"', 'ReverseSortByCommand="short_description DESC"', 'CssClass="dtg_column"'));
     $this->dtgInventoryModel->AddColumn(new QDataGridColumnExt('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('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('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($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);
     $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();
 }
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     try {
         // Get an instance of the database
         $objDatabase = QApplication::$Database[1];
         // Begin a MySQL Transaction to be either committed or rolled back
         $objDatabase->TransactionBegin();
         // This happens whether or not they are creating a new one or editing an existing one
         $this->objInventoryModel->ShortDescription = $this->txtShortDescription->Text;
         $this->objInventoryModel->CategoryId = $this->lstCategory->SelectedValue;
         $this->objInventoryModel->ManufacturerId = $this->lstManufacturer->SelectedValue;
         $this->objInventoryModel->LongDescription = $this->txtLongDescription->Text;
         $this->objInventoryModel->InventoryModelCode = $this->txtInventoryModelCode->Text;
         $blnError = false;
         // If a new inventory model is being created
         if (!$this->blnEditMode) {
             // Check to see if the InventoryModelCode already exists
             $InventoryModelDuplicate = InventoryModel::LoadbyInventoryModelCode($this->objInventoryModel->InventoryModelCode);
             if ($InventoryModelDuplicate) {
                 $blnError = true;
                 $this->txtInventoryModelCode->Warning = "That inventory code is already in use. Please try another.";
             }
             if (!$blnError) {
                 // Object should be saved only if it is new, to obtain the proper InventoryModelId to add to the custom field tables
                 $this->objInventoryModel->Save();
             }
         }
         // Assign input values to custom fields
         if ($this->arrCustomFields) {
             // Save the values from all of the custom field controls to save the inventory model
             CustomField::SaveControls($this->objInventoryModel->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objInventoryModel->InventoryModelId, 2);
         }
         if ($this->blnEditMode) {
             // Check to see if the InventoryModelCode already exists and it is not the code for the inventory model that you are currently working with
             $InventoryModelDuplicate = InventoryModel::LoadbyInventoryModelCode($this->objInventoryModel->InventoryModelCode);
             if ($InventoryModelDuplicate && $InventoryModelDuplicate->InventoryModelId != $this->objInventoryModel->InventoryModelId) {
                 $blnError = true;
                 $this->txtInventoryModelCode->Warning = "That inventory code is already in use. Please try another.";
             }
             if (!$blnError) {
                 // Update the values of all fields for an Ajax reload
                 $this->UpdateInventoryFields();
                 // If inventory model is not new, it must be saved after updating the inventoryfields
                 $this->objInventoryModel->Save();
                 // Setup the InventoryModel again to retrieve the latest Modified information
                 $this->objParentObject->SetupInventoryModel($this);
                 // Give the labels their appropriate values before display
                 $this->UpdateInventoryLabels();
                 // This was necessary because it was not saving the changes of a second edit/save in a row
                 // Reload all custom fields
                 $this->objInventoryModel->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(2, $this->blnEditMode, $this->objInventoryModel->InventoryModelId);
                 // Hide inputs and display labels
                 $this->displayLabels();
                 // Enable the appropriate transaction buttons
                 $this->EnableTransactionButtons();
                 // Commit the above transactions to the database
                 $objDatabase->TransactionCommit();
             }
         } elseif (!$blnError) {
             // Commit the above transactions to the database
             $objDatabase->TransactionCommit();
             // Reload the edit inventory page with the newly created model
             $strRedirect = "inventory_edit.php?intInventoryModelId=" . $this->objInventoryModel->InventoryModelId;
             QApplication::Redirect($strRedirect);
         }
     } catch (QOptimisticLockingException $objExc) {
         // Rollback the database
         $objDatabase->TransactionRollback();
         // Output the error
         $this->btnCancel->Warning = sprintf('This inventory has been updated by another user. You must <a href="inventory_edit.php?intInventoryModelId=%s">Refresh</a> to edit this Inventory.', $this->objInventoryModel->InventoryModelId);
     }
 }
예제 #25
0
 protected function chkCustom_Create()
 {
     $intRoleId = QApplication::QueryString('intRoleId');
     $objCustomFieldArray = CustomField::LoadObjCustomFieldArray($this->intEntityQtypeId, false, null);
     foreach ($objCustomFieldArray as $objCustomField) {
         //For each Custom Field, we setup one checkbox for View Access and one for Edit Access
         $chkCustomView = new QCheckBox($this);
         $chkCustomView->AddAction(new QClickEvent(), new QAjaxAction('chkCustom_Click'));
         $chkCustomEdit = new QCheckBox($this);
         //When we click in a View Checkbox, we need to control the Edit Checkbox Control too in the chkCustom_Click method.
         $chkCustomView->ActionParameter = $chkCustomEdit->ControlId;
         //In order to manipulate the RoleEntityQtypeCustomFieldAuthorization table, we need to obtain the EntityQtypeCustomFieldId field.
         $objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($this->intEntityQtypeId, $objCustomField->CustomFieldId);
         if ($objEntityQtypeCustomField) {
             $objCustomAuthView = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 1);
             //If Creation Mode, the View Privilege of the Custom Fields is checked by default
             if (!$this->blnEditMode) {
                 $chkCustomView->Checked = 1;
             } elseif (isset($objCustomAuthView)) {
                 $chkCustomView->Checked = $objCustomAuthView->AuthorizedFlag;
             }
             $objCustomAuthEdit = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 2);
             //If Creation Mode, the Edit Privilege of the Custom Fields is checked by default
             if (!$this->blnEditMode) {
                 $chkCustomEdit->Checked = 1;
             } elseif (isset($objCustomAuthEdit)) {
                 $chkCustomEdit->Checked = $objCustomAuthEdit->AuthorizedFlag;
             }
             //if view access is not authorized, edit access won't be authorized
             if (!$chkCustomView->Checked) {
                 $chkCustomEdit->Enabled = false;
                 $chkCustomEdit->Checked = false;
             }
         }
         //In order to manipulate all the custom checkbox of the entity, we save them in an associated array.
         $this->arrCustomChecks[] = array('name' => $objCustomField->ShortDescription . ':', 'view' => $chkCustomView, 'edit' => $chkCustomEdit, 'id' => $objCustomField->CustomFieldId);
     }
 }
예제 #26
0
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     if (trim($this->txtShortDescription->Text) == "") {
         $this->txtShortDescription->Warning = 'Short description is required';
         $blnError = true;
     }
     if (trim($this->txtAssetModelCode->Text) == "") {
         $this->txtAssetModelCode->Warning = 'Asset model code is required';
         $blnError = true;
     }
     if ($blnError) {
         return;
     }
     $this->UpdateAssetModelFields();
     $this->objAssetModel->Save();
     // Assign input values to custom fields
     if ($this->arrCustomFields) {
         // Save the values from all of the custom field controls to save the asset
         CustomField::SaveControls($this->objAssetModel->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objAssetModel->AssetModelId, 4);
     }
     if ($this->ifcImage->FileName) {
         // Retrieve the extension (.jpg, .gif) from the filename
         $explosion = explode(".", $this->ifcImage->FileName);
         // Set the file name to ID_asset_model.ext
         $this->ifcImage->FileName = sprintf('%s%s%s.%s', $this->ifcImage->Prefix, $this->objAssetModel->AssetModelId, $this->ifcImage->Suffix, $explosion[1]);
         // Set the image path for saving the asset model
         $this->txtImagePath->Text = $this->ifcImage->FileName;
         // Upload the file to the server
         $this->ifcImage->ProcessUpload();
         // Save the image path information to the AssetModel object
         $this->objAssetModel->ImagePath = $this->txtImagePath->Text;
         $this->objAssetModel->Save(false, true);
     }
     if ($this->blnEditMode) {
         $this->UpdateLabels();
         // This was necessary because it was not saving the changes of a second edit/save in a row
         // Reload all custom fields
         $this->objAssetModel->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(4, $this->blnEditMode, $this->objAssetModel->AssetModelId);
         $this->displayLabels();
     } else {
         // Display the asset model list page
         $strRedirect = "asset_model_list.php";
         QApplication::Redirect($strRedirect);
     }
 }
예제 #27
0
 protected function dtgCompany_Create()
 {
     $this->dtgCompany = new QDataGrid($this);
     $this->dtgCompany->Name = 'company_list';
     $this->dtgCompany->CellPadding = 5;
     $this->dtgCompany->CellSpacing = 0;
     $this->dtgCompany->CssClass = "datagrid";
     // Disable AJAX for the datagrid
     $this->dtgCompany->UseAjax = false;
     // Allow for column toggling
     $this->dtgCompany->ShowColumnToggle = true;
     // Allow for CSV Export
     $this->dtgCompany->ShowExportCsv = true;
     // Enable Pagination
     $objPaginator = new QPaginator($this->dtgCompany);
     $this->dtgCompany->Paginator = $objPaginator;
     $this->dtgCompany->ItemsPerPage = QApplication::$TracmorSettings->SearchResultsPerPage;
     // Add Checkbox Column
     /*$this->dtgCompany->AddColumn(new QDataGridColumnExt('<?= $_CONTROL->chkSelectAll_Render() ?>', '<?=$_CONTROL->chkSelected_Render($_ITEM->CompanyId) ?>', 'CssClass="dtg_column"', 'HtmlEntities=false'));*/
     $this->dtgCompany->AddColumn(new QDataGridColumnExt('ID', '<?= $_ITEM->CompanyId ?>', array('OrderByClause' => QQ::OrderBy(QQN::Company()->CompanyId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Company()->CompanyId, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgCompany->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->dtgCompany->AddColumn(new QDataGridColumnExt('Company Name', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', 'SortByCommand="short_description ASC"', 'ReverseSortByCommand="short_description DESC"', 'CssClass="dtg_column"', 'HtmlEntities=false'));
     $this->dtgCompany->AddColumn(new QDataGridColumnExt('City', '<?= $_ITEM->__toStringCity() ?>', 'Width=200', 'SortByCommand="company__address_id__city ASC"', 'ReverseSortByCommand="company__address_id__city DESC"', 'CssClass="dtg_column"'));
     $this->dtgCompany->AddColumn(new QDataGridColumnExt('State/Province', '<?= $_ITEM->__toStringStateProvince() ?>', 'SortByCommand="company__address_id__state_province_id__short_description ASC"', 'ReverseSortByCommand="company__address_id__state_province_id__short_description DESC"', 'CssClass="dtg_column"'));
     $this->dtgCompany->AddColumn(new QDataGridColumnExt('Country', '<?= $_ITEM->__toStringCountry() ?>', 'SortByCommand="company__address_id__country_id__short_description ASC"', 'ReverseSortByCommand="company__address_id__country_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(7, 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->dtgCompany->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->dtgCompany->SortColumnIndex = 2;
     $this->dtgCompany->SortDirection = 0;
     $objStyle = $this->dtgCompany->RowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#FFFFFF';
     $objStyle->FontSize = 12;
     $objStyle = $this->dtgCompany->AlternateRowStyle;
     $objStyle->BackColor = '#EFEFEF';
     $objStyle = $this->dtgCompany->HeaderRowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#EFEFEF';
     $objStyle->CssClass = 'dtg_header';
     $this->dtgCompany->SetDataBinder('dtgCompany_Bind');
 }
 protected function dtgAssetTransact_Create()
 {
     $this->dtgAssetTransact = new QDataGrid($this);
     $this->dtgAssetTransact->Name = 'asset_transaction';
     $this->dtgAssetTransact->CellPadding = 5;
     $this->dtgAssetTransact->CellSpacing = 0;
     $this->dtgAssetTransact->CssClass = "datagrid";
     // Enable AJAX - this won't work while using the DB profiler
     $this->dtgAssetTransact->UseAjax = true;
     // Enable Pagination, and set to 20 items per page
     $objPaginator = new QPaginator($this->dtgAssetTransact);
     $this->dtgAssetTransact->Paginator = $objPaginator;
     $this->dtgAssetTransact->ItemsPerPage = 20;
     $this->dtgAssetTransact->ShowColumnToggle = true;
     $this->dtgAssetTransact->AddColumn(new QDataGridColumnExt('Asset Code', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgAssetTransact->AddColumn(new QDataGridColumnExt('Model', '<?= $_ITEM->AssetModel->__toStringWithLink("bluelink") ?>', array('Width' => 200, 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgAssetTransact->AddColumn(new QDataGridColumnExt('Current Location', '<?= $_ITEM->Location->__toString() ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false)));
     // 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->dtgAssetTransact->AddColumn(new QDataGridColumnExt($objCustomField->ShortDescription, '<?= $_ITEM->GetVirtualAttribute(\'' . $objCustomField->CustomFieldId . '\') ?>', 'HtmlEntities="false"', 'CssClass="dtg_column"', 'Display="false"'));
             }
         }
     }
     $this->dtgAssetTransact->AddColumn(new QDataGridColumnExt('Action', '<?= $_FORM->RemoveColumn_Render($_ITEM) ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $objStyle = $this->dtgAssetTransact->RowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#FFFFFF';
     $objStyle->FontSize = 12;
     $objStyle = $this->dtgAssetTransact->AlternateRowStyle;
     $objStyle->BackColor = '#EFEFEF';
     $objStyle = $this->dtgAssetTransact->HeaderRowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#EFEFEF';
     $objStyle->CssClass = 'dtg_header';
     $this->blnTransactionModified = true;
 }
예제 #29
0
 protected function customFields_Create()
 {
     // Load all custom fields and their values into an array objCustomFieldArray->CustomFieldSelection->CustomFieldValue
     $this->objReceipt->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(11, $this->blnEditMode, $this->objReceipt->ReceiptId);
     // Create the Custom Field Controls - labels and inputs (text or list) for each
     if ($this->objReceipt->objCustomFieldArray) {
         $this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objReceipt->objCustomFieldArray, $this->blnEditMode, $this, true, true);
     }
     $this->UpdateCustomFields();
 }
 public function btnMassEditApply_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();
     $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
     if ($this->chkDescription->Checked) {
         $set[] = sprintf('`description` ="%s"', $this->txtDescription->Text);
     }
     if ($this->chkCompany->Checked) {
         if ($this->lstCompany->SelectedValue !== null && $this->lstAddress->SelectedValue !== null) {
             $set[] = sprintf('`company_id` = %s', $this->lstCompany->SelectedValue);
             $set[] = sprintf('`address_id` = %s', $this->lstAddress->SelectedValue);
         } else {
             $blnError = true;
             $this->lstCompany->Warning = $this->lstCompany->SelectedValue == null ? 'Company can\'t be empty' : '';
             $this->lstAddress->Warning = $this->lstAddress->SelectedValue == null ? 'Address can\'t be empty' : '';
         }
     }
     $strQuery = sprintf("UPDATE `contact`\n\t\t\t\t\t\t\t SET " . implode(",", $set) . "\n\t\t\t\t\t\t\t WHERE `contact_id` IN (%s)", implode(",", $this->arrContactToEdit));
     // Custom Fields handling
     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);
                 }
             }
         }
     }
     // Transaction
     if (!$blnError) {
         try {
             if (count($this->arrCustomFieldsToEdit) > 0) {
                 // preparing data to edit
                 foreach ($this->arrContactToEdit as $intContactId) {
                     $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Contact, false);
                     $selectedCustomFieldsArray = array();
                     foreach ($objCustomFieldsArray as $objCustomField) {
                         if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
                             $selectedCustomFieldsArray[] = $objCustomField;
                         }
                     }
                     CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intContactId, EntityQtype::Contact);
                 }
             }
             //print $strQuery; exit;
             $objDatabase->NonQuery($strQuery);
             $objDatabase->TransactionCommit();
             QApplication::Redirect('');
         } catch (QMySqliDatabaseException $objExc) {
             $objDatabase->TransactionRollback();
             throw new QDatabaseException();
         }
     } else {
         $objDatabase->TransactionRollback();
         $this->arrCustomFieldsToEdit = array();
         $this->uncheck();
     }
 }