{% extends 'base.html.twig' %}
{% block title %}Weather index{% endblock %}
{% block body %}
<h1 style="color: red">Weather index</h1>
<b>Location: </b> {{ CompanyDetails.getCompanyDetails.weatherLocation }}
<a href="{{ path('office_address') }}"><i style="color: red" class="fa fa-map-marker"></i></a>
<br>
<a class="btn btn-outline-primary btn-sm" href="{{ path('fetch_weather_data') }}">Get Latest Update</a>
<a class="btn btn-outline-primary btn-sm" href="{{ path('fetch_weather_data_hourly') }}">Get Hourly Update</a>
<a target="_blank" class="btn btn-outline-secondary btn-sm"
href="https://www.google.com/search?client=firefox-b-d&q=google%20weather%20near%20"
.{{ CompanyDetails.getCompanyDetails.weatherLocation }}."&llpgabe=CgkvbS8wMnR5ZzA&ved=2ahUKEwj08P6F6e_9AhUQWcAKHZBzD1YQ5ZgEKAB6BAgGEAA">{{ CompanyDetails.getCompanyDetails.weatherLocation }} forecast</a>
<a class="btn btn-outline-danger btn-sm" href="{{ path('weather_delete_all') }}">Delete All</a>
<br>
<table class="table table-responsive">
<thead>
<tr>
<th>Location</th>
<th>Date</th>
<th>Time</th>
<th>Rain</th>
<th></th>
<th>Temperature</th>
</tr>
</thead>
<tbody>
{% for weather in weather %}
{% if weather.date|date('Y-m-d') == today|date('Y-m-d') %}
<tr style="background-color: whitesmoke">
{% else %}
<tr>
{% endif %}
<td>{{ weather.location }}</td>
<td data-sort="{{ weather.date|date('Y-m-d H') }} . {{ weather.time }}">
<a target="_blank"
href="{{ path('weather_edit', {id: weather.id}) }}"> {{ weather.date ? weather.date|date('d-M-Y') : '' }}</a>
</td>
<td data-sort="{{ weather.time }}" style="text-align: right">{{ weather.time }}:00h</td>
<td style="text-align: left">
{% if weather.rain is not empty %}
<i class="fas fa-cloud-rain"
style="color: blue"> </i> {{ weather.rain |number_format(2, '.', ',') }}mm/hr
{% else %}
<i class="fa fa-sun-o" style="color: orange"></i>
{% endif %}
</td>
<td>
</td>
<td style="text-align: right">
{{ weather.weather|number_format(0, '.', ',') }} °C
</td>
</tr>
{% endfor %}
</tbody>
</table>
<a class="btn btn-success btn-sm" href="{{ path('weather_new') }}">New</a>
{% endblock %}
{% block datatable %}
<script>
$(document).ready(function () {
$('.table').DataTable({
'pageLength': 100,
"order": [[1, 'asc']],
"paging": false,
"searching": false,
"bInfo": false
});
});
</script>
{% endblock datatable %}