<?php
/**
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Payment module (https://www.adyen.com/)
 *
 * Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
 * See LICENSE.txt for license details.
 *
 * Author: Adyen <magento@adyen.com>
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @see \Magento\Payment\Block\Info
 */
?>
<?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?>

<?php
$_info = $this->getInfo();
$_isDemoMode = $block->isDemoMode();
?>
<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')): ?>
    <div>
        <?php if ($_isDemoMode): ?>
            <?php echo __('Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="_blank">%1</a>',
                $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
        <?php else: ?>
            <?php echo __('Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="_blank">%1</a>',
                $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
        <?php endif; ?>
    </div>
<?php endif; ?>

<?php if ($_brandCode = $_info->getAdditionalInformation('brand_code')): ?>
    <div><?php echo __('Payment Method: %1', $_brandCode); ?>
    </div>
<?php endif; ?>


<?php if (!empty($block->getBankTransferData())) : ?>

    <?php
    $banktranferData = $block->getBankTransferData();
    $order = $block->getOrder();
    ?>

    <div>
        <table class="edit-order-table" style="text-align:left; margin-top:5px; margin-bottom:0;">
            <tbody>
            <?php if (!empty($order->getGrandTotal())) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Amount')); ?></th>
                    <td><?php echo $order->formatPrice($order->getGrandTotal()); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.reference'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('With reference')); ?></th>
                    <td><?php echo $banktranferData['bankTransfer.reference'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.owner'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Beneficiary Name')); ?></th>
                    <td><?php echo $banktranferData['bankTransfer.owner'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.bankName'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Bank')); ?></th>
                    <td><?php echo $banktranferData['bankTransfer.bankName'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.iban'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('IBAN')); ?></th>
                    <td><?php echo $banktranferData['bankTransfer.iban'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.accountCode'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Bankaccount')); ?></th>
                    <td><?php echo $banktranferData['bankTransfer.accountCode'] ?></td>
                </tr>
            <?php endif; ?>

            </tbody>
        </table>
    </div>
<?php elseif (!empty($block->getMultibancoData())) : ?>

    <?php
    $multibancoData = $block->getMultibancoData();
    ?>

    <div>
        <table class="edit-order-table" style="text-align:left; margin-top:5px; margin-bottom:0;">
            <tbody>
            <?php if (!empty($multibancoData['comprafacil.entity'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Entity')); ?></th>
                    <td><?php echo $multibancoData['comprafacil.entity'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.reference'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Reference')); ?></th>
                    <td><?php echo $multibancoData['comprafacil.reference'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.amount'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Amount')); ?></th>
                    <td><?php echo $multibancoData['comprafacil.amount'] ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.deadline'])) : ?>
                <tr>
                    <th><?php echo $block->escapeHtml(__('Deadline')); ?></th>
                    <td><?php echo $multibancoData['comprafacil.deadline'] ?><?php echo $block->escapeHtml(__('Days')); ?></td>
                </tr>
            <?php endif; ?>

            </tbody>
        </table>
    </div>
<?php endif; ?>

<?php if ($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
    <?php echo __('Total fraud score: %1', $_info->getAdditionalInformation('adyen_total_fraud_score')) ?><br/>
<?php endif; ?>


<?php if ($block->getSplitPayments()): ?>
    <table class="edit-order-table">
        <tr>
            <th>PspReference</th>
            <th>Payment Method</th>
            <th>Amount</th>
            <th>Refunded</th>
        </tr>
        <?php foreach ($block->getSplitPayments() as $payment): ?>
            <tr>
                <td><?php echo $payment->getPspreference() ?></td>
                <td><?php echo $payment->getPaymentMethod() ?></td>
                <td><?php echo $payment->getAmount() ?></td>
                <td><?php echo $payment->getTotalRefunded() ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

<?php if ($_specificInfo = $block->getSpecificInformation()): ?>
    <table class="data-table admin__table-secondary">
        <?php foreach ($_specificInfo as $_label => $_value): ?>
            <tr>
                <th><?php echo $block->escapeHtml($_label) ?>:</th>
                <td><?php echo nl2br(implode("\n", $block->getValueAsArray($_value, true))) ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

<?php if ($ratepayDescriptor = $_info->getAdditionalInformation('adyen_ratepay_descriptor')): ?>
    <div><?php echo __('Invoice Descriptor: %1', $ratepayDescriptor); ?>
    </div>
<?php endif; ?>

<?php echo $block->getChildHtml() ?>
