Compare commits

..

No commits in common. "95b322e4a6f2a5808db5d79803371a1c2b48fd40" and "44f3aac98b25ef505defbc83f543fa7112919978" have entirely different histories.

4 changed files with 3 additions and 114 deletions

37
app.js
View File

@ -597,17 +597,7 @@ 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) => {
var { const { vorname, nachname, geburt, riege, adresse, probe } = req.body;
from,
vorname,
nachname,
geburt,
riege,
adresse,
probe,
from,
training,
} = req.body;
var geb = "01.01.2024"; var geb = "01.01.2024";
const name = vorname + " " + nachname; const name = vorname + " " + nachname;
try { try {
@ -618,24 +608,11 @@ 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]
); );
if (from === "admin") {
selectedKW = moment().isoWeek();
selectedYear = moment().year();
const trainingresult = await getTraining(selectedKW, selectedYear);
training = trainingresult.id;
}
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);
req.session.activeRiege = riege; res.redirect("/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 });
@ -1093,16 +1070,6 @@ 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("/teilnehmer");
});
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}/`);
}); });

View File

@ -28,8 +28,6 @@
</select></br> </select></br>
Adresse: <input type="text" id="adresse" placeholder="Adresse" name="adresse"></br> Adresse: <input type="text" id="adresse" placeholder="Adresse" name="adresse"></br>
Probe: <input type="checkbox" name="probe" value="true"></br> Probe: <input type="checkbox" name="probe" value="true"></br>
<input type="hidden" name="from" value="admin">
<input type="hidden" name="training" value="0">
<button type="submit">Speichern</button> <button type="submit">Speichern</button>
</form> </form>

View File

@ -97,8 +97,7 @@
</p> </p>
</fieldset> </fieldset>
<fieldset> <h2>Telefonnummer hinzufügen</h2>
<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">
@ -114,38 +113,6 @@
<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>
<% } %> <% } %>

View File

@ -328,49 +328,6 @@
<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>