Feiertage auswahl fix, Geburtsdatum editierbar
This commit is contained in:
parent
583804f3ad
commit
c76938ecc5
35
app.js
35
app.js
|
@ -82,30 +82,6 @@ const getTraining = async (selectedDate) => {
|
|||
const today = selectedDate ? new Date(selectedDate) : new Date();
|
||||
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(`
|
||||
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,
|
||||
|
@ -128,7 +104,6 @@ const getTraining = async (selectedDate) => {
|
|||
`, [today]);
|
||||
|
||||
return result.rows[0];
|
||||
}
|
||||
};
|
||||
|
||||
// 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) => {
|
||||
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 {
|
||||
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) VALUES ($1, $2, $3) RETURNING id', [name, geburt, adresse]);
|
||||
putInRiege(riege, teilnehmerID);
|
||||
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]);
|
||||
console.log(teilnehmerID.rows[0].id);
|
||||
putInRiege(riege, teilnehmerID.rows[0].id);
|
||||
res.redirect('/riege');
|
||||
}catch (error) {
|
||||
const message = 'Error:' + error;
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="cont-1" role="tabpanel" aria-labelledby="tab-1">
|
||||
<form method="POST" action="/new-member">
|
||||
Name: <input type="text" id="name" placeholder="Name" name="name"> </br>
|
||||
Geburtsdatum: <input type="date" id="riege" name="geburt"></br>
|
||||
Name: <input type="text" id="vorname" placeholder="Vorname" name="vorname">
|
||||
<input type="text" id="nachname" placeholder="Nachname" name="nachname"> </br>
|
||||
Geburtsdatum: <input type="date" id="geburt" name="geburt"></br>
|
||||
<select name="riege">
|
||||
<option value=1> Riege 1</option>
|
||||
<option value=2> Riege 2</option>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<p>
|
||||
<% numbers.forEach(number => { %>
|
||||
<% 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>
|
||||
|
||||
|
@ -27,8 +27,9 @@
|
|||
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<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">
|
||||
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="type" value="adresse">
|
||||
<strong> Adresse: </strong> <input name="adresse" type="text" value="<%= mitglied.adresse %>">
|
||||
|
|
Loading…
Reference in New Issue