{if (isset($mbe_uap) && $mbe_uap)}
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    if (typeof jQuery === 'undefined') {
        document.write(unescape("%3Cscript src='js/jquery.js' type='text/javascript'%3E%3C/script%3E"));
    }
</script>



<script type="text/javascript">
    $(document).ready(function() {

        if( $( "#delivery_option_{$carrierId}" ).is(':checked')){
            $( "#mbeuap{$carrierId}" ).prop('required', true);
        }

        $('input:radio').change(function() {
            if(this.id === "delivery_option_{$carrierId}")
            {
                $( "#mbeuap{$carrierId}" ).prop('required', true);//.attr('required', 'required');
            }
            else
            {
                $( "#mbeuap{$carrierId}").prop('required', false);//.removeAttr('required');
            }
        });
        var uapList = '{$suap}';
        $( "#mbeuap{$carrierId}" ).change(function () {
            var selectedUap = $("#mbeuap{$carrierId}").children("option:selected").val();

            var setUAP{$carrierId} ='{url entity='module' name='mbeshipping' controller='mbeuap' params=['ajax' => true, 'mbeSelectedUap' => selectedUap, 'mbeUapList' => uapList, 'action' => 'setUAP']}';

            $.ajax({
                type: 'POST',
                url: setUAP{$carrierId},
                cache: false,
                data: {
                    ajax : true,
                    action: 'setUAP',
                    mbeSelectedUap: selectedUap,
                    mbeUapList: uapList,
                },
                success: function(resp, textStatus, jqXHR)
                {
                    console.log('SET UAP');
                },
                error: function(res,textStatus,jqXHR)
                {
                    console.log(res);
                    console.log(textStatus);
                    console.log(jqXHR);
                }
            });
        });
    });
</script>

<div class="form-group row">
    <div class="col-md-12">
        <p>{l s='Set Shipping address to UAP (optional)' d='Modules.mbeshipping'}
        </p>
        <select class="form-control" id="mbeuap{$carrierId}" >
            <option value="">{l s="Select a UAP" d='Modules.mbeshipping'}</option>
            {foreach $uapList as $uap}
                <option value="{$uap['PublicAccessPointID']}">{$uap['Distance']} - {$uap['ConsigneeName']}, {$uap['AddressLine']}, {$uap['PoliticalDivision2']} ({$uap['StandardHoursOfOperation']})</option>
            {/foreach}
        </select>
    </div>
</div>
<div></div>
<div class="form-group row"></div>
{/if}