<?php
/**
 * OpenMage
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available at https://opensource.org/license/afl-3-0-php
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org)
 * @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><?php echo $this->escapeHtml($this->getHeader()) ?></h1>
    </div>
    <?php echo $this->getMessagesBlock()->toHtml() ?>
    <?php if ($this->hasWishlistItems()): ?>
    <form action="<?php echo $this->getUrl('*/*/update') ?>" method="post">
        <div class="fieldset">
            <table class="data-table" id="wishlist-table">
            <col width="1" />
            <col />
            <col width="1" />
            <thead>
                <tr>
                    <th><?php echo $this->__('Product') ?></th>
                    <th><?php echo $this->__('Comment') ?></th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody>
            <?php $_params = $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()])); ?>
            <?php foreach($this->getWishlistItems() as $item): ?>
                <?php
                    $product = $item->getProduct();
                    $isVisibleProduct = $product->isVisibleInSiteVisibility();
                ?>
                <tr>
                    <td>
                        <a class="product-image" href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(113, 113); ?>" width="113" height="113" alt="<?php echo $this->escapeHtml($product->getName()) ?>" /></a>
                        <h2 class="product-name"><a href="<?php echo $this->getProductUrl($item) ?>"><?php echo $this->escapeHtml($product->getName()) ?></a></h2>
                        <?php echo $this->getPriceHtml($product) ?>
                        <?php echo $this->getDetailsHtml($item) ?>
                    </td>
                    <td><?php echo $this->getEscapedDescription($item) ?></td>
                    <td class="a-center">
                    <?php if ($product->isSaleable()): ?>
                        <?php if ($isVisibleProduct): ?>
                            <button type="button" title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>" onclick="setLocation('<?php echo $this->getSharedItemAddToCartUrl($item) ?>')" class="button btn-cart"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                        <?php endif ?>
                    <?php endif ?>
                        <p>
                            <?php $_wishlistUrl = $this->getAddToWishlistUrlCustom($item, false); ?>
                            <a href="#"
                               data-url="<?php echo $_wishlistUrl ?>"
                               data-params="<?php echo $_params ?>"
                               onclick="customFormSubmit('<?php echo $_wishlistUrl ?>', '<?php echo $_params ?>', 'post')"
                               class="link-wishlist">
                                <?php echo $this->__('Add to Wishlist') ?>
                            </a>
                        </p>
                    </td>
                </tr>
            <?php endforeach ?>
            </tbody>
            </table>
            <script type="text/javascript">decorateTable('wishlist-table');</script>
        </div>
        <div class="buttons-set">
            <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
            <?php if($this->isSaleable()):?>
                <button type="button" title="<?php echo $this->quoteEscape($this->__('Add All to Cart')) ?>" onclick="setLocation('<?php echo $this->getUrl('*/*/allcart', ['_current'=>true]) ?>')" class="button"><span><span><?php echo $this->__('Add All to Cart') ?></span></span></button>
            <?php endif ?>
        </div>
    </form>
    <?php else: ?>
        <p><?php echo $this->__('Wishlist is empty now.') ?></p>
    <?php endif ?>
</div>
