Inheritance: extends Elegant
 /**
  * Save CustomField
  * @param CustomField $customField
  * @returns CustomField
  * @throws DaoException, DataDuplicationException
  */
 public function saveCustomField(CustomField $customField)
 {
     try {
         $q = Doctrine_Query::create()->from('CustomField c')->where('c.name = ?', $customField->name)->andWhere('c.id <> ?', $customField->id);
         $freeNum = null;
         if (empty($customField->id)) {
             $q = Doctrine_Query::create()->select('c.field_num')->from('CustomField c')->orderBy('id');
             $fieldNumbers = $q->execute(array(), Doctrine::HYDRATE_SCALAR);
             $count = count($fieldNumbers);
             $i = 1;
             foreach ($fieldNumbers as $num) {
                 if ($num['c_id'] > $i) {
                     $freeNum = $i;
                     break;
                 }
                 $i++;
                 if ($i > 10) {
                     break;
                 }
             }
             if (empty($freeNum) && $i <= 10) {
                 $freeNum = $i;
             }
             $customField->id = $freeNum;
         }
         if (!empty($customField->id)) {
             $customField->save();
         }
         return $customField;
         // @codeCoverageIgnoreStart
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
     // @codeCoverageIgnoreEnd
 }
 public function testSaveCustomField()
 {
     $customField = new CustomField();
     $customField->setName('Hobby');
     $customField->setType(0);
     $customField->setScreen('personal');
     $result = $this->customFieldConfigurationDao->saveCustomField($customField);
     $this->assertTrue($result instanceof CustomField);
     $this->assertEquals('Hobby', $result->getName());
     $this->assertEquals(6, $result->getId());
 }
 public function getFieldinput($custom_field_id)
 {
     $campoextra = CustomField::find($custom_field_id);
     $customfield = $campoextra->getCustomFieldInstance();
     $data['customfield'] = $customfield;
     return View::make('backend/customfields/inputs/' . $campoextra->type, $data);
 }
 protected function addField($row)
 {
     $field = CustomField::constructObject($row);
     if ($field != null) {
         $this->fields[$row['position']][$field->getFieldName()] = $field;
     }
 }
 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();
 }
 /**
  * initializes the default class attributes
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['subtype'] = self::SUBTYPE;
     $this->show_on_register = 'no';
     $this->mandatory = 'no';
     $this->user_editable = 'yes';
 }
Exemple #7
0
 function delete()
 {
     parent::delete();
     G::load($relatedFields, array("SELECT * FROM @customfield WHERE userField=#id#", $this->id));
     foreach ($relatedFields as $f) {
         $f->delete();
     }
 }
 function beforeFind(&$queryData)
 {
     $ret = parent::beforeFind($queryData);
     if (is_array($ret)) {
         $queryData = $ret;
     }
     if ($queryData['conditions'] == null) {
         $queryData['conditions'] = array();
     }
     $queryData['conditions'][$this->name . '.type'] = $this->name;
     return $queryData;
 }
 /**
  * Delete custom fields
  * @param $request
  * @return unknown_type
  */
 public function execute($request)
 {
     $admin = $this->getUser()->hasCredential(Auth::ADMIN_ROLE);
     if (!$admin) {
         $this->forward("auth", "unauthorized");
         return;
     }
     $form = new CustomFieldForm(array(), array(), true);
     $customFieldsService = $this->getCustomFieldService();
     if ($request->isMethod('post')) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             $fieldNum = $form->getValue('field_num');
             $customField = null;
             if (isset($fieldNum)) {
                 $customField = $customFieldsService->getCustomField($fieldNum);
             }
             if (empty($customField)) {
                 $customField = new CustomField();
             }
             $customField->setName($form->getValue('name'));
             $customField->setType($form->getValue('type'));
             $customField->setScreen($form->getValue('screen'));
             $customField->setExtraData($form->getValue('extra_data'));
             $customFieldsService->saveCustomField($customField);
             $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS)));
         }
     }
     $this->redirect('pim/listCustomFields');
 }
 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);
     }
 }
 public function suggest()
 {
     $data = array();
     $id = Request::get(1, VAR_INT);
     $q = Request::get('q');
     $q = SystemEnvironment::fromUtf8($q);
     $db = Database::getObject();
     $db->query("SELECT * FROM <p>fields WHERE id = <id:int>", compact("id"));
     if ($db->numRows() == 1) {
         $field = CustomField::constructObject($db->fetchAssoc());
         if ($field instanceof CustomAutoCompleteTextField) {
             $data = $field->getList($q);
         }
     }
     Response::getObject()->sendHeader('Content-Type: text/plain; charset=' . Config::get('intl.charset'));
     echo implode("\n", $data);
 }
 public static function updateValueByDataIdAndOldValueAndNewValue($customFieldDataId, $oldValue, $newValue)
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     $customFieldTableName = CustomField::getTableName();
     $baseCustomFieldTableName = BaseCustomField::getTableName();
     $baseCustomFieldJoinColumnName = $baseCustomFieldTableName . '_id';
     $valueAttributeColumnName = 'value';
     $dataAttributeColumnName = static::getForeignKeyName('BaseCustomField', 'data');
     $sql = "update {$quote}{$customFieldTableName}{$quote}, {$quote}{$baseCustomFieldTableName}{$quote} ";
     $sql .= "set {$quote}{$valueAttributeColumnName}{$quote} = '{$newValue}' ";
     $sql .= "where {$quote}{$customFieldTableName}{$quote}.{$baseCustomFieldJoinColumnName} = ";
     // Not Coding Standard
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id ";
     $sql .= "AND {$quote}{$dataAttributeColumnName}{$quote} = {$customFieldDataId} ";
     $sql .= "AND {$quote}{$valueAttributeColumnName}{$quote} = '{$oldValue}'";
     ZurmoRedBean::exec($sql);
 }
