From 455d64476dffda501e56cead4bd7fad6624900a8 Mon Sep 17 00:00:00 2001 From: satish <satish.dvnk@vtiger.com> Date: Tue, 7 Feb 2017 15:48:59 +0530 Subject: [PATCH] Show picklist color as background color for picklist value in Edit / Create view --- layouts/v7/modules/Vtiger/uitypes/Picklist.tpl | 18 ++++++++++-------- modules/Vtiger/models/Field.php | 12 +++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl b/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl index f5412d3a1..7eb5c880a 100644 --- a/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl @@ -24,12 +24,14 @@ <option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if $PICKLIST_COLORS[$PICKLIST_NAME]}class="{$CLASS_NAME}"{/if} {if trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option> {/foreach} </select> -<style type="text/css"> - {foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$PICKLIST_VALUES} - {assign var=CLASS_NAME value="{$FIELD_MODEL->getFieldName()}_{$PICKLIST_NAME|replace:' ':'_'}"} - .picklistColor_{$CLASS_NAME} { - background-color: {$PICKLIST_COLORS[$PICKLIST_NAME]} !important; - } - {/foreach} -</style> +{if $PICKLIST_COLORS} + <style type="text/css"> + {foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$PICKLIST_VALUES} + {assign var=CLASS_NAME value="{$FIELD_MODEL->getFieldName()}_{$PICKLIST_NAME|replace:' ':'_'}"} + .picklistColor_{$CLASS_NAME} { + background-color: {$PICKLIST_COLORS[$PICKLIST_NAME]} !important; + } + {/foreach} + </style> +{/if} {/strip} diff --git a/modules/Vtiger/models/Field.php b/modules/Vtiger/models/Field.php index 944892bc3..d8a607979 100644 --- a/modules/Vtiger/models/Field.php +++ b/modules/Vtiger/models/Field.php @@ -1321,11 +1321,13 @@ class Vtiger_Field_Model extends Vtiger_Field { if (!in_array($fieldName, array('hdnTaxType', 'region_id'))) { $db = PearDatabase::getInstance(); $picklistValues = $this->getPicklistValues(); - - if (is_array($picklistValues)) { - $result = $db->pquery("SELECT $fieldName, color FROM vtiger_$fieldName WHERE $fieldName IN (".generateQuestionMarks($picklistValues).")", array_keys($picklistValues)); - while ($row = $db->fetch_row($result)) { - $picklistColors[$row[$fieldName]] = $row['color']; + $tableName = "vtiger_$fieldName"; + if (Vtiger_Utils::CheckTable($tableName)) { + if (is_array($picklistValues)) { + $result = $db->pquery("SELECT $fieldName, color FROM $tableName WHERE $fieldName IN (".generateQuestionMarks($picklistValues).")", array_keys($picklistValues)); + while ($row = $db->fetch_row($result)) { + $picklistColors[$row[$fieldName]] = $row['color']; + } } } } -- GitLab