public static function getValuesFromField($fieldName) { $db = PearDatabase::getInstance(); $primaryKey = Vtiger_Util_Helper::getPickListId($fieldName); $query = 'SELECT * FROM vtiger_' . $fieldName . ' order by sortorderid'; $values = array(); $result = $db->pquery($query, array()); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { //Need to decode the picklist values twice which are saved from old ui $groupColors[] = array('id' => $db->query_result($result, $i, $primaryKey), 'value' => decode_html(decode_html($db->query_result($result, $i, $fieldName))), 'color' => $db->query_result($result, $i, 'color')); } return $groupColors; }
/** * Function which will give the picklist values for a field * @param type $fieldName -- string * @return type -- array of values */ public static function getPickListValues($fieldName) { $cache = Vtiger_Cache::getInstance(); if($cache->getPicklistValues($fieldName)) { return $cache->getPicklistValues($fieldName); } $db = PearDatabase::getInstance(); $primaryKey = Vtiger_Util_Helper::getPickListId($fieldName); $query = 'SELECT '.$primaryKey.', '.$fieldName.' FROM vtiger_'.$fieldName.' order by sortorderid'; $values = array(); $result = $db->pquery($query, array()); $num_rows = $db->num_rows($result); for($i=0; $i<$num_rows; $i++) { //Need to decode the picklist values twice which are saved from old ui $values[$db->query_result($result,$i,$primaryKey)] = decode_html(decode_html($db->query_result($result,$i,$fieldName))); } $cache->setPicklistValues($fieldName, $values); return $values; }
public function updateSequence($pickListFieldName, $picklistValues) { $db = PearDatabase::getInstance(); $primaryKey = Vtiger_Util_Helper::getPickListId($pickListFieldName); $query = 'UPDATE ' . $this->getPickListTableName($pickListFieldName) . ' SET sortorderid = CASE '; foreach ($picklistValues as $values => $sequence) { $query .= ' WHEN ' . $primaryKey . '="' . $values . '" THEN "' . $sequence . '"'; } $query .= ' END'; $db->pquery($query, array()); }
/** * Function which will give the picklist values for a field * @param type $fieldName -- string * @return type -- array of values */ public static function getPickListValues($fieldName) { $cache = Vtiger_Cache::getInstance(); if ($cache->getPicklistValues($fieldName)) { return $cache->getPicklistValues($fieldName); } $db = PearDatabase::getInstance(); $primaryKey = Vtiger_Util_Helper::getPickListId($fieldName); $query = 'SELECT ' . $primaryKey . ', ' . $fieldName . ' FROM vtiger_' . $fieldName . ' order by sortorderid'; $values = []; $result = $db->query($query); while ($row = $db->fetch_array($result)) { $values[$row[$primaryKey]] = decode_html(decode_html($row[$fieldName])); } $cache->setPicklistValues($fieldName, $values); return $values; }
/** * Function which will give the non editable picklist values for a field * @param type $fieldName -- string * @return type -- array of values */ public static function getNonEditablePicklistValues($fieldName) { $cache = Vtiger_Cache::getInstance(); $NonEditablePicklistValues = $cache->get('NonEditablePicklistValues', $fieldName); if ($NonEditablePicklistValues) { return $NonEditablePicklistValues; } $db = PearDatabase::getInstance(); //SalesPlatform.ru begin fix picklist value unique id cretation $primaryKey = Vtiger_Util_Helper::getPickListId($fieldName); $query = "select {$primaryKey} ,{$fieldName} from vtiger_{$fieldName} where presence=0"; //$query = "select $fieldName from vtiger_$fieldName where presence=0"; //SalesPlatform.ru end $values = array(); $result = $db->pquery($query, array()); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { //Need to decode the picklist values twice which are saved from old ui //SalesPlatform.ru begin fix picklist value unique id cretation $values[$db->query_result($result, $i, $primaryKey)] = decode_html(decode_html($db->query_result($result, $i, $fieldName))); //$values[] = decode_html(decode_html($db->query_result($result,$i,$fieldName))); //SalesPlatform.ru end } $cache->set('NonEditablePicklistValues', $fieldName, $values); return $values; }
/** * Function which will give the editable picklist values for a field * @param type $fieldName -- string * @return type -- array of values */ public static function getEditablePicklistValues($fieldName) { $cache = Vtiger_Cache::getInstance(); $EditablePicklistValues = $cache->get('EditablePicklistValues', $fieldName); if ($EditablePicklistValues) { return $EditablePicklistValues; } $db = PearDatabase::getInstance(); $primaryKey = Vtiger_Util_Helper::getPickListId($fieldName); $query = "SELECT {$primaryKey} ,{$fieldName} FROM vtiger_{$fieldName} WHERE presence=1 AND {$fieldName} <> '--None--'"; $values = array(); $result = $db->pquery($query, array()); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { //Need to decode the picklist values twice which are saved from old ui $values[$db->query_result($result, $i, $primaryKey)] = decode_html(decode_html($db->query_result($result, $i, $fieldName))); } $cache->set('EditablePicklistValues', $fieldName, $values); return $values; }