Fix eingeklappte Zeilen nach + - von User in der angeklickten Zeile ausklappen; lange Zeilen aufgeteilt; js schaut nur Tabellen des Typs "collapsible" an

This commit is contained in:
Karsten Siegmund 2024-01-05 16:35:50 +01:00
parent e0baad13f0
commit 9d7a1c41de
5 changed files with 92 additions and 64 deletions

View File

@ -53,14 +53,21 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
<div style="width: 100%;">
<table class="commontable">
<th><button name="BackHelferdaten" value="1" onclick="window.location.href = 'index.php';"><b>&larrhk;</b></button> &nbsp; <b>Admin HelferDB</b>
<th>
<button name="BackHelferdaten" value="1" onclick="window.location.href = 'index.php';">
<b>&larrhk;</b>
</button> &nbsp;
<b>Admin HelferDB</b>
</th>
<tr>
<tr onclick="window.location.href='AdminDienste.php';">
<td>
<a class="fallbacklink" href='AdminDienste.php'><img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;"><b> Dienste und Schichten verwalten</b></a>
<a class="fallbacklink" href='AdminDienste.php'>
<img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;">
<b> Dienste und Schichten verwalten</b>
</a>
</td>
</tr>
<tr onclick="window.location.href='CreateHelfer.php';"> <td>
@ -72,11 +79,17 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
</td> </tr>
<tr onclick="window.location.href='AdminHelferUebersicht.php';">
<td>
<a class="fallbacklink" href='AdminHelferUebersicht.php'><img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;"><b>Helfer&uuml;bersicht (und als Admin &auml;ndern)</b></a>
<a class="fallbacklink" href='AdminHelferUebersicht.php'>
<img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;">
<b>Helfer als Admin &auml;ndern</b>
</a>
</td>
</tr>
<th><b>Helfer als Admin &auml;ndern:<b> <form style="display:inline-block;" method=post><select style="height:33px;width:350px;font-size:20" name="AliasHelferID" id="AliasHelferID" onchange="submit()">
<th>
<b>Helfer als Admin &auml;ndern:<b>
<form style="display:inline-block;" method=post>
<select style="height:33px;width:350px;font-size:20" name="AliasHelferID" id="AliasHelferID" onchange="submit()">
<?php
$db_erg = HelferListe($db_link);
while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
@ -98,13 +111,25 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
- inner table for indent-->
<tr onclick="window.location.href='AdminUserdaten.php';">
<!--td class="invis"></td-->
<td><img src="Bilder/dot.png" width="30px" height="2px"><img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;"><b> Helferdaten &auml;ndern</b></td>
<td>
<img src="Bilder/dot.png" width="30px" height="2px">
<img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;">
<b> Helferdaten &auml;ndern</b>
</td>
</tr>
<tr onclick="window.location.href='AdminMeineSchichten.php';">
<td><img src="Bilder/dot.png" width="30px" height="2px"><img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;"><b> Schichten Anzeigen/Löschen</b></td>
<td>
<img src="Bilder/dot.png" width="30px" height="2px">
<img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;">
<b>Schichten Anzeigen/Löschen</b>
</td>
</tr>
<tr onclick="window.location.href='AdminAlleSchichten.php';">
<td><img src="Bilder/dot.png" width="30px" height="2px"><img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;"><b> Schichten Hinzufügen</b></td>
<td>
<img src="Bilder/dot.png" width="30px" height="2px">
<img src="Bilder/PfeilRechts.jpeg" style="width:30px;height:30px;">
<b> Schichten Hinzufügen</b>
</td>
</tr>
<!--</table></td> </tr> inner table for indent end-->
<!--<tr><th>Weiteres</th></tr>-->
@ -115,8 +140,12 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
<td > <img src="Bilder/More.jpeg" style="width:30px;height:30px;"> <b>Ausdrucke</b> </td>
</tr>
</table>
<p> <img src="Bilder/Info.jpeg" width="25px" height="25px"> Dienst: z.B. Badgekontrolle Eingang A. Schicht: ein Dienst zu einer bestimmten Zeit zB 9-12 Uhr
<p>
<img src="Bilder/Info.jpeg" width="25px" height="25px">
Dienst: z.B. Badgekontrolle Eingang A. Schicht: ein Dienst zu einer bestimmten Zeit zB 9-12 Uhr
</p>
<button class=back name="BackHelferdaten" value="1" onclick="window.location.href = 'index.php';"><b>&larrhk;</b></button>
<button class=back name="BackHelferdaten" value="1" onclick="window.location.href = 'index.php';">
<b>&larrhk;</b>
</button>
</body>
</html>

