reservations #327

Merged
philipp merged 14 commits from reservations into main 2024-04-02 21:46:21 +02:00
16 changed files with 580 additions and 70 deletions

View File

@ -7,6 +7,7 @@ export interface choiceMap {
let choiceObjects: choiceMap = {}; let choiceObjects: choiceMap = {};
let boat_in_ottensheim = true; let boat_in_ottensheim = true;
let boat_reserved_today= true;
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
changeTheme(); changeTheme();
@ -116,6 +117,7 @@ interface ChoiceBoatEvent extends Event {
owner: number; owner: number;
default_destination: string; default_destination: string;
boat_in_ottensheim: boolean; boat_in_ottensheim: boolean;
boat_reserved_today: boolean;
}; };
}; };
} }
@ -134,7 +136,12 @@ function selectBoatChange() {
boatSelect.addEventListener( boatSelect.addEventListener(
"addItem", "addItem",
function (e) { function (e) {
const event = e as ChoiceBoatEvent; const event = e as ChoiceBoatEvent;
boat_reserved_today = event.detail.customProperties.boat_reserved_today;
if (boat_reserved_today){
alert(event.detail.label.trim()+' wurde heute reserviert. Bitte kontrolliere, dass du die Reservierung nicht störst.');
}
boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim; boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim;
const amount_seats = event.detail.customProperties.amount_seats; const amount_seats = event.detail.customProperties.amount_seats;

View File

@ -160,3 +160,16 @@ CREATE TABLE IF NOT EXISTS "notification" (
"category" TEXT NOT NULL, "category" TEXT NOT NULL,
"link" TEXT "link" TEXT
); );
CREATE TABLE IF NOT EXISTS "boat_reservation" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"boat_id" INTEGER NOT NULL REFERENCES boat(id),
"start_date" DATE NOT NULL,
"end_date" DATE NOT NULL,
"time_desc" TEXT NOT NULL,
"usage" TEXT NOT NULL,
"user_id_applicant" INTEGER NOT NULL REFERENCES user(id),
"user_id_confirmation" INTEGER REFERENCES user(id),
"created_at" datetime not null default CURRENT_TIMESTAMP
);

View File

@ -36,9 +36,10 @@ pub enum BoatDamage {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct BoatWithDetails { pub struct BoatWithDetails {
#[serde(flatten)] #[serde(flatten)]
boat: Boat, pub(crate) boat: Boat,
damage: BoatDamage, damage: BoatDamage,
on_water: bool, on_water: bool,
reserved_today: bool,
} }
#[derive(FromForm)] #[derive(FromForm)]
@ -135,6 +136,20 @@ impl Boat {
sqlx::query!("SELECT * FROM boat_damage WHERE boat_id=? AND lock_boat=false AND user_id_verified is null", self.id).fetch_optional(db).await.unwrap().is_some() sqlx::query!("SELECT * FROM boat_damage WHERE boat_id=? AND lock_boat=false AND user_id_verified is null", self.id).fetch_optional(db).await.unwrap().is_some()
} }
pub async fn reserved_today(&self, db: &SqlitePool) -> bool {
sqlx::query!(
"SELECT *
FROM boat_reservation
WHERE boat_id =?
AND date('now') BETWEEN start_date AND end_date;",
self.id
)
.fetch_optional(db)
.await
.unwrap()
.is_some()
}
pub async fn on_water(&self, db: &SqlitePool) -> bool { pub async fn on_water(&self, db: &SqlitePool) -> bool {
sqlx::query!( sqlx::query!(
"SELECT * FROM logbook WHERE boat_id=? AND arrival is null", "SELECT * FROM logbook WHERE boat_id=? AND arrival is null",
@ -159,6 +174,7 @@ impl Boat {
res.push(BoatWithDetails { res.push(BoatWithDetails {
damage, damage,
on_water: boat.on_water(db).await, on_water: boat.on_water(db).await,
reserved_today: boat.reserved_today(db).await,
boat, boat,
}); });
} }

View File

@ -0,0 +1,178 @@
use crate::model::{boat::Boat, user::User};
use chrono::NaiveDate;
use chrono::NaiveDateTime;
use rocket::serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use super::log::Log;
use super::notification::Notification;
use super::role::Role;
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct BoatReservation {
pub id: i64,
pub boat_id: i64,
pub start_date: NaiveDate,
pub end_date: NaiveDate,
pub time_desc: String,
pub usage: String,
pub user_id_applicant: i64,
pub user_id_confirmation: Option<i64>,
pub created_at: NaiveDateTime,
}
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct BoatReservationWithDetails {
#[serde(flatten)]
boat_reservation: BoatReservation,
boat: Boat,
user_applicant: User,
user_confirmation: Option<User>,
}
#[derive(Debug)]
pub struct BoatReservationToAdd<'r> {
pub boat: &'r Boat,
pub start_date: NaiveDate,
pub end_date: NaiveDate,
pub time_desc: &'r str,
pub usage: &'r str,
pub user_applicant: &'r User,
}
impl BoatReservation {
pub async fn find_by_id(db: &SqlitePool, id: i32) -> Option<Self> {
sqlx::query_as!(
Self,
"SELECT id, boat_id, start_date, end_date, time_desc, usage, user_id_applicant, user_id_confirmation, created_at
FROM boat_reservation
WHERE id like ?",
id
)
.fetch_one(db)
.await
.ok()
}
pub async fn all_future(db: &SqlitePool) -> Vec<BoatReservationWithDetails> {
let boatreservations = sqlx::query_as!(
Self,
"
SELECT id, boat_id, start_date, end_date, time_desc, usage, user_id_applicant, user_id_confirmation, created_at
FROM boat_reservation
WHERE end_date >= CURRENT_DATE ORDER BY end_date
"
)
.fetch_all(db)
.await
.unwrap(); //TODO: fixme
let mut res = Vec::new();
for reservation in boatreservations {
let user_confirmation = match reservation.user_id_confirmation {
Some(id) => {
let user = User::find_by_id(db, id as i32).await;
Some(user.unwrap())
}
None => None,
};
let user_applicant = User::find_by_id(db, reservation.user_id_applicant as i32)
.await
.unwrap();
let boat = Boat::find_by_id(db, reservation.boat_id as i32)
.await
.unwrap();
res.push(BoatReservationWithDetails {
boat_reservation: reservation,
boat,
user_applicant,
user_confirmation,
});
}
res
}
pub async fn create(
db: &SqlitePool,
boatreservation: BoatReservationToAdd<'_>,
) -> Result<(), String> {
if Self::boat_reserved_between_dates(
db,
boatreservation.boat,
&boatreservation.start_date,
&boatreservation.end_date,
)
.await
{
return Err("Boot in diesem Zeitraum bereits reserviert.".into());
}
Log::create(db, format!("New boat reservation: {boatreservation:?}")).await;
sqlx::query!(
"INSERT INTO boat_reservation(boat_id, start_date, end_date, time_desc, usage, user_id_applicant) VALUES (?,?,?,?,?,?)",
boatreservation.boat.id,
boatreservation.start_date,
boatreservation.end_date,
boatreservation.time_desc,
boatreservation.usage,
boatreservation.user_applicant.id,
)
.execute(db)
.await
.map_err(|e| e.to_string())?;
let board =
User::all_with_role(db, &Role::find_by_name(db, "Vorstand").await.unwrap()).await;
for user in board {
Notification::create(
db,
&user,
&format!(
"{} hat eine neue Bootsreservierung für Boot '{}' angelegt: Von {} bis {} um {} wegen {}",
boatreservation.user_applicant.name,
boatreservation.boat.name,
boatreservation.start_date,
boatreservation.end_date,
boatreservation.time_desc,
boatreservation.usage
),
"Neue Bootsreservierung",
None,
)
.await;
}
Ok(())
}
pub async fn boat_reserved_between_dates(
db: &SqlitePool,
boat: &Boat,
start_date: &NaiveDate,
end_date: &NaiveDate,
) -> bool {
sqlx::query!(
"SELECT COUNT(*) AS reservation_count
FROM boat_reservation
WHERE boat_id = ?
AND start_date <= ? AND end_date >= ?;",
boat.id,
end_date,
start_date
)
.fetch_one(db)
.await
.unwrap()
.reservation_count
> 0
}
pub async fn delete(&self, db: &SqlitePool) {
sqlx::query!("DELETE FROM boat_reservation WHERE id=?", self.id)
.execute(db)
.await
.unwrap(); //Okay, because we can only create a Boat of a valid id
}
}

View File

@ -10,6 +10,7 @@ use self::{
pub mod boat; pub mod boat;
pub mod boatdamage; pub mod boatdamage;
pub mod boathouse; pub mod boathouse;
pub mod boatreservation;
pub mod family; pub mod family;
pub mod location; pub mod location;
pub mod log; pub mod log;

View File

@ -6,7 +6,7 @@ use ics::{
Event, ICalendar, Event, ICalendar,
}; };
use serde::Serialize; use serde::Serialize;
use sqlx::{FromRow, SqlitePool, Row}; use sqlx::{FromRow, Row, SqlitePool};
use super::{tripdetails::TripDetails, triptype::TripType, user::User}; use super::{tripdetails::TripDetails, triptype::TripType, user::User};

171
src/tera/boatreservation.rs Normal file
View File

@ -0,0 +1,171 @@
use chrono::NaiveDate;
use rocket::{
form::Form,
get, post,
request::FlashMessage,
response::{Flash, Redirect},
routes, FromForm, Route, State,
};
use rocket_dyn_templates::Template;
use sqlx::SqlitePool;
use tera::Context;
use crate::{
model::{
boat::Boat,
boatreservation::{BoatReservation, BoatReservationToAdd},
user::{DonauLinzUser, User, UserWithRoles},
},
tera::log::KioskCookie,
};
#[get("/")]
async fn index_kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let boatreservations = BoatReservation::all_future(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
let linz_boats = Boat::all_for_boatshouse(db).await;
let mut boats = Vec::new();
for boat in linz_boats {
if boat.boat.owner.is_none() {
boats.push(boat);
}
}
context.insert("boatreservations", &boatreservations);
context.insert("boats", &boats);
context.insert("user", &User::all(db).await);
context.insert("show_kiosk_header", &true);
Template::render("boatreservations", context.into_json())
}
#[get("/", rank = 2)]
async fn index(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
user: DonauLinzUser,
) -> Template {
let boatreservations = BoatReservation::all_future(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
let linz_boats = Boat::all_for_boatshouse(db).await;
let mut boats = Vec::new();
for boat in linz_boats {
if boat.boat.owner.is_none() {
boats.push(boat);
}
}
context.insert("boatreservations", &boatreservations);
context.insert("boats", &boats);
context.insert("user", &User::all(db).await);
context.insert(
"loggedin_user",
&UserWithRoles::from_user(user.into(), db).await,
);
Template::render("boatreservations", context.into_json())
}
#[derive(Debug, FromForm)]
pub struct FormBoatReservationToAdd<'r> {
pub boat_id: i64,
pub start_date: &'r str,
pub end_date: &'r str,
pub time_desc: &'r str,
pub usage: &'r str,
pub user_id_applicant: Option<i64>,
}
#[post("/", data = "<data>", rank = 2)]
async fn create<'r>(
db: &State<SqlitePool>,
data: Form<FormBoatReservationToAdd<'r>>,
user: DonauLinzUser,
) -> Flash<Redirect> {
let user_applicant: User = user.into();
let boat = Boat::find_by_id(db, data.boat_id as i32).await.unwrap();
let boatreservation_to_add = BoatReservationToAdd {
boat: &boat,
start_date: NaiveDate::parse_from_str(data.start_date, "%Y-%m-%d").unwrap(),
end_date: NaiveDate::parse_from_str(data.end_date, "%Y-%m-%d").unwrap(),
time_desc: data.time_desc,
usage: data.usage,
user_applicant: &user_applicant,
};
match BoatReservation::create(db, boatreservation_to_add).await {
Ok(_) => Flash::success(
Redirect::to("/boatreservation"),
"Reservierung erfolgreich hinzugefügt",
),
Err(e) => Flash::error(Redirect::to("/boatreservation"), format!("Fehler: {e}")),
}
}
#[post("/", data = "<data>")]
async fn create_from_kiosk<'r>(
db: &State<SqlitePool>,
data: Form<FormBoatReservationToAdd<'r>>,
_kiosk: KioskCookie,
) -> Flash<Redirect> {
let user_applicant: User = User::find_by_id(db, data.user_id_applicant.unwrap() as i32)
.await
.unwrap();
let boat = Boat::find_by_id(db, data.boat_id as i32).await.unwrap();
let boatreservation_to_add = BoatReservationToAdd {
boat: &boat,
start_date: NaiveDate::parse_from_str(data.start_date, "%Y-%m-%d").unwrap(),
end_date: NaiveDate::parse_from_str(data.end_date, "%Y-%m-%d").unwrap(),
time_desc: data.time_desc,
usage: data.usage,
user_applicant: &user_applicant,
};
match BoatReservation::create(db, boatreservation_to_add).await {
Ok(_) => Flash::success(
Redirect::to("/boatreservation"),
"Reservierung erfolgreich hinzugefügt",
),
Err(e) => Flash::error(Redirect::to("/boatreservation"), format!("Fehler: {e}")),
}
}
#[get("/<reservation_id>/delete")]
async fn delete<'r>(
db: &State<SqlitePool>,
reservation_id: i32,
user: DonauLinzUser,
) -> Flash<Redirect> {
let reservation = BoatReservation::find_by_id(db, reservation_id)
.await
.unwrap();
if user.id == reservation.user_id_applicant || user.has_role(db, "admin").await {
reservation.delete(db).await;
Flash::success(
Redirect::to("/boatreservation"),
"Reservierung erfolgreich gelöscht",
)
} else {
Flash::error(
Redirect::to("/boatreservation"),
format!("Nur der Reservierer darf die Reservierung löschen."),
)
}
}
pub fn routes() -> Vec<Route> {
routes![index, index_kiosk, create, create_from_kiosk, delete]
}

View File

@ -17,6 +17,7 @@ use tera::Context;
use crate::model::{ use crate::model::{
boat::Boat, boat::Boat,
boatreservation::BoatReservation,
log::Log, log::Log,
logbook::{ logbook::{
LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookDeleteError, LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookDeleteError,
@ -73,6 +74,7 @@ async fn index(
} }
context.insert("boats", &boats); context.insert("boats", &boats);
context.insert("reservations", &BoatReservation::all_future(db).await);
context.insert("coxes", &coxes); context.insert("coxes", &coxes);
context.insert("users", &users); context.insert("users", &users);
context.insert("logtypes", &logtypes); context.insert("logtypes", &logtypes);
@ -163,6 +165,7 @@ async fn kiosk(
} }
context.insert("boats", &boats); context.insert("boats", &boats);
context.insert("reservations", &BoatReservation::all_future(db).await);
context.insert("coxes", &coxes); context.insert("coxes", &coxes);
context.insert("users", &users); context.insert("users", &users);
context.insert("logtypes", &logtypes); context.insert("logtypes", &logtypes);

View File

@ -26,6 +26,7 @@ pub(crate) mod admin;
mod auth; mod auth;
pub(crate) mod board; pub(crate) mod board;
mod boatdamage; mod boatdamage;
mod boatreservation;
mod cox; mod cox;
mod ergo; mod ergo;
mod log; mod log;
@ -94,6 +95,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.mount("/notification", notification::routes()) .mount("/notification", notification::routes())
.mount("/stat", stat::routes()) .mount("/stat", stat::routes())
.mount("/boatdamage", boatdamage::routes()) .mount("/boatdamage", boatdamage::routes())
.mount("/boatreservation", boatreservation::routes())
.mount("/cox", cox::routes()) .mount("/cox", cox::routes())
.mount("/admin", admin::routes()) .mount("/admin", admin::routes())
.mount("/board", board::routes()) .mount("/board", board::routes())

View File

@ -22,6 +22,7 @@
<a href="/stat" class="px-2">Statistik</a> <a href="/stat" class="px-2">Statistik</a>
<a href="/stat/boats" class="px-2">Bootsauswertung</a> <a href="/stat/boats" class="px-2">Bootsauswertung</a>
<a href="/boatdamage" class="px-2">Bootsschaden</a> <a href="/boatdamage" class="px-2">Bootsschaden</a>
<a href="/boatreservation" class="px-2">Bootsreservierung</a>
</div> </div>
</header> </header>
{% endif %} {% endif %}

View File

@ -0,0 +1,82 @@
{% import "includes/macros" as macros %}
{% import "includes/forms/log" as log %}
{% extends "base" %}
{% block content %}
<div class="max-w-screen-lg w-full">
<h1 class="h1">Bootsreservierungen</h1>
<h2 class="text-md font-bold tracking-wide bg-primary-900 mt-3 p-3 text-white flex justify-between items-center rounded-md">
Neue Reservierung
<a href="#"
class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"
data-sidebar="true"
data-trigger="sidebar"
data-header="Neue Reservierung anlegen"
data-body="#new-reservation">
{% include "includes/plus-icon" %}
<span class="sr-only">Neue Reservierung eintragen</span>
</a>
</h2>
<div class="hidden">
<div id="new-reservation">
<form action="/boatreservation" method="post" class="grid gap-3">
{{ log::boat_select(only_ones=false, id='boat') }}
{% if not loggedin_user %}{{ macros::select(label='Reserviert von', data=user, name='user_id_applicant') }}{% endif %}
{{ macros::input(label='Beginn', name='start_date', type='date', required=true, wrapper_class='col-span-4') }}
{{ macros::input(label='Ende', name='end_date', type='date', required=true, wrapper_class='col-span-4') }}
{{ macros::input(label='Uhrzeit (zB ab 14:00 Uhr, ganztägig, ...)', name='time_desc', type='text', required=true, wrapper_class='col-span-4') }}
{{ macros::input(label='Zweck (Wanderfahrt, ...)', name='usage', type='text', required=true, wrapper_class='col-span-4') }}
<input type="submit"
class="btn btn-primary w-full col-span-4"
value="Reservierung eintragen" />
</form>
</div>
</div>
<div class="search-wrapper">
<label for="name" class="sr-only">Suche</label>
<input type="search"
name="name"
id="filter-js"
class="search-bar"
placeholder="Suchen nach Namen...">
</div>
<div id="filter-result-js" class="search-result"></div>
{% for reservation in boatreservations %}
<div data-filterable="true"
data-filter="{{ reservation.user_applicant.name }} {{ reservation.boat.name }}"
class="w-full border-t bg-white dark:bg-primary-900 text-black dark:text-white p-3">
<div class="w-full">
<strong>Boot:</strong>
{{ reservation.boat.name }}
<br />
<strong>Reservierung:</strong>
{{ reservation.user_applicant.name }}
<br />
<strong>Datum:</strong>
{{ reservation.start_date }}
{% if reservation.end_date != reservation.start_date %}
-
{{ reservation.end_date }}
{% endif %}
<br />
<strong>Uhrzeit:</strong>
{{ reservation.time_desc }}
<br />
<strong>Zweck:</strong>
{{ reservation.usage }}
{% if loggedin_user %}
{% if loggedin_user.id == reservation.user_applicant.id or "admin" in loggedin_user.roles %}
<div class="mt-3 text-right">
<a href="/boatreservation/{{ reservation.id }}/delete"
class="w-28 btn btn-alert"
onclick="return confirm('Willst du diese Reservierung wirklich löschen?');">
{% include "includes/delete-icon" %}
Löschen
</a>
</div>
{% endif %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endblock content %}

View File

@ -104,6 +104,7 @@
<strong class="block text-primary-900 dark:text-white"> <strong class="block text-primary-900 dark:text-white">
{{ log.departure | date(format="%H:%M") }} {{ log.departure | date(format="%H:%M") }}
Uhr Uhr
<small>({{ log.departure | date(format="%d.%m.%Y") }})</small>
</strong> </strong>
<a href="#" <a href="#"
data-sidebar="true" data-sidebar="true"
@ -149,7 +150,8 @@
{% set amount_rowers = log.rowers | length %} {% set amount_rowers = log.rowers | length %}
{% set amount_guests = log.boat.amount_seats - amount_rowers %} {% set amount_guests = log.boat.amount_seats - amount_rowers %}
{% if amount_guests > 0 %} {% if amount_guests > 0 %}
Gäste <small class="text-gray-600">(ohne Account)</small>: Gäste
<small class="text-gray-600">(ohne Account)</small>:
{{ amount_guests }} {{ amount_guests }}
{% endif %} {% endif %}
{% if allowed_to_close and state == "on_water" %} {% if allowed_to_close and state == "on_water" %}
@ -182,18 +184,23 @@
</div> </div>
{% endif %} {% endif %}
<div {% if log.logtype %}class="mt-4 sm:mt-0"{% endif %}> <div {% if log.logtype %}class="mt-4 sm:mt-0"{% endif %}>
<strong class="text-black dark:text-white">{{ log.boat.name }}</strong> <small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}} <strong class="text-black dark:text-white">{{ log.boat.name }}</strong>
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
{% if log.shipmaster_only_steering %} {% if log.shipmaster_only_steering %}
- handgesteuert - handgesteuert
{% endif -%} {% endif -%}
)</small> )</small>
<small class="block text-gray-600 dark:text-gray-100"> <small class="block text-gray-600 dark:text-gray-100">
{% if state == "completed" and log.departure | date(format='%d.%m.%Y') == log.arrival | date(format='%d.%m.%Y') %} {% if state == "completed" and log.departure | date(format='%d.%m.%Y') == log.arrival | date(format='%d.%m.%Y') %}
{{ log.departure | date(format='%d.%m.%Y') }} ({{ log.departure | date(format='%H:%M') }} - {{ log.arrival | date(format='%H:%M') }}) {{ log.departure | date(format='%d.%m.%Y') }}
({{ log.departure | date(format='%H:%M') }}
-
{{ log.arrival | date(format='%H:%M') }})
{% else %} {% else %}
{{ log.departure | date(format='%d.%m.%Y (%H:%M)') }} {{ log.departure | date(format='%d.%m.%Y (%H:%M)') }}
{% if state == "completed" %} {% if state == "completed" %}
- {{ log.arrival | date(format='%d.%m.%Y (%H:%M)') }} -
{{ log.arrival | date(format='%d.%m.%Y (%H:%M)') }}
{% endif %} {% endif %}
{% endif %} {% endif %}
</small> </small>
@ -205,7 +212,8 @@
<div class="text-black dark:text-white"> <div class="text-black dark:text-white">
{{ log.destination }} {{ log.destination }}
{% if state == "completed" %} {% if state == "completed" %}
<small class="text-gray-600 dark:text-gray-100">({{ log.distance_in_km }} km)</small> <small class="text-gray-600 dark:text-gray-100">({{ log.distance_in_km }}
km)</small>
{% endif %} {% endif %}
{% if log.comments %}<span class="text-sm italic">- "{{ log.comments }}"</span>{% endif %} {% if log.comments %}<span class="text-sm italic">- "{{ log.comments }}"</span>{% endif %}
</div> </div>
@ -217,7 +225,9 @@
{% if not loop.last or amount_guests > 0 and log.boat.name != 'Externes Boot' %},{% endif %} {% if not loop.last or amount_guests > 0 and log.boat.name != 'Externes Boot' %},{% endif %}
{% endfor %} {% endfor %}
{% if amount_guests > 0 and log.boat.name != 'Externes Boot' %} {% if amount_guests > 0 and log.boat.name != 'Externes Boot' %}
Gäste <small class="text-gray-600 dark:text-gray-100">(ohne Account)</small>: {{ amount_guests }} Gäste
<small class="text-gray-600 dark:text-gray-100">(ohne Account)</small>:
{{ amount_guests }}
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}

