<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2022 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)
 */
?>
<?= $this->getMessagesBlock()->toHtml() ?>
<div class="page-title">
    <h1><?= $this->__('My Product Reviews') ?></h1>
</div>
<?php if( $this->getCollection() && $this->count()): ?>
    <?= $this->getToolbarHtml() ?>
        <table class="data-table" id="my-reviews-table">
            <col width="1" />
            <col width="210" />
            <col width="1" />
            <col />
            <col width="1" />
            <tbody>
                <?php foreach ($this->getCollection() as $_review): ?>
                <tr>
                    <td><span class="nobr"><?= $this->dateFormat($_review->getReviewCreatedAt()) ?></span></td>
                    <td><h2 class="product-name"><a href="<?= $this->getProductLink() ?>id/<?= $_review->getEntityPkValue() ?>"><?= $this->escapeHtml($_review->getName()) ?></a></h2></td>
                    <td>
                    <?php if($_review->getSum()): ?>
                        <div class="rating-box">
                            <div class="rating" style="width:<?= ( $_review->getSum() / $_review->getCount() ) ?>%;"></div>
                        </div>
                    <?php endif ?>
                    </td>
                    <td><?= $this->helper('review')->getDetailHtml($_review->getDetail()) ?></td>
                    <td><a href="<?= $this->getReviewLink() ?>id/<?= $_review->getReviewId() ?>" class="nobr"><?= $this->__('View Details') ?></a></td>
                </tr>
                <?php endforeach ?>
            </tbody>
        </table>
    <?= $this->getToolbarHtml() ?>
<?php else: ?>
    <p><?= $this->__('You have submitted no reviews.') ?></p>
<?php endif ?>
<div class="buttons-set">
    <p class="back-link"><a href="<?= $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?= $this->__('Back') ?></a></p>
</div>
