<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_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)
 */
?>
<?php if($this->getProductData()->getId()): ?>
<div class="product-review">
    <div class="page-title">
        <h1><?= $this->__('Review Details') ?></h1>
    </div>
    <div class="product-img-box">
        <a href="<?= $this->getProductData()->getProductUrl() ?>" title="<?= $this->escapeHtml($this->getProductData()->getName()) ?>" class="product-image"><img src="<?= $this->helper('catalog/image')->init($this->getProductData(), 'small_image')->resize(325,325) ?>" width="325" height="" alt="<?= $this->escapeHtml($this->getProductData()->getName()) ?>" /></a>
        <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
            <p class="label"><?= $this->__('Average Customer Rating:') ?></p>
            <?= $this->getReviewsSummaryHtml($this->getProductData()) ?>
        <?php endif ?>
    </div>
    <div class="product-details">
        <h2 class="product-name"><?= $this->escapeHtml($this->getProductData()->getName()) ?></h2>
        <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
        <h3><?= ($this->isReviewOwner()) ? $this->__('Your Rating:') : $this->__('Rating:') ?></h3>
        <table class="ratings-table">
        <?php foreach ($this->getRating() as $_rating): ?>
        <?php if($_rating->getPercent()): ?>
            <tr>
                <th><?= $this->escapeHtml($_rating->getRatingCode()) ?></th>
                <td>
                    <div class="rating-box">
                        <div class="rating" style="width:<?= ceil($_rating->getPercent()) ?>%;"></div>
                    </div>
                </td>
            </tr>
        <?php endif ?>
        <?php endforeach ?>
        </table>
        <?php endif ?>
        <dl class="ratings-description">
            <dt>
                <?php if ($this->isReviewOwner()): ?>
                    <?= $this->__('Your Review (submitted on %s):', $this->dateFormat($this->getReviewData()->getCreatedAt())) ?>
                <?php else: ?>
                    <?= $this->__('Review (submitted on %s):', $this->dateFormat($this->getReviewData()->getCreatedAt())) ?>
                <?php endif ?>
            </dt>
            <dd>
                <?= nl2br($this->escapeHtml($this->getReviewData()->getDetail())) ?>
            </dd>
        </dl>
    </div>
    <div class="buttons-set">
        <p class="back-link"><a href="<?= $this->getBackUrl() ?>"><small>&laquo; </small><?= $this->__('Back to My Reviews') ?></a></p>
    </div>
</div>
<?php endif ?>