View File

@ -1,14 +1,26 @@
{% macro boatreservation() %} {% macro boatreservation() %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow grid gap-3" <div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2 mt-3">
style="margin-top: 10px"> <h2 class="h2">Reservierungen ({{ reservations | length }})</h2>
<h2 class="h2">Bootsreservierungen</h2> <div class="grid grid-cols-1 gap-3 mb-3 w-full">
<div class="p2" style="margin-bottom: 10px;"> {% for reservation in reservations %}
<ul style="display: flex; <div class="pt-2 px-3 border-t text-primary-900 dark:text-white">
justify-content: space-around; <strong class="block">
padding: 0; {{ reservation.start_date | date(format="%d.%m.%Y") }}
list-style: none"> {% if reservation.end_date != reservation.start_date %}
<li style="display: inline-block;">30.03. | Manuela Firmötz | Boot: Urfahr</li> -
</ul> {{ reservation.end_date | date(format="%d.%m.%Y") }}
{% endif %}
<small>({{ reservation.time_desc }})</small>
</strong>
<span class="block">
{{ reservation.boat.name }}
<small>({{ reservation.user_applicant.name }})</small>
</span>
<span class="text-sm italic">{{ reservation.usage }}</span>
</div>
{% else %}
<p class="p-3 text-center text-black dark:text-white">Keine Reservierung</p>
{% endfor %}
</div> </div>
</div> </div>
{% endmacro boatreservation %} {% endmacro boatreservation %}
@ -70,6 +82,8 @@
{% endif %} {% endif %}
<a href="/boatdamage" <a href="/boatdamage"
class="block w-100 py-2 hover:text-primary-600 border-t">Bootsschaden</a> class="block w-100 py-2 hover:text-primary-600 border-t">Bootsschaden</a>
<a href="/boatreservation"
class="block w-100 py-2 hover:text-primary-600 border-t">Bootsreservierung</a>
</div> </div>
</div> </div>
{% endif %} {% endif %}
@ -141,7 +155,7 @@
{% if required %}required="required"{% endif %}> {% if required %}required="required"{% endif %}>
{% if default %}<option selected value>{{ default }}</option>{% endif %} {% if default %}<option selected value>{{ default }}</option>{% endif %}
{% for d in data %} {% for d in data %}
<option value="{{ d.id }}" {% if d.id == selected_id %}selected{% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data-{{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}}'{% endif %}> <option value="{{ d.id }}" {% if d.id == selected_id %}selected{% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}}' {% endif %}>
{% for displa in display -%} {% for displa in display -%}
{%- if d[displa] -%} {%- if d[displa] -%}
{{- d[displa] -}} {{- d[displa] -}}

View File

@ -54,19 +54,6 @@
</div> </div>
</details> </details>
</div> </div>
{% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert">
<h2 class="h2">Ergo</h2>
<div class="p-3">
<ul class="list-none ms-2">
<li class="py-1">
<a href="/ergo" class="block w-100 py-2 hover:text-primary-600">Ergo</a>
</li>
</ul>
</div>
</div>
{% endif %}
{% if "Donau Linz" in loggedin_user.roles and "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %} {% if "Donau Linz" in loggedin_user.roles and "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert"> role="alert">
@ -90,6 +77,10 @@
<li class="py-1"> <li class="py-1">
<a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600">Bootsschaden</a> <a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600">Bootsschaden</a>
</li> </li>
<li class="py-1">
<a href="/boatreservation"
class="block w-100 py-2 hover:text-primary-600">Bootsreservierung</a>
</li>
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
@ -162,6 +153,19 @@
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
{% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert">
<h2 class="h2">Ergo</h2>
<div class="p-3">
<ul class="list-none ms-2">
<li class="py-1">
<a href="/ergo" class="block w-100 py-2 hover:text-primary-600">Ergo</a>
</li>
</ul>
</div>
</div>
{% endif %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert"> role="alert">
<h2 class="h2">Allgemein</h2> <h2 class="h2">Allgemein</h2>

View File

@ -9,27 +9,31 @@
{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}
</div> </div>
{% endif %} {% endif %}
{{ macros::boatreservation() }} <div class="w-full grid lg:grid-cols-5 gap-3 mt-5">
<div class="w-full grid md:grid-cols-5 gap-3 mt-5"> <div>
<div class="bg-white dark:bg-primary-900 rounded-md hidden md:block shadow"> <div class="bg-white dark:bg-primary-900 rounded-md hidden md:block shadow">
<h2 class="h2">Boote</h2> <h2 class="h2">Boote</h2>
<div>{{ log::show_boats(only_ones=false) }}</div> <div>{{ log::show_boats(only_ones=false) }}</div>
</div>
</div> </div>
<div class="md:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow"> <div class="lg:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow">
<h2 class="h2">Neue Ausfahrt</h2> <h2 class="h2">Neue Ausfahrt</h2>
<div class="p-3">{{ log::new(only_ones=false, shipmaster=-1) }}</div> <div class="p-3">{{ log::new(only_ones=false, shipmaster=-1) }}</div>
</div> </div>
<div class="bg-white dark:bg-primary-900 rounded-md shadow"> <div>
<h2 class="h2">Am Wasser</h2> <div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2">
<div> <h2 class="h2">Am Wasser</h2>
{% if on_water | length > 0 %} <div>
{% for log in on_water %} {% if on_water | length > 0 %}
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones=false) }} {% for log in on_water %}
{% endfor %} {{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones=false) }}
{% else %} {% endfor %}
<p class="p-3 text-center text-black dark:text-white">Kein Boot am Wasser</p> {% else %}
{% endif %} <p class="p-3 text-center text-black dark:text-white">Kein Boot am Wasser</p>
{% endif %}
</div>
</div> </div>
{{ macros::boatreservation() }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,31 +4,35 @@
{% block content %} {% block content %}
<div class="w-full"> <div class="w-full">
<h1 class="h1">Logbuch</h1> <h1 class="h1">Logbuch</h1>
{{ macros::boatreservation() }} <div class="w-full grid lg:grid-cols-5 gap-3 mt-5">
<div class="w-full grid md:grid-cols-5 gap-3 mt-5"> <div>
<div class="bg-white dark:bg-primary-900 rounded-md hidden md:block shadow"> <div class="bg-white dark:bg-primary-900 rounded-md hidden md:block shadow">
<h2 class="h2">Boote</h2> <h2 class="h2">Boote</h2>
<div>{{ log::show_boats(only_ones=false) }}</div> <div>{{ log::show_boats(only_ones=false) }}</div>
</div>
</div> </div>
<div class="md:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow"> <div class="lg:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow">
<h2 class="h2">Neue Ausfahrt</h2> <h2 class="h2">Neue Ausfahrt</h2>
<div class="p-3">{{ log::new(shipmaster=loggedin_user.id) }}</div> <div class="p-3">{{ log::new(shipmaster=loggedin_user.id) }}</div>
</div> </div>
<div class="bg-white dark:bg-primary-900 rounded-md shadow"> <div>
<h2 class="h2">Am Wasser</h2> <div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2">
{% if on_water | length > 0 %} <h2 class="h2">Am Wasser</h2>
{% for log in on_water %} {% if on_water | length > 0 %}
{% if log.shipmaster == loggedin_user.id %} {% for log in on_water %}
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }} {% if log.shipmaster == loggedin_user.id %}
{% elif "Vorstand" in loggedin_user.roles %} {{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }}
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }} {% elif "Vorstand" in loggedin_user.roles %}
{% else %} {{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }}
{{ log::show(log=log, state="on_water", only_ones=true) }} {% else %}
{% endif %} {{ log::show(log=log, state="on_water", only_ones=true) }}
{% endfor %} {% endif %}
{% else %} {% endfor %}
<p class="p-3 text-center text-black dark:text-white">Kein Boot am Wasser</p> {% else %}
{% endif %} <p class="p-3 text-center text-black dark:text-white">Kein Boot am Wasser</p>
{% endif %}
</div>
{{ macros::boatreservation() }}
</div> </div>
</div> </div>
</div> </div>