{*
* 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="panel">
			<h3><i class="icon-list-alt"></i> {l s='View your data' d='Modules.Agilemultisellerpro.Import'}</h3>
			<div class="alert alert-info">
				<p>{l s='Please match each column of your source CSV file to one of the destination columns.' d='Modules.Agilemultisellerpro.Import'}</p>
			</div>
			<div class="form-horizontal">
				<div class="form-group row" id="divSelectDivImportMatchs" {if empty($import_matchs)}style="display:none"{/if}>
					<label class="form-control-label col-md-3">{l s='Load a data matching configuration' d='Modules.Agilemultisellerpro.Import'}</label>
					<div id="selectDivImportMatchs" class="col-md-3">
						<select id="valueImportMatchs" class="form-control">
							{foreach $import_matchs as $match}
								<option id="{$match.id_import_match|escape:'htmlall':'UTF-8'}" value="{$match.match|escape:'htmlall':'UTF-8'}">{$match.name|escape:'htmlall':'UTF-8'}</option>
							{/foreach}
						</select>
					</div>
					<div class="col-md-6">
						<a id="loadImportMatchs" href="#" class="btn btn-primary"><i class="icon-cogs"></i> {l s='Load' d='Modules.Agilemultisellerpro.Import'}</a>
						<a id="deleteImportMatchs" href="#" class="btn btn-primary"><i class="icon-remove"></i> {l s='Delete' d='Modules.Agilemultisellerpro.Import'}</a>
					</div>
				</div>
				<div class="form-group row">
					<label class="form-control-label col-md-3" for="newImportMatchs">{l s='Save your data matching configuration' d='Modules.Agilemultisellerpro.Import'}</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="newImportMatchs" id="newImportMatchs" />
					</div>
					<div class="col-md-6">
						<a id="saveImportMatchs" class="btn btn-primary" href="#"><i class="icon-save"></i> {l s='Save' d='Modules.Agilemultisellerpro.Import'}</a>
					</div>
				</div>


			</div>

			<div id="error_duplicate_type" class="alert alert-warning" style="display:none;">
				{l s='Two columns cannot have the same type of values' d='Modules.Agilemultisellerpro.Import'}
			</div>
			<div id="required_column" class="alert alert-warning" style="display:none;">
				{l s='This column must be set:' d='Modules.Agilemultisellerpro.Import'} <span id="missing_column">&nbsp;</span>
			</div>
			<form action="{$link->getModuleLink('agilemultisellerpro','productimport',[],true)|escape:'htmlall':'UTF-8'}" method="post" id="import_form" name="import_form" class="form-horizontal">
				<input type="hidden" name="csv" value="{$fields_value.csv|escape:'htmlall':'UTF-8'}" />
				<input type="hidden" name="convert" value="{if isset($fields_value.convert)}{$fields_value.convert|escape:'htmlall':'UTF-8'}{else}0{/if}" />
				<input type="hidden" name="regenerate" value="{$fields_value.regenerate|escape:'htmlall':'UTF-8'}" />
				<input type="hidden" name="entity" value="{$fields_value.entity|escape:'htmlall':'UTF-8'}" />
				<input type="hidden" name="iso_lang" value="{$fields_value.iso_lang|escape:'htmlall':'UTF-8'}" />
				{if $fields_value.truncate}
					<input type="hidden" name="truncate" value="1" />
				{/if}
				{if $fields_value.forceIDs}
					<input type="hidden" name="forceIDs" value="1" />
				{/if}
				{if $fields_value.match_ref}
					<input type="hidden" name="match_ref" value="1" />
				{/if}
				<input type="hidden" name="separator" value="{$fields_value.separator|escape:'htmlall':'UTF-8'}" />
				<input type="hidden" name="multiple_value_separator" value="{$fields_value.multiple_value_separator|escape:'htmlall':'UTF-8'}" />

				<div class="form-group row">
					<label class="form-control-label col-md-3" for="skip">{l s='Lines to skip' d='Modules.Agilemultisellerpro.Import'}</label>
					<div class="col-md-3">
						<input class="fixed-width-sm form-control" type="text" name="skip" id="skip" value="1" />
					</div>
					<div class="col-md-6">
						{l s='This number indicates how many of the first lines of your CSV file should be skipped when importing the data. For instance set it to 1 if the first row of your file contains headers.' d='Modules.Agilemultisellerpro.Import'}
					</div>
				</div>

				<div class="form-group row">
					<div class="col-md-12 table-responsive">
						{section name=nb_i start=0 loop=$nb_table step=1}
							{assign var=i value=$smarty.section.nb_i.index}
							{$data.$i nofilter}
						{/section}
						<button id="btn_left" type="button" class="btn btn-primary pull-left" onclick="showTable(current - 1);">
							<i class="icon-chevron-sign-left"></i>
						</button>
						<button id="btn_right" type="button" class="btn btn-primary pull-right" onclick="showTable(current + 1);">
							<i class="icon-chevron-sign-right"></i>
						</button>
					</div>
				</div>
				<div class="panel-footer">
					<button type="button" class="btn btn-primary" onclick="window.history.back();">
						<i class="process-icon-cancel text-danger"></i>
						{l s='Cancel' d='Modules.Agilemultisellerpro.Import'}
					</button>
					<button id="import" name="import" type="submit" onclick="return (validateImportation(new Array({$res|escape:'htmlall':'UTF-8'})));"  class="btn btn-primary pull-right">
						<i class="process-icon-ok text-success"></i>
						{l s='Import .CSV data' d='Modules.Agilemultisellerpro.Import'}
					</button>
				</div>
			</form>
		</div>
	{/if}

	{/block}

{block name='javascript_bottom'}
    {$smarty.block.parent}

	<script type="text/javascript">
		var nb_table = {$nb_table|escape:'htmlall':'UTF-8'};
	</script>

{/block}
