<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_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)
 */
?>
<?php
/**
 * Last order sidebar
 *
 * @see Mage_Sale_Block_Reorder_Sidebar
 * @var Mage_Sale_Block_Reorder_Sidebar $this
 */
?>
<?php $_items = $this->getItems()?>
<?php if($_items): ?>
<div class="block block-reorder">
    <div class="block-title">
        <strong><span><?= $this->__('My Orders') ?></span></strong>
    </div>
    <form method="post" action="<?= $this->getFormActionUrl() ?>" id="reorder-validate-detail">
        <?= $this->getBlockHtml('formkey') ?>
        <div class="block-content">
            <p class="block-subtitle"><?= $this->__('Last Ordered Items') ?></p>
            <ol id="cart-sidebar-reorder">
            <?php $_showAddButtonFlag = false ?>
            <?php foreach ($_items as $_item): ?>
                <li class="item">
                    <?php if ($this->isItemAvailableForReorder($_item)): ?>
                        <?php $_showAddButtonFlag = true ?>
                        <input type="checkbox" name="order_items[]" id="reorder-item-<?= $_item->getId() ?>" value="<?= $_item->getId() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="checkbox validate-one-required-by-name" />
                        <script type="text/javascript">
                            document.getElementById('reorder-item-<?= $_item->getId() ?>').advaiceContainer = 'cart-sidebar-reorder-advice-container';
                        </script>
                    <?php endif ?>
                    <p class="product-name"><a href="<?= $_item->getProduct()->getProductUrl() ?>"><?= $this->escapeHtml($_item->getName()) ?></a></p>
                </li>
            <?php endforeach ?>
            </ol>
            <div id="cart-sidebar-reorder-advice-container"></div>
            <div class="actions">
                <?php if ($_showAddButtonFlag): ?>
                    <button type="submit" title="<?= Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart"><?= $this->__('Add to Cart') ?></button>
                <?php endif ?>
                <a href="<?= $this->getUrl('customer/account') ?>"><?= $this->__('View All') ?></a>
            </div>
        </div>
    </form>
</div>
<?= $this->getPagerHtml() ?>
<script type="text/javascript">
    var reorderFormDetail = new VarienForm('reorder-validate-detail');
</script>
<?php endif ?>
