<?php
/**
 * Copyright © 2019 Magenest. All rights reserved.
 */
// @codingStandardsIgnoreFile
$delUrl = $block->getUrl('sagepay/customer/del');
?>

<?php $cards = $block->getDataCard(); ?>

<table id="customer-booking-order-list" class="data table table-downloadable-products">
    <?php if (!sizeof($cards)) { ?>
        <div class="message info empty">
            <span><?php echo __('You don\'t store any card yet.'); ?></span>
        </div>
    <?php } else {
        $i = 0;
        ?>
        <thead>
        <tr>
            <th><?php echo __('Credit Card'); ?></th>
            <th><?php echo __('Expires'); ?></th>
            <th><?php echo __('Created At'); ?></th>
            <th><?php echo __('Action'); ?></th>
            <th></th>
        </tr>
        </thead>

        <tbody id="card_table_body">
        <?php foreach ($cards as $card) { ?>
        <tr id="row-<?php echo $card['id']; ?>">
            <td><span><?php echo $card['card_type']; ?></span> - <span><?php echo 'xxxxxxxxxxxx - ' . $card['last_4']; ?></span></td>
            <td><?php echo $card['expire_date']?></td>
            <td><?php echo $card['created_at']; ?></td>
            <td>
                <a href="<?=$block->getDelUrl($card['id'])?>" class="action delete"
                   onclick="return confirm(<?=__('Are you sure you want to cancel this card?')?>);"
                >
                    <span><?php echo __('Delete')?></span>
                </a>
            </td>
            <?php } ?>
        </tbody>
    <?php } ?>
</table>
