{*
* 2007-2024 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    PrestaShop SA <contact@prestashop.com>
*  @copyright 2007-2024 PrestaShop SA
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{extends file='module:agilemultisellerpro/views/templates/front/layouts/selleraccount.tpl'}

{block name='page_content'}
	{if isset($isSeller) AND $isSeller}
		<div class="block-center" id="block-history">
			{if $reviews && count($reviews)}
				<div class="table-responsive clearfix">
					<table id="reviews-list" class="table">
						<thead>
							<tr>
								<th class="first_item">{l s='ID' d='Modules.Agilemultisellerpro.Raitings'}</th>
								<th class="item">{l s='Reviewer' d='Modules.Agilemultisellerpro.Raitings'}</th>
								<th class="item">{l s='Message' d='Modules.Agilemultisellerpro.Raitings'}</th>
								<th class="item">{l s='Your Response' d='Modules.Agilemultisellerpro.Raitings'}</th>
								<th class="last_item">{l s='Action' d='Modules.Agilemultisellerpro.Raitings'}</th>
							</tr>
						</thead>
						<tbody>
							{foreach from=$reviews item=review name=myLoop}
								<tr
									class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if} {if $smarty.foreach.myLoop.index % 2}alternate_item{/if}">
									<td class="history_link bold">
										{$review.idSellerinfoRating|intval}
									</td>
									<td>
										<p style="overflow:hidden;white-space:nowrap;">
											{l s='At' d='Modules.Agilemultisellerpro.Raitings'}: {dateFormat date=$review.dateAdd|escape:'html':'UTF-8' full=1}<br>
											{l s='By' d='Modules.Agilemultisellerpro.Raitings'}: {$review.customer|escape:'html':'UTF-8'}<br>
											{l s='Rating' d='Modules.Agilemultisellerpro.Raitings'}: {$review.grade|round:1|floatval}
										</p>
									</td>
									<td>{$review.content|truncate:20:'...':true|escape:'html':'UTF-8'}</td>
									<td>{$review.response|truncate:20:'...':true|escape:'html':'UTF-8'}</td>
									<td>
										<button type="submit" class="button btn btn-primary"
											onclick="openMessageForm({$review.idSellerinfoRating|intval})">
											<span>{l s='Respond' d='Modules.Agilemultisellerpro.Raitings'}&nbsp;<i class="icon-mail-reply"></i></span>
										</button>
									</td>
								</tr>
								<tr id="trMessageForm_{$review.idSellerinfoRating|intval}" style="display:none;">
									<td colspan="7" align="center">
										<div class="mb-1">
											{l s='Message' d='Modules.Agilemultisellerpro.Raitings'}: {$review.content|escape:'html':'UTF-8'}
										</div>

										<form method="post" action="{$link->getModuleLink('agilemultisellerpro', 'myreviews', [], true)|escape:'htmlall':'UTF-8'}"
											id="messageForm_{$review.idSellerinfoRating|intval}"
											onsubmit="return onSubmitMessageForm({$review.idSellerinfoRating|intval})">
											<div>
												<input type="hidden" name="idSellerinfoRating" value="{$review.idSellerinfoRating|intval}" />
												<textarea class="form-control" rows="7" style="width:100%" name="response"
													id="response_{$review.idSellerinfoRating|intval}">{$review.response|escape:'html':'UTF-8'}</textarea>
												<br>

												<button type="submit" name="submitResponse" class="button btn btn-primary">
													<span>{l s='Respond' d='Modules.Agilemultisellerpro.Raitings'}&nbsp;<i class="icon-chevron-right right"></i></span>
												</button>
												<button type="button" name="cancelResponse" class="btn btn-primary"
													onclick="closeMessageForm({$review.idSellerinfoRating|escape:'htmlall':'UTF-8'})">
													<i class="icon-remove"></i>&nbsp;{l s='Cancel' d='Modules.Agilemultisellerpro.Raitings'}
												</button>
											</div>
										</form>
									</td>
								</tr>
							{/foreach}
						</tbody>
					</table>
				</div>

				{if count($reviews) > 0}
					<hr>
					{block name='pagination'}
						{include file='_partials/pagination.tpl' pagination=$pagination}
					{/block}
				{/if}
			{else}
				<p class="warning">{l s='You do not yet have a review.' d='Modules.Agilemultisellerpro.Raitings'}</p>
			{/if}
		</div>
	{/if}
{/block}
