templates/warehouse/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Hello WarehouseController!{% endblock %}
  3. {% set linkActive = 'warehouse' %}
  4. {% block body %}
  5. <div class="container" style="padding-top: 10px;">
  6.     <div class="row">
  7.         <div class="col-sm-4">
  8.             <div class="input-group">
  9.                 <input type="text" class="form-control" id="search" placeholder="Wyszukaj urządzenie" aria-label="Numer seryjny" aria-describedby="button-search-clear">
  10.                 <button class="btn btn-outline-secondary" type="button" id="button-search-clear">Wyczyść</button>
  11.             </div>
  12.         </div>
  13.         <div class="col-sm-7 offset-1 align-content-end" style="text-align: right">
  14.             <a href="{{ path('hangover_from_warehouse') }}" class="btn btn-success">Wydanie z magazynu</a>
  15.             <a href="{{ path('acceptance_of_delivery') }}" class="btn btn-success">Przyjęcie dostawy</a>
  16.             <a href="{{ path('hangover_of_equipment_to_engineer') }}" class="btn btn-success">Wydanie technikowi</a>
  17.         </div>
  18.     </div>
  19. </div>
  20. <div class="container" style="margin-top: 20px">
  21.     <div class="row">
  22.         <div class="col-sm-12">
  23.             <table id="warehouse" class="table table-striped">
  24.                 <thead>
  25.                     <td>Technik</td>
  26.                     <td>Data pobrania</td>
  27.                     <td>Nazwa urządzenia</td>
  28.                     <td>Numer seryjny</td>
  29.                     <td>Data montażu/wydania</td>
  30.                     <td>Numer zlecenia / Wydanie</td>
  31.                     <td></td>
  32.                 </thead>
  33.                 <tbody></tbody>
  34.             </table>
  35.         </div>
  36.     </div>
  37. </div>
  38. {% endblock %}
  39. {% block js_external %}
  40.     <script>
  41.         $( document ).ready(function() {
  42.             $('#button-search-clear').click(function () {
  43.                 $('#search').val('');
  44.             })
  45.             var timer;
  46.             var timeout = 500;
  47.             $('#search').keyup(function (event) {
  48.                 clearTimeout(timer);
  49.                 if ($('#search').val) {
  50.                     timer = setTimeout(function(){
  51.                         //do stuff here e.g ajax call etc....
  52.                         search();
  53.                     }, timeout);
  54.                 }
  55.                 // selectedDevice = 'test';
  56.                 // serialNumber = 'test';
  57.                 // $('#warehouse tbody').append('<tr><td>' + selectedDevice + '</td><td>' + serialNumber + '</td><td></td></tr>');
  58.                 // event.preventDefault();
  59.             });
  60.         });
  61.         function search() {
  62.             var search = $('#search').val();
  63.             $.ajax({
  64.                 url: '/warehouse/search',
  65.                 data: { search: search }
  66.             }).done(function (data) {
  67.                 $('#warehouse tbody').empty();
  68.                 console.log(data.length);
  69.                 $.each(data, function (i, item) {
  70.                     var returnUrl = '';
  71.                     var notes = item.notes;
  72.                     if (item.hangoverFromWarehouse === true) {
  73.                         notes += ' <strong>wydano z magazynu</strong>';
  74.                     }
  75.                     if (item.releaseDate.length == 0 && item.engineer.length > 0) {
  76.                         returnUrl = '<a class="btn btn-danger btn-sm" href="{{ path('warehouse_return_to_warehouse') }}' + '?deviceId=' + item.id +'">zwróć na magazyn</a>';
  77.                     }
  78.                     $('#warehouse tbody').append('<tr>' +
  79.                         '<td>' + item.engineer + '</td>' +
  80.                         '<td>' + item.admissionDate + '</td>' +
  81.                         '<td>' + item.deviceModel + '</td>' +
  82.                         '<td>' + item.serialNumber + '</td>' +
  83.                         '<td>' + item.releaseDate + '</td>' +
  84.                         '<td>' + notes + '</td>' +
  85.                         '<td>' + returnUrl + '</td></tr>');
  86.                 })
  87.             })
  88.         }
  89.     </script>
  90. {% endblock %}