membership-pdf-new #284

Merged
philipp merged 45 commits from membership-pdf-new into staging 2024-03-20 21:05:23 +01:00
3 changed files with 23 additions and 4 deletions
Showing only changes of commit 6ad07f35f7 - Show all commits

View File

@ -88,6 +88,16 @@ AND u.name != 'Externe Steuerperson';
} }
} }
pub async fn sum_people(db: &SqlitePool, year: Option<i32>) -> i32 {
let stats = Self::people(db, year).await;
let mut sum = 0;
for stat in stats {
sum += stat.rowed_km;
}
sum
}
pub async fn people(db: &SqlitePool, year: Option<i32>) -> Vec<Stat> { pub async fn people(db: &SqlitePool, year: Option<i32>) -> Vec<Stat> {
let year = match year { let year = match year {
Some(year) => year, Some(year) => year,

View File

@ -35,25 +35,27 @@ async fn index_boat_kiosk(
#[get("/?<year>", rank = 2)] #[get("/?<year>", rank = 2)]
async fn index(db: &State<SqlitePool>, user: DonauLinzUser, year: Option<i32>) -> Template { async fn index(db: &State<SqlitePool>, user: DonauLinzUser, year: Option<i32>) -> Template {
let stat = Stat::people(db, year).await; let stat = Stat::people(db, year).await;
let club_km = Stat::sum_people(db, year).await;
let guest_km = Stat::guest(db, year).await; let guest_km = Stat::guest(db, year).await;
let personal = stat::get_personal(db, &user).await; let personal = stat::get_personal(db, &user).await;
let kiosk = false; let kiosk = false;
Template::render( Template::render(
"stat.people", "stat.people",
context!(loggedin_user: &UserWithRoles::from_user(user.into(), db).await, stat, personal, kiosk, guest_km), context!(loggedin_user: &UserWithRoles::from_user(user.into(), db).await, stat, personal, kiosk, guest_km, club_km),
) )
} }
#[get("/?<year>")] #[get("/?<year>")]
async fn index_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie, year: Option<i32>) -> Template { async fn index_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie, year: Option<i32>) -> Template {
let stat = Stat::people(db, year).await; let stat = Stat::people(db, year).await;
let club_km = Stat::sum_people(db, year).await;
let guest_km = Stat::guest(db, year).await; let guest_km = Stat::guest(db, year).await;
let kiosk = true; let kiosk = true;
Template::render( Template::render(
"stat.people", "stat.people",
context!(stat, kiosk, show_kiosk_header: true, guest_km), context!(stat, kiosk, show_kiosk_header: true, guest_km, club_km),
) )
} }

View File

@ -22,7 +22,7 @@
<div class="border-r border-l border-gray-200 dark:border-primary-600"> <div class="border-r border-l border-gray-200 dark:border-primary-600">
{% set_global km = 0 %} {% set_global index = 1 %} {% set_global km = 0 %} {% set_global index = 1 %}
{% for s in stat %} {% for s in stat %}
<div class="border-t border-gray-200 dark:border-primary-600 {% if loop.last %}border-b{% endif %} bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1" <div class="border-t border-gray-200 dark:border-primary-600 bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1"
data-filterable="true" data-filterable="true"
data-filter="{{ s.name }}"> data-filter="{{ s.name }}">
<span class="text-sm text-gray-600 dark:text-gray-100 w-10"> <span class="text-sm text-gray-600 dark:text-gray-100 w-10">
@ -38,7 +38,14 @@
{% set_global km = s.rowed_km %} {% set_global km = s.rowed_km %}
</div> </div>
{% endfor %} {% endfor %}
<div class="border-t border-gray-200 dark:border-primary-600 {% if loop.last %}border-b{% endif %} bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1" <div class="border-t border-gray-200 dark:border-primary-600 bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1"
data-filterable="true"
data-filter="Gesamtkilometer Donau Linz">
<span class="text-sm text-gray-600 dark:text-gray-100 w-10"></span>
<span class="grow">Gesamtkilometer Donau Linz</span>
<span>{{ club_km }} km</span>
</div>
<div class="border-t border-gray-200 dark:border-primary-600 border-b bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1"
data-filterable="true" data-filterable="true"
data-filter="{{ guest_km.name }}"> data-filter="{{ guest_km.name }}">
<span class="text-sm text-gray-600 dark:text-gray-100 w-10"></span> <span class="text-sm text-gray-600 dark:text-gray-100 w-10"></span>