Exemple #13
0
 /**
  * Create a new instance and populate its properties with JSON data
  * @param array $jsonData
  * @return \moosend\Models\Subscriber
  */
 public static function withJSON(array $jsonData)
 {
     $instance = new self();
     $instance->ID = $jsonData['ID'];
     $instance->Name = $jsonData['Name'];
     $instance->Email = $jsonData['Email'];
     $instance->CreatedOn = $jsonData['CreatedOn'];
     $instance->UpdatedOn = $jsonData['UpdatedOn'];
     $instance->UnsubscribedOn = $jsonData['UnsubscribedOn'];
     $instance->UnsubscribedFromID = $jsonData['UnsubscribedFromID'];
     $instance->SubscribeType = $jsonData['SubscribeType'];
     $instance->CustomFields = array();
     foreach ($jsonData['CustomFields'] as $field) {
         $customField = CustomField::withJSON($field);
         array_push($instance->CustomFields, $customField);
     }
     return $instance;
 }
 protected function SetupCustomField()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intCustomFieldId = QApplication::QueryString('intCustomFieldId');
     if ($intCustomFieldId) {
         $this->objCustomField = CustomField::Load($intCustomFieldId);
         if (!$this->objCustomField) {
             throw new Exception('Could not find a CustomField object with PK arguments: ' . $intCustomFieldId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objCustomField = new CustomField();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
    public static function LoadAllWithCustomFields($strOrderBy = null, $strLimit = null, $objExpansionMap = null)
    {
        Manufacturer::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $strExpandSelect, $strExpandFrom, $objExpansionMap, $objDatabase);
        // Setup QueryExpansion
        $objQueryExpansion = new QQueryExpansion();
        if ($objExpansionMap) {
            try {
                Manufacturer::ExpandQuery('manufacturer', null, $objExpansionMap, $objQueryExpansion);
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }
        }
        $arrCustomFieldSql = CustomField::GenerateSql(5);
        $strQuery = sprintf('
				SELECT
					%s
					`manufacturer`.`manufacturer_id` AS `manufacturer_id`,
					`manufacturer`.`short_description` AS `short_description`,
					`manufacturer`.`long_description` AS `long_description`,
					`manufacturer`.`image_path` AS `image_path`,
					`manufacturer`.`created_by` AS `created_by`,
					`manufacturer`.`creation_date` AS `creation_date`,
					`manufacturer`.`modified_by` AS `modified_by`,
					`manufacturer`.`modified_date` AS `modified_date`
					%s
					%s
				FROM
					`manufacturer` AS `manufacturer`
					%s
					%s
				WHERE
				1=1
				%s
				%s
			', $strLimitPrefix, $objQueryExpansion->GetSelectSql(",\n\t\t\t\t\t", ",\n\t\t\t\t\t"), $arrCustomFieldSql['strSelect'], $objQueryExpansion->GetFromSql("", "\n\t\t\t\t\t"), $arrCustomFieldSql['strFrom'], $strOrderBy, $strLimitSuffix);
        //echo($strQuery); exit;
        $objDbResult = $objDatabase->Query($strQuery);
        return Manufacturer::InstantiateDbResult($objDbResult);
    }
Exemple #16
0
 public function testValidation()
 {
     $f = new CustomField();
     $f->name = 'Id';
     $f->format = 'IP';
     $f->element = "text";
     /*$this->assertDoesntThrow(function () {
         $f->save();
       });*/
     $this->assertFalse(CustomField::saving($f));
     //horrible hacky workaround to even problems
     //for Laravel testing. Blech.
     $g = new CustomField();
     $g->name = 'totally_unique_name';
     $g->format = 'IP';
     $g->element = "text";
     //$this->assertTrue($g->validate($g->toArray()));
     $this->assertTrue(CustomField::saving($g));
     /*$this->assertThrows(function () {
         $f->save();
       });*/
 }
Exemple #17
0
 protected function Form_PreRender()
 {
     $objExpansionMap[CustomField::ExpandCreatedByObject] = true;
     // Get Total Count b/c of Pagination
     $this->dtgCustomField->TotalItemCount = CustomField::CountAll();
     if ($this->dtgCustomField->TotalItemCount == 0) {
         $this->dtgCustomField->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = $this->dtgCustomField->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgCustomField->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::CustomField()->CreatedByObject)) {
             array_push($objClauses, $objClause);
         }
         $this->dtgCustomField->DataSource = CustomField::LoadAll($objClauses);
         $this->dtgCustomField->ShowHeader = true;
     }
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof DropDownAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $defaultValueOrder = $attributeForm->defaultValueOrder;
     $elementType = $attributeForm->getAttributeTypeName();
     $partialTypeRule = $attributeForm->getModelAttributePartialRule();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $customFieldDataName = $attributeForm->customFieldDataName;
     if ($customFieldDataName == null) {
         $customFieldDataName = ucfirst(strtolower($attributeForm->attributeName));
         //should we do something else instead?
     }
     $customFieldDataData = $attributeForm->customFieldDataData;
     $customFieldDataLabels = $attributeForm->customFieldDataLabels;
     $defaultValue = DropDownDefaultValueOrderUtil::getDefaultValueFromDefaultValueOrder($defaultValueOrder, $customFieldDataData);
     ModelMetadataUtil::addOrUpdateCustomFieldRelation($modelClassName, $attributeName, $attributeLabels, $defaultValue, $isRequired, $isAudited, $elementType, $customFieldDataName, $customFieldDataData, $customFieldDataLabels);
     if ($attributeForm->getCustomFieldDataId() != null) {
         $oldAndNewValuePairs = array();
         foreach ($attributeForm->customFieldDataData as $order => $newValue) {
             if (isset($attributeForm->customFieldDataDataExistingValues[$order]) && $attributeForm->customFieldDataDataExistingValues[$order] != $newValue) {
                 CustomField::updateValueByDataIdAndOldValueAndNewValue($attributeForm->getCustomFieldDataId(), $attributeForm->customFieldDataDataExistingValues[$order], $newValue);
                 $oldValue = $attributeForm->customFieldDataDataExistingValues[$order];
                 $oldAndNewValuePairs[$oldValue] = $newValue;
             }
         }
         if (count($oldAndNewValuePairs) > 0) {
             DropDownDependencyDerivedAttributeDesignerUtil::updateValueInMappingByOldAndNewValue($modelClassName, $attributeName, $oldAndNewValuePairs, $attributeForm->customFieldDataDataExistingValues[$order], $newValue);
         }
         DropDownDependencyDerivedAttributeDesignerUtil::resolveValuesInMappingWhenValueWasRemoved($modelClassName, $attributeName, $attributeForm->customFieldDataData);
     }
     $this->resolveDatabaseSchemaForModel($modelClassName);
 }
Exemple #19
0
 protected function DisplayInputs()
 {
     // Hide labels
     $this->lblFromCompany->Display = false;
     $this->lblFromContact->Display = false;
     $this->lblToContact->Display = false;
     $this->lblToAddress->Display = false;
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         $this->lblReceiptNumber->Display = false;
     }
     $this->pnlNote->Display = false;
     $this->lblDueDate->Display = false;
     $this->btnEdit->Display = false;
     $this->btnDelete->Display = false;
     $this->atcAttach->btnUpload->Display = false;
     if ($this->blnEditMode) {
         $this->dtgAssetTransact->RemoveColumnByName('&nbsp;');
         $this->dtgInventoryTransact->RemoveColumnByName('&nbsp;');
     }
     // Display inputs
     $this->lstFromCompany->Display = true;
     $this->lstFromContact->Display = true;
     $this->lstToContact->Display = true;
     $this->lstToAddress->Display = true;
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         $this->txtReceiptNumber->Display = true;
     }
     $this->txtNote->Display = true;
     $this->calDueDate->Display = true;
     if (!$this->objReceipt->ReceivedFlag) {
         $this->rblAssetType->SelectedIndex = 0;
         $this->rblAssetType->Display = true;
         $this->txtNewAssetCode->Text = '';
         $this->txtNewAssetCode->Enabled = true;
         $this->txtNewAssetCode->Display = true;
         $this->lstAssetModel->SelectedIndex = 0;
         $this->lstAssetModel->Display = false;
         $this->chkAutoGenerateAssetCode->Checked = false;
         $this->chkAutoGenerateAssetCode->Display = false;
         $this->btnAddAsset->Display = true;
         $this->lblAddAsset->Display = true;
         if ($this->blnShowInventory) {
             $this->txtNewInventoryModelCode->Display = true;
             $this->txtQuantity->Display = true;
             $this->lblLookup->Display = true;
             $this->btnAddInventory->Display = true;
         }
         $this->dtgAssetTransact->AddColumn(new QDataGridColumn('&nbsp;', '<?= $_FORM->RemoveAssetColumn_Render($_ITEM) ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false)));
         $this->dtgInventoryTransact->AddColumn(new QDataGridColumn('&nbsp;', '<?= $_FORM->RemoveInventoryColumn_Render($_ITEM) ?>', array('CssClass' => "dtg_column", 'HtmlEntities' => false)));
     } else {
         if ($this->blnEditMode) {
             $this->calDateReceived->DateTime = $this->objReceipt->ReceiptDate;
             $this->calDateReceived->Display = true;
             $this->lblReceiptDate->Display = false;
         }
     }
     $this->lblNewFromCompany->Display = true;
     $this->lblNewFromContact->Display = true;
     $this->lblNewToContact->Display = true;
     $this->lblNewToAddress->Display = true;
     //If the user is not authorized to edit built-in fields, the fields are render as labels.
     if (!$this->blnEditBuiltInFields) {
         $this->DisplayLabels();
     }
     $this->btnSave->Display = true;
     $this->btnCancel->Display = true;
     // Display custom field inputs
     if ($this->arrCustomFields) {
         CustomField::DisplayInputs($this->arrCustomFields);
     }
 }
 public function __construct($options = null, $id = null, $name = null, $description = null, $isActive = null, $entityType = null, $dataType = null, $visibility = null)
 {
     parent::__construct();
     $this->options = $options;
     $this->id = $id;
     $this->name = $name;
     $this->description = $description;
     $this->isActive = $isActive;
     $this->entityType = $entityType;
     $this->dataType = $dataType;
     $this->visibility = $visibility;
 }
 public function __construct($options = NULL, $id = NULL, $name = NULL, $description = NULL, $isActive = NULL, $entityType = NULL, $dataType = NULL, $visibility = NULL, $CustomFieldType = NULL)
 {
     if (get_parent_class('DropDownCustomField')) {
         parent::__construct();
     }
     $this->options = $options;
     $this->id = $id;
     $this->name = $name;
     $this->description = $description;
     $this->isActive = $isActive;
     $this->entityType = $entityType;
     $this->dataType = $dataType;
     $this->visibility = $visibility;
     $this->CustomFieldType = $CustomFieldType;
 }
Exemple #22
0
    $options_list = $_REQUEST['option'];
    $count = 0;
    foreach ($options_list as $option) {
        if ($option == "") {
            $count++;
            continue;
        }
        $options_csv .= trim($option);
        $count++;
        if ($count != count($options_list)) {
            $options_csv .= "/";
        }
    }
} else {
    if (isset($_REQUEST['range_lower'])) {
        $range_lower = trim($_REQUEST['range_lower']);
        $range_upper = trim($_REQUEST['range_upper']);
        $unit = trim($_REQUEST['unit']);
        $options_csv = $range_lower . ":" . $range_upper . ":" . $unit;
    }
}
$updated_entry = new CustomField();
$updated_entry->id = $field_id;
$updated_entry->fieldName = $field_name;
$updated_entry->fieldOptions = $options_csv;
if ($del == "Delete") {
    CustomField::deleteById($updated_entry, $lab_config_id, $type);
    FieldOrdering::deleteFieldOrderEntry($lab_config_id, 1);
} else {
    CustomField::updateById($updated_entry, $lab_config_id, $type, $offset);
}
	function CustomNumber() {
		parent::CustomField(2,"CustomNumber");
	}
