2012-03-11 67 views
0

问题:如何根据正值或负值输出值更改目标单元格行?if statement(banking - credit/debit)

下面输出的是一个数值,可以是扣除(例如 - $ 500.00),也可以是一个加法(例如$ 500)。

<td><?php echo Mage::helper('core')->currency($_item->getValueChange())?></td> 

我想在单独的行单元格中显示银行扣除和添加。目前它们显示在同一行单元格内。

下面是我的意思是一个截图。我已经创建了将放置值的行。

enter image description here

我的编码如下:

<thead> 
     <tr> 
      <th><?php echo $this->__('Date') ?></th> 
      <th><?php echo $this->__('Action') ?></th> 
      <th><?php echo $this->__('Particulars') ?></th> 
      <th><?php echo $this->__('Added') ?></th> 
      <th><?php echo $this->__('Deducted') ?></th> 
      <th><?php echo $this->__('Temporary') ?></th>         
      <th><?php echo $this->__('Credit Balance') ?></th> 
     </tr> 
    </thead> 
    <tbody> 
     <?php foreach ($_items as $_item): ?> 
      <tr> 
       <td><?php echo $_item->getActionDate()?></td> 
       <td><?php echo $this->getActionTypeLabel($_item->getActionType())?></td>      
       <td><?php echo $_item->getComment()?></td> 
       <td> </td> 
       <td> </td>     
       <td><?php echo Mage::helper('core')->currency($_item->getValueChange())?></td>      
       <td><?php echo Mage::helper('core')->currency($_item->getValue())?></td>      
      </tr> 
     <?php endforeach;?> 
    </tbody> 

可有人请通过这样的值插入到我的网站上正确的单元格修改我当前的代码帮助我,也许?

谢谢!

回答

1

这不是最简单的做一些类似的事情; (未经测试,以便看到的伪代码)

<?php foreach ($_items as $_item): ?> 
    <?php $valuechange = Mage::helper('core')->currency($_item->getValueChange()); ?> 
    <tr> 

......后来......

<td><?php if($valuechange>0) echo $valuechange; ?></td> 
    <td><?php if($valuechange<0) echo -$valuechange; ?></td> 
+0

嗨,老兄,上面似乎并不似乎返回任何值。我会继续玩一下。无论如何,感谢您的帮助。 – 2012-03-11 12:05:48

+0

我认为我的问题可能是扣分符号“ - ”可能分开插入......因此,所有值都可能是正数,直到插入此符号为止......我必须弄清楚这个符号在什么阶段是插入并正确。 – 2012-03-11 12:17:00