phpstan level 0 error free - fixes for kyu subpage - move mams into participo framework - remove legacy `lib/db.php` usage - add attributer admin function - add newsposter - fixing apiKey creation
136 lines
5.6 KiB
PHP
136 lines
5.6 KiB
PHP
<?php
|
|
require_once "bootstrap.php";
|
|
|
|
// libraries
|
|
require_once "participoLib/participo.php";
|
|
require_once "participoLib/attendance.php";
|
|
require_once "participoLib/user.php";
|
|
|
|
participo::init($CONFIG["cwsvJudo"], $SECRETS["cwsvJudo"]);
|
|
|
|
Participo\Attendance\processPostData(
|
|
db: participo::getDbConnection(),
|
|
post: $_POST,
|
|
redirectLocation: "mams",
|
|
);
|
|
|
|
$judokas = getUsersWithAttribute(participo::getDbConnection(), "inTraining");
|
|
|
|
$lastAttendances = getLastAttendances(participo::getDbConnection());
|
|
$lastAttendancesAssocArray = [];
|
|
foreach ($lastAttendances as $a) {
|
|
if (!array_key_exists($a["date"], $lastAttendancesAssocArray)) {
|
|
$lastAttendancesAssocArray[$a["date"]] = [];
|
|
}
|
|
array_push($lastAttendancesAssocArray[$a["date"]], $a);
|
|
}
|
|
|
|
$dateLastWendsday = new DateTime("wednesday this week");
|
|
$dateLastFriday = new DateTime("friday this week");
|
|
$lastTrainingDay = max($dateLastWendsday, $dateLastFriday);
|
|
?>
|
|
<html lang="de">
|
|
<header>
|
|
<!-- shared imports (common css, MaterializeCss) -->
|
|
<?php readfile("shared/imports.php"); ?>
|
|
<!-- inits for the materializeCss -->
|
|
<script src="mams.js"></script>
|
|
<!--Let browser know website is optimized for mobile-->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
|
|
<title>Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV</title>
|
|
</header>
|
|
<body>
|
|
<!-- sidenav for mams-->
|
|
<?php include_once "mams.sidenav.php"; ?>
|
|
<h2 id="addAttendences">Anwesenheiten hinzufügen</h2>
|
|
|
|
<form action="mams" method="POST">
|
|
<div class="input-field">
|
|
<input id="giveAttendanceAction" name="action" value="giveAttendance" type="hidden" />
|
|
<input id="attendenceDate" name="attandanceDate" value="<?php echo $lastTrainingDay->format(
|
|
"Y-m-d",
|
|
); ?>" type="text" class="datepicker"/>
|
|
<select name="judokaIdsInTraining[]" id="judokaIdsInTraining" multiple><option value="" disabled selected>Anwesende auswählen</option>
|
|
<?php foreach ($judokas as $j) {
|
|
echo "<option value=\"" .
|
|
$j["userId"] .
|
|
"\">" .
|
|
$j["vorname"] .
|
|
" " .
|
|
$j["name"] .
|
|
"</option>";
|
|
} ?>
|
|
</select>
|
|
<input type="submit" value="Submit">
|
|
</div>
|
|
</form>
|
|
|
|
<h2 id="addCoronaUser">Corona-Trainee hinzufügen</h2>
|
|
<?php if (array_key_exists("addCoronaUserSuccess", $_GET)) {
|
|
echo $_GET["addCoronaUserSuccess"] == "true"
|
|
? "<div>Added user.</div>"
|
|
: "<div>ERROR</div>";
|
|
} ?>
|
|
<form action="." method="POST">
|
|
<input name="action" value="addCoronaUser" type="hidden" />
|
|
<input placeholder="Name" name="name" type="text" />
|
|
<input placeholder="Vorname" name="vorname" type="text" />
|
|
<input placeholder="PLZ" name="corona_PLZ" type ="text" />
|
|
<input placeholder="Telefon" name="corona_telephon" type="tel" />
|
|
<input placeholder="eMail" name="corona_eMail" type="text" />
|
|
<input type="submit" value="Neuen Corona-User eintragen" />
|
|
</form>
|
|
|
|
<h2 id="showAttendences">Anwesenheiten</h2>
|
|
<h3>Sende Anwesenheitsliste an eMail</h3>
|
|
<form method="POST" action="." >
|
|
<input name="toEmail" type="text" placeholder="toEmail" />
|
|
<input name="action" type="hidden" value="sendAttandeesPerEmail" />
|
|
<input name="emailText" type="hidden" value="<?php echo Participo\Attendance\attendancesAssocArray2mdList(
|
|
$lastAttendancesAssocArray,
|
|
); ?>" />
|
|
<input type="submit" value="Send Email" />
|
|
</form>
|
|
<?php foreach ($lastAttendancesAssocArray as $date => $attendees) {
|
|
echo "<h3>{$date}</h3>";
|
|
echo "<table class=\"responsive-table striped\" border=\"1\">";
|
|
echo "<tr>";
|
|
echo "<th>name</th>";
|
|
echo "<th>vorname</th>";
|
|
echo "<th>PLZ</th>";
|
|
echo "<th>Telefon</th>";
|
|
echo "<th>eMail</th>";
|
|
echo "</tr>";
|
|
foreach ($attendees as $a) {
|
|
echo "<tr>";
|
|
echo "<td>" . $a["name"] . "</td>";
|
|
echo "<td>" . $a["vorname"] . "</td>";
|
|
echo "<td>" .
|
|
($a["corona_PLZ"]
|
|
? $a["corona_PLZ"]
|
|
: "<form action=\".\" method=\"POST\"><input name=\"action\" value =\"updateCoronaData\" type=\"hidden\" /><input name=\"columnName\" value=\"corona_PLZ\" type=\"hidden\" /><input name=\"userId\" value=\"" .
|
|
$a["userId"] .
|
|
"\" type=\"hidden\" /><input name=\"columnValue\" type=\"text\" placeholder=\"PLZ\" /><input type=\"submit\" value=\"Submit\"></form>") .
|
|
"</td>";
|
|
echo "<td>" .
|
|
($a["corona_telephon"]
|
|
? $a["corona_telephon"]
|
|
: "<form action=\".\" method=\"POST\"><input name=\"action\" value =\"updateCoronaData\" type=\"hidden\" /><input name=\"columnName\" value=\"corona_telephon\" type=\"hidden\" /><input name=\"userId\" value=\"" .
|
|
$a["userId"] .
|
|
"\" type=\"hidden\" /><input name=\"columnValue\" type=\"text\" placeholder=\"Telephpon\" /><input type=\"submit\" value=\"Submit\"></form>") .
|
|
"</td>";
|
|
echo "<td>" .
|
|
($a["corona_eMail"]
|
|
? $a["corona_eMail"]
|
|
: "<form action=\".\" method=\"POST\"><input name=\"action\" value =\"updateCoronaData\" type=\"hidden\" /><input name=\"columnName\" value=\"corona_eMail\" type=\"hidden\" /><input name=\"userId\" value=\"" .
|
|
$a["userId"] .
|
|
"\" type=\"hidden\" /><input name=\"columnValue\" type=\"text\" placeholder=\"eMail\" /><input type=\"submit\" value=\"Submit\"></form>") .
|
|
"</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
} ?>
|
|
</body>
|
|
</html>
|