Exemple #24
0
 function tranformEnumValuesInner($field)
 {
     CustomField::tranformEnumValuesForClass($field, "item", __FILE__, __LINE__);
     CustomField::tranformEnumValuesForClass($field, "search", __FILE__, __LINE__);
 }
 /**
  * Internally called method to assist with early binding of objects
  * on load methods.  Can only early-bind references that this class owns in the database.
  * @param string $strParentAlias the alias of the parent (if any)
  * @param string $strAlias the alias of this object
  * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding
  * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion)
  */
 public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion)
 {
     if ($strAlias) {
         $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `asset_custom_field_asset_model` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`asset_custom_field_asset_model_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`asset_custom_field_asset_model_id` AS `%s__%s__asset_custom_field_asset_model_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`asset_model_id` AS `%s__%s__asset_model_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`custom_field_id` AS `%s__%s__custom_field_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $strParentAlias = $strParentAlias . '__' . $strAlias;
     }
     if (is_array($objExpansionMap)) {
         foreach ($objExpansionMap as $strKey => $objValue) {
             switch ($strKey) {
                 case 'asset_model_id':
                     try {
                         AssetModel::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 case 'custom_field_id':
                     try {
                         CustomField::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 default:
                     throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey));
             }
         }
     }
 }
