templates/home/home_index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}{{companyName}} | {% trans %}Accueil{% endtrans %}{% endblock %}
  3. {% block stylesheets %}
  4.     {{ parent() }}
  5.     <link href="{{ asset('css/home.func.css') }}" rel="stylesheet" />
  6.     <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
  7.     <style>
  8.         .modal { width:75% !important ; height: 75% !important ; }
  9.         .truncate-overflow {
  10.             display: -webkit-box;
  11.             -webkit-line-clamp: 4;
  12.             -webkit-box-orient: vertical;
  13.             overflow: hidden;
  14.             font-size: 14px;
  15.         }
  16.         .truncate-overflow:hover {
  17.             cursor: pointer;
  18.         }
  19.         div.ex3 {
  20.             background-color: #ffffff;
  21.             height: 250px;
  22.             width: 100%;
  23.             overflow-y: auto;
  24.         }
  25.         div.ex4 {
  26.             background-color: #ffffff;
  27.             height: 300px;
  28.             border-radius: 30px;
  29.             width: 100%;
  30.             overflow-y: auto;
  31.         }
  32.     </style>
  33.     <style>
  34.         .container-caroussel {
  35.             position: relative;
  36.             width: 50%;
  37.         }
  38.         .image-caroussel {
  39.             display: block;
  40.             width: 100%;
  41.             height: auto;
  42.         }
  43.         .btn-a-body {
  44.             --b: 3px;     /* the border thickness*/
  45.             --g: 5px;    /* the gap */
  46.             --c: rgba(3, 128, 13, 0.97); /* the color */
  47.             background: -webkit-linear-gradient(45deg, rgba(3, 128, 13, 0.97), #16945b);
  48.             margin-right: 15px;
  49.             padding: 10px; border-radius: 20px;
  50.             aspect-ratio: 0.5;
  51.             color:white;
  52.             cursor: pointer;
  53.             transition: .3s;
  54.         }
  55.         .btn-a-body:hover {
  56.             outline: var(--b) solid var(--c);
  57.             outline-offset: var(--g);
  58.             background: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.87), rgba(255, 255, 255, 0.85));
  59.             color: rgba(3, 128, 13, 0.96);
  60.         }
  61.         .overlay-caroussel {
  62.             position: absolute;
  63.             bottom: 0;
  64.             left: 0;
  65.             right: 0;
  66.             background-color: #008CBA;
  67.             overflow: hidden;
  68.             width: 100%;
  69.             height: 0;
  70.             transition: .5s ease;
  71.         }
  72.         .container-caroussel:hover .overlay {
  73.             height: 100%;
  74.         }
  75.         .text-caroussel {
  76.             color: white;
  77.             font-size: 20px;
  78.             position: absolute;
  79.             top: 50%;
  80.             left: 50%;
  81.             -webkit-transform: translate(-50%, -50%);
  82.             -ms-transform: translate(-50%, -50%);
  83.             transform: translate(-50%, -50%);
  84.             text-align: center;
  85.         }
  86.     </style>
  87. {% endblock %}
  88. {% block body %}
  89.     {{ parent() }}
  90.    <div class="" id="content">
  91.        <div class="row" style="margin-top: 20px;position: relative;
  92.     background: -webkit-linear-gradient(45deg, rgba(25,118,210,0.38), rgba(25,118,210,0.38)) ;">
  93.            <div class="slider     " style="">
  94.                <ul class="slides" style="" >
  95.                    {% for background in backgrounds %}
  96.                        <li>
  97.                            <img src="{{ asset('media/' ~ background.picture.filePath) | trans}}"  >
  98.                            <div class="caption   left-align"
  99.                                 style="
  100.                        background: -webkit-linear-gradient(45deg, rgba(179,177,169,0.25), rgba(152,149,133,0.26)) ;" >
  101.                                <br>
  102.                                {% if local =="fr" %}
  103.                                    <h4 class="ml12 hide-on-small-only" style="margin-top: 40px; margin-left: 80px; margin-right: 40px;">
  104.                                        {{ background.data.title }}
  105.                                    </h4>
  106.                                    <br>
  107.                                    <h5 class="white-text ml13 hide-on-small-only " style="text-align: justify;
  108.                                 margin-left: 80px; margin-right: 40px">
  109.                                        {{ background.data.message }}
  110.                                    </h5>
  111.                                {% endif %}
  112.                                {% if local =="en" or local =="it" or local =="zh_CN"%}
  113.                                {% endif %}
  114.                            </div>
  115.                        </li>
  116.                    {% endfor %}
  117.                </ul>
  118.            </div>
  119.        </div>
  120.        <div class="row" style="margin-top: -180px; margin-bottom: 40px">
  121.            <div class="col s10 offset-s1" style="margin-top: -30px; z-index: 100; position: absolute">
  122.                <ul class="tabs" style=" background-color: rgba(192,220,126,0);">
  123.                    {% for buildingType in buildingTypes %}
  124.                        {% if buildingType.enable ==true %}
  125.                            <li class="tab col s3  " style="
  126.                    margin: 5px;
  127.  background-color: rgba(192,220,126,0.7);
  128.                       ">
  129.                                <a href="#building_{{buildingType.id }}" class="black-text waves-ripple waves-effect">
  130.                                    <i class="fas fa-hotel  " style="margin-left: -5px; margin-right:  50px"></i>
  131.                                    {{buildingType.type }}
  132.                                </a></li>
  133.                        {% endif %}
  134.                    {%endfor %}
  135.                </ul>
  136.            </div>
  137.            {% for buildingType in buildingTypes %}
  138.                {% if buildingType.enable ==true %}
  139.                    <div id="building_{{buildingType.id }}"
  140.                         class="col s10 offset-s1  " style=" margin-top: 20px;
  141.                        z-index: 100; position: absolute" >
  142.                        <div class="col s12 card" style="  background-color: rgba(192,220,126,0.57);">
  143.                            <div class="input-field col m6 s12 l3 m6">
  144.                                <div class="col s12" >
  145.                                    <i class="fas fa-bed" style=" font-size: 18px; position: absolute; margin-left: -30px;margin-top: 10px; float: right; z-index: 100 "></i>
  146.                                    <select class="js-example-basic-single" name="destinationTown" id="destinationTown_{{buildingType.id  }}" style="width: 100%;   ">
  147.                                        {% for town in towns %}
  148.                                            <option value="{{ town.id }}">{{ town.townName }}</option>
  149.                                        {%endfor %}
  150.                                    </select>
  151.                                </div>
  152.                            </div>
  153.                            <div class="col m6 s12 l4  m6 ">
  154.                                <div class="col s12">
  155.                                    <div class="col s6">
  156.                                        <h6>Arrivée Le</h6>
  157.                                        <input style="margin-top: -10px" type="datetime-local" id="startDate_{{ buildingType.id }}"  placeholder="Date d'arrivée" name="startDate"  class="col s12  "/>
  158.                                    </div>
  159.                                    <div class="col s6">
  160.                                        <h6>Départ Le</h6>
  161.                                        <input   style="margin-top: -10px" type="datetime-local" id="endDate_{{ buildingType.id }}"  placeholder="Date de départ"  name="endDate"  class="col s12  "/>
  162.                                    </div>
  163.                                </div>
  164.                            </div>
  165.                            <div class="col s12 l3 m6 ">
  166.                                <div class="col s12">
  167.                                    <div class="col s3 pull-l1 "  style="margin-top: 20px">
  168.                                        <h6 style="margin-left: -10px">
  169.                                            <i class="fas fa-user-friends " style="position: absolute; float: right; margin-left: -10px" ></i>
  170.                                            <span style="margin-left: 15px">Adultes</span>
  171.                                        </h6>
  172.                                    </div>
  173.                                    <div class="s3 col"   style="margin-top: 20px">
  174.                                        <input style="margin-top: -10px" min="1" value="1" type="number" id="adult_{{ buildingType.id }}"   name="adult_{{ buildingType.id }}"  class="col s12  "/>
  175.                                    </div>
  176.                                    <div class="s3 col "  style="margin-top: 20px">
  177.                                        <h6 style="margin-left: -10px">
  178.                                            <i class="fas fa-baby " style="position: absolute; float: right; margin-left: -10px" ></i>
  179.                                            <span style="margin-left: 15px">Enfants</span>
  180.                                        </h6>
  181.                                    </div>
  182.                                    <div class="s3 col"   style="margin-top: 20px">
  183.                                        <input style="margin-top: -10px; margin-left: 10px; font-weight: 20;" min="0" value="0" type="number" id="child_{{ buildingType.id }}"   name="child_{{ buildingType.id }}"  class="col s12  "/>
  184.                                    </div>
  185.                                </div>
  186.                            </div>
  187.                            <a id="btn_search_{{ buildingType.id }}" onclick="findBuilding({{ buildingType.id }}, '{{ buildingType.type }}')" href="#!" class="   card black-text  col m6 s12 l2 m6 button  waves-ripple waves-effect " style=" padding: 10px; border-radius: 20px; margin-top: 20px">
  188.                                <i class="fas fa-search" style="margin-left: 5px; margin-right:  5px"></i>
  189.                                <span class="" id="btn_text_{{ buildingType.id }}">Rechercher</span>
  190.                                <img id="btn_loading_{{ buildingType.id }}" src="{{ asset('img/loading.webp') }}" class="hide" style="max-height: 20px; position: absolute; float: right; right: 0; padding-right: 10px" alt="">
  191.                            </a>
  192.                        </div>
  193.                    </div>
  194.                {% endif %}
  195.            {%endfor %}
  196.        </div>
  197.        <div class="row" >
  198.            <div class="col s10 offset-s1 hide-on-med-and-down hide-on-small-only hide-on-med-only" style="margin-top: 140px">
  199.                <h5>Offres</h5>
  200.                <h6>Promotions, deals and special offers for you</h6>
  201.            </div>
  202.            <div class="col s10 offset-s1  hide-on-large-only hide-on-extra-large-only " style="margin-top: 300px">
  203.                <h5>Offres</h5>
  204.                <h6>Promotions, deals and special offers for you</h6>
  205.            </div>
  206.            <div class="col s10 offset-s1 autoplayBestProd">
  207.                {% for announce in announces %}
  208.                    <div class="col s12 l5 " style="margin: 20px">
  209.                        <div class="col s12 card">
  210.                            <div class="col s7 ">
  211.                                <h5>
  212.                                    {{ announce.titleEn }}
  213.                                </h5>
  214.                                <p class="truncate-overflow">{{ announce.description }}</p>
  215.                            </div>
  216.                            <div class="col s5">
  217.                                <img class="  card  image-n-margin  responsive-img halfway-fab hoverable"   src="{{ onlinePath }}/media/{{ announce.cover }}" style=" padding-top: 20px; border-radius: 20px; width: 200px; height: 200px" alt="">
  218.                            </div>
  219.                            <div class="col s12 " style="margin-top: 20px; margin-bottom: 20px">
  220.                                <a href="{{ path('app_announce_detail',{'announce':announce.id}) }}" id="btnLocation" class=" hide-on-small-and-down hide-on-small-only   card btn-a-body" style="">
  221.                                    En Savoir plus..
  222.                                    <i class="fas fa-eye" style="margin-left: 15px; margin-right:  5px"></i>
  223.                                </a>
  224.                                <h5 class="right right-align black-text" style="margin-top: -10px; padding-right: 0px; font-size: 23px">
  225.                                    {{ announce.amount|number_format(2, '.', ',')  }}
  226.                                    <i class="fas fa-cart-plus"></i>
  227.                                </h5>
  228.                            </div>
  229.                        </div>
  230.                    </div>
  231.                {%endfor %}
  232.            </div>
  233.        </div>
  234.        <div class="row">
  235.            <div class="col s10 offset-s1 hide-on-med-and-down hide-on-small-only hide-on-med-only" >
  236.                <h5>Trending destinations</h5>
  237.                <h6>Travellers searching for Chile also booked these</h6>
  238.            </div>
  239.            <div class="col s10 offset-s1  hide-on-large-only hide-on-extra-large-only " >
  240.                <h5>Trending destinations</h5>
  241.                <h6>Travellers searching for Chile also booked these</h6>
  242.            </div>
  243.            <div class="col s10 offset-s1 autoplayBestProd">
  244.                {% for town in trendingDestinations %}
  245.                    <div class="col s12 l5 " style="padding: 20px">
  246.                        <div class="col s12  " style="  ">
  247.                            <div class="col s12 card"   style="margin-bottom: -100px;  background: -webkit-linear-gradient(90deg, rgba(16,16,16,0.1), rgba(16,16,16,0.07)) ; ">
  248.                                <h5 style="font-weight: bold; color: white">
  249.                                    {{ town.town }}
  250.                                    <span style="font-size: 15px">
  251.                               ( {{ town.country.countryName }} )</span>
  252.                                    <img class=" "   src="{{ onlinePath }}/media/{{ town.country.countryFlag }}" style="margin-left: 1px; width: 17px; height: 17px; " alt="">
  253.                                </h5>
  254.                            </div>
  255.                            {%  if town.picture != NULL %}
  256.                                <a href="{{ path('app_building_detail', {'destination': town.townId, 'buildingType': 'all','startDate':'', 'endDate': '','adult':'', 'child':'' }) }}">
  257.                                <img class=" "   src="{{ onlinePath }}/media/{{ town.picture }}" style="  margin-top: -150px; width: 100%; height: 300px" alt="">
  258.                                </a>
  259.                            {%else %}
  260.                                <a href="{{ path('app_building_detail', {'destination': town.townId, 'buildingType': 'all','startDate':'', 'endDate': '','adult':'', 'child':'' }) }}">
  261.                                <img class=" "   src="{{ asset("img/default_town.jpg") }}" style=" width: 100%; height: 300px" alt="">
  262.                                </a>
  263.                            {%endif %}
  264.                        </div>
  265.                    </div>
  266.                {%endfor %}
  267.            </div>
  268.        </div>
  269.        <div class="row" id="residentCountry">
  270.        </div>
  271.    </div>
  272. {% endblock %}
  273.   {% block javascripts %}
  274.       {{ parent() }}
  275.       <script src="{{ asset('js/home.func.js') }}"></script>
  276.       <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
  277.       <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
  278.       <script type="text/javascript">
  279.           $(function() {
  280.               var startDay = moment().format('MM/YYYY/DD');
  281.               $('input[name="datetimes"]').daterangepicker({
  282.                   timePicker: true,
  283.                   startDate: moment().startOf('hour'),
  284.                   endDate: moment().startOf('hour').add(32, 'hour'),
  285.                   locale: {
  286.                       format: 'M/DD hh:mm A'
  287.                   },
  288.                   minDate:  startDay,
  289.                   minYear:  parseInt(moment().format('YYYY'),0),
  290.                   maxYear: parseInt(moment().format('YYYY'),10)
  291.               });
  292.           });
  293.           $(document).ready(function() {
  294.               $('.js-example-basic-single').select2();
  295.               $('.datepicker').pickadate({
  296.                   selectMonths: true, // Creates a dropdown to control month
  297.                   selectYears: 15, // Creates a dropdown of 15 years to control year,
  298.                   today: 'Today',
  299.                   clear: 'Clear',
  300.                   close: 'Ok',
  301.                   closeOnSelect: false, // Close upon selecting a date,
  302.                   container: undefined, // ex. 'body' will append picker to body
  303.               });
  304.               $('.modal').modal({
  305.                       dismissible: true, // Modal can be dismissed by clicking outside of the modal
  306.                       opacity: .4, // Opacity of modal background
  307.                       inDuration: 300, // Transition in duration
  308.                       outDuration: 200, // Transition out duration
  309.                       startingTop: '4%', // Starting top style attribute
  310.                       endingTop: '15%', // Ending top style attribute
  311.                       ready: function(modal, trigger) { // Callback for Modal open. Modal and trigger parameters available.
  312.                       },
  313.                       complete: function() {
  314.                       } // Callback for Modal close
  315.                   }
  316.               );
  317.               $('.autoplayTestimony').slick({
  318.                   slidesToShow: 3,
  319.                   slidesToScroll: 1,
  320.                   autoplay: true,
  321.                   autoplaySpeed: 2000,
  322.                   responsive: [
  323.                       {
  324.                           breakpoint: 2024,
  325.                           settings: {
  326.                               slidesToShow: 4,
  327.                               slidesToScroll: 4,
  328.                               infinite: true,
  329.                               dots: true
  330.                           }
  331.                       },
  332.                       {
  333.                           breakpoint: 1424,
  334.                           settings: {
  335.                               slidesToShow: 3,
  336.                               slidesToScroll: 3,
  337.                               infinite: true,
  338.                               dots: true
  339.                           }
  340.                       },
  341.                       {
  342.                           breakpoint: 900,
  343.                           settings: {
  344.                               slidesToShow: 2,
  345.                               slidesToScroll: 2
  346.                           }
  347.                       },
  348.                       {
  349.                           breakpoint: 480,
  350.                           settings: {
  351.                               slidesToShow: 1,
  352.                               slidesToScroll: 1
  353.                           }
  354.                       }
  355.                   ]
  356.               })
  357.               $('.autoplayPack').slick({
  358.                   slidesToShow: 1,
  359.                   slidesToScroll: 1,
  360.                   autoplay: true,
  361.                   autoplaySpeed: 2000,
  362.                   responsive: [
  363.                       {
  364.                           breakpoint: 1024,
  365.                           settings: {
  366.                               slidesToShow: 1,
  367.                               slidesToScroll: 1,
  368.                               infinite: true,
  369.                               dots: true
  370.                           }
  371.                       },
  372.                       {
  373.                           breakpoint: 600,
  374.                           settings: {
  375.                               slidesToShow: 1,
  376.                               slidesToScroll: 1
  377.                           }
  378.                       },
  379.                       {
  380.                           breakpoint: 480,
  381.                           settings: {
  382.                               slidesToShow: 1,
  383.                               slidesToScroll: 1
  384.                           }
  385.                       }
  386.                   ]
  387.               });
  388.               $('.autoplayBestProd').slick({
  389.                   slidesToShow: 2,
  390.                   slidesToScroll: 2,
  391.                   autoplay: true,
  392.                   autoplaySpeed: 22000,
  393.                   responsive: [
  394.                       {
  395.                           breakpoint: 1024,
  396.                           settings: {
  397.                               slidesToShow: 2,
  398.                               slidesToScroll: 2,
  399.                               infinite: true,
  400.                               dots: true
  401.                           }
  402.                       },
  403.                       {
  404.                           breakpoint: 600,
  405.                           settings: {
  406.                               slidesToShow: 1,
  407.                               slidesToScroll: 1
  408.                           }
  409.                       },
  410.                       {
  411.                           breakpoint: 480,
  412.                           settings: {
  413.                               slidesToShow: 1,
  414.                               slidesToScroll: 1
  415.                           }
  416.                       }
  417.                   ]
  418.               });
  419.           });
  420.           var apiBaseUrl="{{ host }}"
  421.           var loginUrl="{{ path('authentication_token') }}";
  422.           getClientLocation ();
  423.           function submitComment() {
  424.               setTimeout(function () {
  425.                   Swal.mixin({
  426.                       imageUrl: '{{ asset('img/logo-logercm.png') }}',
  427.                       imageHeight: 60,
  428.                       background: '#fff url({{ asset('img/trees.png') }})',
  429.                       imageAlt: 'Logo {{ companyName }}',
  430.                       allowOutsideClick: false,
  431.                       allowEscapeKey: false,
  432.                       reverseButtons: true,
  433.                       confirmButtonText:
  434.                           '{% trans %}Suivant{% endtrans %} <i class="fa fa-arrow-right"></i>',
  435.                       showCancelButton: true,
  436.                       progressSteps: ['1', '2', '3','4','5'],
  437.                       cancelButtonText:
  438.                           '<i class="fa fa-trash"></i> Annuler',
  439.                       cancelButtonAriaLabel: '{% trans %}Annuler{% endtrans %}'
  440.                   }).
  441.                   queue([
  442.                       {
  443.                           title: '{% trans %}Laissez-nous un témoignage{% endtrans %}',
  444.                           text: '{% trans %}Votre Nom{% endtrans %}:',
  445.                           inputPlaceholder: 'John Doe.',
  446.                           input: 'text',
  447.                           inputValidator: (result) => {
  448.                               return !result && '{% trans %}Vous devez indiquer votre nom {% endtrans %}'
  449.                           }
  450.                       },
  451.                       {
  452.                           title: '{% trans %}Laissez-nous un témoignage{% endtrans %}',
  453.                           text: '{% trans %}Votre contact{% endtrans %}:',
  454.                           inputPlaceholder: '23760000000.',
  455.                           input: 'text',
  456.                           inputValidator: (result) => {
  457.                               return !result && '{% trans %}Vous devez indiquer votre contact{% endtrans %}'
  458.                           }
  459.                       },
  460.                       {
  461.                           title: "{% trans %}Que pensez des produits et services biocarrylife?{% endtrans %}",
  462.                           text: '{% trans %}Un petit commentaire{% endtrans %}',
  463.                           inputAttributes: {
  464.                               'maxlength': 1255,
  465.                           },
  466.                           inputPlaceholder: '{% trans %}Je suis satisfait des produits biocarrylife{% endtrans %}.',
  467.                           input: 'textarea',
  468.                           inputValidator: (result) => {
  469.                               return !result && '{% trans %}Vous avez oublié votre appréciation{% endtrans %}.'
  470.                           }
  471.                       },
  472.                       {
  473.                           title: '{% trans %}Sur une echelle de 1 à 10 quelle est votre note?{% endtrans %}',
  474.                           text: '{% trans %}Votre note{% endtrans %}:',
  475.                           input: 'number',
  476.                           inputPlaceholder: '5',
  477.                           inputAttributes: {
  478.                               min: 0,
  479.                               max: 10
  480.                           },
  481.                           inputValidator: (value) => {
  482.                               if (!value) {
  483.                                   return '{% trans %}Ce champ est obligatoire{% endtrans %}!'
  484.                               }
  485.                               if(parseInt(value)<0 || parseInt(value)>10){
  486.                                   return '{% trans %}Votre note doit être comprise entre 1 et 10{% endtrans %}!'
  487.                               }
  488.                           }
  489.                       },
  490.                       {
  491.                           title: "{% trans %}Nous avons besoin d'une jolie photo de vous{% endtrans %}?",
  492.                           text: '{% trans %}Cliquez ici pour charger une photo{% endtrans %}:',
  493.                           input: 'file',
  494.                           inputAttributes: {
  495.                               'accept': 'image/*',
  496.                               'aria-label': 'Upload your profile picture'
  497.                           },
  498.                       }
  499.                   ]).then((result) => {
  500.                       if (result.value) {
  501.                           var form = new FormData();
  502.                           form.append("file",  result.value[4]);
  503.                           console.log(form);
  504.                           var settings = {
  505.                               "url": apiBaseUrl+"media_objects",
  506.                               "method": "POST",
  507.                               "timeout": 0,
  508.                               "headers": {
  509.                                   "Accept": "application/json",
  510.                                   "Authorization": "Bearer "+ getCookie("{{ companyName }}_user_token")
  511.                               },
  512.                               "processData": false,
  513.                               "mimeType": "multipart/form-data",
  514.                               "contentType": false,
  515.                               "data": form
  516.                           };
  517.                           $.ajax(settings).done(function (response) {
  518.                               console.log(response);
  519.                               var picture=JSON.parse(response);
  520.                               $.ajax({
  521.                                   method: "POST",
  522.                                   tryCount  : 0,
  523.                                   retryLimit  : 4,
  524.                                   "url": apiBaseUrl+"testimonies",
  525.                                   "headers": {
  526.                                       "Content-Type":  "application/json",
  527.                                       "Authorization": "Bearer "+ getCookie("{{ companyName }}_user_token")
  528.                                   },
  529.                                   data: JSON.stringify({
  530.                                       "picture": apiBaseUrl+"media_objects/"+picture.id,
  531.                                       "client": result.value[0],
  532.                                       "message": result.value[2],
  533.                                       "contact": result.value[1],
  534.                                       "appreciation": parseInt(result.value[3]),
  535.                                       "approved": false }),
  536.                                   beforeSend:function () {
  537.                                   },
  538.                                   success: function(data){
  539.                                       console.log(data);
  540.                                       Swal.fire(
  541.                                           '{% trans %}Super{% endtrans %}!',
  542.                                           '{% trans %}Votre témoignage à été pris en compte{% endtrans %}!',
  543.                                           'success'
  544.                                       )
  545.                                   },
  546.                                   error:function (xhr, textStatus, errorThrown) {
  547.                                   }
  548.                               });
  549.                           });
  550.                       }
  551.                   });
  552.                   $(".swal2-input").css("max-width","100%")
  553.               },500)
  554.           }
  555.           function getClientLocation () {
  556.               var locationUrl="{{ path('client_location') }}";
  557.               $.ajax({
  558.                   method: "GET",
  559.                   tryCount  : 0,
  560.                   retryLimit  : 4,
  561.                   url: "https://api.ipify.org?format=json",
  562.                   beforeSend:function () {
  563.                   },
  564.                   success: function(data){
  565.                       console.log("data ip");
  566.                       console.log(data);
  567.                       var api_address=data.ip;
  568.                       $.ajax({
  569.                           method: "POST",
  570.                           tryCount  : 0,
  571.                           retryLimit  : 4,
  572.                           url: locationUrl,
  573.                           "headers": {
  574.                               "Content-Type": "application/json"
  575.                           },
  576.                           data: JSON.stringify({
  577.                               "api_address":api_address}),
  578.                           beforeSend:function () {
  579.                           },
  580.                           success: function(data){
  581.                               console.log("data location");
  582.                               setCookie("visitor",data,20)
  583.                               console.log(data.trendingTown);
  584.                               $("#residentCountry").append(`
  585.                                 <div class="col s10 offset-s1  " >
  586.                            <h5>Trending destinations in `+data.country +` </h5>
  587.                              <h6>Most visited places</h6>
  588.                               </div>   <div class="col s10 offset-s1 residentCountry"> </div>
  589.                               `);
  590.                               var i=0;j=0;
  591.                               if(data.trendingTown!==null){
  592.                                   console.log("ok if");
  593.                                   console.log("data.trendingTown.length "+data.trendingTown[0]);
  594.                                   console.log("data.trendingTown.length "+ data.total);
  595.                                   for(i=0; i< data.total; i++){
  596.                                       console.log("ok for "+i);
  597.                                       if(j<10){
  598.                                           console.log("ok if j "+j);
  599.                                           if(data.trendingTown[i].picture!==null){
  600.                                               $(".residentCountry").append(`
  601.                                               <div class="col s12 l5 " style="padding: 20px">
  602.                 <div class="col s12  " style="  ">
  603.                    <div class="col s12 card" style="margin-bottom: -100px;  background: -webkit-linear-gradient(90deg, rgba(16,16,16,0.1), rgba(16,16,16,0.07)) ; ">
  604.                        <h5 style="font-weight: bold; color: white">
  605.                                `+data.trendingTown[i].town+`
  606.                            <span style="font-size: 15px">
  607.                               ( `+data.trendingTown[i].country+`)</span>
  608.                            <img class=" "   src="{{ onlinePath }}/media/`+data.trendingTown[i].countryFlag +`" style="margin-left: 1px; width: 17px; height: 17px; " alt="">
  609.                        </h5>
  610.                    </div>
  611.                           <a href="{{ onlinePath}}/building/detail?destination=`+data.trendingTown[i].townId+`&buildingType=all&startDate=&endDate=&child=&adult=">
  612.                             <img class=" "   src="{{ onlinePath }}/media/`+ data.trendingTown[i].picture +`" style="  margin-top: -150px; width: 100%; height: 300px" alt="">
  613.                         </a>
  614.                 </div>
  615.             </div>
  616.                                           `);
  617.                                           }else{
  618.                                               $(".residentCountry").append(`
  619.                                               <div class="col s12 l5 " style="padding: 20px">
  620.                 <div class="col s12  " style="  ">
  621.                    <div class="col s12 card" style="margin-bottom: -100px;  background: -webkit-linear-gradient(90deg, rgba(16,16,16,0.1), rgba(16,16,16,0.07)) ; ">
  622.                        <h5 style="font-weight: bold; color: white">
  623.                                `+data.trendingTown[i].town+`
  624.                            <span style="font-size: 15px">
  625.                               ( `+data.trendingTown[i].country+`)</span>
  626.                            <img class=" "   src="{{ onlinePath }}/media/`+data.trendingTown[i].countryFlag +`" style="margin-left: 1px; width: 17px; height: 17px; " alt="">
  627.                        </h5>
  628.                    </div>
  629.                         <a href="{{ onlinePath}}/building/detail?destination=`+data.trendingTown[i].townId+`&buildingType=all&startDate=&endDate=&child=&adult=">
  630.                             <img class=" "   src="{{ asset("img/default_town.jpg") }}" style="  margin-top: -150px; width: 100%; height: 300px" alt="">
  631.                         </a>
  632.                 </div>
  633.             </div>
  634.                                           `);
  635.                                           }
  636.                                           j++
  637.                                       }
  638.                                   }
  639.                               }
  640.                               setTimeout(function () {
  641.                                   $('.residentCountry').slick({
  642.                                       slidesToShow: 3,
  643.                                       slidesToScroll: 3,
  644.                                       autoplay: true,
  645.                                       autoplaySpeed: 9000,
  646.                                       responsive: [
  647.                                           {
  648.                                               breakpoint: 1024,
  649.                                               settings: {
  650.                                                   slidesToShow: 2,
  651.                                                   slidesToScroll: 2,
  652.                                                   infinite: true,
  653.                                                   dots: true
  654.                                               }
  655.                                           },
  656.                                           {
  657.                                               breakpoint: 600,
  658.                                               settings: {
  659.                                                   slidesToShow: 1,
  660.                                                   slidesToScroll: 1
  661.                                               }
  662.                                           },
  663.                                           {
  664.                                               breakpoint: 480,
  665.                                               settings: {
  666.                                                   slidesToShow: 1,
  667.                                                   slidesToScroll: 1
  668.                                               }
  669.                                           }
  670.                                       ]
  671.                                   });
  672.                               },3000)
  673.                           },
  674.                           error:function (xhr, textStatus, errorThrown) {
  675.                               console.log(xhr);
  676.                           }
  677.                       });
  678.                   },
  679.                   error:function (xhr, textStatus, errorThrown) {
  680.                   }
  681.               });
  682.           }
  683.           function refreshToken() {
  684.               $.ajax({
  685.                   method: "POST",
  686.                   tryCount  : 0,
  687.                   retryLimit  : 4,
  688.                   url: loginUrl,
  689.                   "headers": {
  690.                       "Content-Type": "application/json"
  691.                   },
  692.                   data: JSON.stringify({
  693.                       "username":getCookie("{{ companyName }}_user_username"),
  694.                       "password":getCookie("{{ companyName }}_user_userpass")}),
  695.                   beforeSend:function () {
  696.                   },
  697.                   success: function(data){
  698.                       setCookie("{{ companyName }}_user_token",data.token,1);
  699.                   },
  700.                   error:function (xhr, textStatus, errorThrown) {
  701.                   }
  702.               });
  703.           }
  704.           function findBuilding(buildingType, type) {
  705.               var destinationTown=$("#destinationTown_"+buildingType).val();
  706.               var startDate=$("#startDate_"+buildingType).val();
  707.               var endDate=$("#endDate_"+buildingType).val();
  708.               var adult=$("#adult_"+buildingType).val();
  709.               var child=$("#child_"+buildingType).val();
  710.               $.ajax({
  711.                   method: "POST",
  712.                   tryCount  : 0,
  713.                   retryLimit  : 4,
  714.                   url: "{{ path("find_buildings") }}",
  715.                   "headers": {
  716.                       "Content-Type": "application/json"
  717.                   },
  718.                   data: JSON.stringify({
  719.                       "town":destinationTown ,
  720.                       "buildType": buildingType,
  721.                       "startedDate": startDate,
  722.                       "endDate": endDate,
  723.                       }),
  724.                   beforeSend:function () {
  725.                       //btn_text_/btn_loading_/btn_search_
  726.                       const button = document.getElementById("btn_search_"+buildingType);
  727. // Disable the button
  728.                       button.disabled = true;
  729.                       $("#btn_search_"+buildingType).addClass("disabled");
  730.                       $("#btn_loading_"+buildingType).removeClass("hide");
  731.                       $("#btn_text_"+buildingType).html("Patientez... ");
  732.                   },
  733.                   success: function(data){
  734.                       const button = document.getElementById("btn_search_"+buildingType);
  735. // Disable the button
  736.                       button.disabled = false;
  737.                       console.log(data);
  738.                       if(data.length===0){
  739.                           var Toast = Swal.mixin({
  740.                               toast: true,
  741.                               position: 'top-end',
  742.                               showConfirmButton: false,
  743.                               timer: 14000,
  744.                               timerProgressBar: true,
  745.                               didOpen: (toast) => {
  746.                                   toast.addEventListener('mouseenter', Swal.stopTimer)
  747.                                   toast.addEventListener('mouseleave', Swal.resumeTimer)
  748.                               }
  749.                           })
  750.                           Toast.fire({
  751.                               icon: 'warning',
  752.                               title: 'Aucun (e) '+type+" trouvé(e)"
  753.                           });
  754.                       }else{
  755.                           window.location.assign("{{ onlinePath}}/building/detail?destination="+destinationTown+"&buildingType="+buildingType+"&startDate="+startDate+"&endDate="+endDate+"&child="+child+"&adult="+adult);
  756.                       }
  757.                       $("#btn_search_"+buildingType).removeClass("disabled");
  758.                       $("#btn_loading_"+buildingType).addClass("hide");
  759.                       $("#btn_text_"+buildingType).html("Rechercher");
  760.                   },
  761.                   error:function (xhr, textStatus, errorThrown) {
  762.                       const button = document.getElementById("btn_search_"+buildingType);
  763. // Disable the button
  764.                       button.disabled = false;
  765.                       $("#btn_search_"+buildingType).removeClass("disabled");
  766.                       $("#btn_loading_"+buildingType).addClass("hide");
  767.                       $("#btn_text_"+buildingType).html("Rechercher");
  768.                   }
  769.               });
  770.           }
  771.           /*  E-commerce part   */
  772.           function reduceItem(productId){
  773.               var currentQuantity=parseInt($("#item_"+productId).val());
  774.               if(currentQuantity>1){
  775.                   document.getElementById("item_"+productId).value =  (currentQuantity-1);
  776.               }
  777.           }
  778.           function adjustItem(productId, stock){
  779.               var currentQuantity=parseInt($("#item_"+productId).val());
  780.               if(currentQuantity<parseInt(stock)){
  781.                   document.getElementById("item_"+productId).value =  (currentQuantity+1);
  782.               }
  783.           }
  784.           const nodeList = document.querySelectorAll(".ml12");
  785.           for (let i = 0; i < nodeList.length; i++) {
  786.               nodeList[i].innerHTML = nodeList[i].textContent.replace(/\S/g, "<span class='letter'>$&</span>");
  787.           }
  788.           const nodeList13 = document.querySelectorAll(".ml13");
  789.           for (let i = 0; i < nodeList13.length; i++) {
  790.               nodeList13[i].innerHTML = nodeList13[i].textContent.replace(/\S/g, "<span class='letter'>$&</span>");
  791.           }
  792.           anime.timeline({loop: true})
  793.               .add({
  794.                   targets: '.ml12 .letter',
  795.                   scale: [2,1],
  796.                   opacity: [0,1],
  797.                   translateZ: 0,
  798.                   easing: "easeInExpo",
  799.                   duration: 950,
  800.                   delay: (el, i) => 70*i
  801.               }).add({
  802.               targets: '.ml12',
  803.               opacity: 0,
  804.               duration: 13000,
  805.               easing: "easeInExpo",
  806.               delay: 800
  807.           });
  808.           anime.timeline({loop: true})
  809.               .add({
  810.                   targets: '.ml13 .letter',
  811.                   translateX: [40,0],
  812.                   translateZ: 0,
  813.                   opacity: [0,1],
  814.                   easing: "easeOutExpo",
  815.                   duration: 1200,
  816.                   delay: (el, i) => 500 + 30 * i
  817.               }).add({
  818.               targets: '.ml13 .letter',
  819.               translateX: [0,-30],
  820.               opacity: [1,0],
  821.               easing: "easeInExpo",
  822.               duration: 10500,
  823.               delay: (el, i) => 100 + 30 * i
  824.           });
  825.       </script>
  826.   {% endblock %}