{*
* 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
*}
{if isset($product->id) && !$product->is_virtual && Combination::isFeatureActive()}
	<div id="product-combinations" class="panel product-tab">
		<input type="hidden" name="submitted_tabs[]" value="Combinations" />

		<h3>{$field.label|escape:'htmlall':'UTF-8'}</h3>

		<select name="id_tax_rules_group" id="id_tax_rules_group" style="display:none;">
			<option value="{$product->id_tax_rules_group|intval}"></option>
		</select>
		<input type="hidden" name="id_product_attribute" id="id_product_attribute" value="0" />
		<span id="finalPrice" style="display:none;">{$field.availableValues.finalPrice|escape:'htmlall':'UTF-8'}</span>

		<div class="separation"></div>

		<div id="add_new_combination" class="panel" style="display: {if $notifications.error}{else}none;{/if}">

			<div class="form-group row">
				<label class="col-md-3 form-control-label" for="attribute_group">
					{l s='Attribute:' d='Modules.Agilemultisellerpro.Product'}
				</label>

				<div class="col-md-9 js-input-column">
					<select id="attribute_group" class="form-control form-control-select" name="attribute_group"
						onchange="populate_attrs();">
						{if !empty($field.availableValues.attributes_groups)}
							{foreach from=$field.availableValues.attributes_groups key=k item=attribute_group}
								<option value="{$attribute_group.id_attribute_group|intval}">
									{$attribute_group.name|escape:'html':'UTF-8'}&nbsp;&nbsp;
								</option>
							{/foreach}
						{/if}
					</select>
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 form-control-label" for="attribute_group">
					{l s='Value:' d='Modules.Agilemultisellerpro.Product'}
				</label>

				<div class="col-md-9 js-input-column">
					<div class="form-group row">
						<div class="col-xs-8">
							<select class="form-control" name="attribute" id="attribute">
								<option value="0">-</option>
							</select>
						</div>
						<div class="col-xs-4">
							<button type="button" class="btn btn-default btn-block" onclick="add_attr();">
								<i class="icon-plus-sign-alt"></i>&nbsp;{l s='Add' d='Modules.Agilemultisellerpro.Product'}
							</button>
						</div>
					</div>

					<div class="form-group row">
						<div class="col-xs-8">
							<select class="form-control" id="product_att_list" name="attribute_combination_list[]"
								multiple="multiple"></select>
						</div>
						<div class="col-xs-4">
							<button type="button" class="btn btn-default btn-block" onclick="del_attr();">
								<i class="icon-plus-sign-alt"></i>&nbsp;{l s='Delete' d='Modules.Agilemultisellerpro.Product'}
							</button>
						</div>
					</div>
				</div>
			</div>

			<hr />

			{form_field field=[
				'name' => 'attribute_reference',
				'type' => 'text',
				'required' => false,
				'label' => {l s='Reference' d='Modules.Agilemultisellerpro.Product'},
				'value' => '',
				'maxLength' => 0,
				'errors' => [],
				'autocomplete' => ''
			]}

			{form_field field=[
				'name' => 'attribute_ean13',
				'type' => 'number',
				'required' => false,
				'label' => {l s='EAN13' d='Modules.Agilemultisellerpro.Product'},
				'value' => '',
				'maxLength' => 13,
				'errors' => [],
				'autocomplete' => ''
			]}

			{form_field field=[
				'name' => 'attribute_upc',
				'type' => 'text',
				'required' => false,
				'label' => {l s='UPC' d='Modules.Agilemultisellerpro.Product'},
				'value' => '',
				'maxLength' => 12,
				'errors' => [],
				'autocomplete' => ''
			]}

			<hr />

			<div class="form-group row">
				<label class="col-md-3 form-control-label" for="ecotax">
					{l s='Impact on price (tax excl.)' d='Modules.Agilemultisellerpro.Product'}
				</label>

				<div class="col-md-6 js-input-column">
					<div class="input-group">
						<input type="hidden" name="attribute_price_impact" value="1">
						{* <input id="priceType" name="priceType" value="TE" type="hidden"> *}
						<input id="priceTI" class="form-control" type="number" value="" step="0.01" name="attribute_price">
						<span
							class="input-group-addon">{$field.availableValues.currencyDefault->iso_code|escape:'htmlall':'UTF-8'}</span>
					</div>
				</div>
				<div class="col-md-3 form-control-comment">{l s='Optional' d='Shop.Forms.Labels'}</div>
			</div>

			{include file="module:agilemultisellerpro/views/templates/front/_partials/form-fields.tpl"
				languages=$languages
				field=[
					'name' => 'attribute_minimal_quantity',
					'type' => 'number',
					'required' => false,
					'label' => {l s='Minimum quantity' d='Modules.Agilemultisellerpro.Product'},
					'value' => '',
					'availableValues' => [
						'otherAttr' => 'step="0.01"'
					],
					'maxLength' => 0,
					'errors' => [],
					'autocomplete' => '',
					'isLang' => false
				]
			}

			{form_field field=[
				'name' => 'available_date_attribute',
				'type' => 'date',
				'required' => false,
				'label' => {l s='Available date' d='Modules.Agilemultisellerpro.Product'},
				'value' => $product->available_date,
				'maxLength' => 0,
				'errors' => [],
				'autocomplete' => ''
			]}

			<hr />

			<div class="form-group row">
				<label class="col-md-3 form-control-label">{l s='Image'  d='Modules.Agilemultisellerpro.Product'}</label>

				<div class="col-md-9 js-input-column">
					<ul id="id_image_attr" class="list-inline">
						{foreach from=$field.availableValues.images key=k item=image}
							<li>
								<span class="custom-checkbox">
									<label>
										<input name="id_image_attr[]" type="checkbox" value="{$image.id_image|intval}" id="id_image_attr_{$image.id_image|intval}" />
										<span><i class="material-icons rtl-no-flip checkbox-checked">&#xE5CA;</i></span>
										<img
											src="{$image.link|escape:'htmlall':'UTF-8'}"
											alt="{$image.legend|escape:'html':'UTF-8'}" title="{$image.legend|escape:'html':'UTF-8'}" />
									</label>
								</span>
							</li>
						{/foreach}
					</ul>
				</div>
			</div>

			<hr />

			{form_field field=[
				'name' => 'attribute_default',
				'type' => 'checkbox',
				'required' => false,
				'label' => {l s='Make this combination the default combination for this product' d='Modules.Agilemultisellerpro.Product'},
				'value' => 0,
				'maxLength' => 0,
				'errors' => [],
				'autocomplete' => ''
			]}

			<hr />

		</div> <!-- End of add_new_combination -->

		<div class="panel-footer">
			<span id="ResetSpan">
				<button class="btn btn-primary form-control-submit" type="reset" name="brnCancelNewComb" id="brnCancelNewComb"
					style="display:{if $notifications.error}{else}none;{/if};" onclick="javascript:toggle_add_new_combination_form();"
					class="agile-btn agile-btn-default">
					<i class="icon-undo"></i>&nbsp;{l s='Cancel modification' d='Modules.Agilemultisellerpro.Product'}
				</button>
			</span>
			<span id="SaveSpan">
				<button class="btn btn-primary form-control-submit" type="submit" name="submitTabProduct" value="{$product_menu|intval}"
					id="submitCombinations" style="display:{if $notifications.error}{else}none;{/if};"
					class="agile-btn agile-btn-default">
					<i class="icon-save"></i>&nbsp;{l s='Save' d='Modules.Agilemultisellerpro.Product'}
				</button>
			</span>
			<span id="NewSpan">
				<button class="btn btn-primary form-control-submit" type="button" name="btnAddNewComb" id="btnAddNewComb"
					style="display:{if !$notifications.error}{else}none;{/if}" name="brnAddComb"
					onclick="javascript:toggle_add_new_combination_form()"
					value="{l s='New combination' d='Modules.Agilemultisellerpro.Product'}" />
				<i class="icon-plus-sign-alt"></i>&nbsp;{l s='New combination' d='Modules.Agilemultisellerpro.Product'}
				</button>
			</span>
		</div>
	</div> <!-- End of Panel -->
	<br>
	<div class="panel">
		<div class="table-responsive clearfix">
			<table id="combinations-list" class="table" style="width:100%">
				<thead>
					<tr class="nodrag nodrop">
						<th class="center fixed-width-xs"></th>
						<th class=" left"><span class="title_box ">{l s='Attributes' d='Modules.Agilemultisellerpro.Product'}</span>
						</th>
						<th class=" left"><span class="title_box ">{l s='Impact' d='Modules.Agilemultisellerpro.Product'}</span></th>
						<th class=" left"><span class="title_box ">{l s='Weight' d='Modules.Agilemultisellerpro.Product'}</span></th>
						<th class=" left"><span class="title_box ">{l s='Reference' d='Modules.Agilemultisellerpro.Product'}</span>
						</th>
						<th class=" left"><span class="title_box ">{l s='EAN13' d='Modules.Agilemultisellerpro.Product'}</span></th>
						<th class=" left"><span class="title_box ">{l s='UPC' d='Modules.Agilemultisellerpro.Product'}</span></th>
						<th class=" left"><span class="title_box ">{l s='Actions' d='Modules.Agilemultisellerpro.Product'}</span></th>
					</tr>
				</thead>
				<tbody>
					{foreach from=$field.availableValues.combinationArray key=k item=comb}
						<tr id="tr_comb_{$k|escape:'htmlall':'UTF-8'}" {if isset($comb.default_on) && $comb.default_on}
							highlighted{/if}>
							<td class="text-center"></td>
							<td class="left">{$k|escape:'htmlall':'UTF-8'}-{$comb.attributes|escape:'htmlall':'UTF-8'}</td>
							<td class="left">{$comb.price|escape:'htmlall':'UTF-8'}</td>
							<td class="left">{$comb.weight|escape:'htmlall':'UTF-8'}</td>
							<td class="left">{$comb.reference|escape:'htmlall':'UTF-8'}</td>
							<td class="left">{$comb.ean13|escape:'htmlall':'UTF-8'}</td>
							<td class="left">{$comb.upc|escape:'htmlall':'UTF-8'}</td>
							<td class="left" style="cursor:pointer">
								<i class="material-icons btn-outline-primary" aria-hidden="true"
									onclick="edit_comb({$product->id|intval},{$k|escape:'htmlall':'UTF-8'})">edit</i>
								<i class="material-icons btn-outline-danger" aria-hidden="true"
									onclick="delete_comb({$product->id|intval},{$k|escape:'htmlall':'UTF-8'})">delete</i>
								{if $comb.default_on}
									<i id="icon_default_{$k|escape:'htmlall':'UTF-8'}" class="material-icons btn-outline-success"
										aria-hidden="true" onclick="set_default_comb({$product->id|intval},{$k|escape:'htmlall':'UTF-8'})"
										style="cursor:default">check_circle_outline</i>
								{else}
									<i id="icon_default_{$k|escape:'htmlall':'UTF-8'}" class="material-icons btn-outline-success"
										aria-hidden="true"
										onclick="set_default_comb({$product->id|intval},{$k|escape:'htmlall':'UTF-8'})">radio_button_unchecked</i>
								{/if}
							</td>
						</tr>
					{/foreach}
			</table>
		</div>
	{elseif $product->is_virtual}
		<div id="product-combinations" class="panel product-tab">
			<h3>{l s='Add or modify combinations for this product.' d='Modules.Agilemultisellerpro.Product'}</h3>
			<div id="error_edit_file" class="alert alert-danger">
				{l s='You cannot edit your file here because it is a virtual product. Please edit it in the Virtual Product tab' d='Modules.Agilemultisellerpro.Product'}
			</div>
		</div>
	{else}
		<div class="alert alert-info">
			{l s='This feature is disabled or the product is virtual.' d='Modules.Agilemultisellerpro.Product'}</div>
{/if}
