Files
CRM/modules/Campaigns/models/Field.php
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

52 lines
1.8 KiB
PHP

<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
/**
* User Field Model Class
*/
class Campaigns_Field_Model extends Vtiger_Field_Model {
/**
* Function to get all the available picklist values for the current field
* @return <Array> List of picklist values if the field is of type picklist or multipicklist, null otherwise.
*/
public function getPicklistValues() {
if ($this->get('uitype') == '33') {
$db = PearDatabase::getInstance();
$table = $this->getFieldName();
$filed = $this->getFieldName();
if($this->getFieldName() == 'cf_1153') {
$table = 'products';
$filed = 'productname';
}
$query = 'SELECT '.$filed.' FROM vtiger_'.$table;
if($this->getFieldName() == 'cf_1155') {
$table = 'users';
$filed = 'username';
$query = 'SELECT CONCAT(first_name, " ", last_name) as username FROM vtiger_'.$table.' WHERE status = "Active"';
}
$result = $db->pquery($query, array());
$num_rows = $db->num_rows($result);
$fieldPickListValues = array();
for($i=0; $i<$num_rows; $i++) {
$picklistValue = $db->query_result($result,$i,$filed);
$fieldPickListValues[$picklistValue] = vtranslate($picklistValue,$this->getModuleName());
}
return $fieldPickListValues;
}
return parent::getPicklistValues();
}
}