Exemple #26
0
 protected static function GenerateSearchSql($strFirstName, $strLastName = null, $strCompany = null, $arrCustomFields = null, $strDateModified = null, $strDateModifiedFirst = null, $strDateModifiedLast = null, $blnAttachment = null)
 {
     $arrSearchSql = array("strFirstNameSql" => "", "strLastNameSql" => "", "strCompanySql" => "", "strCustomFieldsSql" => "", "strDateModifiedSql" => "", "strAttachmentSql" => "", "strAuthorizationSql" => "");
     if ($strFirstName) {
         // Properly Escape All Input Parameters using Database->SqlVariable()
         $strFirstName = QApplication::$Database[1]->SqlVariable("%" . $strFirstName . "%", false);
         $arrSearchSql['strFirstNameSql'] = "AND `contact` . `first_name` LIKE {$strFirstName}";
     }
     if ($strLastName) {
         // Properly Escape All Input Parameters using Database->SqlVariable()
         $strLastName = QApplication::$Database[1]->SqlVariable("%" . $strLastName . "%", false);
         $arrSearchSql['strLastNameSql'] = "AND `contact` . `last_name` LIKE {$strLastName}";
     }
     if ($strCompany) {
         // Properly Escape All Input Parameters using Database->SqlVariable()
         $strCompany = QApplication::$Database[1]->SqlVariable("%" . $strCompany . "%", false);
         $arrSearchSql['strCompanySql'] = "AND `contact__company_id` . `short_description` LIKE {$strCompany}";
     }
     if ($strDateModified) {
         if ($strDateModified == "before" && $strDateModifiedFirst instanceof QDateTime) {
             $strDateModifiedFirst = QApplication::$Database[1]->SqlVariable($strDateModifiedFirst->Timestamp, false);
             $arrSearchSql['strDateModifiedSql'] = sprintf("AND UNIX_TIMESTAMP(`contact`.`modified_date`) < %s", $strDateModifiedFirst);
         } elseif ($strDateModified == "after" && $strDateModifiedFirst instanceof QDateTime) {
             $strDateModifiedFirst = QApplication::$Database[1]->SqlVariable($strDateModifiedFirst->Timestamp, false);
             $arrSearchSql['strDateModifiedSql'] = sprintf("AND UNIX_TIMESTAMP(`contact`.`modified_date`) > %s", $strDateModifiedFirst);
         } elseif ($strDateModified == "between" && $strDateModifiedFirst instanceof QDateTime && $strDateModifiedLast instanceof QDateTime) {
             $strDateModifiedFirst = QApplication::$Database[1]->SqlVariable($strDateModifiedFirst->Timestamp, false);
             // Added 86399 (23 hrs., 59 mins., 59 secs) because the After variable needs to include the date given
             // When only a date is given, conversion to a timestamp assumes 12:00am
             $strDateModifiedLast = QApplication::$Database[1]->SqlVariable($strDateModifiedLast->Timestamp, false) + 86399;
             $arrSearchSql['strDateModifiedSql'] = sprintf("AND UNIX_TIMESTAMP(`contact`.`modified_date`) > %s", $strDateModifiedFirst);
             $arrSearchSql['strDateModifiedSql'] .= sprintf("\nAND UNIX_TIMESTAMP(`contact`.`modified_date`) < %s", $strDateModifiedLast);
         }
     }
     if ($blnAttachment) {
         $arrSearchSql['strAttachmentSql'] = sprintf("AND attachment.attachment_id IS NOT NULL");
     }
     if ($arrCustomFields) {
         $arrSearchSql['strCustomFieldsSql'] = CustomField::GenerateSearchHelperSql($arrCustomFields, EntityQtype::Contact);
     }
     // Generate Authorization SQL based on the QApplication::$objRoleModule
     $arrSearchSql['strAuthorizationSql'] = QApplication::AuthorizationSql('REPLACE!!!!');
     return $arrSearchSql;
 }
 /**
  * @depends testSetAttributesWithPostForCustomField
  */
 public function testUpdateValueOnCustomFieldRows()
 {
     $values = array('A', 'B', 'C');
     $customFieldData = CustomFieldData::getByName('updateItems');
     $customFieldData->serializedData = serialize($values);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     $customField = new CustomField();
     $customField->value = 'A';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'B';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $quote = DatabaseCompatibilityUtil::getQuote();
     $customFieldTableName = CustomField::getTableName();
     $baseCustomFieldTableName = BaseCustomField::getTableName();
     $valueAttributeColumnName = 'value';
     $dataAttributeColumnName = RedBeanModel::getForeignKeyName('CustomField', 'data');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id}";
     $ids = ZurmoRedBean::getCol($sql);
     $beans = ZurmoRedBean::batch($customFieldTableName, $ids);
     $customFields = RedBeanModel::makeModels($beans, 'CustomField');
     $this->assertEquals(4, count($customFields));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     CustomField::updateValueByDataIdAndOldValueAndNewValue($id, 'C', 'E');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
 }
