<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>

<?php
/**
 * @see Mage_Downloadable_Block_Customer_Products_List
 */
?>
<?php $_items = $this->getItems(); ?>
<h1><?php echo Mage::helper('downloadable')->__('My Downloadable Products') ?></h1>

<div class="white-box-inner">
	<div class="page-messages">
		<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
	</div>
<?php echo $this->getChildHtml('pager'); ?>
<?php if(count($_items)): ?>
    <table class="data-table" id="my-downloadable-products-table">
        <col width="1" />
        <col width="1" />
        <col />
        <col width="1" />
        <col width="1" />
        <thead>
            <tr>
                <th><?php echo Mage::helper('downloadable')->__('Order #') ?></th>
                <th><?php echo Mage::helper('downloadable')->__('Date') ?></th>
                <th><?php echo Mage::helper('downloadable')->__('Title') ?></th>
                <th><?php echo Mage::helper('downloadable')->__('Status') ?></th>
                <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Remaining Downloads') ?></span></th>
            </tr>
        </thead>
        <tbody>
            <?php $_odd = ''; ?>
            <?php foreach ($_items as $_item): ?>
                <tr>
                    <td><a href="<?php echo $this->getOrderViewUrl($_item->getPurchased()->getOrderId()) ?>" title="<?php echo Mage::helper('downloadable')->__('View Order') ?>"><?php echo $_item->getPurchased()->getOrderIncrementId() ?></a></td>
                    <td><span class="nobr"><?php echo $this->formatDate($_item->getPurchased()->getCreatedAt()) ?></span></td>
                    <td><?php echo $this->htmlEscape($_item->getPurchased()->getProductName()) ?> - <a href="<?php echo $this->getDownloadUrl($_item) ?>" title="<?php echo Mage::helper('downloadable')->__('Start Download') ?>" <?php echo $this->getIsOpenInNewWindow()?'onclick="this.target=\'_blank\'"':''; ?>><?php echo $_item->getLinkTitle() ?></a></td>
                    <td><em><?php echo Mage::helper('downloadable')->__(ucfirst($_item->getStatus())) ?></em></td>
                    <td><?php echo $this->getRemainingDownloads($_item) ?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    <script type="text/javascript">decorateTable('my-downloadable-products-table')</script>
<?php else: ?>
    <p><?php echo Mage::helper('downloadable')->__('You have not purchased any downloadable products yet.'); ?></p>
<?php endif; ?>
<?php echo $this->getChildHtml('pager'); ?>
</div>

<div class="box-action">
    <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
</div>
