templates/weather/index.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% block title %}
  3.     Weather
  4.     {% if CompanyDetailsService is not null %}
  5.         : {{ CompanyDetailsService.getCompanyDetails.weatherLocation }}
  6.     {% endif %}
  7. {% endblock %}
  8. {% block body %}
  9.     <h1 style="color: red">
  10.         Weather{% if CompanyDetailsService is not null %}: {{ CompanyDetailsService.getCompanyDetails.weatherLocation }}
  11.         {% endif %}
  12.     </h1>
  13.     {% include 'weather/parts/update_and_delete_buttons.html.twig' %}
  14.     {% set grouped = {} %}
  15.     {% for w in weather %}
  16.         {% if w.date > today %}
  17.             {% set dayKey = w.date|date('Y-m-d') %}
  18.             {% if grouped[dayKey] is not defined %}
  19.                 {% set grouped = grouped|merge({ (dayKey): [w] }) %}
  20.             {% else %}
  21.                 {% set grouped = grouped|merge({ (dayKey): grouped[dayKey]|merge([w]) }) %}
  22.             {% endif %}
  23.         {% endif %}
  24.     {% endfor %}
  25.     {% for date, dayWeather in grouped %}
  26.         {% if selectedDate is empty or selectedDate == date %}
  27.             <h3>{{ date|date("l, d M Y") }}</h3>
  28.             <table class="table table-responsive small">
  29.                 <thead>
  30.                 <tr>
  31.                     <th>Time</th>
  32.                     <th>Sun/<br>Rain</th>
  33.                     <th>Rainfall</th>
  34.                     <th>Temp</th>
  35.                 </tr>
  36.                 </thead>
  37.                 <tbody>
  38.                 {% for weather in dayWeather %}
  39.                     <tr>
  40.                         <td data-sort="{{ weather.time }}" style="text-align: right">{{ weather.time }}:00h</td>
  41.                         <td style="text-align: center">
  42.                             {% if weather.rain is not empty %}
  43.                                 <i class="fas fa-cloud-rain" style="color: blue"></i>
  44.                             {% else %}
  45.                                 <i class="fa fa-sun-o" style="color: orange"></i>
  46.                             {% endif %}
  47.                         </td>
  48.                         <td style="text-align: left">
  49.                             {% if weather.rain is not empty %}
  50.                                 {{ weather.rain |number_format(2, '.', ',') }}mm/hr
  51.                             {% endif %}
  52.                         </td>
  53.                         <td style="text-align: right">
  54.                             {{ weather.weather|number_format(0, '.', ',') }} °C
  55.                         </td>
  56.                     </tr>
  57.                 {% endfor %}
  58.                 </tbody>
  59.             </table>
  60.         {% endif %}
  61.     {% else %}
  62.         <br>
  63.         <br>
  64.         <br>
  65.         <br>
  66.         <br>
  67.         <br>
  68.         <br>
  69.         <p>No future weather data available.</p>
  70.     {% endfor %}
  71. {% endblock %}
  72. {% block datatable %}
  73.     <script>
  74.         $(document).ready(function () {
  75.             $('.table').DataTable({
  76.                 'pageLength': 100,
  77.                 "order": [[0, 'asc']],
  78.                 "paging": false,
  79.                 "searching": false,
  80.                 "bInfo": false
  81.             });
  82.         });
  83.     </script>
  84. {% endblock %}