diff --git a/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl b/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl index f5412d3a1cef4706c664d0255dad0a786a167cc4..7eb5c880ac947e1db0b16616fe34a069f2c75139 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 944892bc3beddb33add76a9719b2994a5c975070..d8a607979a71bfd8dd42834a2683b95c461d6e2a 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']; + } } } }