Skip to content
Snippets Groups Projects
Commit 455d6447 authored by Satish's avatar Satish
Browse files

Show picklist color as background color for picklist value in Edit / Create view

parent 4870f1f5
No related branches found
No related tags found
No related merge requests found
......@@ -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}
......@@ -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'];
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment