Liste der Anwesenheiten auf Mitgliederseite

This commit is contained in:
Klaas Börgmann 2025-01-09 22:11:27 +01:00
parent adf955cbc7
commit cd59aa0546
2 changed files with 11 additions and 7 deletions

11
app.js
View File

@ -101,19 +101,13 @@ const isBirthday = (birthdate, date, previousTraining) => {
let adjustedBirthdate = new Date(birthdate); let adjustedBirthdate = new Date(birthdate);
adjustedBirthdate.setFullYear(date.getFullYear()); adjustedBirthdate.setFullYear(date.getFullYear());
if (adjustedBirthdate.getMonth() == 10) {
console.log("checking:", adjustedBirthdate, date, previousTraining);
}
if (adjustedBirthdate.getTime() === date.getTime()) { if (adjustedBirthdate.getTime() === date.getTime()) {
console.log("birthday");
return 2; return 2;
} }
if ( if (
adjustedBirthdate.getTime() >= previousTraining.getTime() && adjustedBirthdate.getTime() >= previousTraining.getTime() &&
adjustedBirthdate.getTime() <= date.getTime() adjustedBirthdate.getTime() <= date.getTime()
) { ) {
console.log("had birthday");
return 1; return 1;
} }
return 0; return 0;
@ -926,9 +920,11 @@ app.get("/mitglied/:id", requireAuth, requireAdmin, async (req, res) => {
} }
req.session.activeRiege = riege; req.session.activeRiege = riege;
const anwesendResult = await pool.query( const anwesendResult = await pool.query(
"SELECT * FROM anwesend WHERE fid_teilnehmer = $1", "SELECT t.id, TO_CHAR(t.datum, 'DD.MM.YYYY') as date, t.* FROM trainings t JOIN anwesend a ON t.id = a.fid_training WHERE a.fid_teilnehmer = $1;",
[id] [id]
); );
console.log(anwesendResult);
const anwesenheiten = anwesendResult.rows;
const anwesend = anwesendResult.rows.length; const anwesend = anwesendResult.rows.length;
const numberResult = await pool.query( const numberResult = await pool.query(
"SELECT telefonnummern.*, telverbindung.bezeichnung FROM telefonnummern JOIN telverbindung ON telefonnummern.verbindung = telverbindung.id WHERE telefonnummern.fid_teilnehmer = $1", "SELECT telefonnummern.*, telverbindung.bezeichnung FROM telefonnummern JOIN telverbindung ON telefonnummern.verbindung = telverbindung.id WHERE telefonnummern.fid_teilnehmer = $1",
@ -945,6 +941,7 @@ app.get("/mitglied/:id", requireAuth, requireAdmin, async (req, res) => {
mitglied: mitglied[0], mitglied: mitglied[0],
numbers, numbers,
riege, riege,
anwesenheiten,
anwesend, anwesend,
session: req.session, session: req.session,
}); });

View File

@ -153,6 +153,13 @@
</div> </div>
<% } %> <% } %>
<ul>
<% anwesenheiten.forEach(date => { %>
<li> <%= date.date %> </li>
<% }) %>
</ul>
<script> <script>
function toggleDivs() { function toggleDivs() {
$('#view').toggleClass('d-none d-block'); $('#view').toggleClass('d-none d-block');