<?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)
 */
/** @var Mage_Wishlist_Block_Share_Wishlist $this */
?>
<div class="my-wishlist">
    <div class="page-title">
        <h1><?= $this->escapeHtml($this->getHeader()) ?></h1>
    </div>
    <?= $this->getMessagesBlock()->toHtml() ?>
    <?php if ($this->hasWishlistItems()): ?>
    <form action="<?= $this->getUrl('*/*/update') ?>" method="post">
        <fieldset>
            <table class="data-table" id="wishlist-table">
            <col width="1" />
            <col />
            <col width="1" />
            <thead>
                <tr>
                    <th><?= $this->__('Product') ?></th>
                    <th><?= $this->__('Comment') ?></th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach($this->getWishlistItems() as $item): ?>
                <?php
                    $product = $item->getProduct();
                    $isVisibleProduct = $product->isVisibleInSiteVisibility();
                ?>
                <tr>
                    <td>
                        <a class="product-image" href="<?= $this->getProductUrl($item) ?>" title="<?= $this->escapeHtml($product->getName()) ?>"><img src="<?= $this->helper('catalog/image')->init($product, 'small_image')->resize(113, 113) ?>" width="113" height="113" alt="<?= $this->escapeHtml($product->getName()) ?>" /></a>
                        <h2 class="product-name"><a href="<?= $this->getProductUrl($item) ?>"><?= $this->escapeHtml($product->getName()) ?></a></h2>
                        <?= $this->getPriceHtml($product) ?>
                        <?= $this->getDetailsHtml($item) ?>
                    </td>
                    <td><?= $this->getEscapedDescription($item) ?></td>
                    <td class="a-center">
                    <?php if ($product->isSaleable()): ?>
                        <?php if ($isVisibleProduct): ?>
                            <button type="button" title="<?= Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" onclick="setLocation('<?= $this->getSharedItemAddToCartUrl($item) ?>')" class="button btn-cart"><?= $this->__('Add to Cart') ?></button>
                        <?php endif ?>
                    <?php endif ?>
                        <p>
                            <a href="#"
                               onclick="customFormSubmit(
                                       '<?= $this->getAddToWishlistUrlCustom($item, false) ?>',
                                       '<?= $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()])) ?>',
                                       'post')"
                               class="link-wishlist">
                                <?= $this->__('Add to Wishlist') ?>
                            </a>
                        </p>
                    </td>
                </tr>
            <?php endforeach ?>
            </tbody>
            </table>
        </fieldset>
        <div class="buttons-set">
            <p class="back-link"><a href="<?= $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?= $this->__('Back') ?></a></p>
            <?php if($this->isSaleable()):?>
                <button type="button" title="<?= Mage::helper('core')->quoteEscape($this->__('Add All to Cart')) ?>" onclick="setLocation('<?= $this->getUrl('*/*/allcart', ['_current'=>true]) ?>')" class="button"><?= $this->__('Add All to Cart') ?></button>
            <?php endif ?>
        </div>
    </form>
    <?php else: ?>
        <p><?= $this->__('Wishlist is empty now.') ?></p>
    <?php endif ?>
</div>
