public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // Record Method Callbacks
     $this->strSetEditPanelMethod = $strSetEditPanelMethod;
     $this->strCloseEditPanelMethod = $strCloseEditPanelMethod;
     // Setup DataGrid Columns
     $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_CONTROL->ParentControl->dtgCustomField_EditLinkColumn_Render($_ITEM) ?>');
     $this->colEditLinkColumn->HtmlEntities = false;
     $this->colCustomFieldId = new QDataGridColumn(QApplication::Translate('Custom Field Id'), '<?= $_ITEM->CustomFieldId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldId, false)));
     $this->colCustomFieldQtypeId = new QDataGridColumn(QApplication::Translate('Custom Field Qtype'), '<?= $_CONTROL->ParentControl->dtgCustomField_CustomFieldQtypeId_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId, false)));
     $this->colDefaultCustomFieldValueId = new QDataGridColumn(QApplication::Translate('Default Custom Field Value Id'), '<?= $_CONTROL->ParentControl->dtgCustomField_DefaultCustomFieldValue_Render($_ITEM); ?>');
     $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription, false)));
     $this->colActiveFlag = new QDataGridColumn(QApplication::Translate('Active Flag'), '<?= ($_ITEM->ActiveFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag, false)));
     $this->colRequiredFlag = new QDataGridColumn(QApplication::Translate('Required Flag'), '<?= ($_ITEM->RequiredFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag, false)));
     $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgCustomField_CreatedByObject_Render($_ITEM); ?>');
     $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgCustomField_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CreationDate, false)));
     $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgCustomField_ModifiedByObject_Render($_ITEM); ?>');
     $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ModifiedDate, false)));
     // Setup DataGrid
     $this->dtgCustomField = new QDataGrid($this);
     $this->dtgCustomField->CellSpacing = 0;
     $this->dtgCustomField->CellPadding = 4;
     $this->dtgCustomField->BorderStyle = QBorderStyle::Solid;
     $this->dtgCustomField->BorderWidth = 1;
     $this->dtgCustomField->GridLines = QGridLines::Both;
     // Datagrid Paginator
     $this->dtgCustomField->Paginator = new QPaginator($this->dtgCustomField);
     $this->dtgCustomField->ItemsPerPage = 10;
     // Specify Whether or Not to Refresh using Ajax
     $this->dtgCustomField->UseAjax = true;
     // Specify the local databind method this datagrid will use
     $this->dtgCustomField->SetDataBinder('dtgCustomField_Bind', $this);
     $this->dtgCustomField->AddColumn($this->colEditLinkColumn);
     $this->dtgCustomField->AddColumn($this->colCustomFieldId);
     $this->dtgCustomField->AddColumn($this->colCustomFieldQtypeId);
     $this->dtgCustomField->AddColumn($this->colDefaultCustomFieldValueId);
     $this->dtgCustomField->AddColumn($this->colShortDescription);
     $this->dtgCustomField->AddColumn($this->colActiveFlag);
     $this->dtgCustomField->AddColumn($this->colRequiredFlag);
     $this->dtgCustomField->AddColumn($this->colCreatedBy);
     $this->dtgCustomField->AddColumn($this->colCreationDate);
     $this->dtgCustomField->AddColumn($this->colModifiedBy);
     $this->dtgCustomField->AddColumn($this->colModifiedDate);
     // Setup the Create New button
     $this->btnCreateNew = new QButton($this);
     $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('CustomField');
     $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
 }
 protected function Form_Create()
 {
     // Setup DataGrid Columns
     $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgCustomField_EditLinkColumn_Render($_ITEM) ?>');
     $this->colEditLinkColumn->HtmlEntities = false;
     $this->colCustomFieldId = new QDataGridColumn(QApplication::Translate('Custom Field Id'), '<?= $_ITEM->CustomFieldId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldId, false)));
     $this->colCustomFieldQtypeId = new QDataGridColumn(QApplication::Translate('Custom Field Qtype'), '<?= $_FORM->dtgCustomField_CustomFieldQtypeId_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId, false)));
     $this->colDefaultCustomFieldValueId = new QDataGridColumn(QApplication::Translate('Default Custom Field Value Id'), '<?= $_FORM->dtgCustomField_DefaultCustomFieldValue_Render($_ITEM); ?>');
     $this->colShortDescription = new QDataGridColumn(QApplication::Translate('Short Description'), '<?= QString::Truncate($_ITEM->ShortDescription, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription, false)));
     $this->colActiveFlag = new QDataGridColumn(QApplication::Translate('Active Flag'), '<?= ($_ITEM->ActiveFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag, false)));
     $this->colRequiredFlag = new QDataGridColumn(QApplication::Translate('Required Flag'), '<?= ($_ITEM->RequiredFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag, false)));
     $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgCustomField_CreatedByObject_Render($_ITEM); ?>');
     $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgCustomField_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CreationDate, false)));
     $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgCustomField_ModifiedByObject_Render($_ITEM); ?>');
     $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ModifiedDate, false)));
     // Setup DataGrid
     $this->dtgCustomField = new QDataGrid($this);
     $this->dtgCustomField->CellSpacing = 0;
     $this->dtgCustomField->CellPadding = 4;
     $this->dtgCustomField->BorderStyle = QBorderStyle::Solid;
     $this->dtgCustomField->BorderWidth = 1;
     $this->dtgCustomField->GridLines = QGridLines::Both;
     // Datagrid Paginator
     $this->dtgCustomField->Paginator = new QPaginator($this->dtgCustomField);
     $this->dtgCustomField->ItemsPerPage = 10;
     // Specify Whether or Not to Refresh using Ajax
     $this->dtgCustomField->UseAjax = false;
     // Specify the local databind method this datagrid will use
     $this->dtgCustomField->SetDataBinder('dtgCustomField_Bind');
     $this->dtgCustomField->AddColumn($this->colEditLinkColumn);
     $this->dtgCustomField->AddColumn($this->colCustomFieldId);
     $this->dtgCustomField->AddColumn($this->colCustomFieldQtypeId);
     $this->dtgCustomField->AddColumn($this->colDefaultCustomFieldValueId);
     $this->dtgCustomField->AddColumn($this->colShortDescription);
     $this->dtgCustomField->AddColumn($this->colActiveFlag);
     $this->dtgCustomField->AddColumn($this->colRequiredFlag);
     $this->dtgCustomField->AddColumn($this->colCreatedBy);
     $this->dtgCustomField->AddColumn($this->colCreationDate);
     $this->dtgCustomField->AddColumn($this->colModifiedBy);
     $this->dtgCustomField->AddColumn($this->colModifiedDate);
 }
