Feiertage auswahl fix, Geburtsdatum editierbar

This commit is contained in:
Klaas 2024-05-30 17:43:11 +02:00
parent 583804f3ad
commit c76938ecc5
3 changed files with 13 additions and 34 deletions

35
app.js
View File

@ -82,30 +82,6 @@ const getTraining = async (selectedDate) => {
const today = selectedDate ? new Date(selectedDate) : new Date(); const today = selectedDate ? new Date(selectedDate) : new Date();
const dayOfWeek = today.getDay(); const dayOfWeek = today.getDay();
// Wenn heute Donnerstag ist
if (dayOfWeek === 4) {
const result = await pool.query(`
SELECT tr.*, g1.name AS geraet_riege_1_name, g2.name AS geraet_riege_2_name,
g3.name AS geraet_riege_3_name, g4.name AS geraet_riege_4_name,
g5.name AS geraet_riege_5_name,
t1.name AS aufwaermleiter_name, t2.name AS spielleiter_name,
sp1.name AS aufwaermen_name, sp2.name AS spiel_name
FROM trainings tr
LEFT JOIN geraete g1 ON tr.geraet_riege_1 = g1.id
LEFT JOIN geraete g2 ON tr.geraet_riege_2 = g2.id
LEFT JOIN geraete g3 ON tr.geraet_riege_3 = g3.id
LEFT JOIN geraete g4 ON tr.geraet_riege_4 = g4.id
LEFT JOIN geraete g5 ON tr.geraet_riege_5 = g5.id
LEFT JOIN teilnehmende t1 ON tr.aufwaermleiter = t1.id
LEFT JOIN teilnehmende t2 ON tr.spielleiter = t2.id
LEFT JOIN spiele sp1 ON tr.aufwaermen = sp1.id
LEFT JOIN spiele sp2 ON tr.spiel = sp2.id
WHERE tr.datum = $1
LIMIT 1
`, [today]);
return result.rows[0];
} else {
const result = await pool.query(` const result = await pool.query(`
SELECT tr.*, g1.name AS geraet_riege_1_name, g2.name AS geraet_riege_2_name, SELECT tr.*, g1.name AS geraet_riege_1_name, g2.name AS geraet_riege_2_name,
g3.name AS geraet_riege_3_name, g4.name AS geraet_riege_4_name, g3.name AS geraet_riege_3_name, g4.name AS geraet_riege_4_name,
@ -128,7 +104,6 @@ const getTraining = async (selectedDate) => {
`, [today]); `, [today]);
return result.rows[0]; return result.rows[0];
}
}; };
// Funktion zum Laden aller Spiele // Funktion zum Laden aller Spiele
@ -486,11 +461,13 @@ app.get('/admin', requireAuth, requireAdmin, async (req, res) => {
}); });
app.post('/new-member', requireAuth, requireAdmin ,async(req, res) => { app.post('/new-member', requireAuth, requireAdmin ,async(req, res) => {
const {name, geburt, riege, adresse} = req.body; const {vorname, nachname, geburt, riege, adresse} = req.body;
const name = vorname + ' ' + nachname;
console.log(name + ', ' + geburt + ', ' + riege + ', ' + adresse);
try { try {
console.log(('INSERT INTO teilnehmende (name, geburtsdatum, adresse) VALUES ($1, $2, $3) RETURNING id', [name, geburt, adresse])); const teilnehmerID = await pool.query('INSERT INTO teilnehmende (name, geburtsdatum, adresse, vorname, nachname) VALUES ($1, $2, $3, $4, $5) RETURNING id', [name, geburt, adresse, vorname, nachname]);
const teilnehmerID = await pool.query('INSERT INTO teilnehmende (name, geburtsdatum, adresse) VALUES ($1, $2, $3) RETURNING id', [name, geburt, adresse]); console.log(teilnehmerID.rows[0].id);
putInRiege(riege, teilnehmerID); putInRiege(riege, teilnehmerID.rows[0].id);
res.redirect('/riege'); res.redirect('/riege');
}catch (error) { }catch (error) {
const message = 'Error:' + error; const message = 'Error:' + error;

View File

@ -16,8 +16,9 @@
<div class="tab-content" id="myTabContent"> <div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="cont-1" role="tabpanel" aria-labelledby="tab-1"> <div class="tab-pane fade show active" id="cont-1" role="tabpanel" aria-labelledby="tab-1">
<form method="POST" action="/new-member"> <form method="POST" action="/new-member">
Name: <input type="text" id="name" placeholder="Name" name="name"> </br> Name: <input type="text" id="vorname" placeholder="Vorname" name="vorname">
Geburtsdatum: <input type="date" id="riege" name="geburt"></br> <input type="text" id="nachname" placeholder="Nachname" name="nachname"> </br>
Geburtsdatum: <input type="date" id="geburt" name="geburt"></br>
<select name="riege"> <select name="riege">
<option value=1> Riege 1</option> <option value=1> Riege 1</option>
<option value=2> Riege 2</option> <option value=2> Riege 2</option>

View File

@ -16,7 +16,7 @@
<p> <p>
<% numbers.forEach(number => { %> <% numbers.forEach(number => { %>
<% if (number.verbindung != 4) { %> <% if (number.verbindung != 4) { %>
<strong><%= number.bezeichnung %> - <%= number.name %>: </strong> <%= number.nummer %> <% if (number.stand) { %>(stand: <%= number.stand.getDate() %>.<%= number.stand.getMonth() %>.<%= number.stand.getFullYear() %>) <% } %></br> <strong><%= number.bezeichnung %> - <%= number.name %>: </strong> <%= number.nummer %> <% if (number.stand) { %>(stand: <%= ("00" + birthday.getDate()).slice(-2) %>.<%= ("00" + (birthday.getMonth() + 1)).slice(-2) %>.<%= number.stand.getFullYear() %>) <% } %></br>
<% }}) %> <% }}) %>
</p> </p>
@ -27,8 +27,9 @@
<% if (session && session.role === 'admin') { %> <% if (session && session.role === 'admin') { %>
<div id="edit" class="mt-5 d-none"> <div id="edit" class="mt-5 d-none">
<strong> Geburtsdatum: </strong> <%= birthday.getDate() %>.<%= birthday.getMonth() + 1 %>.<%= birthday.getFullYear() %> (<%= mitglied.age %>)</br>
<form method="POST" action="/update-mitglied"> <form method="POST" action="/update-mitglied">
Geburtsdatum: <input type="date" id="geburt" name="geburt" value="<%= birthday.getFullYear() %>-<%= ('00' + (birthday.getMonth() + 1)).slice(-2) %>-<%= ('00' + birthday.getDate()).slice(-2) %>"></br>
<input type="hidden" name="id" value="<%= id %>"> <input type="hidden" name="id" value="<%= id %>">
<input type="hidden" name="type" value="adresse"> <input type="hidden" name="type" value="adresse">
<strong> Adresse: </strong> <input name="adresse" type="text" value="<%= mitglied.adresse %>"> <strong> Adresse: </strong> <input name="adresse" type="text" value="<%= mitglied.adresse %>">