templates/main/track/index.html.twig line 1

Open in your IDE?
  1. {% extends base ~"/base.html.twig" %} 
  2. {% block title %}Suivre ma commande{% endblock %}
  3. {% block main %}
  4. <style>
  5.     .card {
  6.         z-index: 0;
  7.         background-color: #ECEFF1;
  8.         padding-bottom: 20px;
  9.         margin-top: 20px;
  10.         margin-bottom: 90px;
  11.         border-radius: 10px;
  12.     }
  13.     .top {
  14.         padding-top: 40px;
  15.         padding-left: 13% !important;
  16.         padding-right: 13% !important;
  17.     }
  18.     /*Icon progressbar*/
  19.     #progressbar {
  20.         margin-bottom: 30px;
  21.         overflow: hidden;
  22.         color: #455A64;
  23.         padding-left: 0px;
  24.         margin-top: 30px;
  25.     }
  26.     #progressbar li {
  27.         list-style-type: none;
  28.         font-size: 13px;
  29.         width: 25%;
  30.         float: left;
  31.         position: relative;
  32.         font-weight: 400;
  33.     }
  34.     #progressbar .step0:before {
  35.         font-family: FontAwesome;
  36.         content: "\f10c";
  37.         color: #fff;
  38.     }
  39.     #progressbar li:before {
  40.         width: 40px;
  41.         height: 40px;
  42.         line-height: 45px;
  43.         display: block;
  44.         font-size: 20px;
  45.         background: #C5CAE9;
  46.         border-radius: 50%;
  47.         margin: auto;
  48.         padding: 0px;
  49.     }
  50.     /*ProgressBar connectors*/
  51.     #progressbar li:after {
  52.         content: '';
  53.         width: 100%;
  54.         height: 12px;
  55.         background: #C5CAE9;
  56.         position: absolute;
  57.         left: 0;
  58.         top: 16px;
  59.         z-index: -1;
  60.     }
  61.     #progressbar li:last-child:after {
  62.         border-top-right-radius: 10px;
  63.         border-bottom-right-radius: 10px;
  64.         position: absolute;
  65.         left: -50%;
  66.     }
  67.     #progressbar li:nth-child(2):after,
  68.     #progressbar li:nth-child(3):after {
  69.         left: -50%;
  70.     }
  71.     #progressbar li:first-child:after {
  72.         border-top-left-radius: 10px;
  73.         border-bottom-left-radius: 10px;
  74.         position: absolute;
  75.         left: 50%;
  76.     }
  77.     #progressbar li:last-child:after {
  78.         border-top-right-radius: 10px;
  79.         border-bottom-right-radius: 10px;
  80.     }
  81.     #progressbar li:first-child:after {
  82.         border-top-left-radius: 10px;
  83.         border-bottom-left-radius: 10px;
  84.     }
  85.     /*Color number of the step and the connector before it*/
  86.     #progressbar li.active:before,
  87.     #progressbar li.active:after {
  88.         background: #651FFF;
  89.     }
  90.     #progressbar li.active:before {
  91.         font-family: FontAwesome;
  92.         content: "\f00c";
  93.     }
  94.     .icon-track {
  95.         width: 60px;
  96.         height: 60px;
  97.         margin-right: 15px;
  98.     }
  99.     .icon-content {
  100.         padding-bottom: 20px;
  101.     }
  102.     @media screen and (max-width: 992px) {
  103.         .icon-content {
  104.             width: 50%;
  105.         }
  106.     }
  107. </style>
  108. <main class="main">
  109.     <nav aria-label="breadcrumb" class="breadcrumb-nav mb-2">
  110.         <div class="container">
  111.             <ol class="breadcrumb">
  112.                 <li class="breadcrumb-item">
  113.                     <a href="/">{{'Home'|trans}}</a>
  114.                 </li>
  115.                 <li class="breadcrumb-item active" aria-current="page">{{ 'Track my order'|trans }}</li>
  116.             </ol>
  117.         </div>
  118.         <!-- End .container -->
  119.     </nav>
  120.     <!-- End .breadcrumb-nav -->
  121.     <div class="page-content">
  122.         <div id="track-order" class="container">
  123.             <h3>Suivre une commande</h3>
  124.             <div class="form-group">
  125.                 <label for="" class="required">{{'Number'|trans}}</label>
  126.                 <input type="text" value="{{ order is defined ? order.number:''}}" id="order-number" name="order-number"
  127.                     required="required" autocomplete="email" class="form-control">
  128.                 <small id="order-number-help" class="text-danger"></small>
  129.             </div>
  130.             <div>
  131.                 <small>
  132.                     {{'Enter your order number'|trans}}.
  133.                 </small>
  134.             </div>
  135.             <button class="btn-send-order-number btn btn-primary">{{'Send order number'|trans}}</button>
  136.         </div>
  137.         {% if app.request.get('_route') == 'track_index' %}
  138.         <div id="track-show"></div>
  139.         {% else %}
  140.         <div id="track-show">
  141.             {% include base ~ "/track/_track_view.html.twig" %}
  142.         </div>
  143.         {% endif %}
  144.     </div>
  145. </main>
  146. {% endblock %}
  147. {% block javascripts %}
  148. <script type="text/javascript">
  149.     $(document).ready(function () {
  150.         $(document).on('click', '.btn-send-order-number', function () {
  151.             let number = $('#order-number').val()
  152.             if (number.length == '') {
  153.                 Swal.fire({
  154.                     title: 'Oups !',
  155.                     text: 'Entrer un nombre',
  156.                     icon: 'warning',
  157.                     showConfirmButton: false,
  158.                     timer: 2000
  159.                 })
  160.                 $('#order-number-help').text('Entrer un numbre.')
  161.                 $('#track-show').html('')
  162.                 return false
  163.             }
  164.             if (!validation.isNumber(number)) {
  165.                 Swal.fire({
  166.                     title: 'Oups !',
  167.                     text: 'Entrer un nombre',
  168.                     icon: 'warning',
  169.                     showConfirmButton: false,
  170.                     timer: 2000
  171.                 })
  172.                 $('#order-number-help').text('Entrer un numbre.')
  173.                 $('#track-show').html('')
  174.                 return false
  175.             }
  176.             $.ajax({
  177.                 url: '/js/track-my-order/' + number,
  178.                 method: 'POST',
  179.                 beforeSend: function () {
  180.                     $('.js-loader-text').text('Vérification en cour ...')
  181.                     $('.js-loader').css('display', 'flex')
  182.                 },
  183.                 success: function (data) {
  184.                     $('.js-loader').css('display', 'none')
  185.                     if (data.reponse) {
  186.                         $('#track-show').html(data.content)
  187.                         Swal.fire({
  188.                             title: 'Bien joué !',
  189.                             text: 'Chargement terminé',
  190.                             icon: 'success',
  191.                             showConfirmButton: false,
  192.                             timer: 2000
  193.                         })
  194.                     } else {
  195.                         $('#order-number-help').text('Numéro incorrect')
  196.                         $('#track-show').html('')
  197.                     }
  198.                     $('#order-number-help').text('')
  199.                 },
  200.                 error: function () {
  201.                     Swal.fire({
  202.                         title: 'Oups !',
  203.                         text: 'Entrer un nombre',
  204.                         icon: 'error',
  205.                         showConfirmButton: false,
  206.                         timer: 2000
  207.                     })
  208.                     $('#order-number-help').text('Numéro incorrect')
  209.                     $('#track-show').html('')
  210.                     $('.js-loader').css('display', 'none')
  211.                 }
  212.             })
  213.         })
  214.         var validation = {
  215.             isEmailAddress: function (str) {
  216.                 var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  217.                 return pattern.test(str);  // returns a boolean
  218.             },
  219.             isNotEmpty: function (str) {
  220.                 var pattern = /\S+/;
  221.                 return pattern.test(str);  // returns a boolean
  222.             },
  223.             isNumber: function (str) {
  224.                 var pattern = /^\d+\.?\d*$/;
  225.                 return pattern.test(str);  // returns a boolean
  226.             },
  227.             isSame: function (str1, str2) {
  228.                 return str1 === str2;
  229.             }
  230.         };
  231.     })
  232. </script>
  233. {% endblock %}