Geburtstag in Riegenliste und Stand der Telefonnummer
This commit is contained in:
parent
0ac7e87d3e
commit
dd1c4e4c63
11
app.js
11
app.js
|
@ -82,7 +82,11 @@ const transporter = nodemailer.createTransport({
|
||||||
|
|
||||||
// Datenbankverbindung
|
// Datenbankverbindung
|
||||||
const pool = new Pool({
|
const pool = new Pool({
|
||||||
connectionString: process.env.DATABASE_URL,
|
connectionString: process.env.DATABASE_URL + "tkd",
|
||||||
|
});
|
||||||
|
|
||||||
|
const poolNew = new Pool({
|
||||||
|
connectionString: process.env.DATABASE_URL + "tkd_neu",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Altersberechnung
|
// Altersberechnung
|
||||||
|
@ -872,6 +876,7 @@ ORDER BY r.riegennummer, t.geburtsdatum ASC;
|
||||||
helfer: row.helfer,
|
helfer: row.helfer,
|
||||||
probe: row.probe,
|
probe: row.probe,
|
||||||
anwesenheit: row.anwesenheit,
|
anwesenheit: row.anwesenheit,
|
||||||
|
birthday: row.geburtsdatum,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -981,8 +986,8 @@ app.post("/update-mitglied", requireAdmin, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (type == "tel") {
|
if (type == "tel") {
|
||||||
await pool.query(
|
await pool.query(
|
||||||
"INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer, stand) VALUES ($1, $2, $3, $4, $5)",
|
"INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer) VALUES ($1, $2, $3, $4)",
|
||||||
[id, name, verbindung, nummer, moment().toDate()]
|
[id, name, verbindung, nummer]
|
||||||
);
|
);
|
||||||
} else if (type == "tel-delete") {
|
} else if (type == "tel-delete") {
|
||||||
await pool.query("DELETE FROM telefonnummern WHERE id = $1", [telid]);
|
await pool.query("DELETE FROM telefonnummern WHERE id = $1", [telid]);
|
||||||
|
|
|
@ -19,7 +19,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: <%= ("00" + birthday.getDate()).slice(-2) %>.<%= ("00" + (birthday.getMonth() + 1)).slice(-2) %>.<%= number.stand.getFullYear() %>) <% } %></br>
|
<strong><%= number.bezeichnung %> - <%= number.name %>: </strong> <%= number.nummer %> <% if (number.stand) { %>(stand: <%= ("00" + number.stand.getDate()).slice(-2) %>.<%= ("00" + (number.stand.getMonth() + 1)).slice(-2) %>.<%= number.stand.getFullYear() %>) <% } %></br>
|
||||||
<% }}) %>
|
<% }}) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
<th onclick="sortTable(0, 'table-<%= riegennummer %>')">Vorname</th>
|
<th onclick="sortTable(0, 'table-<%= riegennummer %>')">Vorname</th>
|
||||||
<th onclick="sortTable(1, 'table-<%= riegennummer %>')">Nachname</th>
|
<th onclick="sortTable(1, 'table-<%= riegennummer %>')">Nachname</th>
|
||||||
<th onclick="sortTable(2, 'table-<%= riegennummer %>')">Alter</th>
|
<th onclick="sortTable(2, 'table-<%= riegennummer %>')">Alter</th>
|
||||||
|
<th onclick="sortTable(3, 'table-<%= riegennummer %>')">
|
||||||
|
Geburtstag
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -75,6 +78,11 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= teilnehmer.age %> Jahre</td>
|
<td><%= teilnehmer.age %> Jahre</td>
|
||||||
|
<td>
|
||||||
|
<%= ('00' + teilnehmer.birthday.getDate()).slice(-2) %>.<%= ('00' +
|
||||||
|
(teilnehmer.birthday.getMonth() + 1)).slice(-2) %>.<%=
|
||||||
|
teilnehmer.birthday.getFullYear() %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -84,23 +92,39 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function sortTable(spaltenIndex, tableId) {
|
function sortTable(spaltenIndex, tableID) {
|
||||||
const table = document.getElementById(tableId);
|
const table = document.getElementById(tableID);
|
||||||
let rows = Array.from(table.rows).slice(1); // Überschrift auslassen
|
let rows = Array.from(table.rows).slice(1); // Überschrift auslassen
|
||||||
let isAscending = table.getAttribute("data-sort") === "asc";
|
let isAscending = table.getAttribute("data-sort") === "asc";
|
||||||
|
|
||||||
rows.sort((rowA, rowB) => {
|
rows.sort((rowA, rowB) => {
|
||||||
let cellA = rowA.cells[spaltenIndex].innerText.toLowerCase();
|
let cellA = rowA.cells[spaltenIndex].innerText.trim();
|
||||||
let cellB = rowB.cells[spaltenIndex].innerText.toLowerCase();
|
let cellB = rowB.cells[spaltenIndex].innerText.trim();
|
||||||
|
|
||||||
if (!isNaN(cellA) && !isNaN(cellB)) {
|
// Prüfen, ob das Format dem Geburtsdatum (TT-MM.JJJJ) entspricht
|
||||||
// Wenn die Zellen Zahlen sind, sortiere nach Zahlengröße
|
const datePattern = /^(\d{2}).(\d{2})\.(\d{4})$/;
|
||||||
cellA = parseFloat(cellA);
|
let dateA = cellA.match(datePattern);
|
||||||
cellB = parseFloat(cellB);
|
let dateB = cellB.match(datePattern);
|
||||||
|
|
||||||
|
if (dateA && dateB) {
|
||||||
|
// Umwandlung in das Format JJJJ-MM-TT für die korrekte Sortierung
|
||||||
|
let dateObjA = new Date(`${dateA[3]}-${dateA[2]}-${dateA[1]}`);
|
||||||
|
let dateObjB = new Date(`${dateB[3]}-${dateB[2]}-${dateB[1]}`);
|
||||||
|
|
||||||
|
return isAscending ? dateObjA - dateObjB : dateObjB - dateObjA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cellA < cellB) return isAscending ? 1 : -1;
|
// Überprüfen, ob beide Werte Zahlen sind
|
||||||
if (cellA > cellB) return isAscending ? -1 : 1;
|
let numA = parseFloat(cellA);
|
||||||
|
let numB = parseFloat(cellB);
|
||||||
|
|
||||||
|
if (!isNaN(numA) && !isNaN(numB)) {
|
||||||
|
return isAscending ? numA - numB : numB - numA;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alphabetische Sortierung als Fallback
|
||||||
|
if (cellA < cellB) return isAscending ? -1 : 1;
|
||||||
|
if (cellA > cellB) return isAscending ? 1 : -1;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue