<?php
/*
 * @author     M2E Pro Developers Team
 * @copyright  M2E LTD
 * @license    Commercial use is forbidden
 */

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Magento_Payment_Info */

?>

<table>
    <?php if ($this->getPaymentMethod() != '') { ?>
        <tr>
            <td style="width: 200px;">
                <label><?php echo Mage::helper('M2ePro')->__('Payment Method'); ?>:</label>
            </td>
            <td>
                <strong><?php echo $this->escapeHtml($this->getPaymentMethod()); ?></strong>
            </td>
        </tr>
    <?php } ?>
    <?php if ($this->getChannelOrderId() != '') { ?>
        <tr>
            <?php
                $message = Mage::helper('M2ePro')->__('%channel_title% Order ID', $this->getChannelTitle());
            ?>
            <td style="width: 200px;"><?php echo Mage::helper('M2ePro')->__($message) ?>:</td>
            <td>
                <?php if ($this->getChannelOrderUrl() != '') { ?>
                    <a href="<?php echo $this->getChannelOrderUrl() ?>" target="_blank"><?php echo $this->escapeHtml($this->getChannelOrderId()); ?></a>
                <?php } else { ?>
                    <strong><?php echo $this->escapeHtml($this->getChannelOrderId()); ?></strong>
                <?php } ?>
            </td>
        </tr>
    <?php } ?>
    <?php if ($this->getChannelFinalFee() > 0) { ?>
        <tr>
            <?php
                $message = Mage::helper('M2ePro')->__('%channel_title% Final Fee', $this->getChannelTitle());
            ?>
            <td style="width: 200px;"><?php echo Mage::helper('M2ePro')->__($message) ?>:</td>
            <td><strong><?php echo $this->getOrder() !== null ? $this->getOrder()->formatPrice($this->getChannelFinalFee()) : $this->getChannelFinalFee(); ?></strong></td>
        </tr>
    <?php } ?>
    <?php if ($this->getCashOnDeliveryCost() > 0) { ?>
        <tr>
            <?php
            $message = Mage::helper('M2ePro')->__('Cash On Delivery Cost');
            ?>
            <td style="width: 200px;"><?php echo Mage::helper('M2ePro')->__($message) ?>:</td>
            <td><strong><?php echo $this->getOrder() !== null ? $this->getOrder()->formatPrice($this->getCashOnDeliveryCost()) : $this->getCashOnDeliveryCost(); ?></strong></td>
        </tr>
    <?php } ?>
    <?php if ($this->getTaxId() != ''): ?>
        <tr>
            <?php $message = Mage::helper('M2ePro')->__('Buyer Tax ID'); ?>
            <td style="width: 200px;"><?php echo Mage::helper('M2ePro')->__($message) ?>:</td>
            <td><strong><?php echo $this->getTaxId(); ?></strong></td>
        </tr>
    <?php endif; ?>
    <?php $transactions = $this->getTransactions(); if (!empty($transactions)) { ?>
        <tr>
            <td class="grid" colspan="2">
                <br/>
                <h4><?php echo Mage::helper('M2ePro')->__('Transactions'); ?></h4>
                <table class="data" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr class="headings">
                            <th><?php echo Mage::helper('M2ePro')->__('Transaction #'); ?></th>
                            <th><?php echo Mage::helper('M2ePro')->__('Fee'); ?></th>
                            <th><?php echo Mage::helper('M2ePro')->__('Amount'); ?></th>
                            <th><?php echo Mage::helper('M2ePro')->__('Date'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($transactions as $key => $transaction) { ?>
                            <tr class="<?php echo $key % 2 ? 'odd' : 'even' ?>">
                                <td>
                                    <?php if (strtolower($this->getPaymentMethod()) == 'paypal') { ?>
                                        <a href="<?php echo Mage::helper('adminhtml')->getUrl('M2ePro/adminhtml_ebay_order/goToPaypal', array('transaction_id' => $transaction['transaction_id'])); ?>" target="_blank"><?php echo $transaction['transaction_id']; ?></a>
                                    <?php } else { ?>
                                        <?php echo $transaction['transaction_id']; ?>
                                    <?php } ?>
                                </td>
                                <td><?php echo $this->getOrder() !== null ? $this->getOrder()->formatPrice($transaction['fee']) : $transaction['fee']; ?></td>
                                <td><?php echo $this->getOrder() !== null ? $this->getOrder()->formatPrice($transaction['sum']) : $transaction['sum']; ?></td>
                                <td><?php echo Mage::helper('core')->formatDate($transaction['transaction_date'], 'medium', true); ?></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </td>
        </tr>
    <?php } ?>
</table>