templates/frontend/checkout.html.twig line 1

Open in your IDE?
  1.     {% extends 'admin/base.html.twig' %}
  2.     {% block title %}La livraison et coupon rabais
  3.     {% endblock %}
  4.     {% block _cart_checkout_newAddress_widget %}
  5.         <div class="row">
  6.             <div class="col-md-8">{{form_row(form.name)}}</div>
  7.             <div class="col-md-4">{{form_row(form.phone)}}</div>
  8.         </div>
  9.         <div class="row">
  10.             <div class="col-md-3">{{form_row(form.civicNumber)}}</div>
  11.             <div class="col-md-6">{{form_row(form.streetName)}}</div>
  12.             <div class="col-md-3">{{form_row(form.unit)}}</div>
  13.         </div>
  14.         <div class="row">
  15.             <div class="col-md-4">{{form_row(form.city)}}</div>
  16.             <div class="col-md-4">{{form_row(form.province)}}</div>
  17.             <div class="col-md-4">{{form_row(form.zipCode)}}</div>
  18.         </div>
  19.         {#
  20.         <div class="row">
  21.             <div class="col-md-12">{{form_row(form.note)}}</div>
  22.         </div>
  23.         #}
  24.     {% endblock %}
  25.     {% block CSS %}
  26.     <link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
  27.     <link rel="stylesheet" href="/resources/demos/style.css">
  28.         <link rel="stylesheet" type="text/css" href="{{ asset('build/frontend/checkout.css') }}">
  29.         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />
  30.         <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet"/>
  31.     {% endblock %}
  32.     {% block JS %}
  33.         <script src="{{ asset('build/frontend/checkout.js') }}"></script>
  34.         <script src="/assets/frontend/js/jquery-3.1.1.min.js"></script>
  35.         <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous"></script>
  36.         <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/locale/fr.min.js" integrity="sha512-RAt2+PIRwJiyjWpzvvhKAG2LEdPpQhTgWfbEkFDCo8wC4rFYh5GQzJBVIFDswwaEDEYX16GEE/4fpeDNr7OIZw==" crossorigin="anonymous"></script>
  37.         <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  38.         <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
  39.         <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" integrity="sha512-T/tUfKSV1bihCnd+MxKD0Hm1uBBroVYBOYSk1knyvQ9VyZJpc/ALb4P0r6ubwVPSGB2GvjeoMAJJImBG12TiaQ==" crossorigin="anonymous"></script>
  40.         <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/locales/bootstrap-datepicker.fr.min.js" integrity="sha512-fx3aztaUjb4NyoD+Tso5g7R1l29bU3jnnTfNRKBiY9fdQOHzVhKJ10wEAgQ1zM/WXCzB9bnVryHD1M40775Tsw==" crossorigin="anonymous"></script>
  41.         {% if global.getCart.hasJIT %}
  42.         <script>
  43.         var cartHasJIT = true;
  44.         </script>
  45.         {% else %}
  46.         <script>
  47.         var cartHasJIT = false;
  48.         </script>
  49.         {% endif %}
  50.         <script type="text/javascript">
  51.     //$("#action_shipping").prop("checked", true);    
  52.         $('#checkPickUp').css("color", "gray");
  53.         var actionShipping = document.querySelector('#action_shipping');
  54.         {# console.log(actionShipping.checked); #}
  55.         if (actionShipping.checked == false){
  56.                 $("#choiceShippingDate").hide();
  57.             $("#blocPickUp").show();
  58.             $("#blocShipping").hide();
  59.             $('#checkPickUp').css("color", "black");
  60.             $('#checkShipping').css("color", "gray");
  61.         }else if(actionShipping.checked == true){
  62.             $("#blocPickUp").hide();
  63.             $("#blocShipping").show();
  64.             $("#choiceShippingDate").show();
  65.             $('#checkShipping').css("color", "black");
  66.             //$('#checkGift').css("color", "gray");
  67.             $('#checkPickUp').css("color", "gray");
  68.             $("#blocGift").show();
  69.         }
  70.         
  71.         //$('#checkGift').css("color", "gray");
  72.         $(document.body).on("click",'.choiceCustomShipping', function() {
  73.         var test = $(".choiceCustomShipping").not(this).prop('checked', false);
  74.         //console.log(test.val());
  75.     if (this.checked) {
  76.         this.setAttribute("checked", "checked");
  77.         var selectBox =  $(this).val();
  78.         //console.log(selectBox);
  79.         if (selectBox == "domicile"){
  80.             $("#blocPickUp").hide();
  81.             $("#blocShipping").show();
  82.             $("#choiceShippingDate").show();
  83.             $('#checkShipping').css("color", "black");
  84.             //$('#checkGift').css("color", "gray");
  85.             $('#checkPickUp').css("color", "gray");
  86.             $("#blocGift").show();    
  87.         }else if(selectBox == "cueillette") {
  88.             $("#DeliveryChoiceCheckbox").removeAttr('checked');
  89.             $("#pickupSchedule").attr("disabled", false);
  90.             $("#choiceShippingDate").hide();
  91.             $("#pickupAdressBlock").show();
  92.             $("#blocPickUp").show();
  93.             $("#blocShipping").hide();
  94.             $('#checkPickUp').css("color", "black");
  95.             $('#checkShipping').css("color", "gray");
  96.              $('#checkGift').removeAttr('checked');
  97.             $("#blocGift").hide();    
  98.         }
  99.         /*else{
  100.             $("#blocShipping").hide();
  101.             $("#choiceShippingDate").show();
  102.             // $('#checkGift').css("color", "black");
  103.             $('#checkShipping').css("color", "gray");
  104.             $('#checkPickUp').css("color", "gray");
  105.             // $("#blocGift").show();
  106.             $("#blocPickUp").hide();
  107.         }*/
  108.         
  109.     } 
  110.         test.removeAttr('checked');
  111.     
  112.     });
  113.             $(function () {
  114.                 $(document.body).on('change','#adresse_province', function(e) {
  115.                     if ($(this).val() == "QC") {
  116.                         $('#newAddress_cityQC').show();
  117.                         $('#newAddress_cityAny').hide();
  118.                         $('#newAddress_cityON').hide();
  119.                     }else if ($(this).val() == "ON") {
  120.                         $('#newAddress_cityQC').hide();
  121.                         $('#newAddress_cityAny').hide();
  122.                         $('#newAddress_cityON').show();
  123.                     } else {
  124.                         $('#newAddress_cityQC').hide();
  125.                         $('#newAddress_cityAny').show();
  126.                         $('#newAddress_cityON').hide();
  127.                     }
  128.                 });
  129.                 $(document.body).on('click','#proceedToPaymentSubmitBtn', function(e) {
  130.                     var formIsValid = true;
  131.                     var errorMsg = 'Veuillez remplir ce champ.';
  132.                     if ($('#checkoutAddressSelection').val() == "none") {
  133.                         var selectCheckbox = document.getElementById("pickupScheduleCheckbox");
  134.                         var selectCheckboxValue = selectCheckbox.checked;
  135.                         //console.log(selectCheckboxValue);
  136.                         if (selectCheckboxValue == false){
  137.                             //SaveMyAdresse();
  138.                         var selector = 'newAddress_name';
  139.                         if (!$('#'+selector).val()) {
  140.                             $('#'+selector).get(0).setCustomValidity(errorMsg);
  141.                             formIsValid = false;
  142.                         } else {
  143.                             $('#'+selector).get(0).setCustomValidity("");
  144.                         }
  145.                         {# var selector = 'street_number';
  146.                         if (!$('#'+selector).val()) {
  147.                             $('#'+selector).get(0).setCustomValidity(errorMsg);
  148.                             formIsValid = false;
  149.                         } else {
  150.                             $('#'+selector).get(0).setCustomValidity("");
  151.                         } #}
  152.                         var selector = 'postal_code';
  153.                         if (!$('#'+selector).val()) {
  154.                             $('#'+selector).get(0).setCustomValidity(errorMsg);
  155.                             formIsValid = false;
  156.                         } else {
  157.                             $('#'+selector).get(0).setCustomValidity("");
  158.                         }
  159.                         var selector = 'newAddress_phone';
  160.                         if (!$('#'+selector).val()) {
  161.                             $('#'+selector).get(0).setCustomValidity(errorMsg);
  162.                             formIsValid = false;
  163.                         } else {
  164.                             $('#'+selector).get(0).setCustomValidity("");
  165.                         }
  166.                         }
  167.                     }
  168.                     //console.log(selector);
  169.                     if (!formIsValid) {
  170.                         document.getElementById('se-pre-con').style.display='none';
  171.                     } else {
  172.                         
  173.                         $('#proceedToPaymentForm').submit();
  174.                         document.getElementById('se-pre-con').style.display='initial';
  175.                     }
  176.                 });
  177.                 $(document.body).on('change','#checkoutAddressSelection', function(e) {
  178.                     if ($(this).val() == "none") {
  179.                         $('#add_new_address').show();
  180.                         $('#proceedToPaymentSubmitBtn').html("Enregistrer et Passer au Paiement");
  181.                     } else {
  182.                         $('#proceedToPaymentSubmitBtn').html("Passer au paiement");
  183.                         $('#add_new_address').hide();
  184.                     }
  185.                     updateDeliveryDateEstimate();
  186.                 });
  187.                 $(document.body).on('change','#newAddress_citySelectQC', function(e) {
  188.                     updateDeliveryDateEstimate();
  189.                 });
  190.                 $(document.body).on('change','#newAddress_citySelectON', function(e) {
  191.                     updateDeliveryDateEstimate();
  192.                 });
  193.                 $(document.body).on('change','#newAddress_cityInputAny', function(e) {
  194.                     updateDeliveryDateEstimate();
  195.                 });
  196.                 var updateDeliveryDateEstimate = function() {
  197.                     //$('#deliveryEstimateCard').hide();
  198.                     //$('#deliveryEstimateSpinner').show();
  199.                     var shippingAddressId = $('#checkoutAddressSelection').val();
  200.                     
  201.                     var shippingAddressCity = false;
  202.                     var newAddressProvince = $('#newAddress_province').find(":selected").val();
  203.                     if (shippingAddressId == "none") {
  204.                         if (newAddressProvince == "QC") {
  205.                             shippingAddressCity = $('#newAddress_citySelectQC').val();
  206.                         } else if (newAddressProvince == "ON") {
  207.                             shippingAddressCity = $('#newAddress_citySelectON').val();
  208.                         } else {
  209.                             shippingAddressCity = $('#newAddress_cityInputAny').val();
  210.                         }
  211.                     }
  212.                     if (shippingAddressId == "none" && !shippingAddressCity) {
  213.                         return;
  214.                     }
  215.                     $.post( "/deliveryEstimateAjax", {
  216.                         shippingAddressId: shippingAddressId,
  217.                         shippingAddressCity: shippingAddressCity,
  218.                         newAddressProvince: newAddressProvince
  219.                     }).done(function( jsonData ) {
  220.                             var data = JSON.parse(jsonData);
  221.                     //console.log( data );
  222.                         
  223.                             var options = { weekday: 'long',year: 'numeric', month: 'long', day: 'numeric' };
  224.                             var daylivraison = new Date(data.route);
  225.                             var livraison = daylivraison.toLocaleDateString("fr-FR", options);
  226.                             var thisDay = new Date();
  227.                             var phraseDateChoice = null
  228.                             var spanEvolutiveDateDelivery = null;
  229.                             var phraseDateChoice = null;
  230.                             if (data.dow != false){
  231.                                 spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
  232.                                 phraseDateChoice = livraison;
  233.                             }else {
  234.                                 Date.prototype.addDays = function(days) {
  235.                                     var date = new Date(this.valueOf());
  236.                                     date.setDate(date.getDate() + days);
  237.                                     return date;
  238.                                 }
  239.                                 if (thisDay.getDay() == 1 || thisDay.getDay() == 2){
  240.                                     if (thisDay.getDay() == 2 && thisDay.getHours() < 12){
  241.                                     var Purolivraison = new Date(daylivraison.getTime() + 7 * 24 * 60 * 60 * 1000);
  242.                                     }
  243.                                     var Purolivraison = daylivraison;
  244.                                 }else{
  245.                                 var Purolivraison = daylivraison;
  246.                                 }
  247.                                 var PuroFormatLivraison = Purolivraison.toLocaleDateString("fr-FR", options);
  248.                                 var addTwoDaysToDate = Purolivraison.addDays(2);
  249.                                 var livraisonAdd48h = addTwoDaysToDate.toLocaleDateString("fr-FR", options);
  250.                                 spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
  251.                                 phraseDateChoice = ' entre le ' + PuroFormatLivraison + ' et le ' +  livraisonAdd48h;
  252.                             }
  253.                             //console.log(phraseDateChoice);
  254.                             if (phraseDateChoice){
  255.                             spanEvolutiveDateDelivery.innerHTML = phraseDateChoice;
  256.                             }
  257.                             var daysOfWeekDisabled = [0,1,2,3,4,5,6];
  258.                             if (data.dow) {
  259.                                 var index = daysOfWeekDisabled.indexOf(data.dow);
  260.                                 if (index !== -1) {
  261.                                     daysOfWeekDisabled.splice(index, 1);
  262.                                 }
  263.                             } else {
  264.                                 daysOfWeekDisabled = [0,1,5,6];
  265.                             }
  266.                             
  267.                             if (data.idRoute == "19") {
  268.                                 daysOfWeekDisabled = [0,1,5,6];
  269.                             } 
  270.                             if (data.idRoute == "18" || data.nameRoute == "Agglo Longueuil") {
  271.                                 daysOfWeekDisabled = [0,1,5,6];
  272.                             } 
  273.                             $( "#datepickerCustomDelivery" ).datepicker('destroy');
  274.                             var now = new Date();
  275.                             var startDate = new Date();
  276.                             if (cartHasJIT){
  277.                                     if (now.getDay() == 6 || now.getDay() == 0){
  278.                                         var numberOfDaysToAdd = 2;
  279.                                     }else if (now.getDay() >= 1 || now.getDay() <= 3){
  280.                                         var numberOfDaysToAdd = 5;
  281.                                     }else{
  282.                                         var numberOfDaysToAdd = 2;
  283.                                     }
  284.                             }else{
  285.                                 if (data.dow != false){
  286.                                     var numberOfDaysToAdd = 2;
  287.                                 }else{
  288.                                     var numberOfDaysToAdd = 5;
  289.                                 }
  290.                             }
  291.                             startDate.setDate(startDate.getDate() + numberOfDaysToAdd);
  292.                             $( "#datepickerCustomDelivery" ).datepicker({
  293.                                 daysOfWeekDisabled: daysOfWeekDisabled,
  294.                                 endDate: '+2m',
  295.                                 orientation: "bottom left", 
  296.                                 startDate: startDate,
  297.                                 format: 'DD d MM yyyy',
  298.                                 language: 'fr'
  299.                             });
  300.                             $('#deliveryEstimateSpinner').hide();
  301.                             $('#deliveryEstimateCard').show();
  302.                     });
  303.                 }
  304.             $(function() {
  305.                             $('#pickupScheduleCheckbox').click(function() {
  306.                                 $('#DeliveryChoiceCheckbox').prop( "checked", false );
  307.                             });
  308.                             $('#DeliveryChoiceCheckbox').change(function () {
  309.                         if ($(this).prop('checked')) {
  310.                                         $('#pickupAdressBlock').hide();
  311.                                         $('#pickupSchedule').attr("disabled", true);
  312.                                         $('#action_gift').attr("disabled", false);
  313.                                         $('#pickupScheduleCheckbox').prop( "checked", false );
  314.                                         $('#customDelivery').show();
  315.                                     } else {
  316.                                         $('#customDelivery').hide();
  317.                                     }
  318.                             });
  319.                 $("#datepickerCustomDelivery").on("change",function() {
  320.                     var selected = $(this).val();
  321.                                 //console.log(selected);
  322.                                 $("#datepickerCustomDelivery").datepicker('hide');
  323.                     spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
  324.                     if (selected){
  325.                         spanEvolutiveDateDelivery.innerHTML = selected;
  326.                     }
  327.                 });
  328.             });
  329.                 updateDeliveryDateEstimate();
  330.                 var now = new Date();
  331.                 now.setDate(now.getDate() + 1);
  332.                 var startDate = now;
  333.                 if (cartHasJIT) {
  334.                     console.log('+++with jit');
  335.                     var x = 2;
  336.                     var now = new Date();
  337.                     now.setDate(now.getDate() + (x+(7-now.getDay())) % 7);
  338.                     startDate = now;
  339.                 }
  340.                 /*console.log("----");
  341.                 console.log(moment(startDate).format("DD d MM yyyy"));
  342.                 console.log("----");*/
  343.             $('#pickupSchedule').datepicker({
  344.                     format: 'dd/mm/yyyy',
  345.                     startDate: moment(startDate).format("DD d MM yyyy"),
  346.                         autoclose: true,
  347.                         language: 'fr',
  348.                         // minDate: moment().add(12, "hours").format("DD/MM/YYYY"),
  349.                         endDate: moment().add(7, "days").format("DD d MM yyyy"),
  350.                 }).on('changeDate', function(e) {
  351.                     var date = e.date;
  352.                     var selected_date = moment(date).format("DD/MM/YYYY");
  353.                     var tomorrow_date = moment().add(1, "day").format("DD d MM yyyy");
  354.                     var is_tomorrow = false;
  355.                     if (selected_date == tomorrow_date) {
  356.                         is_tomorrow = true;
  357.                     }
  358.                     var dayOfWeek = date.getDay();
  359.                     generateDateTimePicker(dayOfWeek, is_tomorrow);
  360.                 });
  361.                     $(document.body).on('change','#cart_checkout_newAddress_province', function(e) {
  362.                         if ($(this).val()=="QC") {
  363.                             $('.citySearchClass').next(".select2-container").show();
  364.                             $('.citySearchClass').replaceWith('<select id="cart_checkout_newAddress_city" class="form-control citySearchClass" name="cart_checkout[newAddress][city]" style="display:none;"></select>');
  365.                         } else {
  366.                             $('.citySearchClass').next(".select2-container").hide();
  367.                             $('.citySearchClass').replaceWith('<input type="text" name="cart_checkout[newAddress][city]" required class="form-control citySearchClass">');
  368.                         }
  369.                         // $('#manualCityName').show();
  370.                     });
  371.                     $(document.body).on('click','#timepicker_hour', function(e) {
  372.                         $( ".timepicker-selected" ).each(function( index, element ) {
  373.                             $(element).removeClass("timepicker-selected");
  374.                         });
  375.                         $(this).find("div").addClass("timepicker-selected");
  376.                         var hour = $(this).attr("data-id");
  377.                         var pickupSchedule = $('#pickupSchedule').val() + ' ' + hour;
  378.                         $('#pickupScheduleHidden').val(pickupSchedule);
  379.                     });
  380.                     var generateDateTimePicker = function(dayOfWeek, is_tomorrow) {
  381.                         $('#pickupScheduleHidden').val('');
  382.                         var HTML = '';
  383.                         var schedule = JSON.parse(pickupSchedule);
  384.                         if (!schedule[String(dayOfWeek)]) {
  385.                             HTML += '<div class="col-12" > \
  386.                                 <div class="timepicker-hour-box timepicker-warning"> \
  387.                                     <strong>Aucune disponibilitée durant cette journée. Veuillez choisir une autre date.</strong> \
  388.                                 </div> \
  389.                             </div>';
  390.                         }
  391.                         var hours = schedule[String(dayOfWeek)];
  392.                         for(hour in hours) {
  393.                             var is_disabled = false;
  394.                             if (is_tomorrow) {
  395.                                 if (moment().format("HH\hmm") >="12h00" && hours[hour][0] <= "12h00") {
  396.                                         is_disabled = true;
  397.                                 }
  398.                             }
  399.                             if (cartHasJIT) {
  400.                                 //between tuesday 12 PM to friday 12PM for JIT
  401.                                 if (dayOfWeek == 2) {
  402.                                     if (hours[hour][0] < "12h00") {
  403.                                         is_disabled = true;
  404.                                     }
  405.                                 }
  406.                                 /*if (dayOfWeek == 5) {
  407.                                     if (hours[hour][0] > "12h00") {
  408.                                         is_disabled = true;
  409.                                     }
  410.                                 }*/
  411.                             }
  412.                             HTML += '<div class="col-3 mb-3" ';
  413.                             if (!is_disabled) {
  414.                                 HTML += ' id="timepicker_hour" ';
  415.                             }
  416.                             HTML += ' data-id="'+hours[hour][0]+'"> \
  417.                                 <div class="timepicker-hour-box';
  418.                             if (is_disabled) {
  419.                                 HTML += ' timepicker-hour-box-disabled ';
  420.                             }
  421.                             HTML += '"> \
  422.                                     <strong>'+hours[hour][0]+'</strong> \
  423.                                 </div> \
  424.                             </div>';
  425.                         }
  426.                         $('#dateTimePickerRow').html(HTML);
  427.                         $('#datetime_picker').show();
  428.                         $('#dateTimePickerRow').show();
  429.                     }
  430.                     var pickupLocationScheduleDisplay = function() {
  431.                         var HTML = '';
  432.                         var schedule = JSON.parse(pickupSchedule);
  433.                         for ( dayOfWeek in schedule) {
  434.                             var dayOfWeekString = '';
  435.                             if (dayOfWeek == 1) { dayOfWeekString = "Lundi"; }
  436.                             if (dayOfWeek == 2) { dayOfWeekString = "Mardi"; }
  437.                             if (dayOfWeek == 3) { dayOfWeekString = "Mercredi"; }
  438.                             if (dayOfWeek == 4) { dayOfWeekString = "Jeudi"; }
  439.                             if (dayOfWeek == 5) { dayOfWeekString = "Vendredi"; }
  440.                             if (dayOfWeek == 6) { dayOfWeekString = "Samedi"; }
  441.                             if (dayOfWeek == 7) { dayOfWeekString = "Dimanche"; }
  442.                             HTML += "&bull; " + dayOfWeekString + " : ";
  443.                             var hours = schedule[String(dayOfWeek)];
  444.                             var hours_start = hours.shift();
  445.                             var hours_end = hours[hours.length - 1];
  446.                             HTML += hours_start[0] + ' à ' + hours_end[1];
  447.                             HTML += "<br/>" ;
  448.                         }
  449.                         $('#pickupLocationScheduleDisplay').html(HTML);
  450.                     }
  451.                     pickupLocationScheduleDisplay();
  452.             $('#pickupLocations').change(function () {
  453.                         $('#datetimeSelectionRow').show();
  454.                         var newPickupLocation = $('#pickupLocations').val();
  455.                         $('#pickupLocation').val(newPickupLocation);
  456.                         var pickupSchedulesObject = JSON.parse(pickupSchedules);
  457.                         var newPickupSchedule = JSON.stringify(pickupSchedulesObject[newPickupLocation]);
  458.                         pickupSchedule = newPickupSchedule;
  459.                         var _daysOfWeekDisabled = [ 0, 1, 2, 3, 4, 5, 6 ];
  460.                         for ( var index in pickupSchedulesObject[newPickupLocation] ) {
  461.                             if (cartHasJIT && index == 1) {
  462.                                 continue;
  463.                             }
  464.                             delete _daysOfWeekDisabled[index];
  465.                         }
  466.                         var _daysOfWeekDisabled = _daysOfWeekDisabled.filter(function (el) {
  467.                         return el != null;
  468.                         });
  469.                         $('#pickupSchedule').datepicker('destroy');
  470.                         var now = new Date('monday');
  471.                         var _startDate ;
  472.                         if (now.getDay() >= 3 && cartHasJIT) {
  473.                             //if wednesday go to next week
  474.                             var startDate = 7-now.getDay() ;
  475.                             _startDate = moment().add(startDate, "days").format("DD/MM/YYYY");
  476.                             _endDate = moment(_startDate, 'DD/MM/YYYY').add(10, "days").format("DD/MM/YYYY");
  477.                         }else{
  478.                             _startDate = moment().add(1, "days").format("DD/MM/YYYY");
  479.                             _endDate = moment(_startDate, 'DD/MM/YYYY').add(10, "days").format("DD/MM/YYYY");
  480.                         }
  481.                         if (cartHasJIT) {
  482.                             console.log("cart has JIT");
  483.                             const dayINeed = 2; // for tuesday
  484.                             const today = moment().isoWeekday();
  485.                             // if we haven't yet passed the day of the week that I need:
  486.                             /*if (today <= dayINeed) {
  487.                                 _startDate= moment().isoWeekday(dayINeed).format("DD/MM/YYYY");
  488.                             } else {*/
  489.                                 _startDate = moment().add(1, 'weeks').isoWeekday(dayINeed).format("DD/MM/YYYY");
  490.                             //}
  491.                             //_startDate = moment().add(_startDate.getDay(), "days").format("DD/MM/YYYY");
  492.                             _endDate = moment(_startDate, 'DD/MM/YYYY').add(7, "days").format("DD/MM/YYYY");
  493.                             _currentDate = moment().format("DD/MM/YYYY");
  494.                         }
  495.                         console.log(_startDate);
  496.                         $('#pickupSchedule').datepicker({
  497.                             format: 'DD d MM yyyy',
  498.                             startDate: _startDate,
  499.                                 autoclose: true,
  500.                                 language: 'fr',
  501.                                 orientation: "left bottom",
  502.                                 daysOfWeekDisabled: _daysOfWeekDisabled,
  503.                                 endDate: _endDate,
  504.                         }).on('changeDate', function(e) {
  505.                             var date = e.date;
  506.                             var selected_date = moment(date).format("DD d MM yyyy");
  507.                             var today_date = moment().format("DD d MM yyyy");
  508.                             var tomorrow_date = moment().add(1, "day").format("DD d MM yyyy");
  509.                             var is_tomorrow = false;
  510.                             if (selected_date == tomorrow_date) {
  511.                                 is_tomorrow = true;
  512.                             }
  513.                             var dayOfWeek = date.getDay();
  514.                             generateDateTimePicker(dayOfWeek, is_tomorrow);
  515.                         });
  516.                         $('#pickupScheduleHidden').val('');
  517.                         $('#pickupSchedule').val('');
  518.                         $('#datetime_picker').hide();
  519.                         $('#dateTimePickerRow').hide();
  520.                         pickupLocationScheduleDisplay();
  521.                     });
  522.             /*$('#pickupScheduleCheckbox').change(function () {
  523.                 if ($(this).prop('checked')) {
  524.                                             $('#customDelivery').hide();
  525.                                             $('#pickupAdressBlock').show();
  526.                         $('#pickupSchedule').attr("disabled", false);
  527.                         $('#action_bulkshipping').attr("disabled", true);
  528.                     } else {
  529.                                             $('#pickupAdressBlock').hide();
  530.                         $('#pickupSchedule').attr("disabled", true);
  531.                         $('#action_bulkshipping').attr("disabled", false);
  532.                     }
  533.                 });
  534.     */
  535.             });
  536.             $(document).ready(function () {
  537.                 $('#newAddress_citySelectQC').select2({
  538.                 ajax: {
  539.                         delay: 250,
  540.                         url: '{{ path('cityAdressAJAXSearch',{ 'province': 'QC'}) }}',
  541.                         dataType: 'json'
  542.                     },
  543.                                     "language": {
  544.                                     "noResults": function(){
  545.                                         return "Veuillez entrer le nom d'une ville...";
  546.                                     }
  547.                                 },
  548.                 });
  549.             });
  550.             $(document).ready(function () {
  551.                 $('#newAddress_citySelectON').select2({
  552.                 ajax: {
  553.                         delay: 250,
  554.                         url: '{{ path('cityAdressAJAXSearch',{ 'province': 'ON'}) }}',
  555.                         dataType: 'json'
  556.                     },
  557.                                     "language": {
  558.                                     "noResults": function(){
  559.                                         return "Veuillez entrer le nom d'une ville d'ontario...";
  560.                                     }
  561.                                 },
  562.                 });
  563.             });
  564.         </script>
  565.     <script>
  566.         </script>
  567.         <!-- Include Google Maps JS API -->
  568.         <script type="text/javascript"  src="https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyBpav0kc3zAMAcy7DhIto2hDhPivUCr3vI&langues=fr"></script>
  569.         <script>
  570. // This sample uses the Places Autocomplete widget to:
  571. // 1. Help the user select a place
  572. // 2. Retrieve the address components associated with that place
  573. // 3. Populate the form fields with those address components.
  574. // This sample requires the Places library, Maps JavaScript API.
  575. // Include the libraries=places parameter when you first load the API.
  576. // For example: <script
  577. // src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
  578. let autocomplete;
  579. let address1Field;
  580. let address2Field;
  581. let postalField;
  582. function initAutocomplete() {
  583.   address1Field = document.querySelector("#newAddress_autocomplete");
  584.   address2Field = document.querySelector("#newAddress_unit");
  585.   postalField = document.querySelector("#postal_code");
  586.     const center = { lat: 45.5333387, lng: -73.4200318 };
  587.     // Create a bounding box with sides ~10km away from the center point
  588.     const defaultBounds = {
  589.     north: center.lat + 0.5,
  590.     south: center.lat - 0.5,
  591.     east: center.lng + 0.5,
  592.     west: center.lng - 0.5,
  593.     };
  594.   // Create the autocomplete object, restricting the search predictions to
  595.   // addresses in the Canada.
  596.   autocomplete = new google.maps.places.Autocomplete(address1Field, {
  597.     componentRestrictions: { country: ["ca"] },
  598.     bounds: defaultBounds,
  599.    // fields: ["address_components", "geometry"],
  600.     types: ["address"],
  601.   });
  602.   address1Field.focus();
  603.   // When the user selects an address from the drop-down, populate the
  604.   // address fields in the form.
  605.   autocomplete.addListener("place_changed", fillInAddress);
  606. }
  607. function fillInAddress() {
  608.   // Get the place details from the autocomplete object.
  609.   const place = autocomplete.getPlace();
  610.   let address1 = "";
  611.   let postcode = "";
  612.   // Get each component of the address from the place details,
  613.   // and then fill-in the corresponding field on the form.
  614.   // place.address_components are google.maps.GeocoderAddressComponent objects
  615.   // which are documented at http://goo.gle/3l5i5Mr
  616.   for (const component of place.address_components) {
  617.     // @ts-ignore remove once typings fixed
  618.     const componentType = component.types[0];
  619.     switch (componentType) {
  620.       case "street_number": {
  621.         address1 = `${component.long_name} ${address1}`;
  622.         break;
  623.       }
  624.       case "route": {
  625.         address1 += component.long_name;
  626.         break;
  627.       }
  628.       case "postal_code": {
  629.         postcode = `${component.long_name}${postcode}`;
  630.         break;
  631.       }
  632.       case "postal_code_suffix": {
  633.         postcode = `${postcode}-${component.long_name}`;
  634.         break;
  635.       }
  636.       case "locality":
  637.         document.querySelector("#adresse_city").value = component.long_name;
  638.         break;
  639.       case "administrative_area_level_1": {
  640.         document.querySelector("#adresse_province").value = component.short_name;
  641.         break;
  642.       }
  643.     }
  644.   }
  645.   address1Field.value = address1;
  646.   postalField.value = postcode;
  647.   // After filling the form with address components from the Autocomplete
  648.   // prediction, set cursor focus on the second address line to encourage
  649.   // entry of subpremise information such as apartment, unit, or floor number.
  650.   address2Field.focus();
  651. }
  652. window.initAutocomplete = initAutocomplete;
  653.         {# function initializeAutocomplete(id) {
  654.         var element = document.getElementById(id);
  655.         const options = {
  656.             componentRestrictions: { country: "ca" },
  657.             types: ['address']
  658.         };
  659.         if (element) {
  660.             var autocomplete = new google.maps.places.Autocomplete(element, options);
  661.             google.maps.event.addListener(autocomplete, 'place_changed', onPlaceChanged);
  662.         }
  663.         } #}
  664.         function onPlaceChanged() {
  665.         var place = this.getPlace();
  666.         //console.log(place);  // Uncomment this line to view the full object returned by Google API.
  667.             for (var i in place.address_components) {
  668.                 var component = place.address_components[i];
  669.                 for (var j in component.types) {  // Some types are ["country", "political"]
  670.                 var type_element = document.getElementById(component.types[j]);
  671.                 if (type_element) {
  672.                     type_element.value = component.long_name;
  673.                 }
  674.                 }
  675.             }
  676.         }
  677.         function googleMapsCustomError(){
  678.             alert('Google Maps custom error triggered');
  679.         }
  680.         (function takeOverConsole() { // taken from http://tobyho.com/2012/07/27/taking-over-console-log/
  681.             var console = window.console
  682.             if (!console) return
  683.             function intercept(method) {
  684.                 var original = console[method]
  685.                 console[method] = function() {
  686.                 // check message
  687.                 if(arguments[0] && arguments[0].indexOf('OverQuotaMapError') !== -1) {
  688.                     googleMapsCustomError();
  689.                 }
  690.                 
  691.                     if (original.apply) {
  692.                         // Do this for normal browsers
  693.                         original.apply(console, arguments)
  694.                     } else {
  695.                         // Do this for IE
  696.                         var message = Array.prototype.slice.apply(arguments).join(' ')
  697.                         original(message)
  698.                     }
  699.                 }
  700.             }
  701.             var methods = ['error']; // only interested in the console.error method
  702.             for (var i = 0; i < methods.length; i++)
  703.                 intercept(methods[i])
  704.         }())
  705. window.gm_authFailure = function() {
  706.     // remove the map div or maybe call another API to load map
  707.    // maybe display a useful message to the user
  708.    document.getElementById('newAddress_autocomplete').id = 'newAddress';
  709.    var newInput = document.getElementById('newAddress');
  710.    newInput.name = 'newAddress';
  711.    newInput.classList.remove("pac-target-input");
  712.    newInput.classList.remove("gm-err-autocomplete");
  713.    newInput.style.removeProperty("background-image");
  714.    newInput.removeAttribute('disabled');
  715.    //alert('Google maps failed to load!');
  716. }
  717.         google.maps.event.addDomListener(window, 'load', function() {
  718.         initAutocomplete('newAddress_autocomplete');
  719.         });
  720.         {# google.maps.event.addDomListener(window, 'load', function() {
  721.         initializeAutocomplete('newAddressGift_autocomplete');
  722.         }); #}
  723.         function SaveMyAdresse(e) {
  724.             if ($('#newAddress_autocomplete').val()){
  725.                 var adresse_autocomplete = $('#newAddress_autocomplete').val(); 
  726.             }else{
  727.                 var adresse_autocomplete = $('#newAddress').val(); 
  728.             }
  729.                     
  730. //console.log(adresse_autocomplete);
  731.                     var adresse_phone = $('#newAddress_phone').val(); 
  732.                     var adresse_name = $('#newAddress_name').val();
  733.                     if ($('#newAddress_unit').val()){
  734.                         var adresse_unit = $('#newAddress_unit').val();
  735.                     }
  736.                     var adresse_zipcode = $('#postal_code').val(); 
  737.                     var adresse_city = $('#adresse_city').val();  
  738.                     var adresse_province = $('#adresse_province').val(); 
  739.                     //console.log(adresse_autocomplete);
  740.                 if (!adresse_name){ 
  741.                         document.getElementById("newAddress_name").style.border = "red solid 2px"
  742.                         event.preventDefault();
  743.                         event.stopImmediatePropagation();
  744.                         
  745.                         return window.location = "#proceedToPaymentForm";
  746.                 }    
  747.                 if (!adresse_phone){ 
  748.                         document.getElementById("newAddress_phone").style.border = "red solid 2px"
  749.                         event.preventDefault();
  750.                         event.stopImmediatePropagation();
  751.                         
  752.                         return window.location = "#proceedToPaymentForm";
  753.                 }
  754.                 if (!adresse_zipcode){ 
  755.                         document.getElementById("postal_code").style.border = "red solid 2px"
  756.                         event.preventDefault();
  757.                         event.stopImmediatePropagation();
  758.                         
  759.                         return window.location = "#proceedToPaymentForm";
  760.                 }
  761.                 if (!adresse_name){ 
  762.                         document.getElementById("newAddress_name").style.border = "red solid 2px"
  763.                         event.preventDefault();
  764.                         event.stopImmediatePropagation();
  765.                         
  766.                         return window.location = "#proceedToPaymentForm";
  767.                 }
  768.                 if (!adresse_city){ 
  769.                         document.getElementById("adresse_city").style.border = "red solid 2px"
  770.                         event.preventDefault();
  771.                         event.stopImmediatePropagation();
  772.                         
  773.                         return window.location = "#proceedToPaymentForm";
  774.                 }
  775.                 if (!adresse_province){ 
  776.                         document.getElementById("adresse_province").style.border = "red solid 2px"
  777.                         event.preventDefault();
  778.                         event.stopImmediatePropagation();
  779.                         
  780.                         return window.location = "#proceedToPaymentForm";
  781.                 }
  782.                 if (!adresse_autocomplete){ 
  783.                         document.getElementById("newAddress_autocomplete").style.border = "red solid 2px"
  784.                         event.preventDefault();
  785.                         event.stopImmediatePropagation();
  786.                         
  787.                         return  window.location = "#proceedToPaymentForm";
  788.                 }
  789.                     
  790.                     $.ajax({
  791.                         type: "POST",
  792.                         url: '{{ path('SaveNewAdress',{ 'adresse': 'adresse'})  }}',
  793.                         async: true,
  794.                         data: {
  795.                                 adresse_autocomplete: $('#newAddress_autocomplete').val(),
  796.                                 adresse_manuel: $('#newAddress').val(),
  797.                                 adresse_phone: $('#newAddress_phone').val(),
  798.                                 adresse_name: $('#newAddress_name').val(),
  799.                                 adresse_unit : $('#newAddress_unit').val(), 
  800.                                 adresse_zipcode : $('#postal_code').val(),
  801.                                 adresse_province : $('#adresse_province').val(), 
  802.                                 adresse_city : $('#adresse_city').val(), 
  803.                             },
  804.                         success: function () {
  805.                             console.log('success');
  806.                             location.reload(true)
  807.                         }
  808.                     });
  809.                      
  810.                 };
  811.         </script>
  812.         {% endblock %}
  813.         {% block content %}
  814.             <form method="post" id="proceedToPaymentForm">
  815.             <input type="hidden" name="action" value="proceed_to_payment">
  816.             <!-- Page-Title -->
  817.             <div class="row">
  818.                 <div class="col-lg-8 mx-auto">
  819.                     <div class="row">
  820.                         <div class="col-sm-12">
  821.                             <p class="product-subtitle-brand">
  822.                                 <ul class="breadcrumb breadcrump-cart pull-right" >
  823.                                     <li>
  824.                                         <a href="{{path('viewCart')}}" class="">Panier</a>
  825.                                     </li>
  826.                                     <li>
  827.                                         <a href="{{path('checkout')}}" class="">
  828.                                             <u>Livraison / Cueillette</u>
  829.                                         </a>
  830.                                     </li>
  831.                                     <li>
  832.                                         <a href="{{path('cartPayment')}}" class="">Paiement</a>
  833.                                     </li>
  834.                                     <li>
  835.                                         <a href="{{path('home')}}" class="">Retour au magasin</a>
  836.                                     </li>
  837.                                 </ul>
  838.                             </p>
  839.                         </div>
  840.                     </div>
  841.                     {# <h1 class="text-primary text-center">PAGE TEST</h1> #}
  842.                     <div class="card-box">
  843.                         <h4 class=" checkoutBlocTitle">
  844.                             Confirmez votre mode de livraison
  845.                         </h4>
  846.                         <div class="checkout-form d-flex">
  847.                         {% set isAPickUp = global.getCart.getIsPickupOmeloView  %}
  848.                                 <div id="checkShipping" class="py-3 pr-5" style="font-size: 18px;">
  849.                                 <input type="checkbox" value="domicile" class="choiceCustomShipping" {% if isAPickUp != 'Oui' %} checked="checked" {% endif %} name="action_shipping" id="action_shipping" />
  850.                                     <label for="action_shipping">Livraison à domicile</label>
  851.                                 </div>
  852.                                 <div id="checkPickUp" class="py-3 pr-5" style="font-size: 18px;">
  853.                                 <input type="checkbox" value="cueillette" class="choiceCustomShipping" {% if isAPickUp == 'Oui' %} checked="checked" {% endif %}  id="pickupScheduleCheckbox"  name="pickupScheduleCheckbox" />
  854.                                     <label for="pickupScheduleCheckbox">Point de cueillette</label>
  855.                                 </div>
  856.                                 {# <div id="checkGift" class="py-3" style="font-size: 18px;">
  857.                                 <input type="checkbox" value="cadeau" class="choiceCustomShipping" name="action_gift" id="action_gift" />
  858.                                     <label for="action_gift">Je veux faire un cadeau</label>
  859.                                 </div> #}
  860.                             </div>
  861.                             
  862.                     <!--end checkout-form-->
  863.                 <div id="blocShipping" style="{% if isAPickUp != 'Oui' %}display:none;{% endif %}">
  864.                 
  865.                             <h4 class="checkoutBlocTitle">
  866.                                 Entrez votre adresse :
  867.                             </h4>
  868.                         
  869.                         <div class="checkout-form">
  870.                         {% set lastShippingAddress = global.getLastUsedShippingAddress %}
  871.                         {% set lastShippingAddressId = 0 %}
  872.                         {% if lastShippingAddress %}
  873.                             {% set lastShippingAddressId = lastShippingAddress.id %}
  874.                         {% endif %}
  875.                         <select class="form-control {% if app.user.validShippingAddresses is empty %} d-none {% endif %}" id="checkoutAddressSelection" name="checkoutAddressSelection" style="font-size:15px">
  876.                             <option value="none">Choisir une adresse existante ou entrer une nouvelle adresse</option>
  877.                             {% for shippingAddress in app.user.validShippingAddresses %}
  878.                                 <option value="{{shippingAddress.id}}" {% if lastShippingAddressId == shippingAddress.id %} selected {% endif %}>{{shippingAddress}}</option>
  879.                             {% endfor %}
  880.                         </select>
  881.                         <div id="add_new_address" class="m-t-20" style="{% if app.user.validShippingAddresses is not empty %}display:none;{% endif %}">
  882.                             <h4 class="header-title mt-0 mb-3 {% if app.user.validShippingAddresses is empty %}d-none{% endif %}">
  883.                                 Nouvelle adresse
  884.                             </h4>
  885.                             <br/>
  886.                             <div class="row">
  887.                                 <div class="col-md-8">
  888.                                     <label>Nom</label>
  889.                                     <input type="text" class="form-control" id="newAddress_name" name="newAddress_name">
  890.                                 </div>
  891.                                 <div class="col-md-4">
  892.                                     <label>Téléphone</label>
  893.                                     <input type="text" class="form-control" placeholder="(999) 999-9999" id="newAddress_phone" name="newAddress_phone">
  894.                                     {# <input type="tel" class="form-control" id="newAddress_phone" name="newAddress_phone" placeholder="9999999999" maxlength="15" required> #}
  895.                                     <script>
  896.                                         document.getElementById('newAddress_phone').addEventListener('input', function (e) {
  897.                                         var x = e.target.value.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
  898.                                         e.target.value = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
  899.                                         });
  900.                                     </script>
  901.                                 </div>
  902.                             </div>
  903.                             <br/>
  904.                             <div class="row">
  905.                                 <div class="col-md-8 col-lg-8">
  906.                                     <label>Veuillez entrer votre addresse</label>
  907.                                     <input type="text" class="form-control" placeholder="ex : 36 Rue Sainte-Catherine Ouest" id="newAddress_autocomplete" name="newAddress_autocomplete" autocomplete="off">
  908.                                 </div>
  909.                                 <div class="col-md-4">
  910.                                     <label>Unité</label>
  911.                                     <input type="text" class="form-control" placeholder="ex : Appartement/Unité/Batiment" id="newAddress_unit" name="newAddress_unit" maxlength="5">
  912.                                 </div>
  913.                             </div>
  914.                             <div class="row m-3">
  915.                                 {# <div class="col-md-4">
  916.                                     <label>province</label>
  917.                                     <input type="text" class="form-control" placeholder="" id="adresse_province" name="adresse_province" >
  918.                                 </div> #}
  919.                                 <div class="col-md-4">
  920.                                     <label>Province</label>
  921.                                 <select class="form-control" id="adresse_province" name="adresse_province">
  922.                                     <option value="QC">Québec</option>
  923.                                     <option value="AB">Alberta</option>
  924.                                     <option value="BC">Colombie-Britannique</option>
  925.                                     <option value="PE">Île-du-Prince-Édouard</option>
  926.                                     <option value="MB">Manitoba</option>
  927.                                     <option value="NB">Nouveau-Brunswick</option>
  928.                                     <option value="NS">Nouvelle-Écosse</option>
  929.                                     <option value="NU">Nunavut</option>
  930.                                     <option value="ON">Ontario</option>
  931.                                     <option value="SK">Saskatchewan</option>
  932.                                     <option value="NL">Terre-Neuve-et-Labrador</option>
  933.                                     <option value="NT">Territoires du Nord-Ouest</option>
  934.                                     <option value="YT">Yukon</option>
  935.                                 </select>
  936.                             </div>
  937.                                 
  938.                                 <div class="col-md-4">
  939.                                     <label>ville</label>
  940.                                     <input type="text" class="form-control" placeholder="" id="adresse_city" name="adresse_city">
  941.                                 </div>
  942.                             {# <div class="col-md-4">
  943.                                 <label>Ville</label>
  944.                                 <div id="newAddress_cityQC">
  945.                                     <select class="form-control" id="newAddress_citySelectQC" name="newAddress_citySelectQC"></select>
  946.                                 </div>
  947.                                 <div id="newAddress_cityON" style="display:none;">
  948.                                     <select class="form-control" id="newAddress_citySelectON" name="newAddress_citySelectON"></select>
  949.                                 </div>
  950.                                 <div id="newAddress_cityAny" style="display:none;">
  951.                                     <input type="text" class="form-control" id="newAddress_cityInputAny" name="newAddress_cityInputAny">
  952.                                 </div>
  953.                             </div> #}
  954.                                 <div class="col-md-4">
  955.                                     <label class="control-label">Code postal</label>
  956.                                     <input type="text" class="form-control" id="postal_code" name="newAddress_zipcode">
  957.                                 </div>
  958.                             </div>
  959.                             <div class="row" style="justify-content:end;">
  960.                                 <div class="col-md-3">
  961.                                     <input type="bouton" id="SaveAdress" value="Enregistrer" onClick="SaveMyAdresse()" class="btn-primary btn py-2 px-4"></input>
  962.                                 </div>
  963.                             </div>
  964.                         </div>
  965.                         </div>
  966.                     </div>
  967.             
  968.     <div id="blocPickUp" style="display:none;">
  969.         {% if global.getAssociationUserIsBrowsing and
  970.         global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.canPickUp') %}
  971.             <div class="checkout-form">
  972.                 <div class=" mx-auto">
  973.                         <h4 class="checkoutBlocTitle">
  974.                             Cueillette au marche
  975.                         </h4>
  976.                         <div class="checkout-form">
  977.                             <div class="row">
  978.                                 <div class="col-12">
  979.                                     <div class="form-group">
  980.                                         <label for="exampleFormControlSelect2">Addresse</label>
  981.                                         {% if global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpAdress') %}
  982.                                             <input readonly type="text" class="form-control" value="{{ global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpAdress').value }}">
  983.                                         {% else %}
  984.                                             <input readonly type="text" class="form-control" value="{{ global.getAssociationUserIsBrowsing.urlName}}">
  985.                                         {% endif %}
  986.                                     </div>
  987.                                 </div>
  988.                             </div>
  989.                             {# PICKUP SELECT : only avalaible for associations #}
  990.                             <div class="row">
  991.                                 <div class="col-12">
  992.                                     {% set dayNameMap = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'] %}
  993.                                     <div class="form-group col-4">
  994.                                         {% if global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpSchedule') %}
  995.                                             <label for="pickupScheduleChoice">Horaire de cueillette</label>
  996.                                             <select class="form-control" id="pickupScheduleChoice" name="pickupSchedule">
  997.                                                 {% for schedule in global.pickupChoiceForCurrentAssociation %}
  998.                                                     <option value="{{ schedule['day']|date("Y/m/d") }} de {{ schedule['start'] }} à {{ schedule['end'] }}">{{ dayNameMap[(schedule['day']|date("N"))-1] }}
  999.                                                         {{
  1000.                                         schedule['day']|date("d/m") }}
  1001.                                                         : de
  1002.                                                         {{ schedule['start'] }}
  1003.                                                         à
  1004.                                                         {{ schedule['end'] }}
  1005.                                                     </option>
  1006.                                                 {% endfor %}
  1007.                                             </select>
  1008.                                         {% else %}
  1009.                                         <div class="col-4">
  1010.                                             <label for="pickupScheduleChoice">Dites-nous quand comptez-vous venir :</label>
  1011.                                             <input type="text" class="form-control col-4" name="pickupSchedule">
  1012.                                         </div>
  1013.                                         {% endif %}
  1014.                                     </div>
  1015.                                 </div>
  1016.                             </div>
  1017.                             {# PACKING SELECT : only avalaible for associations #}
  1018.                             {% if checkout.hasPickup %}
  1019.                                 <div class="row">
  1020.                                     <div class="col-12">
  1021.                                         <div class="form-group">
  1022.                                             <label for="withPackingChoice">Choix du type de ramassage</label>
  1023.                                             <select class="form-control" id="withPackingChoice" name="withPacking">
  1024.                                                 {% if global.canPackup(checkout) > 0 %}
  1025.                                                     <option value="true">
  1026.                                                         Cueillette unique
  1027.                                                         {% if checkout.getPackingCost(false) > 0 %}: frais applicables de
  1028.                                                             {{
  1029.                                         checkout.getPackingCost(false) }}$
  1030.                                                         {% endif %}
  1031.                                                     </option>
  1032.                                                 {% endif %}
  1033.                                                 {% if global.canPackup(checkout) != 1 %}
  1034.                                                     <option value="false">Cueillette aux kiosques</option>
  1035.                                                 {% endif %}
  1036.                                             </select>
  1037.                                             <br>
  1038.                                             <ul>
  1039.                                                 <li>
  1040.                                                     <strong>Cueillette unique :</strong>
  1041.                                                     Votre commande sera préparée par notre marché et prête pour le ramassage
  1042.                                                 </li>
  1043.                                                 <li>
  1044.                                                     <strong>Cueillette aux kiosques :</strong>
  1045.                                                     Visitez chacun des exposants pour récupérer en kiosque les items de votre commande :
  1046.                                                                                         sans frais
  1047.                                                 </li>
  1048.                                             </ul>
  1049.                                         </div>
  1050.                                     </div>
  1051.                                 </div>
  1052.                             {% endif %}
  1053.                         </div>
  1054.                         <!--end checkout-form-->
  1055.                 </div>
  1056.                 <!--end col-->
  1057.             </div>
  1058.             <!--end row-->
  1059.         {% else %}
  1060.             {% if global.hasGlobalPickUpEnabled %}
  1061.                 {% set pickupSchedule = global.getGlobalPickUpSchedule %}
  1062.                 {% set pickupSchedules = global.getGlobalPickUpSchedules %}
  1063.                 {% set pickupLocation = global.getGlobalPickUpLocation %}
  1064.                 {% set pickupLocations = global.getGlobalPickUpLocations %}
  1065.                 {% if pickupSchedule %}
  1066.                 <script>
  1067.                 var pickupSchedule = '{{pickupSchedule|raw}}';
  1068.                 var pickupSchedules = '{{pickupSchedules|json_encode()|raw}}';
  1069.                 var pickupLocations = '{{pickupLocations|json_encode()|raw}}';
  1070.                 </script>
  1071.                 {% endif %}
  1072.                 <div class="checkout-form">
  1073.                     <div class=" mx-auto">
  1074.                         <div id="pickupAdressBlock"  >
  1075.                             <h4 class="checkoutBlocTitle">
  1076.                                 Cueillette en personne
  1077.                             </h4>
  1078.                         {# {% if app.user.getIsBetaTester %} #}
  1079.                             <div class="row my-2">
  1080.                                 <div class="col-md-6">
  1081.                                     <label>Nom</label>
  1082.                                     <input type="text" class="form-control" id="pickup_name" required="" name="pickup_name" value="{{ app.user.firstname }}">
  1083.                                 </div>
  1084.                                 <div class="col-md-4">
  1085.                                     <label>Téléphone</label>
  1086.                                     <input type="text" class="form-control" placeholder="(999) 999-9999" required="" id="pickup_phone" name="pickup_phone" value="{{ app.user.phone }}">
  1087.                                     <script>
  1088.                                         document.getElementById('pickup_phone').addEventListener('input', function (e) {
  1089.                                         var x = e.target.value.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
  1090.                                         e.target.value = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
  1091.                                         });
  1092.                                     </script>
  1093.                                 </div>
  1094.                             </div>
  1095.                             {# {% endif %} #}
  1096.                             <div class="checkout-form">
  1097.                                     <div class="row">
  1098.                                         <div class="col-12">
  1099.                                             <div class="form-group">
  1100.                                                 <label for="pickupLocations">Lieu de la cueillette</label>
  1101.                                                 <input type="hidden" name="pickupLocation" value="{{pickupLocation}}" id="pickupLocation">
  1102.                                                 <select class="form-control" name="pickupLocations" id="pickupLocations" style="overflow: scroll;">
  1103.                                                     <option value="" disabled SELECTED>--- Veuillez choisir le lieu de la cueillette ---</Option>
  1104.                                                     {% for pickupLocation in pickupLocations %}
  1105.                                                         <option value="{{pickupLocation.value}}">{{pickupLocation.text}}</option>
  1106.                                                     {% endfor %}
  1107.                                                 </select>
  1108.                                             </div>
  1109.                                         </div>
  1110.                                     </div>
  1111.                                     {# <hr/> #}
  1112.                                     <div class="row" id="datetimeSelectionRow" style="display:none;">
  1113.                                         <div class="col-12">
  1114.                                             <div class="form-group">
  1115.                                                 <br/>
  1116.                                                 <label for="exampleFormControlSelect2">Horaire d'ouverture</label>
  1117.                                                 <div id="pickupLocationScheduleDisplay"></div>
  1118.                                                 <br/>
  1119.                                                 <div class="form-check">
  1120.                                                     <label for="pickupScheduleChoice">Dites-nous quand comptez-vous venir : <i class="fa fa-info-circle" ></i>
  1121.                                                         <div id="InfoPickUpChoice"><strong>Important :
  1122.                                                         </strong> Afin d'assurer la bonne préservation des aliments de votre boîte Maturin, 
  1123.                                                         il est important d'aller chercher votre commande au point de cueillette le jour de la livraison.
  1124.                                                         </div>    
  1125.                                                     </label>
  1126.                                                     
  1127.                                                     <input type="text"  readonly class="form-control" style="cursor:pointer;" placeholder="Cliquer ici pour choisir la date" id='pickupSchedule'>
  1128.                                                     <input type="hidden" id="pickupScheduleHidden" name="pickupSchedule">
  1129.                                                 </div>
  1130.                                                 <br/>
  1131.                                                 <div style="display:none;" id="datetime_picker">
  1132.                                                     <label for="pickupScheduleChoice">Dites-nous à quelle heure comptez-vous venir :</label>
  1133.                                                     <style>
  1134.                                                     .timepicker-hour-box {
  1135.                                                         border-radius:10px;
  1136.                                                         border:1px solid #ccc;
  1137.                                                         background-color: #eee;
  1138.                                                         padding: 10px;
  1139.                                                         cursor: pointer;
  1140.                                                     }
  1141.                                                     .timepicker-hour-box-disabled {
  1142.                                                         background-color: #666;
  1143.                                                         cursor: not-allowed;
  1144.                                                     }
  1145.                                                     .timepicker-selected {
  1146.                                                         background-color: green;
  1147.                                                     }
  1148.                                                     .timepicker-warning {
  1149.                                                         background-color: orange;
  1150.                                                     }
  1151.                                                     </style>
  1152.                                                 </div>
  1153.                                                 <div class="row" id="dateTimePickerRow">
  1154.                                                 </div>
  1155.                                             </div>
  1156.                                         </div>
  1157.                                     </div>
  1158.                                 </div>
  1159.                             </div>
  1160.                             <!--end checkout-form-->
  1161.                     
  1162.                     </div>
  1163.                     <!--end col-->
  1164.                 </div>
  1165.                 <!--end row-->
  1166.             {% endif %}
  1167.         {% endif %}
  1168.         </div>
  1169.         </div>    
  1170.         </div>
  1171.         </div>
  1172.     
  1173.                 <!--end card-box-->
  1174.             <!--end col-->
  1175.         <div  id="choiceShippingDate">
  1176.             <div class="row">
  1177.         {% set dateDelivery = global.getCart.getDeliveryChoiceDate  %}
  1178.                 <div class="col-lg-8 mx-auto">
  1179.                     <div class="text-center mb-3" id="deliveryEstimateSpinner">
  1180.                         <img src="/images/loading.gif" alt="Remplisser le formuliare avant de passer à la suite.">
  1181.                     </div>
  1182.                     <div class="card-box" id="deliveryEstimateCard">
  1183.                     <h4 class="checkoutBlocTitle">
  1184.                                 Choisissez une date de livraison
  1185.                             </h4>
  1186.                         <p id="pChoiceDate" style="font-size:18px">Votre commande sera livrée le 
  1187.                             <b id="defaultCustomDate" style="color:#53a321;">
  1188.                             {# {% if dateDelivery is null %} #}
  1189.                             <span id="evolutiveDateDelivery"> {{ dateDelivery| localizeddate('medium', 'none', null, '-7', 'l dd MMMM y') }}</span>
  1190.                                 {#{% set route = global.getEstimationShippingRouteForMaturinProducts(global.getCart)  %}
  1191.                                 {% if route['route'] is not null and not route['route'].isPuro %}
  1192.                                     
  1193.                                         {# {{route['date'] | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}} #}
  1194.                                 {# {% else %} #}
  1195.                                     {# entre {{route['date'] | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}}
  1196.                                     et {{global.add48hToDate(route['date']) | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}} #}
  1197.                                 {# {% endif %} #}
  1198.                                     {# {% else %} #}
  1199.                                     
  1200.                                 
  1201.                                 {# {% endif %} #}
  1202.                             entre 12h et 21h
  1203.                             </b>
  1204.                                 </p>
  1205.                         <div class="form-check">
  1206.                             <input class="" type="checkbox" value="on" name="DeliveryCheck" id="DeliveryChoiceCheckbox"
  1207.                             {% if global.getCart.preOrder %}
  1208.                                 checked
  1209.                             {% endif %}
  1210.                             >
  1211.                             <label class="form-check-label" for="flexCheckDefault" id="DateChoice" style="font-size:18px">
  1212.                                 Choisir une autre date <i class="fa fa-info-circle"></i>
  1213.                                 <div id="InfoDateChoice" class='m-2' style="font-size:18px">Vous pouvez choisir une date de livraison jusqu'à 8 semaines en avance</div>
  1214.                             </label>
  1215.                             <p/>
  1216.                             <div id="customDelivery" {% if dateDelivery is null %} style="display:none" {% endif %}>
  1217.                                 {# Choisissez votre date: #}
  1218.                                 <input type="text" class="form-control" placeholder="Cliquer ici pour choisir la date"  style="font-size:18px" readonly name="livraisonDate" id="datepickerCustomDelivery">
  1219.                         </div>
  1220.                     </div>
  1221.                     <!--end checkout-form-->
  1222.                 </div>
  1223.                 <!--end card-box-->
  1224.             </div>
  1225.         </div>
  1226.             <!--end col-->
  1227. </div>
  1228.         <div id="blocGift" style="display:none;">
  1229.             {#<div class="row">
  1230.                 <div class="col-lg-8 mx-auto">
  1231.                     <div class="card-box">
  1232.                         {{ block("content", "frontend/bulkshipModify.cart.html.twig") }}
  1233.                     </div>
  1234.                 </div>
  1235.             </div>#}
  1236.         
  1237.             <div class="row">
  1238.                     <div class="col-lg-8 mx-auto">
  1239.                         <div class="card-box">
  1240.                             <h4 class="checkoutBlocTitle">
  1241.                                 Commande contenant un cadeau
  1242.                             </h4>
  1243.                             {# {% set display_bulkshipping_checkbox = true %}
  1244.                                 {% if display_bulkshipping_checkbox %} #}
  1245.                                 <div class="form-group">
  1246.                                     <input type="checkbox" name="action_bulkshipping" id="action_bulkshipping">
  1247.                                         <label for="action_bulkshipping" style="font-size:18px">Je veux faire un cadeau</label>
  1248.                                 </div>
  1249.                                 {# {% endif %} #}
  1250.                         
  1251.                         <!--end checkout-form-->
  1252.                     </div>
  1253.                     <!--end card-box-->
  1254.                 </div>
  1255.                 <!--end col-->
  1256.             </div>
  1257.         </div> 
  1258.                     {% if contains_alcohol %}
  1259.             <div class="row">
  1260.                 <div class="col-lg-8 mx-auto">
  1261.                     <div class="card-box">
  1262.                         <h4 class="checkoutBlocTitle">
  1263.                             Âge requis pour acheter
  1264.                         </h4>
  1265.                         <div class="checkout-form">
  1266.                             <div class="row">
  1267.                                 <div class="col-12">
  1268.                                     <div class="form-group">
  1269.                                         <input type="checkbox" name="18YearsOld">
  1270.                                         <label for="exampleFormControlSelect2"> Je confirme avoir 18 ans et plus. </label>    
  1271.                                     </div>
  1272.                                 </div>
  1273.                             </div>
  1274.                             <hr/>
  1275.                             <div class="row">
  1276.                                 <div class="col-12">
  1277.                                     <div class="form-group">
  1278.                                         <p>L'alcool n’étant pas un produit comme les autres,
  1279.                                                                             nous nous devons de faire respecter la loi relative à
  1280.                                                                             la commercialisation de boissons alcooliques.</p>
  1281.                                         <p>Cela exige que nous mettions tout en œuvre pour
  1282.                                                                             nous assurer que nos produits sont vendus à des
  1283.                                                                             personnes âgées de 18 ans ou plus.</p>
  1284.                                     </div>
  1285.                                 </div>
  1286.                             </div>
  1287.                         </div>
  1288.                         <!--end checkout-form-->
  1289.                     </div>
  1290.                     <!--end card-box-->
  1291.                 </div>
  1292.                 <!--end col-->
  1293.             </div>
  1294.             <!--end row-->
  1295.         {% endif %}
  1296.         <div class="row" >
  1297.             <div class="col-lg-8 mx-auto">
  1298.                 <div class="card-box">
  1299.                     <h4 class="checkoutBlocTitle">
  1300.                         Coupon rabais
  1301.                     </h4>
  1302.                     <br/>
  1303.                         <div class="checkout-form">
  1304.                             {% if couponMarketing %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');">Coupon de <b>{{couponMarketing.amount }} $</b> ({{couponMarketing.code}})</a></p><br/>{% endif %}
  1305.                             {% for coupon in couponLists %}
  1306.                         {#    {{ dump(date()|date("Y-m-d"))}} <= {{ dump(coupon.dateTo|date("Y-m-d"))}} #}
  1307.                                 {% if date()|date("Y-m-d") <= coupon.dateTo|date("Y-m-d") %}
  1308.                                     {% if coupon.type == 0 %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');" style="color : #53a321;">Coupon de <b>{{coupon.amount }} %</b> ({{coupon.code}})</a></p><br/>{% endif %}
  1309.                                     {% if coupon.type == 2 %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');" style="color : #53a321;">Coupon de <b>{{coupon.amount }} $</b> ({{coupon.code}})</a></p><br/>{% endif %}
  1310.                                 {% else %}
  1311.                                     {% if coupon.type == 0 %}<p style="color : gray;">Coupon de <b>{{coupon.amount }} %</b> ({{coupon.code}}) (Expiré)</p><br/>{% endif %}
  1312.                                     {% if coupon.type == 2 %}<p style="color : gray;">Coupon de <b>{{coupon.amount }} $</b> ({{coupon.code}}) (Expiré)</p><br/>{% endif %}
  1313.                                 {% endif %}
  1314.                             {% endfor %}
  1315.                             {% set usedCouponCode = "" %}
  1316.                             {% if checkout.usedCoupon %}
  1317.                                 {% set usedCouponCode = checkout.usedCoupon.code %}
  1318.                             {% endif %}
  1319.                             
  1320.                             <input name="coupon" type="text" class="form-control" value="{{usedCouponCode}}" id="coupon" placeholder="Aucun coupon">
  1321.                         </div>
  1322.                 </div>
  1323.                 <!--end card-box-->
  1324.             </div>
  1325.             <!--end col-->
  1326.         </div>
  1327.         <!--end row-->
  1328.         <div class="row">
  1329.             <div class="col-lg-8 mx-auto">
  1330.                 {% if global.getAssociationUserIsBrowsing and
  1331.             global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.canPickUp') %}
  1332.                     {% set display_bulkshipping_checkbox = false %}
  1333.                 {% endif %}
  1334.                 <div style="width: 100%; text-align: right;">
  1335.                  {% if app.user.validShippingAddresses is empty %}
  1336.                      <button class="btn-primary btn py-2 px-4" name="proceedToPaymentSubmitBtn" id="proceedToPaymentSubmitBtn">Enregistrer et passer au paiement</button>
  1337.                  {% else %}
  1338.                     <button class="btn-primary btn py-2 px-4" name="proceedToPaymentSubmitBtn" id="proceedToPaymentSubmitBtn">Passer au paiement</button>
  1339.                 {% endif %}
  1340.                 </div>
  1341.             </div>
  1342.             <!--end col-->
  1343.         </div>
  1344.         <!--end row-->
  1345.     </form>
  1346.     {% endblock %}