templates/client/new.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Nouveau Client{% endblock %}
  3. {% block body %}
  4.     <ol class="breadcrumb">
  5.         <li>
  6.             <i class="clip-grid-6"></i>
  7.             <a href="#">
  8.                 Client
  9.             </a>
  10.         </li>
  11.         <li class="active">
  12.             Liste
  13.         </li>
  14.         <li class="search-box">
  15.             <form class="sidebar-search">
  16.                 <div class="form-group">
  17.                     <input type="text" placeholder="Start Searching..." data-default="130">
  18.                     <button class="submit">
  19.                         <i class="clip-search-3"></i>
  20.                     </button>
  21.                 </div>
  22.             </form>
  23.         </li>
  24.     </ol>
  25.     <div class="page-header">
  26.         <h1>Ajout d'un client</h1>
  27.     </div>
  28.     <div class="row">
  29.         <div class="col-md-12">
  30.             {{ include('client/_form.html.twig') }}
  31.         </div>
  32.     </div>
  33.     <a href="{{ path('client_index') }}" class="btn btn-outline-info back-button">Revenir à la liste</a>
  34. {% endblock %}
  35. {% block javascripts %}
  36.     {{ parent() }}
  37.     <script type="application/javascript">
  38.         $('#filter_status').select2( {width: '250px' });
  39.         function addTagForm($collectionHolder) {
  40.             // Get the data-prototype explained earlier
  41.             var prototype = $collectionHolder.data('prototype');
  42.             // get the new index
  43.             var index = $collectionHolder.data('index');
  44.             var newForm = prototype;
  45.             // You need this only if you didn't set 'label' => false in your tags field in TaskType
  46.             // Replace '__name__label__' in the prototype's HTML to
  47.             // instead be a number based on how many items we have
  48.             // newForm = newForm.replace(/__name__label__/g, index);
  49.             // Replace '__name__' in the prototype's HTML to
  50.             // instead be a number based on how many items we have
  51.             newForm = newForm.replace(/__name__/g, index);
  52.             // increase the index with one for the next item
  53.             $collectionHolder.data('index', index + 1);
  54.             // Display the form in the page in an li, before the "Add a tag" link li
  55.             var $newFormLi = $('<div></div>').append(newForm);
  56.             //$newLinkLi.before($newFormLi);
  57.             $collectionHolder.after($newFormLi);
  58.             $newFormLi.find(".flatpicker").flatpickr({
  59.                 'dateFormat' : 'd-m-Y',
  60.                 "locale": "fr"
  61.             });
  62.             $('.hourPicker:not(.flatpickr-input):not(.input)').flatpickr({
  63.                 enableTime: true,
  64.                 noCalendar: true,
  65.                 dateFormat: "H:i",
  66.                 time_24hr: true,
  67.                 locale: "fr"
  68.             });
  69.         }
  70.         jQuery(document).ready(function() {
  71.           $('#client_site').select2({ width: '100%' });
  72.           var $collectionHolder;
  73.             const $addTagButton = jQuery('.btnAddContrat');
  74.             const $addFamilyButton = jQuery('.btnAddFamily');
  75.             const $familyList = jQuery('.familyList');
  76.             // Get the ul that holds the collection of tags
  77.             $collectionHolder = jQuery('ul.contratList');
  78.             // count the current form inputs we have (e.g. 2), use that as the new
  79.             // index when inserting a new item (e.g. 2)
  80.             $collectionHolder.data('index', $collectionHolder.find(':input').length);
  81.             $familyList.data('index', $collectionHolder.find(':input').length);
  82.             $addTagButton.on('click', function(e) {
  83.                 // add a new tag form (see next code block)
  84.                 addTagForm($collectionHolder);
  85.                 $('.select-product').select2({ width: '100%' });
  86.             });
  87.             $addFamilyButton.on('click', function(e) {
  88.                 // add a new tag form (see next code block)
  89.                 addTagForm($familyList);
  90.             });
  91.             // DELETE CONTRACT
  92.             $(document).on('click','.btnDeleteContract', function(e) {
  93.                 // add a new tag form (see next code block)
  94.                 $(e.target).parents('.contract-item').remove();
  95.                 var index = $collectionHolder.data('index');
  96.                 $collectionHolder.data('index', index - 1);
  97.             });
  98.             // DELETE FAMILY
  99.             $(document).on('click','.btnDeleteFamily', function(e) {
  100.                 // add a new tag form (see next code block)
  101.                 console.log($(e.target).parents('.family-item'));
  102.                 $(e.target).parents('.family-item').remove();
  103.                 var index = $familyList.data('index');
  104.                 $familyList.data('index', index - 1);
  105.             });
  106.             // filter products
  107.             $(document).on('change', '.tag', function (e) {
  108.                 console.log('tag changed');
  109.                 const val =  $(e.target).val();
  110.                 var url = '{{ path("app_client_ajaxgetproducts", {'id': 'salon_id'}) }}';
  111.                 url = url.replace("salon_id", val);
  112.                 $.ajax({
  113.                     url: url,
  114.                     type: 'get',
  115.                     success: function(data) {
  116.                         $(e.target).parents('.contract-item').find('.select-product').empty();
  117.                         console.log(data);
  118.                         for(var i = 0; i < data.length; i++) {
  119.                             var item = data[i];
  120.                             $(e.target).parents('.contract-item').find('.select-product').append('<option value="' + item.id + '">'+ item.name + '</option>');
  121.                         }
  122.                     }
  123.                 });
  124.             });
  125.             // Change payMonde
  126.             $('#client_billingInfos_payMode').on('change', function () {
  127.                 const val = $('#client_billingInfos_payMode').val();
  128.                 if(val === 'sepa') {
  129.                     $('.hide').each(function (e) {
  130.                         $( this ).removeClass('hide');
  131.                     })
  132.                 }
  133.                 else {
  134.                     $('.hiddenFields').each(function (e) {
  135.                         $( this ).addClass('hide');
  136.                     });
  137.                 }
  138.             });
  139.             $('#form_client').submit( function(e) {
  140.                 e.preventDefault();
  141.                 // if(($('#client_billingInfos_sendMode').val() === '' || $('#client_billingInfos_sendMode').val() === 'email') && $('#client_billingInfos_email').val() === ''){
  142.                 //     notie.alert({
  143.                 //         text: 'Veuillez entrer un email de facturation',
  144.                 //
  145.                 //     });
  146.                 //     return false;
  147.                 // }
  148.                 if($('#client_deathday').val()) {
  149.                     notie.confirm({
  150.                         text: 'Vous avez entré une date de décès êtes vous sur de continuer ?',
  151.                         submitText: 'Confirmer', // optional, default = 'Yes'
  152.                         cancelText: 'Annuler', // optional, default = 'Cancel'
  153.                         submitCallback: function () {
  154.                             $(this).unbind();
  155.                             $(this).submit();
  156.                         }, // optional
  157.                         cancelCallback: function () {
  158.                             return false;
  159.                         } // optional
  160.                     });
  161.                 }
  162.                 $(this).unbind();
  163.                 $(this).submit();
  164.             });
  165.         });
  166.         $('#dateDebut').flatpickr({
  167.             'dateFormat': 'Y-m-d',
  168.             "locale": "fr"
  169.         });
  170.     </script>
  171. {% endblock %}