Neue Mitglieder aus der Anwesenheitsliste erstellen. Neue Mitglieder sind automatisch anwesend
This commit is contained in:
parent
44f3aac98b
commit
52f36328d5
26
app.js
26
app.js
|
@ -597,7 +597,8 @@ app.get("/admin", requireAuth, requireAdmin, async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/new-member", requireAuth, requireAdmin, async (req, res) => {
|
app.post("/new-member", requireAuth, requireAdmin, async (req, res) => {
|
||||||
const { vorname, nachname, geburt, riege, adresse, probe } = req.body;
|
const { from, vorname, nachname, geburt, riege, adresse, probe, training } =
|
||||||
|
req.body;
|
||||||
var geb = "01.01.2024";
|
var geb = "01.01.2024";
|
||||||
const name = vorname + " " + nachname;
|
const name = vorname + " " + nachname;
|
||||||
try {
|
try {
|
||||||
|
@ -608,11 +609,22 @@ app.post("/new-member", requireAuth, requireAdmin, async (req, res) => {
|
||||||
"INSERT INTO teilnehmende (name, geburtsdatum, adresse, vorname, nachname, probe) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id",
|
"INSERT INTO teilnehmende (name, geburtsdatum, adresse, vorname, nachname, probe) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id",
|
||||||
[name, geb, adresse, vorname, nachname, probe ? true : false]
|
[name, geb, adresse, vorname, nachname, probe ? true : false]
|
||||||
);
|
);
|
||||||
|
await pool.query(
|
||||||
|
"INSERT INTO anwesend (fid_teilnehmer, fid_training) VALUES ($1, $2)",
|
||||||
|
[teilnehmerID.rows[0].id, training]
|
||||||
|
);
|
||||||
|
|
||||||
log.Info(
|
log.Info(
|
||||||
"Mitglied " + name + " durch " + req.session.userName + " angelegt"
|
"Mitglied " + name + " durch " + req.session.userName + " angelegt"
|
||||||
);
|
);
|
||||||
putInRiege(riege, teilnehmerID.rows[0].id);
|
putInRiege(riege, teilnehmerID.rows[0].id);
|
||||||
res.redirect("/riege");
|
if (from === "admin") {
|
||||||
|
res.redirect("/riege");
|
||||||
|
} else if (from === "training") {
|
||||||
|
req.session.activeRiege = riege;
|
||||||
|
req.session.activeTab = "anwesend";
|
||||||
|
res.redirect("/training");
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = "Error:" + error;
|
const message = "Error:" + error;
|
||||||
res.render("error", { session: req.session, message });
|
res.render("error", { session: req.session, message });
|
||||||
|
@ -1070,6 +1082,16 @@ app.post("/anwesend", requireAuth, async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post('/deleteMember', requireAuth, async (req, res) => {
|
||||||
|
const { id } = req.body
|
||||||
|
try {
|
||||||
|
await pool.query('DELETE from teilnehmende WHERE id = $1', [id])
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error)
|
||||||
|
}
|
||||||
|
res.redirect('/training')
|
||||||
|
})
|
||||||
|
|
||||||
const server = app.listen(port, "0.0.0.0", () => {
|
const server = app.listen(port, "0.0.0.0", () => {
|
||||||
log.Info(`Server is running on ${process.env.HOST}:${port}/`);
|
log.Info(`Server is running on ${process.env.HOST}:${port}/`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,8 @@
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Telefonnummer hinzufügen</h2>
|
<fieldset>
|
||||||
|
<legend>Telefonnummern hinzufügen</legend>
|
||||||
<form method="POST" action="/update-mitglied">
|
<form method="POST" action="/update-mitglied">
|
||||||
<input type="hidden" name="id" value="<%= id %>">
|
<input type="hidden" name="id" value="<%= id %>">
|
||||||
<input type="hidden" name="type" value="tel">
|
<input type="hidden" name="type" value="tel">
|
||||||
|
@ -113,6 +114,38 @@
|
||||||
<input name="nummer" placeholder="+49 123 456 789" type="text">
|
<input name="nummer" placeholder="+49 123 456 789" type="text">
|
||||||
<button type="submit">Speichern</button>
|
<button type="submit">Speichern</button>
|
||||||
</form>
|
</form>
|
||||||
|
</fieldset>
|
||||||
|
<p>
|
||||||
|
<!-- Button trigger modal -->
|
||||||
|
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
|
||||||
|
Mitglied löschen
|
||||||
|
</button></br>
|
||||||
|
</p>
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h1 class="modal-title fs-5" id="exampleModalLabel">Mitglied löschen</h1>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Möchtest du das Mitglied <%= mitglied.vorname %> <%= mitglied.nachname %> wirklich löschen?
|
||||||
|
Diese Aktion kann nicht rüchgängig gemacht werden!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<form method="POST" action="/deleteMember">
|
||||||
|
<input type="hidden" name="id" value="<%= id %>">
|
||||||
|
<button type="submit" class="btn btn-danger">Löschen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-secondary" onclick="toggleDivs()">Zum View-Modus wechseln</button>
|
<button class="btn btn-secondary" onclick="toggleDivs()">Zum View-Modus wechseln</button>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
@ -328,6 +328,49 @@
|
||||||
<button type="submit">Speichern</button>
|
<button type="submit">Speichern</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newMemberModal-<%= riegennummer %>">
|
||||||
|
Neues Mitglied
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="newMemberModal-<%= riegennummer %>" tabindex="-1" aria-labelledby="newMemberModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h1 class="modal-title fs-5" id="exampleModalLabel">Neues Mitglied</h1>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form method="POST" action="/new-member">
|
||||||
|
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" value="<%= riegennummer %>">
|
||||||
|
<option value=1 <%= riegennummer == 1 ? 'selected' : '' %>> Riege 1</option>
|
||||||
|
<option value=2 <%= riegennummer == 2 ? 'selected' : '' %>> Riege 2</option>
|
||||||
|
<option value=3 <%= riegennummer == 3 ? 'selected' : '' %>> Riege 3</option>
|
||||||
|
<option value=4 <%= riegennummer == 4 ? 'selected' : '' %>> Riege 4</option>
|
||||||
|
<option value=5 <%= riegennummer == 5 ? 'selected' : '' %>> Riege 5</option>
|
||||||
|
</select></br>
|
||||||
|
Adresse: <input type="text" id="adresse" placeholder="Adresse" name="adresse"></br>
|
||||||
|
Probe: <input type="checkbox" name="probe" value="true"></br>
|
||||||
|
<input type="hidden" name="from" value="training">
|
||||||
|
<input type="hidden" name="training" value="<%= training.id %>">
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="submit">Speichern</button>
|
||||||
|
</form>
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue