diff --git a/app.js b/app.js index d603760..6a41ca7 100644 --- a/app.js +++ b/app.js @@ -101,12 +101,19 @@ const isBirthday = (birthdate, date, previousTraining) => { let adjustedBirthdate = new Date(birthdate); adjustedBirthdate.setFullYear(date.getFullYear()); - if (adjustedBirthdate === date) { + if (adjustedBirthdate.getMonth() == 10) { + console.log("checking:", adjustedBirthdate, date, previousTraining); + } + + if (adjustedBirthdate.getTime() === date.getTime()) { console.log("birthday"); return 2; } - if (adjustedBirthdate >= previousTraining && adjustedBirthdate <= date) { - console.log("had birthday", adjustedBirthdate, date, previousTraining); + if ( + adjustedBirthdate.getTime() >= previousTraining.getTime() && + adjustedBirthdate.getTime() <= date.getTime() + ) { + console.log("had birthday"); return 1; } return 0; @@ -146,7 +153,6 @@ const getTraining = async (kw, jahr) => { `, [kw, jahr] ); - return result.rows[0]; }; @@ -757,7 +763,6 @@ ORDER BY r.riegennummer, t.geburtsdatum ASC; anzahl, }); }); - if (training) { training.datum = getdayOfWeek(training.kw, training.jahr); } @@ -946,17 +951,12 @@ app.post("/update-mitglied", requireAdmin, async (req, res) => { } = req.body; try { if (type == "tel") { - console.log( - "INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer, stand) VALUES ($1, $2, $3, $4, $5)", - [id, name, verbindung, nummer, moment().toDate()] - ); await pool.query( "INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer, stand) VALUES ($1, $2, $3, $4, $5)", [id, name, verbindung, nummer, moment().toDate()] ); } else if (type == "tel-delete") { await pool.query("DELETE FROM telefonnummern WHERE id = $1", [telid]); - console.log("delete numer $1", [telid]); } else if (type == "adresse") { await pool.query( "UPDATE teilnehmende SET vorname = $1, nachname = $2, geburtsdatum = $3, adresse = $4, probe = $5, helfer = $6 WHERE id = $7", @@ -1008,7 +1008,6 @@ app.get("/spiele", async (req, res) => { app.post("/delete-spiel", requireAdmin, async (req, res) => { const { spielId } = req.body; - console.log(spielId); await pool.query("DELETE FROM spiele WHERE id = $1", [spielId]); res.redirect("/spiele"); }); @@ -1116,7 +1115,6 @@ app.post("/anwesend", requireAuth, async (req, res) => { anw = [anw]; } for (const teilnehmer of anw) { - console.log(teilnehmer); const Tnresult = await pool.query( "SELECT *From anwesend WHERE fid_teilnehmer = $1 AND fid_training=$2", [teilnehmer, trainingId] @@ -1169,12 +1167,10 @@ app.get("/feature", requireAuth, async (req, res) => { app.post("/feature", requireAdmin, async (req, res) => { const { title, body, type, urgency, user } = req.body; - console.log(user); const userResult = await pool.query( "SELECT id FROM users WHERE username = $1", [user] ); - console.log(userResult.rows[0].id); try { await pool.query( "INSERT INTO features (title, body, type, urgency, fid_user) VALUES ($1, $2, $3, $4, $5);", diff --git a/views/trainings.ejs b/views/trainings.ejs index 898cca5..c9a1fdf 100644 --- a/views/trainings.ejs +++ b/views/trainings.ejs @@ -10,8 +10,7 @@ <% } %> - - + <% if (training) { %> -
+

Spiel:

@@ -139,9 +139,6 @@ <% } %>
- -
-

Anwesenheit

Anwesend: <%= anwesend.length %>

@@ -265,7 +262,7 @@ -
+ <% } else { %>