예제 #3
0
 /**
  * Count CustomFields
  * by DefaultCustomFieldValueId Index(es)
  * @param integer $intDefaultCustomFieldValueId
  * @return int
  */
 public static function CountByDefaultCustomFieldValueId($intDefaultCustomFieldValueId)
 {
     // Call CustomField::QueryCount to perform the CountByDefaultCustomFieldValueId query
     return CustomField::QueryCount(QQ::Equal(QQN::CustomField()->DefaultCustomFieldValueId, $intDefaultCustomFieldValueId));
 }
예제 #4
0
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     try {
         $arrRestrictedFields = array('asset code', 'asset tag', 'model', 'category', 'manufacturer', 'location', 'assets', 'name', 'asset model code', 'model number', 'inventory code', 'quantity', 'company name', 'city', 'state/province', 'country', 'title', 'company', 'email', 'address', 'shipment number', 'ship date', 'ship to company', 'ship to contact', 'ship to address', 'scheduled by', 'status', 'tracking', 'receipt number', 'receive from company', 'receive from contact', 'description', 'account', 'courier', 'account number', 'field name', 'type', 'enabled', 'required', 'role', 'username', 'user role', 'active', 'admin');
         $blnError = false;
         /*if ($this->chkRequiredFlag->Checked) {
         			if ($this->lstCustomFieldQtype->SelectedValue != 2 && $this->txtDefaultValue->Text == '') {
         				$blnError = true;
         				$this->btnCancel->Warning = 'A custom field must have a default value if it is required.';
         			}
         		}*/
         if (count($this->chkEntityQtype->SelectedItems) == 0) {
             $blnError = true;
             $this->btnCancel->Warning = 'You must select at least one field in the Apply To list box.';
         }
         if (in_array(strtolower($this->txtShortDescription->Text), $arrRestrictedFields, false)) {
             $blnError = true;
             $this->btnCancel->Warning = sprintf("'%s' is a Tracmor restricted word. Please choose another name for this custom field", $this->txtShortDescription->Text);
         }
         if (in_array('1', $this->chkEntityQtype->SelectedValues) && $this->rblAllAssetModels->SelectedValue == 2 && count($this->arrAssetModels) == 0) {
             $blnError = true;
             $this->btnCancel->Warning = 'You must apply at least one Model.';
         }
         if ($this->blnEditMode) {
             $objCustomFieldDuplicate = CustomField::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::CustomField()->ShortDescription, $this->txtShortDescription->Text), QQ::NotEqual(QQN::CustomField()->CustomFieldId, $this->objCustomField->CustomFieldId)));
         } else {
             $objCustomFieldDuplicate = CustomField::QuerySingle(QQ::Equal(QQN::CustomField()->ShortDescription, $this->txtShortDescription->Text));
         }
         if ($objCustomFieldDuplicate) {
             $blnError = true;
             $this->btnCancel->Warning = 'A custom field already exists with that name. Please choose another.';
         }
         if (!$blnError) {
             $this->UpdateCustomFieldFields();
             $this->objCustomField->Save();
             // If this field is a required field
             if ($this->objCustomField->RequiredFlag) {
                 $blnDefaultIsNone = false;
                 // If this custom field is a text or textarea,
                 if ($this->lstCustomFieldQtype->SelectedValue != 2) {
                     if ($this->txtDefaultValue->Text != null) {
                         // Assign the existing DefaultCustomFieldValue
                         if ($this->blnEditMode && $this->objCustomField->DefaultCustomFieldValueId) {
                             $objCustomFieldValue = CustomFieldValue::Load($this->objCustomField->DefaultCustomFieldValueId);
                         } else {
                             $objCustomFieldValue = new CustomFieldValue();
                             $objCustomFieldValue->CustomFieldId = $this->objCustomField->CustomFieldId;
                         }
                         // Save the new CustomFieldValue
                         $objCustomFieldValue->ShortDescription = $this->txtDefaultValue->Text;
                         $objCustomFieldValue->Save();
                         // Set the DefaultCustomFieldValueId of the custom field
                         $this->objCustomField->DefaultCustomFieldValueId = $objCustomFieldValue->CustomFieldValueId;
                     } else {
                         $this->objCustomField->DefaultCustomFieldValueId = null;
                         $blnDefaultIsNone = true;
                     }
                 } elseif ($this->lstCustomFieldQtype->SelectedValue == 2) {
                     $this->objCustomField->DefaultCustomFieldValueId = $this->lstDefaultValue->SelectedValue;
                     if ($this->lstDefaultValue->SelectedValue == null) {
                         $blnDefaultIsNone = true;
                     }
                 }
                 // Save the custom field
                 $this->objCustomField->Save();
                 // Update the EntityQtypeCustomFields if they have changed (or if it is a new custom field
                 $this->UpdateEntityQtypeCustomFields();
                 // Update all of the CustomFieldSelections and values for the EntityQtypes
                 if (!$blnDefaultIsNone) {
                     $this->objCustomField->UpdateRequiredFieldSelections();
                     // impove logic for asset customfields
                     if ($this->blnAssetEntityType && $this->rblAllAssetModels->SelectedValue == 2) {
                         // define assets to set default value
                         $chosenAssetModels = array();
                         foreach ($this->arrAssetModels as $chosenAssetModel) {
                             $assetsToFill = Asset::LoadArrayByAssetModelId($chosenAssetModel->AssetModelId);
                             if (count($assetsToFill > 0)) {
                                 foreach ($assetsToFill as $assetToFill) {
                                     array_push($chosenAssetModels, $assetToFill->AssetId);
                                 }
                             }
                         }
                         $chosenAssetModels = implode(",", $chosenAssetModels);
                         if ($chosenAssetModels) {
                             $objDatabase = CustomField::GetDatabase();
                             $strQuery = sprintf("UPDATE `asset_custom_field_helper` SET `cfv_%s`= NULL WHERE `asset_id` NOT IN({$chosenAssetModels});", $this->objCustomField->CustomFieldId);
                             $objDatabase->NonQuery($strQuery);
                         }
                     }
                 }
             } else {
                 $this->objCustomField->DefaultCustomFieldValueId = null;
                 $this->objCustomField->Save();
                 $this->UpdateEntityQtypeCustomFields();
             }
             // If it is a new select Custom Field, then stay to add options
             if (!$this->blnEditMode && $this->objCustomField->CustomFieldQtypeId == 2) {
                 QApplication::Redirect('custom_field_edit.php?intCustomFieldId=' . $this->objCustomField->CustomFieldId);
             } else {
                 QApplication::Redirect('custom_field_list.php');
             }
         }
     } catch (QExtendedOptimisticLockingException $objExc) {
         $this->btnCancel->Warning = sprintf('This custom field has been updated by another user. You must <a href="custom_field_edit.php?intCustomFieldId=%s">Refresh</a> to edit this custom field.', $this->objCustomField->CustomFieldId);
     }
 }