View File

@ -103,7 +103,7 @@ if (isset($_GET['ZeitBereich'])) {
?>
<form method="post" action="AlleSchichten.php#Info">
<form method="post" action="AlleSchichten.php">
<?php
@ -112,24 +112,17 @@ if (isset($_GET['ZeitBereich'])) {
///////////////////////////////////////////////////////////
if (isset($_POST['plusschicht'])) {
$messages = [];
$SchichtId = $_POST['plusschicht'];
// Eingaben überprüfen:
// if(!preg_match('/^[a-zA-Z]+[a-zA-Z0-9._]+$/', $HelferName)) {
// $messages[] = 'Bitte prüfen Sie die eingegebenen Namen';
// }
$SchichtID = $_POST['plusschicht'];
// Nutzer hat hier zuletzt etwas geändert und wir klappen das deshalb auf,
// indem wir unten target=active setzen
$_SESSION["SchichtIdAktiv"] = $SchichtID;
if (empty($messages)) {
// Helfer Schicht zuweisen
$db_erg = HelferSchichtZuweisen($db_link, $HelferID, $SchichtId);
$db_erg = HelferSchichtZuweisen($db_link, $HelferID, $SchichtID);
// Erfolg vermelden und Skript beenden, damit Formular nicht erneut ausgegeben wird
$HelferName = '';
$HelferEmail = '';
$HelferHandy = '';
//die('<div class="Helfer wurde angelegt.</div>');
} else {
// Fehlermeldungen ausgeben:
echo '<div class="error"><ul>';
@ -145,6 +138,8 @@ if (isset($_POST['minusschicht'])) {
$messages = [];
$SchichtID = $_POST['minusschicht'];
// Nutzer hat hier zuletzt etwas geaenndert und wir klappen das deshalb auf:
$_SESSION["SchichtIdAktiv"] = $SchichtID;
if (empty($messages)) {
// Helfer aus Schicht entfernen
@ -169,6 +164,7 @@ if (isset($_POST['minusschicht'])) {
$db_erg = SchichtenSummeEinesHelfers($db_link, $HelferID);
$zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC);
//"Mein Dienstplan"
echo '<table class="commontable"><tr class="header"><th onclick="window.location.href=\'MeineSchichten.php\'">';
echo '<img src="Bilder/PfeilRechts2.png" style="width:30px;height:30px;align:middle;">' . " Mein Dienstplan (";
echo $zeile['Anzahl'];
@ -206,7 +202,6 @@ if ($addschicht == '0') {
echo "<button name='addschicht' value='2'>Dienste</button></p>";
}
//echo "InfoAlleSchichtID ".$InfoAlleSchichtID;
if ($addschicht != '0') {
//$db_erg = AlleSchichten($db_link,$dienstsort);
@ -237,21 +232,11 @@ if ($addschicht != '0') {
$iBelegteSchichtenCount = AlleBelegteSchichtenCount($db_link);
echo "<button type='button' onclick='expand_all_table_rows();'>Alles Ausklappen</button>";
//echo "<p><button name='addschicht' value='0'><b>&larrhk;</b></button></p>";
echo '<table id="customers">';
// "Alle Schichten der Con"
echo '<table class="commontable">';
echo "<tr class='header'>";
echo "<th colspan='7'>" . "Alle Schichten der Con (" . $iBelegteSchichtenCount . "/" . $iAlleSchichtenCount . ")</th></tr>";
echo "<th colspan='7'>Alle Schichten der Con (" . $iBelegteSchichtenCount . "/" . $iAlleSchichtenCount . ")</th></tr>";
/*
if ($dienstsort=='1')
{
echo "<th>". "Dienst" . "</th>";
}
else
{
echo "<th>". "Von" . "</th>";
}
*/
echo "<tr class='header'>"; // Zeitbereich tr
if ($ZeitBereich == 1) {
echo "<th style='width:100px; background-color:#0000FF' onclick='window.location.href=\"AlleSchichten.php?ZeitBereich=1\"'>" . "Alle" . "</th>";
@ -298,7 +283,8 @@ if ($addschicht != '0') {
//print_r($MeineDienste);
echo '</table>';
echo '<table id="customers">';
// Tabelle mit allen Diensten und Schichten
echo '<table class="commontable collapsible">';
while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
if ($dienstsort == '1') {
$Tag = $zeile['Tag'];
@ -313,7 +299,8 @@ if ($addschicht != '0') {
$Was = $zeile['Was'];
if ($Was != $OldWas) {
echo "<tr class='header'><th colspan='7' style='width:100%'>";
// + in <span> becomes - when rows are opened
echo "<tr class='header'><th colspan='7' style='width:100%'><span>+</span> ";
echo $Was;
echo "</th>";
/*
@ -349,6 +336,9 @@ if ($addschicht != '0') {
$rowstyle = 'dbinfo="SchichtID:' . $zeile['SchichtID'] . ';helferlvl:' . $HelferLevel . '" ';
$regtext = '';
}
if ($_SESSION["SchichtIdAktiv"] == $zeile['SchichtID']) {
$rowstyle = $rowstyle . " target='active' "; // dont collapse when the user did something
}
echo '<tr ' . $rowstyle . 'onclick="window.location.href=\'DetailsSchichten.php?InfoAlleSchichtID=' . $zeile['SchichtID'] . '#Info\';" >';
@ -363,8 +353,7 @@ if ($addschicht != '0') {
echo "" . $zeile['Soll'] . "</td>";
// buttons sind in der selben Zelle
echo "<td width='30px'>" . "<button width='20px' name='plusschicht' value='" . $zeile['SchichtID'] . "'>+</button>" . "";
echo "" . "&nbsp;&nbsp;<button width='120px' name='minusschicht' value='" . $zeile['SchichtID'] . "'>&ndash;</button> $regtext" . "</td>";
//echo "<td>$regtext</td>";
echo "&nbsp;&nbsp;<button width='120px' name='minusschicht' value='" . $zeile['SchichtID'] . "'>&ndash;</button> $regtext" . "</td>";
echo "</tr>\n";
}
echo "</table>";

View File

@ -62,7 +62,7 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
</tr>
<tr onclick="window.location.href='TeilnehmerSchichtenAusdruck.php';">
<td > <img src="Bilder/More.jpeg" style="width:30px;height:30px;"> <b>Ausdruck Schichten(I)</b> </td> </tr>
<tr onclick="window.location.href='TeilnehmerSchichtenAusdruck.php';">
<tr onclick="window.location.href='TeilnehmerSchichtenAusdruck2.php';">
<td > <img src="Bilder/More.jpeg" style="width:30px;height:30px;"> <b>Ausdruck Schichten(II)</b> </td> </tr>
</table>
<button class=back name="BackHelferdaten" value="1" onclick="window.location.href = 'Admin.php';"><b>&larrhk;</b></button>

View File

@ -94,7 +94,6 @@ if (isset($_GET['ZeitBereich'])) {
?>
<!--form method="post" action="AlleSchichtenAusdruck.php#Info"-->
<?php
@ -176,7 +175,8 @@ $iBelegteSchichtenCount = AlleBelegteSchichtenCount($db_link);
//echo "<p><button name='addschicht' value='0'><b>&larrhk;</b></button></p>";
echo '<table class="commontable">';
echo "<tr class='header'>";
echo "<th colspan='7'>" . "Alle Schichten der Con (" . $iBelegteSchichtenCount . "/" . $iAlleSchichtenCount . ")</th></tr>";
echo "<th colspan='7'>" . "Alle Schichten der Con (";
echo $iBelegteSchichtenCount . "/" . $iAlleSchichtenCount . ")</th></tr>";
echo "\n<tr class='header'>\n"; // Zeitbereich tr
@ -227,7 +227,9 @@ foreach ($ZeitBereichWerte as &$EinZeitBereich) {
//$Text="$Text <br>$MeinVon $MeinBis"; // debug time strings
// write the field for each day
echo "<th style='width:{$ZeitBereichFeldBreite}%; $color' onclick='window.location.href=\"AlleSchichtenAusdruck.php?ZeitBereich={$EinZeitBereich}\";'>" . "$Text" . "</th>\n";
echo "<th style='width:{$ZeitBereichFeldBreite}%; $color' ";
echo "onclick='window.location.href=\"TeilnehmerSchichtenAusdruck.php?ZeitBereich={$EinZeitBereich}\";'>";
echo "$Text" . "</th>\n";
}
echo "</tr>"; //Zeitbereich tr
@ -242,13 +244,16 @@ $MeineDienste = SchichtIdArrayEinesHelfers($db_link, $HelferID);
echo "</table>\n";
// Table to print out the shifts for people to enter their name in. If a shift is already taken, the name is printed out.
// Table to print out the shifts for people to enter their name in.
// If a shift is already taken, the name is printed out.
// The table prints just one day, specified via Zeitbereich. The heading above wrote out the day.
// the table is sorted by shift type (Was) first and then by time (Ab).
// "Was" is printed in the middle together with two-letter day and time.
// the first and the 5th (last) column also contain two-letter day and time for people to tear off and take with them.
// the 2nd and 4th column are for the namer. if the shift is already taken, the name is printed in, else the field is empty to write in.
// we iterate over all tasks (Was) and then over Ist and Soll for each task, filling one field for each Ist or Soll and filling in the name in Ist and leave it empty if it is Soll.
// the 2nd and 4th column are for the name.
// if the shift is already taken, the name is printed in, else the field is empty to write in.
// we iterate over all tasks (Was) and then over Ist and Soll for each task,
// filling one field for each Ist or Soll and filling in the name in Ist and leave it empty if it is Soll.
echo "<br>next table<br>\n";
echo "<table class='commontable'>\n";
// $db_erg ist aus AlleSchichtenImZeitbereich
@ -269,7 +274,8 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
echo "<tr class='header'>";
echo "<th colspan=5 style='text-align:center'>$Was ($TagKurz)</th></tr>\n";
}
$db_erg_helfer = BeteiligteHelfer($db_link, $zeile['SchichtID']); // get the people who are already signed up for this shift
// get the people who are already signed up for this shift
$db_erg_helfer = BeteiligteHelfer($db_link, $zeile['SchichtID']);
// Wir geben zwei Helfer pro Zeile fuer die selbe Schicht aus
while ($Soll > 0) {
$Soll = $Soll - 1;

View File

@ -30,16 +30,21 @@ function collapse_table_rows()
{
$(document).ready(
function () {
$('tr:not(.header)').hide();
$('tr.header').click(
// Unter-Zeilen in collapsible Tabellen verbergen
$('table.collapsible tr:not(.header)').hide();
// Zeile mit dem target="active" (von PHP nach submit gesetzt) und dazugehoerige Zeilen anzeigen
$('table.collapsible tr[target="active"]').prevUntil('tr.header').addBack().nextUntil('tr.header').addBack().show();
// id="active" als Anker auf letztes tr.header vor der target=active Seite setzen und dort hin springen
// damit der Nutzer nach Abschicken des Posts seine geoeffneten Optionen sieht
$('table.collapsible tr[target="active"]').prevAll('.header').first().attr('id', 'active');
location.href = '#active';
$('table.collapsible tr.header').click(
function () {
$(this).find('span').text(
function (_, value) {
return value == '-' ? '+' : '-'
}
);
$(this).nextUntil('tr.header').slideToggle(100, function () {});
}
);
@ -50,6 +55,5 @@ function collapse_table_rows()
function expand_all_table_rows()
{
$('tr:not(.header)').hide(); // make all collapsed so that slideToggle doesnt close opened ones
$('tr:not(.header)').slideToggle(100, function () {});
$('tr:not(.header)').show();
}