{*
* 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 $freeMembershipEligibility}
    {$freeMembershipEligibility nofilter}
{/if}

<div id="agile_order_carriers">
    <input type="hidden" id="id_cart_sellershipping" value="{$id_cart_sellershipping|intval}">

    <div class="row">
        <legend class="mb-1">
            {l s='Shipping Carrier Selection' d='Modules.Agilemultisellerpro.Shippingcheckoutstep'}
        </legend>
        <p>{l s='You are able to choose a different shipping carrier for each seller, this will affect the total shipping fees.' d='Modules.Agilemultisellerpro.Shippingcheckoutstep'}</p>
    </div>

    {foreach from=$shippingData item=shipping }
        <div class="row mt-2 mb-2">
            <div class="col-xs-4 col-md-2 mt-1">
                <a target="_blank" href="{$shipping.sellerLink|escape:'htmlall':'UTF-8'}">
                    <img src="{$shipping.logoImageUrl|escape:'htmlall':'UTF-8'}" alt="{$shipping.shop->name|escape:'htmlall':'UTF-8'}" width="80" />
                </a>
            </div>

            <div class="col-xs-8 col-md-4 mt-1">
                <h5>
                    <a target="_blank" id="agile_prod_name_{$shipping.idSellerinfo|intval}" class="agile-prod-name" href="{$shipping.sellerLink|escape:'htmlall':'UTF-8'}">{$shipping.shop->name|escape:'htmlall':'UTF-8'}</a>
                </h5>
                <a href="#" class="js-display-seller-products" data-idsellerinfo="{$shipping.idSellerinfo|escape:'htmlall':'UTF-8'}">
                    {l s='Items' d='Modules.Agilemultisellerpro.Shippingcheckoutstep'}: {$shipping.count_products|escape:'htmlall':'UTF-8'}
                </a>
            </div>

            <div class="col-xs-12 col-md-6 mt-1">
                <select class="form-control form-control-select"
                        name="id_carrier_sellershipping_{$shipping.idSellerinfo|escape:'htmlall':'UTF-8'}" id="id_carrier_sellershipping_{$shipping.idSellerinfo|escape:'htmlall':'UTF-8'}"
                        onchange="update_seller_carrier_real({$shipping.idSellerinfo|escape:'htmlall':'UTF-8'}, {$id_cart_sellershipping|escape:'htmlall':'UTF-8'})">

                    {foreach from=$shipping.carriers item=carrier}
                        {if $carrier.available == true}
                            <option value="{$carrier.adminCarrier->id_reference|escape:'htmlall':'UTF-8'}"{if $carrier.adminCarrier->id_reference == $shipping.selectedIdCarrierReference} selected{/if}>{$carrier.adminCarrier->name|escape:'htmlall':'UTF-8'}: ({$carrier.currentCurrencyPriceFormatted|escape:'htmlall':'UTF-8'})</option>
                        {/if}
                    {/foreach}
                </select>
                {if $shipping.isCariersAvailable == false}
                    <input type="hidden" id="isCariersAvailable" value="0">
                    <div class="alert alert-danger">
                        {l s='No available carriers!' d='Modules.Agilemultisellerpro.Shippingcheckoutstep'}
                    </div>
                {else}
                    <div class="agl-carrier-locations" id="id_carrier_locations_{$shipping.idSellerinfo|intval}"></div>
                {/if}
            </div>

        </div>

        <div id="seller-products-list_{$shipping.idSellerinfo|escape:'htmlall':'UTF-8'}" style="display: none;">
        {foreach from=$shipping.products item=product name=productLoop}

            <div class="row mt-0 mb-1">

                <div class="col-xs-4 col-md-2 mt-0">
                    <a target="_parent" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">
                        <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, $image_size)|escape:'htmlall':'UTF-8'}" alt="{$product.name|escape:'htmlall':'UTF-8'}" width="50" />
                    </a>
                </div>

                <div class="col-xs-8 col-md-10 mt-0">
                    <h5>
                        <a target="_blank" class="agile-prod-name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a>
                    </h5>
                    {l s='Quantity' d='Modules.Agilemultisellerpro.Shippingcheckoutstep'}:{$product.cart_quantity|escape:'htmlall':'UTF-8'}<br>
                    {if isset($product.attributes) && $product.attributes}<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>{/if}
                </div>
            </div>

        {/foreach}
        </div>
    {/foreach}

    <div id="agile_map" style="height:300px;display:none"></div>

</div>