Exemple #28
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');
 }
Exemple #29
0
 protected function DisplayInputs()
 {
     // Do not display labels
     $this->lblShortDescription->Display = false;
     $this->lblAddress1->Display = false;
     $this->lblAddress2->Display = false;
     $this->lblCity->Display = false;
     $this->lblStateProvince->Display = false;
     $this->lblCountry->Display = false;
     $this->lblPostalCode->Display = false;
     // Do not display Edit and Delete buttons
     $this->btnEdit->Display = false;
     $this->btnDelete->Display = false;
     $this->atcAttach->btnUpload->Display = false;
     // Display inputs
     $this->txtShortDescription->Display = true;
     $this->txtAddress1->Display = true;
     $this->txtAddress2->Display = true;
     $this->txtCity->Display = true;
     $this->lstStateProvince->Display = true;
     $this->lstCountry->Display = true;
     $this->txtPostalCode->Display = true;
     //If the user is not authorized to edit built-in fields, the fields are render as labels.
     if (!$this->blnEditBuiltInFields) {
         $this->DisplayLabels();
     }
     // Display custom field inputs
     if ($this->arrCustomFields) {
         CustomField::DisplayInputs($this->arrCustomFields);
     }
     // Display Cancel and Save buttons
     $this->btnCancel->Display = true;
     $this->btnSave->Display = true;
 }
Exemple #30
0
 public function getCustomFields($type)
 {
     $customField = new CustomField();
     $data = $customField->Find("type = ?", array($type));
     return $data;
 }