我有一个重复的表格行:
<h3>{sugarCRM_translate label='LBL_RPT_GROUP_BY_EMPLOYEES' module='Opportunities'}</h3>
<table cellspacing="0" cellpadding="0" border="0" class="list view gird" width="100%">
<tr>
<th width="13%">{sugarCRM_translate label='LBL_LIST_NAME' module='Employees'}</td>
<th width="7%">{sugarCRM_translate label='LBL_LIST_DEPARTMENT' module='Employees'}</td>
<th scope="col">{sugarCRM_translate label='LBL_MONTHLY_TARGET' module='Opportunities'}</th>
<th scope="col">{$labelActual}</th>
<th scope="col">{sugarCRM_translate label='LBL_RPT_COMPLETED_PERCENT' module='Opportunities'}</th>
<th scope="col">{$labelMissing}</th>
</tr>
{counter start=0 name="rowCounter" print=false assign="rowCounter"}
{foreach name=rowEmpl from=$employees key=id item=row}
{if $smarty.foreach.rowEmpl.iteration is odd}
{assign var='_rowColor' value=$rowColor[0]}
{else}
{assign var='_rowColor' value=$rowColor[1]}
{/if}
{counter name="rowCounter"}
<tr class="{$_rowColor}S1">
<td>{$row.name}</td>
<td>{$row.department}</td>
<td align="right">{$row.MonthlyTarget|format_number}</td>
<td align="right">{$row.ActualAmount|format_number}</td>
<td align="center">{$row.PercentTarget}%</td>
<td align="right">{$row.MissingAmount|format_number}</td>
</tr>
{/foreach}
</table>
我的问题:
我需要在bgcolor
时更改包含MissingAmount
为红色的$row.MissingAmount >=0
,并在$row.MissingAmount < 0
时将其更改为蓝色。
我该怎么做?
答案 0 :(得分:0)
我希望这会有所帮助尝试这个
<td align="right" if({$row.MissingAmount0}>0){style="background: blue"} elseif({$row.MissingAmount}<0){style="background: red"} >{$row.MissingAmount|format_number}</td>
答案 1 :(得分:0)
我修好了它:
{counter start=0 name="rowCounter" print=false assign="rowCounter"}
{foreach name=rowEmpl from=$employees key=id item=row}
{if $smarty.foreach.rowEmpl.iteration is odd}
{assign var='_rowColor' value=$rowColor[0]}
{else}
{assign var='_rowColor' value=$rowColor[1]}
{/if}
{if $row.MissingAmount >= 0}
{assign var='_Color' value="green"}
{else}
{assign var='_Color' value="red"}
{/if}
{counter name="rowCounter"}
<tr class="{$_rowColor}S1">
<td>{$row.name}</td>
<td>{$row.department}</td>
<td align="right">{$row.MonthlyTarget|format_number}</td>
<td align="right">{$row.ActualAmount|format_number}</td>
<td align="center">{$row.PercentTarget}%</td>
<td style="color:{$_Color}" align="right">{$row.MissingAmount|format_number}</td>
</tr>
{/foreach}