2012-03-11 66 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