本文整理汇总了PHP中CustomField::QuerySingle方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::QuerySingle方法的具体用法?PHP CustomField::QuerySingle怎么用?PHP CustomField::QuerySingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomField
的用法示例。
在下文中一共展示了CustomField::QuerySingle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadByCustomFieldId
/**
* Load a single CustomField object,
* by CustomFieldId Index(es)
* @param integer $intCustomFieldId
* @return CustomField
*/
public static function LoadByCustomFieldId($intCustomFieldId)
{
return CustomField::QuerySingle(QQ::Equal(QQN::CustomField()->CustomFieldId, $intCustomFieldId));
}
示例2: btnSave_Click
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');
//.........这里部分代码省略.........
示例3: LoadByCustomFieldId
/**
* Load a single CustomField object,
* by CustomFieldId Index(es)
* @param integer $intCustomFieldId
* @return CustomField
*/
public static function LoadByCustomFieldId($intCustomFieldId, $objOptionalClauses = null)
{
return CustomField::QuerySingle(QQ::Equal(QQN::CustomField()->CustomFieldId, $intCustomFieldId), $objOptionalClauses);
}
示例4: btnSave_Click
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);
}
}