{*
* 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}
		{function name=getError field=''}{if isset($errorFields[$field])}{$errorFields[$field]|escape:'htmlall':'UTF-8'}{/if}{/function}

		<h3>
			{if $location->getIdLocationCarrier()}
				{l s='Edit' d='Modules.Agilemultisellerpro.Business'}
			{else}
				{l s='Add' d='Modules.Agilemultisellerpro.Business'}
			{/if}

		  	{l s='Location' d='Modules.Agilemultisellerpro.Location'}
		</h3>

		<form method="post" enctype="multipart/form-data">
			<input type="hidden" value="{$location->getIdLocationCarrier()|intval}">

			{form_field field=[
				'name' => 'active',
				'type' => 'select',
				'required' => true,
				'label' => {l s='Status' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->isActive()|intval},
				'availableValues' => [
					0 => {l s='Inactive' d='Modules.Agilemultisellerpro.Location'},
					1 => {l s='Active' d='Modules.Agilemultisellerpro.Location'}
				],
				'maxLength' => 0,
				'errors' => [],
				'autocomplete' => ''
			]}

			{$error = {getError field='id_carrier_reference'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'id_carrier_reference',
				'type' => 'select',
				'required' => true,
				'label' => {l s='Carrier' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getIdCarrierReference()|intval},
				'availableValues' => $carriers,
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='location'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'location',
				'type' => 'text',
				'required' => true,
				'label' => {l s='Location' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getLocation()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='email'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'email',
				'type' => 'text',
				'required' => true,
				'label' => {l s='Email' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getEmail()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='address1'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'address1',
				'type' => 'text',
				'required' => true,
				'label' => {l s='Address' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getAddress1()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='address2'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'address2',
				'type' => 'text',
				'required' => false,
				'label' => {l s='Address (Line 2)' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getAddress2()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='city'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'city',
				'type' => 'text',
				'required' => true,
				'label' => {l s='City' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getCity()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='postcode'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'postcode',
				'type' => 'text',
				'required' => true,
				'label' => {l s='Zip / Postal code' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getPostcode()|escape:'htmlall':'UTF-8'},
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='id_country'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'id_country',
				'type' => 'select',
				'required' => true,
				'label' => {l s='Country' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getIdCountry()|intval},
				'availableValues' => $countries,
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='id_state'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'id_state',
				'type' => 'select',
				'required' => false,
				'label' => {l s='State' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getIdState()|intval},
				'availableValues' => [],
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='phone'}}
			{if !$error}
				{$error = []}
			{/if}
			{form_field field=[
				'name' => 'phone',
				'type' => 'text',
				'required' => false,
				'label' => {l s='Phone' d='Modules.Agilemultisellerpro.Location'},
				'value' => {$location->getPhone()|escape:'htmlall':'UTF-8'},
				'availableValues' => [],
				'maxLength' => 0,
				'errors' => $error,
				'autocomplete' => ''
			]}

			{$error = {getError field='description'}}
			{if !$error}
				{$error = []}
			{/if}
			{include file="module:agilemultisellerpro/views/templates/front/_partials/form-fields.tpl"
				field=[
					'name' => 'description',
					'type' => 'textarea',
					'required' => false,
					'label' => {l s='Description' d='Modules.Agilemultisellerpro.Location'},
					'value' => {$location->getDescription()|escape:'htmlall':'UTF-8'},
					'availableValues' => [],
					'maxLength' => 0,
					'errors' => $error,
					'autocomplete' => '',
					'isLang' => false
				]
			}

			{$error = {getError field='latitude'}}
			{if !$error}
				{$error = []}
			{/if}
			{include file="module:agilemultisellerpro/views/templates/front/_partials/form-fields.tpl"
				field=[
					'name' => 'latitude',
					'type' => 'number',
					'required' => false,
					'label' => {l s='Latitude' d='Modules.Agilemultisellerpro.Location'},
					'value' => {$location->getLatitude()|floatval},
					'availableValues' => [
						'otherAttr' => 'step="any"'
					],
					'maxLength' => 0,
					'errors' => $error,
					'autocomplete' => '',
					'isLang' => false
				]
			}

			{$error = {getError field='longitude'}}
			{if !$error}
				{$error = []}
			{/if}
			{include file="module:agilemultisellerpro/views/templates/front/_partials/form-fields.tpl"
				field=[
					'name' => 'longitude',
					'type' => 'number',
					'required' => false,
					'label' => {l s='Longitude' d='Modules.Agilemultisellerpro.Location'},
					'value' => {$location->getLongitude()|floatval},
					'availableValues' => [
						'otherAttr' => 'step="any"'
					],
					'maxLength' => 0,
					'errors' => $error,
					'autocomplete' => '',
					'isLang' => false
				]
			}

			{if $isMap}
				<div class="form-group row ">
					<div class="offset-md-3 col-md-6 js-input-column">
						<div id="agile_map"></div>
					</div>
				</div>
			{/if}

			<div class="row p-0 p-md-1 ">
				<div class="col-xs-12 col-md-6 text-xs-center text-md-left pt-1">
					<a class="btn btn-link"
					href="{$sellerCarrierListUrl|escape:'htmlall':'UTF-8'}">
						<i class="icon-th-list"></i>{l s=' Back to carriers list' d='Modules.Agilemultisellerpro.Product'}
					</a>
				</div>
				<div class="col-xs-12 col-md-6 text-xs-center text-md-right pt-1 pb-2">
					<button class="btn btn-primary form-control-submit"
							name="submitCarrierLocation" value="1"
							data-link-action="save-customer" type="submit">
						{l s='Save' d='Shop.Theme.Actions'}
					</button>
				</div>
			</div>
		</form>
	{/if}
{/block}