예제 #5
0
 protected function dtgCustomField_Create()
 {
     $this->dtgCustomField = new QDataGrid($this);
     $this->dtgCustomField->CellPadding = 5;
     $this->dtgCustomField->CellSpacing = 0;
     $this->dtgCustomField->CssClass = "datagrid";
     $this->dtgCustomField->SortColumnIndex = 0;
     // Enable AJAX - this won't work while using the DB profiler
     $this->dtgCustomField->UseAjax = true;
     // Enable Pagination, and set to 20 items per page
     $objPaginator = new QPaginator($this->dtgCustomField);
     $this->dtgCustomField->Paginator = $objPaginator;
     $this->dtgCustomField->ItemsPerPage = 20;
     $this->dtgCustomField->AddColumn(new QDataGridColumn('Field Name', '<?= $_ITEM->__toStringWithLink("bluelink") ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ShortDescription, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgCustomField->AddColumn(new QDataGridColumn('Type', '<?= CustomFieldQtype::ToString($_ITEM->CustomFieldQtypeId) ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CustomFieldQtypeId, false), 'CssClass' => "dtg_column")));
     $this->dtgCustomField->AddColumn(new QDataGridColumn('Enabled', '<?= $_ITEM->__toStringActiveFlag() ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->ActiveFlag, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgCustomField->AddColumn(new QDataGridColumn('Required', '<?= $_ITEM->__toStringRequiredFlag() ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->RequiredFlag, false), 'CssClass' => "dtg_column", 'HtmlEntities' => false)));
     $this->dtgCustomField->AddColumn(new QDataGridColumn('Created By', '<?= $_ITEM->CreatedByObject->__toStringFullName() ?>', array('OrderByClause' => QQ::OrderBy(QQN::CustomField()->CreatedByObject->LastName, false, QQN::CustomField()->CreatedByObject->FirstName, false), 'ReverseOrderByClause' => QQ::OrderBy(QQN::CustomField()->CreatedByObject->LastName, QQN::CustomField()->CreatedByObject->FirstName), 'CssClass' => "dtg_column")));
     $this->dtgCustomField->SortColumnIndex = 0;
     $this->dtgCustomField->SortDirection = 0;
     $objStyle = $this->dtgCustomField->RowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#FFFFFF';
     $objStyle->FontSize = 12;
     $objStyle = $this->dtgCustomField->AlternateRowStyle;
     $objStyle->BackColor = '#EFEFEF';
     $objStyle = $this->dtgCustomField->HeaderRowStyle;
     $objStyle->ForeColor = '#000000';
     $objStyle->BackColor = '#EFEFEF';
     $objStyle->CssClass = 'dtg_header';
 }
 /**
  * Used internally by the Meta-based Add Column tools.
  *
  * Given a QQNode or a Text String, this will return a CustomField-based QQNode.
  * It will also verify that it is a proper CustomField-based QQNode, and will throw an exception otherwise.
  *
  * @param mixed $mixContent
  * @return QQNode
  */
 protected function ResolveContentItem($mixContent)
 {
     if ($mixContent instanceof QQNode) {
         if (!$mixContent->_ParentNode) {
             throw new QCallerException('Content QQNode cannot be a Top Level Node');
         }
         if ($mixContent->_RootTableName == 'custom_field') {
             if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             }
             $objCurrentNode = $mixContent;
             while ($objCurrentNode = $objCurrentNode->_ParentNode) {
                 if (!$objCurrentNode instanceof QQNode) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
                 if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
             }
             return $mixContent;
         } else {
             throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "custom_field".');
         }
     } else {
         if (is_string($mixContent)) {
             switch ($mixContent) {
                 case 'CustomFieldId':
                     return QQN::CustomField()->CustomFieldId;
                 case 'CustomFieldQtypeId':
                     return QQN::CustomField()->CustomFieldQtypeId;
                 case 'DefaultCustomFieldValueId':
                     return QQN::CustomField()->DefaultCustomFieldValueId;
                 case 'DefaultCustomFieldValue':
                     return QQN::CustomField()->DefaultCustomFieldValue;
                 case 'ShortDescription':
                     return QQN::CustomField()->ShortDescription;
                 case 'ActiveFlag':
                     return QQN::CustomField()->ActiveFlag;
                 case 'RequiredFlag':
                     return QQN::CustomField()->RequiredFlag;
                 case 'AllAssetModelsFlag':
                     return QQN::CustomField()->AllAssetModelsFlag;
                 case 'SearchableFlag':
                     return QQN::CustomField()->SearchableFlag;
                 case 'CreatedBy':
                     return QQN::CustomField()->CreatedBy;
                 case 'CreatedByObject':
                     return QQN::CustomField()->CreatedByObject;
                 case 'CreationDate':
                     return QQN::CustomField()->CreationDate;
                 case 'ModifiedBy':
                     return QQN::CustomField()->ModifiedBy;
                 case 'ModifiedByObject':
                     return QQN::CustomField()->ModifiedByObject;
                 case 'ModifiedDate':
                     return QQN::CustomField()->ModifiedDate;
                 default:
                     throw new QCallerException('Simple Property not found in CustomFieldDataGrid content: ' . $mixContent);
             }
         } else {
             if ($mixContent instanceof QQAssociationNode) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             } else {
                 throw new QCallerException('Invalid Content type');
             }
         }
     }
 }
예제 #7
0
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     try {
         $arrRestrictedFields = array('asset code', 'model', 'category', 'manufacturer', 'location', 'assets', 'name', 'asset model code', 'inventory code', 'quantity', 'company name', 'city', 'state/province', 'country', 'title', 'company', 'email', 'address', 'shipment number', 'ship date', 'ship to company', 'ship to contact', 'ship to address', 'scheduled by', 'status', 'tracking', 'receipt number', 'receive from company', 'receive from contact', 'description', 'account', 'courier', 'account number', 'field name', 'type', 'enabled', 'required', 'role', 'username', 'user role', 'active', 'admin');
         $blnError = false;
         if ($this->chkRequiredFlag->Checked) {
             if ($this->lstCustomFieldQtype->SelectedValue != 2 && $this->txtDefaultValue->Text == '') {
                 $blnError = true;
                 $this->btnCancel->Warning = 'A custom field must have a default value if it is required.';
             }
         }
         if (count($this->lstEntityQtype->SelectedItems) == 0) {
             $blnError = true;
             $this->btnCancel->Warning = 'You must select at least one field in the Apply To list box.';
         }
         if (in_array(strtolower($this->txtShortDescription->Text), $arrRestrictedFields, false)) {
             $blnError = true;
             $this->btnCancel->Warning = sprintf("'%s' is a Tracmor restricted word. Please choose another name for this custom field", $this->txtShortDescription->Text);
         }
         if ($this->blnEditMode) {
             $objCustomFieldDuplicate = CustomField::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::CustomField()->ShortDescription, $this->txtShortDescription->Text), QQ::NotEqual(QQN::CustomField()->CustomFieldId, $this->objCustomField->CustomFieldId)));
         } else {
             $objCustomFieldDuplicate = CustomField::QuerySingle(QQ::Equal(QQN::CustomField()->ShortDescription, $this->txtShortDescription->Text));
         }
         if ($objCustomFieldDuplicate) {
             $blnError = true;
             $this->btnCancel->Warning = 'A custom field already exists with that name. Please choose another.';
         }
         if (!$blnError) {
             $this->UpdateCustomFieldFields();
             $this->objCustomField->Save();
             // If this field is a required field
             if ($this->objCustomField->RequiredFlag) {
                 // If this custom field is a text or textarea,
                 if ($this->lstCustomFieldQtype->SelectedValue != 2) {
                     // Assign the existing DefaultCustomFieldValue
                     if ($this->blnEditMode && $this->objCustomField->DefaultCustomFieldValueId) {
                         $objCustomFieldValue = CustomFieldValue::Load($this->objCustomField->DefaultCustomFieldValueId);
                     } else {
                         $objCustomFieldValue = new CustomFieldValue();
                         $objCustomFieldValue->CustomFieldId = $this->objCustomField->CustomFieldId;
                     }
                     // Save the new CustomFieldValue
                     $objCustomFieldValue->ShortDescription = $this->txtDefaultValue->Text;
                     $objCustomFieldValue->Save();
                     // Set the DefaultCustomFieldValueId of the custom field
                     $this->objCustomField->DefaultCustomFieldValueId = $objCustomFieldValue->CustomFieldValueId;
                 } elseif ($this->lstCustomFieldQtype->SelectedValue == 2) {
                     $this->objCustomField->DefaultCustomFieldValueId = $this->lstDefaultValue->SelectedValue;
                 }
                 // Save the custom field
                 $this->objCustomField->Save();
                 // Update the EntityQtypeCustomFields if they have changed (or if it is a new custom field
                 $this->UpdateEntityQtypeCustomFields();
                 // Update all of the CustomFieldSelections and values for the EntityQtypes
                 $this->objCustomField->UpdateRequiredFieldSelections();
             } else {
                 $this->objCustomField->DefaultCustomFieldValueId = null;
                 $this->objCustomField->Save();
                 $this->UpdateEntityQtypeCustomFields();
             }
             // If it is a new select Custom Field, then stay to add options
             if (!$this->blnEditMode && $this->objCustomField->CustomFieldQtypeId == 2) {
                 QApplication::Redirect('custom_field_edit.php?intCustomFieldId=' . $this->objCustomField->CustomFieldId);
             } else {
                 QApplication::Redirect('custom_field_list.php');
             }
         }
     } catch (QExtendedOptimisticLockingException $objExc) {
         $this->btnCancel->Warning = sprintf('This custom field has been updated by another user. You must <a href="custom_field_edit.php?intCustomFieldId=%s">Refresh</a> to edit this custom field.', $this->objCustomField->CustomFieldId);
     }
 }