Anwesenheit kann gelöscht werden.
This commit is contained in:
parent
264dcebf6c
commit
8530cbf21b
8
app.js
8
app.js
|
@ -827,15 +827,15 @@ app.post('/changelog', requireAdmin, async (req, res) => {
|
||||||
app.post('/anwesend', requireAuth, async (req, res) => {
|
app.post('/anwesend', requireAuth, async (req, res) => {
|
||||||
const { anw, trainingId, riege } = req.body;
|
const { anw, trainingId, riege } = req.body;
|
||||||
req.session.activeTab = 'anwesend';
|
req.session.activeTab = 'anwesend';
|
||||||
req.session.message = [title = 'Erfolg', body = 'Die Anwesenheit wurde gespeichert', type = 'success'];
|
|
||||||
try {
|
try {
|
||||||
|
await pool.query('Delete FROM anwesend WHERE fid_training = $1', [trainingId]);
|
||||||
for (const teilnehmer of anw) {
|
for (const teilnehmer of anw) {
|
||||||
const resultAnw = await pool.query('Select * FROM anwesend WHERE fid_teilnehmer = $1 AND fid_training = $2', [teilnehmer, trainingId]);
|
|
||||||
if (resultAnw.rows.length == 0) {
|
|
||||||
await pool.query('INSERT INTO anwesend (fid_teilnehmer, fid_training) VALUES ($1, $2)', [teilnehmer, trainingId]);
|
await pool.query('INSERT INTO anwesend (fid_teilnehmer, fid_training) VALUES ($1, $2)', [teilnehmer, trainingId]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
req.session.activeRiege = riege;
|
req.session.activeRiege = riege;
|
||||||
|
req.session.activeTab = 'anwesend';
|
||||||
|
req.session.message = [title = 'Erfolg', body = 'Die Anwesenheit wurde gespeichert', type = 'success'];
|
||||||
res.redirect('/training');
|
res.redirect('/training');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|
Loading…
Reference in New Issue