{*
* 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 id="agile">
			<div class="block-center" id="block-history">
				<div class="table-responsive">
					<table id="order-list" class="table">
						<thead>
							<tr>
								<th class="first_item">
									{l s='Date' d='Modules.Agilemultisellerpro.Orders'}
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.date_add' && $orderWay=='ASC'}current{/if}"
										onclick="orderByWay('o.date_add','ASC')"><i class="icon-caret-up"></i></a>
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.date_add' && $orderWay=='DESC'}current{/if}"
										onclick="orderByWay('o.date_add','DESC')"><i class="icon-caret-down"></i></a>
								</th>

								<th class="item">
									{l s='Reference' d='Modules.Agilemultisellerpro.Orders'}
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.reference' && $orderWay=='ASC'}current{/if}"
										onclick="orderByWay('o.reference','ASC')"><i class="icon-caret-up"></i></a>
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.reference' && $orderWay=='DESC'}current{/if}"
										onclick="orderByWay('o.reference','DESC')"><i class="icon-caret-down"></i></a>
								</th>

								{* <th class="item">
									{l s='Order' d='Modules.Agilemultisellerpro.Orders'} #
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.id_order' && $orderWay=='ASC'}current{/if}"
										onclick="orderByWay('o.id_order','ASC')"><i class="icon-caret-up"></i></a>
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='o.id_order' && $orderWay=='DESC'}current{/if}"
										onclick="orderByWay('o.id_order','DESC')"><i class="icon-caret-down"></i></a>
								</th> *}

								{* <th class="item">{l s='New' d='Modules.Agilemultisellerpro.Orders'}</th> *}

								<th class="item">
									{l s='Customer' d='Modules.Agilemultisellerpro.Orders'}
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='c.firstname' && $orderWay=='ASC'}current{/if}"
										onclick="orderByWay('c.firstname','ASC')"><i class="icon-caret-up"></i></a>
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='c.firstname' && $orderWay=='DESC'}current{/if}"
										onclick="orderByWay('c.firstname','DESC')"><i class="icon-caret-down"></i></a>
								</th>

								<th class="item">
									{l s='Total' d='Modules.Agilemultisellerpro.Orders'}
									<span class="text-nowrap">
										<a href="javascript:void(0)"
											class="agile-orders-sort {if $orderBy=='o.total_paid' && $orderWay=='ASC'}current{/if}"
											onclick="orderByWay('o.total_paid','ASC')"><i class="icon-caret-up"></i></a>
										<a href="javascript:void(0)"
											class="agile-orders-sort {if $orderBy=='o.total_paid' && $orderWay=='DESC'}current{/if}"
											onclick="orderByWay('o.total_paid','DESC')"><i class="icon-caret-down"></i></a>
									</span>
								</th>

								<th class="item">
									<span class="text-nowrap">
									{l s='Payment' d='Modules.Agilemultisellerpro.Orders'}

										<a href="javascript:void(0)"
											class="agile-orders-sort {if $orderBy=='o.payment' && $orderWay=='ASC'}current{/if}"
											onclick="orderByWay('o.payment','ASC')"><i class="icon-caret-up"></i></a>
										<a href="javascript:void(0)"
											class="agile-orders-sort {if $orderBy=='o.payment' && $orderWay=='DESC'}current{/if}"
											onclick="orderByWay('o.payment','DESC')"><i class="icon-caret-down"></i></a>
									</span>
								</th>

								<th class="item">
									{l s='Status' d='Modules.Agilemultisellerpro.Orders'}
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='osl.name' && $orderWay=='ASC'}current{/if}"
										onclick="orderByWay('osl.name','ASC')"><i class="icon-caret-up"></i></a>
									<a href="javascript:void(0)"
										class="agile-orders-sort {if $orderBy=='osl.name' && $orderWay=='DESC'}current{/if}"
										onclick="orderByWay('osl.name','DESC')"><i class="icon-caret-down"></i></a>
								</th>

								{* <th class="item">{l s='Invoice' d='Modules.Agilemultisellerpro.Orders'}</th> *}

								<th class="last_item">
									<input type="button" class="btn btn-primary btn-sm" name="export" value="Export" id="order_export"
										onclick="CSVOnClick()" />
								</th>
							</tr>

							<tr>
								<th class="align-middle agile-filter-date">
									<div class="col-md-6 ag-pl-5 ag-pr-5">
										<input class="form-control btn-block agile-padding-lr4" type="date" id="filter_date_add_from"
											name="filter_date_add_from" value="{$filter_date_add_from|escape:'htmlall':'UTF-8'}" maxlength="10"
											autocomplete="off" />
									</div>

									<div class="col-md-6 ag-pl-5 ag-pr-5">
										<input class="form-control btn-block agile-padding-lr4" type="date" id="filter_date_add_to"
											name="filter_date_add_to" value="{$filter_date_add_to|escape:'htmlall':'UTF-8'}" maxlength="10"
											autocomplete="off" />
									</div>
								</th>

								<th class="align-middle">
									<input type="text" class="form-control agile-padding-lr4" name="filter_reference" id="filter_reference"
										value="{$filter_reference|escape:'htmlall':'UTF-8'}">
								</th>

								{* <th class="align-middle">
									<input type="number" min="1" step="any" class="form-control agile-padding-lr4" name="filter_id_order" id="filter_id_order"
										value="{$filter_id_order|escape:'htmlall':'UTF-8'}">
								</th> *}

								{* <th></th> *}

								<th class="align-middle">
									<input type="text" class="form-control agile-padding-lr4" name="filter_customer" id="filter_customer"
										value="{$filter_customer|escape:'htmlall':'UTF-8'}">
								</th>

								<th class="align-middle">
									<input type="number" min="1" step="any" class="form-control agile-padding-lr4" name="filter_total" id="filter_total" value="{$filter_total|escape:'htmlall':'UTF-8'}">
								</th>

								<th class="align-middle">
									<input type="text" class="form-control agile-padding-lr4" name="filter_payment" id="filter_payment"
										value="{$filter_payment|escape:'htmlall':'UTF-8'}">
								</th>

								<th class="align-middle">
									<select class="form-control agile-padding-lr4" name="filter_id_order_state" id="filter_id_order_state">
										<option value=""></option>
										{foreach $statuses as $status}
											<option value="{$status.id_order_state|intval}"
												{if $status.id_order_state  == $filter_id_order_state}selected{/if}>
												{$status.name|escape:'htmlall':'UTF-8'}</option>
										{/foreach}
									</select>
								</th>

								{* <th></th> *}

								<th class="align-middle agile-filter-action">
									<div class="col-md-6 ag-pl-5 ag-pr-5">
										<button type="button" class="btn btn-warning btn-block agile-padding-lr4" name="reset" id="reset"
											onclick="ResetOnClick()"
											title="{l s='Reset' d='Modules.Agilemultisellerpro.Products'}">
											<i class="material-icons" aria-hidden="true">clear</i>
										</button>
									</div>

									<div class="col-md-6 ag-pl-5 ag-pr-5">
										<button type="button" class="btn btn-primary btn-block agile-padding-lr4" name="btnGo"
											onclick="goOnClick()"
											title="{l s='Search' d='Modules.Agilemultisellerpro.Products'}">
											<i class="material-icons mr-0" aria-hidden="true">search</i>
										</button>
									</div>
								</th>
							</tr>
						</thead>
						<tbody>
							{foreach from=$orders item=order 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_date bold">{dateFormat date=$order.date_add full=0}</td>
									<td class="history_link bold">
										{if isset($order.invoice) && $order.invoice && isset($order.virtual) && $order.virtual}<img
												src="{$base_dir_ssl|escape:'htmlall':'UTF-8'}modules/agilemultisellerpro/views/img/download_product.gif"
												class="icon" alt="{l s='Products to download' d='Modules.Agilemultisellerpro.Orders'}"
											title="{l s='Products to download' d='Modules.Agilemultisellerpro.Orders'}" />{/if}
										<a class="color-myaccount"
											href="{$link->getModuleLink('agilemultisellerpro', 'sellerorderdetail', ['ref_order' => $order.reference], true)|escape:'htmlall':'UTF-8'}">{$order.reference|escape:'htmlall':'UTF-8'}</a>
									</td>
									{* <td>{$order.id_order|escape:'htmlall':'UTF-8'}</td> *}
									{* <td>
										{if $order.new == 1}
											<img src="{$base_dir_ssl|escape:'htmlall':'UTF-8'}modules/agilemultisellerpro/views/img/news-new.gif" />
										{/if}
									</td> *}
									<td>{$order.customer|escape:'htmlall':'UTF-8'}</td>
									<td class="history_price"><span class="price">{$order.total_paid|escape:'htmlall':'UTF-8'}</span></td>
									<td class="history_method">{$order.payment|escape:'htmlall':'UTF-8'}</td>
									<td class="history_state">
										{if isset($order.order_state)}
											<span {if $order.color}style="background: {$order.color|escape:'htmlall':'UTF-8'}"{/if}>
												{$order.order_state|escape:'htmlall':'UTF-8'}
											</span>
										{/if}
									</td>
									<td class="history_invoice">
										{if isset($order.invoice) && $order.invoice && isset($invoiceAllowed) && $invoiceAllowed == 1}
											<a href="{$link->getModuleLink('agilemultisellerpro', 'sellerpdfinvoice', ['id_order' => $order.id_order], true)|escape:'htmlall':'UTF-8'}"
												title="{l s='Invoice' d='Modules.Agilemultisellerpro.Orders'}" target="pdf"><i class="material-icons mr-0" aria-hidden="true" style="color: red;">picture_as_pdf</i></a>
											<a href="{$link->getModuleLink('agilemultisellerpro', 'sellerpdfinvoice', ['id_order' => $order.id_order], true)|escape:'htmlall':'UTF-8'}"
												title="{l s='Invoice' d='Modules.Agilemultisellerpro.Orders'}"
												target="pdf">{l s='PDF' d='Modules.Agilemultisellerpro.Orders'}</a>
										{/if}
									</td>
									{* <td class="history_detail"></td> *}
								</tr>
							{/foreach}

							{if count($orders) < 1}
								<tr>
									<td colspan="10">
										<p class="alert alert-warning">
											{l s='Orders not found.' d='Modules.Agilemultisellerpro.Products'}
										</p>
									</td>
								</tr>
							{/if}
						</tbody>
					</table>
				</div> <!-- responsive -->

				{if count($orders) > 0}
					<hr>
					{block name='pagination'}
						{include file='_partials/pagination.tpl' pagination=$pagination}
					{/block}
				{/if}

				<div id="block-order-detail" class="hidden">&nbsp;</div>
			</div> <!-- block-center -->
		</div> <!-- agile -->
	{/if}

{/block}
