<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Downloadable_Block_Customer_Products_List $this */
?>
<?php $_items = $this->getItems(); ?>
<div class="page-title">
    <h1><?= Mage::helper('downloadable')->__('My Downloadable Products') ?></h1>
</div>
<?= $this->getMessagesBlock()->toHtml() ?>
<?= $this->getChildHtml('pager') ?>
<?php if(count($_items)): ?>
    <table class="data-table linearize-table-large" id="my-downloadable-products-table">
        <col width="1" />
        <col width="1" />
        <col />
        <col width="1" />
        <col width="1" />
        <thead>
            <tr>
                <th><?= Mage::helper('downloadable')->__('Order #') ?></th>
                <th><?= Mage::helper('downloadable')->__('Date') ?></th>
                <th><?= Mage::helper('downloadable')->__('Title') ?></th>
                <th><?= Mage::helper('downloadable')->__('Status') ?></th>
                <th><span class="nobr"><?= Mage::helper('downloadable')->__('Remaining Downloads') ?></span></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($_items as $_item): ?>
                <tr>
                    <td data-rwd-label="<?= Mage::helper('downloadable')->__('Order #') ?>"><a href="<?= $this->getOrderViewUrl($_item->getPurchased()->getOrderId()) ?>" title="<?= Mage::helper('core')->quoteEscape(Mage::helper('downloadable')->__('View Order')) ?>"><?= $_item->getPurchased()->getOrderIncrementId() ?></a></td>
                    <td data-rwd-label="<?= Mage::helper('downloadable')->__('Date') ?>"><span class="nobr"><?= $this->formatDate($_item->getPurchased()->getCreatedAt()) ?></span></td>
                    <td data-rwd-label="<?= Mage::helper('downloadable')->__('Title') ?>"><?= $this->escapeHtml($_item->getPurchased()->getProductName()) ?> - <a href="<?= $this->getDownloadUrl($_item) ?>" title="<?= Mage::helper('core')->quoteEscape(Mage::helper('downloadable')->__('Start Download')) ?>" <?= $this->getIsOpenInNewWindow()?'onclick="this.target=\'_blank\'"':'' ?>><?= $this->escapeHtml($_item->getLinkTitle()) ?></a></td>
                    <td data-rwd-label="<?= Mage::helper('downloadable')->__('Status') ?>"><em><?= Mage::helper('downloadable')->__(ucfirst($_item->getStatus())) ?></em></td>
                    <td data-rwd-label="<?= Mage::helper('downloadable')->__('Remaining Downloads') ?>"><?= $this->getRemainingDownloads($_item) ?></td>
                </tr>
            <?php endforeach ?>
        </tbody>
    </table>
<?php else: ?>
    <p><?= Mage::helper('downloadable')->__('You have not purchased any downloadable products yet.') ?></p>
<?php endif ?>
<?= $this->getChildHtml('pager') ?>
<div class="buttons-set">
    <p class="back-link"><a href="<?= $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?= $this->__('Back') ?></a></p>
</div>
