templates/employee_log_hour/log.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}{{ title }}{% endblock %}
  3. {% block stylesheets %}
  4.     <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">
  5.     <style>
  6.         #kt_datatable_row_grouping tr.group {
  7.             --bs-table-accent-bg: var(--bs-table-striped-bg) !important;
  8.         }
  9.         #kt_datatable_row_grouping tr.even, #kt_datatable_row_grouping tr.odd {
  10.             --bs-table-accent-bg: white !important;
  11.         }
  12.         #logDate {
  13.             text-align: center;
  14.             font-size: 25px;
  15.             font-weight: bold;
  16.         }
  17.     </style>
  18. {% endblock %}
  19. {% block body %}
  20.     <div class="card mb-5 mb-xl-10">
  21.         <div class="card-body fs-6 py-15 px-10 py-lg-15 px-lg-15 text-gray-700">
  22.             <div class="pb-10 row g-6 g-xl-9">
  23.                 <div class="col-md-4"></div>
  24.                 <div class="col-md-4"><input id="logDate" type="text" class="form-control form-control-solid"
  25.                                              autocomplete="false"></div>
  26.                 <div class="col-md-2">
  27.                     <button id="exportLogSheet" class="btn btn-primary">Exporter la fiche d'absence</button>
  28.                 </div>
  29.                 <div class="col-md-2"></div>
  30.             </div>
  31.             <!--begin::Wrapper-->
  32.             <div class="d-flex flex-stack flex-wrap mb-5">
  33.                 <!--begin::Search-->
  34.                 <div class="d-flex align-items-center position-relative my-1 mb-2 mb-md-0">
  35.                     <!--begin::Svg Icon | path: icons/duotune/general/gen021.svg-->
  36.                     <span class="svg-icon svg-icon-1 position-absolute ms-6">
  37.                                                         <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
  38.                                                              xmlns="http://www.w3.org/2000/svg">
  39.                                                             <rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546"
  40.                                                                   height="2" rx="1"
  41.                                                                   transform="rotate(45 17.0365 15.1223)"
  42.                                                                   fill="currentColor"/>
  43.                                                             <path d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z"
  44.                                                                   fill="currentColor"/>
  45.                                                         </svg>
  46.                                                     </span>
  47.                     <!--end::Svg Icon-->
  48.                     <input type="text" data-table-filter="search" class="form-control form-control-solid w-250px ps-15"
  49.                            placeholder="Search"/>
  50.                 </div>
  51.                 <!--end::Search-->
  52.             </div>
  53.             <!--end::Wrapper-->
  54.             <table id="kt_datatable_row_grouping"
  55.                    class="table table-row-bordered gy-5 gs-7 border rounded w-100">
  56.                 <thead>
  57.                 <tr>
  58.                     <th>Département</th>
  59.                     <th>Poste</th>
  60.                     <th>Nom Complet</th>
  61.                     <th>Historique</th>
  62.                     <th>Type</th>
  63.                     <th>Heure</th>
  64.                     <th>#</th>
  65.                 </tr>
  66.                 </thead>
  67.                 <tbody>
  68.                 {% for employee in employees %}
  69.                     <tr data-employee-id="{{ employee.id }}">
  70.                         <th>{{ employee.department }}</th>
  71.                         <th>{{ employee.position }}</th>
  72.                         <th><a href="{{ path('employee_show', {'id': employee.id}) }}">{{ employee.fullName }}</a></th>
  73.                         <th>
  74.                             <div class="history">{{ employee.historyHtml | raw }}</div>
  75.                         </th>
  76.                         <th>
  77.                             <select class="form-select form-select-solid in_out no-select" size="1" autocomplete="off">
  78.                                 {% set InOut = enum('App\\Enum\\EmployeeHourLog\\InOut') %}
  79.                                 <option value="" selected>Séléctionner le type</option>
  80.                                 {% for type in InOut.cases() %}
  81.                                     <option value="{{ type.value }}">
  82.                                         {{ type.title() }}
  83.                                     </option>
  84.                                 {% endfor %}
  85.                             </select>
  86.                         </th>
  87.                         <th>
  88.                             <input type="text" class="form-control form-control-solid logTime">
  89.                         </th>
  90.                         <th>
  91.                             <button type="button" class="btn btn-primary btn-success me-10 logTimeValidate">
  92.                                 <span class="indicator-label">Valider</span>
  93.                                 <span class="indicator-progress">Pointage en cours... <span
  94.                                             class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
  95.                             </button>
  96.                         </th>
  97.                     </tr>
  98.                 {% endfor %}
  99.                 </tbody>
  100.             </table>
  101.         </div>
  102.     </div>
  103. {% endblock %}
  104. {% block javascripts %}
  105.     <script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
  106.     <script>
  107.         var groupColumn = 0;
  108.         var table = $("#kt_datatable_row_grouping").DataTable({
  109.             columnDefs: [
  110.                 {
  111.                     targets: groupColumn,
  112.                     visible: false,
  113.                 },
  114.                 {
  115.                     targets: 1,
  116.                     width: "15%"
  117.                 },
  118.                 {
  119.                     targets: 2,
  120.                     width: "15%"
  121.                 },
  122.                 {
  123.                     targets: 3,
  124.                     width: "20%"
  125.                 }
  126.             ],
  127.             order: [
  128.                 [
  129.                     groupColumn, "asc"
  130.                 ]
  131.             ],
  132.             displayLength: 500,
  133.             drawCallback: function (settings) {
  134.                 var api = this.api();
  135.                 var rows = api.rows({
  136.                     page: "current"
  137.                 }).nodes();
  138.                 var last = null;
  139.                 api.column(groupColumn, {
  140.                     page: "current"
  141.                 }).data().each(function (group, i) {
  142.                     if (last !== group) {
  143.                         $(rows).eq(i).before(
  144.                             "<tr class=\"group fs-5 fw-bolder\"><td colspan=\"5\">" + group + "</td></tr>"
  145.                         );
  146.                         last = group;
  147.                     }
  148.                 });
  149.             }
  150.         });
  151.         $("#kt_datatable_row_grouping tbody").on("click", "tr.group", function () {
  152.             var currentOrder = table.order()[0];
  153.             if (currentOrder[0] === groupColumn && currentOrder[1] === "asc") {
  154.                 table.order([groupColumn, "desc"]).draw();
  155.             } else {
  156.                 table.order([groupColumn, "asc"]).draw();
  157.             }
  158.         });
  159.         handleSearchDatatable(table);
  160.         var today = new Date();
  161.         $('.logTime').timepicker({
  162.             timeFormat: 'HH:mm',
  163.             interval: 15,
  164.             minTime: '6:00am',
  165.             maxTime: '11:00pm',
  166.             defaultTime: new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours(), 0, 0),
  167.             startTime: '06:00am',
  168.             dynamic: false,
  169.             dropdown: true,
  170.             scrollbar: true
  171.         });
  172.         $(".logTimeValidate").on('click', function () {
  173.             let element = $(this);
  174.             element.attr('data-kt-indicator', 'on');
  175.             var tr = $(this).parents('tr');
  176.             let date = $("#logDate").val();
  177.             let time = tr.find('.logTime').val();
  178.             let employeeId = tr.attr('data-employee-id');
  179.             let inOut = tr.find('.in_out').val();
  180.             if (typeof inOut === 'undefined' || inOut === '') {
  181.                 Swal.fire("Erreur!", "Le type est obligatoire !", "error");
  182.                 element.removeAttr('data-kt-indicator');
  183.                 return false;
  184.             }
  185.             var data = {
  186.                 'employeeId': employeeId,
  187.                 'inOut': inOut,
  188.                 'logDate': date,
  189.                 'logTime': time,
  190.             }
  191.             $.ajax({
  192.                 url: '{{ path('employee_log_hour_add') }}',
  193.                 data: data,
  194.                 dataType: 'json',
  195.                 type: "POST",
  196.                 success: function (response) {
  197.                     if (response.status) {
  198.                         toastr["success"]('MAJ', response.message);
  199.                     } else {
  200.                         Swal.fire("Erreur!", response.message, "error")
  201.                     }
  202.                     tr.find('.history').html(response.historyHtml);
  203.                     element.removeAttr('data-kt-indicator');
  204.                     tr.find('.in_out').val('');
  205.                 },
  206.                 error: function (error) {
  207.                     Swal.fire("Erreur!", "Une erreur s'est produite, Prière de contacter la direction !", "error")
  208.                 }
  209.             });
  210.             //element.removeAttr('data-kt-indicator');
  211.         });
  212.         window.date = '{{ date }}';
  213.         var logDate = $('#logDate');
  214.         logDate.daterangepicker({
  215.             singleDatePicker: true,
  216.             showDropdowns: true,
  217.             autoUpdateInput: true,
  218.             startDate: window.date,
  219.             locale: {
  220.                 format: "DD/MM/YYYY",
  221.                 applyLabel: "Appliquer",
  222.                 cancelLabel: "Annuler",
  223.                 weekLabel: "W",
  224.                 firstDay: 1,
  225.             }
  226.         });
  227.         logDate.on('apply.daterangepicker', function (ev, picker) {
  228.             Swal.fire({
  229.                 text: 'Attention: la page va se raffraichir',
  230.                 icon: "info",
  231.                 confirmButtonText: "Confirmer !",
  232.                 customClass: {
  233.                     confirmButton: "btn btn-danger font-weight-bold btn-pill",
  234.                     cancelButton: "btn btn-secondary font-weight-bold btn-pill"
  235.                 },
  236.                 cancelButtonText: 'Annuler',
  237.                 showCancelButton: true
  238.             }).then((result) => {
  239.                 if (result.isConfirmed) {
  240.                     let date = picker.startDate.format("DD/MM/YYYY");
  241.                     $(this).val(date);
  242.                     window.location.href = window.location.href.replace(/[\?#].*|$/, "?date=" + date);
  243.                 }
  244.                 $(this).val(window.date);
  245.             })
  246.         });
  247.         logDate.on('cancel.daterangepicker', function (ev, picker) {
  248.             $(this).val(window.date);
  249.         });
  250.         $('#exportLogSheet').on('click', function (e) {
  251.             e.preventDefault();
  252.             var url = '{{ path('employee_log_sheet') }}';
  253.             window.open(url.replace(/[\?#].*|$/, "?date=" + $('#logDate').val()));
  254.         })
  255.     </script>
  256. {% endblock %}