Add date info on todays list

This commit is contained in:
Samuel Ortion 2022-08-14 09:40:44 +02:00
parent 128e3f33bb
commit 8f5388c6f2
2 changed files with 27 additions and 14 deletions

View File

@ -21,6 +21,7 @@ class TodayController extends AbstractController
$this->connection = $connection;
$date = date('Y-m-d');
return $this->render('today/index.html.twig', [
"date" => $date,
"species" => $this->recorded_species_by_date($date),
]);
}
@ -33,6 +34,7 @@ class TodayController extends AbstractController
$this->connection = $connection;
$date = date('Y-m-d');
return $this->render('today/index.html.twig', [
"date" => $date,
"species" => $this->recorded_species_by_date($date)
]);
}
@ -45,6 +47,7 @@ class TodayController extends AbstractController
$this->connection = $connection;
$date = date('Y-m-d');
return $this->render('today/species.html.twig', [
"date" => $date,
"results" => $this->recorded_species_by_id_and_date($id, $date)
]);
}

View File

@ -1,17 +1,27 @@
{% extends "base.html.twig" %}
{% block content %}
<h2>{{ "Today's Detected Species" | trans }}</h2>
{# Display a list of records if any, else, print message #}
{% if results[0] is defined and results[0] | length > 0 %}
<ul>
{% for sp in results %}
<li class="species">
<a href="./species/{{ sp['taxon_id'] }}">
<span class="scientific-name">{{ sp["scientific_name"] }} (</span><span class="common-name">{{ sp["common_name"] }}</span>)
</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
<h2>
{% set today = "now" | date("Y-m-d") %}
{% if today == date %}
{{ "Today's detected species" | trans }}
{% else %}
{{ "Detected species on" | trans }}
{{ date | format_datetime("full", "none") }}
{% endif %}
</h2>
{# Display a list of records if any, else, print message #}
{% if results[0] is defined and results[0] | length > 0 %}
<ul>
{% for sp in results %}
<li class="species">
<a href="./species/{{ sp['taxon_id'] }}">
<span class="scientific-name">{{ sp["scientific_name"] }}
(</span>
<span class="common-name">{{ sp["common_name"] }}</span>)
</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}