<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php $_source  = $this->getSource() ?>
<?php $this->setPriceDataObject($_source) ?>
<?php $_currency= $this->getCurrency() ?>
<?php if ($_source): ?>
<table cellspacing="0" width="100%">
    <col />
    <col width="100" />
    <tfoot>
        <tr>
            <td class="label">
                <strong><?php echo $this->helper('sales')->__('Total Refund') ?></strong>
            </td>
            <td class="emph">
                <?php echo $this->displayPriceAttribute('grand_total', true) ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
        <?php if ((float) $_source->getSubtotal()): ?>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Subtotal') ?></td>
            <td><?php echo $this->displayPriceAttribute('subtotal') ?></td>
        </tr>
        <?php endif; ?>

        <?php if ((float) $_source->getTaxAmount()): ?>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Tax') ?></td>
            <td><?php echo $this->displayPriceAttribute('tax_amount') ?></td>
        </tr>
        <?php endif; ?>
        <?php if ((float) $_source->getDiscountAmount()): ?>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Discount') ?></td>
            <td><?php echo $this->displayPriceAttribute('discount_amount') ?></td>
        </tr>
        <?php endif; ?>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Refund Shipping') ?></td>
            <td><input type="text" name="creditmemo[shipping_amount]" value="<?php echo $_source->getBaseShippingAmount()*1 ?>" class="input-text not-negative-amount" style="width:60px;text-align:right" id="shipping_amount" /></td>
        </tr>
        <tr>
            <td colspan="2" id="shipping_amount_adv" class="advice-bg-right"></td>
        </tr>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Adjustment Refund') ?></td>
            <td><input type="text" name="creditmemo[adjustment_positive]" value="<?php echo $_source->getBaseAdjustmentFeePositive()*1 ?>" class="input-text not-negative-amount" style="width:60px;text-align:right" id="adjustment_positive" /></td>
        </tr>
        <tr>
            <td colspan="2" id="adjustment_positive_adv" class="advice-bg-right"></td>
        </tr>
        <tr>
            <td class="label"><?php echo $this->helper('sales')->__('Adjustment Fee') ?></td>
            <td><input type="text" name="creditmemo[adjustment_negative]" value="<?php echo $_source->getBaseAdjustmentFeeNegative()*1 ?>" class="input-text not-negative-amount" style="width:60px;text-align:right" id="adjustment_negative"/></td>
        </tr>
        <tr>
            <td colspan="2" id="adjustment_negative_adv" class="advice-bg-right"></td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
//<![CDATA[
Validation.addAllThese([
    ['not-negative-amount', '<?php echo $this->helper('sales')->__('Please enter positive number in this field.') ?>', function(v) {
        if(v.length)
            return parseFloat(v) >= 0;
        else
            return true;
    }]
]);
if ($('shipping_amount')) $('shipping_amount').advaiceContainer = $('shipping_amount_adv');
if ($('adjustment_positive')) $('adjustment_positive').advaiceContainer = $('adjustment_positive_adv');
if ($('adjustment_negative')) $('adjustment_negative').advaiceContainer = $('adjustment_negative_adv');
//]]>
</script>
<?php endif; ?>