"; // debug
$OldTag = "";
$OldWas = "";
// um Zeilen mit von mir belegten Schichten hervorzuheben
$MeineDienste = SchichtIdArrayEinesHelfers($db_link, $HelferID);
//print_r($MeineDienste);
echo "
\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.
// 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.
echo " next table \n";
echo "
\n";
// $db_erg ist aus AlleSchichtenImZeitbereich
// und gibt zurueck Was, Ab, Bis, Ist, Tag, Soll - Ist und Soll sind die HelferStunden
$OldWas = "";
while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
$Tag = $zeile['Tag']; //this should be set above, because we only look at one day
$Ab = $zeile['Ab'];
$Bis = $zeile['Bis'];
$Ist = $zeile['Ist'];
$Soll = $zeile['Soll'];
$Was = $zeile['Was'];
$TagKurz = substr($Tag, 0, 2);
if (substr($Ab, 0, 2) == substr($Bis, 0, 2)) {
$Bis = substr($Bis, 2);
} // if start and end time are on the same day, we only print the end time
if ($Was != $OldWas) {
echo "
";
echo "
$Was ($TagKurz)
\n";
}
$db_erg_helfer = BeteiligteHelfer($db_link, $zeile['SchichtID']); // get the people who are already signed up for this shift
// Wir geben zwei Helfer pro Zeile fuer die selbe Schicht aus
while ($Soll > 0) {
$Soll = $Soll - 1;
$HelferZeile = mysqli_fetch_array($db_erg_helfer, MYSQLI_ASSOC);
if (isset($HelferZeile['Name'])) {
$Helfername = $HelferZeile['Name'];
} else {
$Helfername = '';
}
echo "
$Was $Ab - $Bis
";
echo "
$Helfername
";
echo "
$Was $Ab-$Bis
";
if ($Soll > 0) { // zweite Spalte nur ausgeben, wenn noch eine Schicht offen ist
$Soll = $Soll - 1;
$HelferZeile = mysqli_fetch_array($db_erg_helfer, MYSQLI_ASSOC); // get the next person
if (isset($HelferZeile['Name'])) {
$Helfername = $HelferZeile['Name'];
} else {
$Helfername = '';
}
echo "
$Helfername
";
echo "
$Was $Ab-$Bis
";
} else {//if there is no more shift to fill in, we fill the rest of the row with empty fields
echo "
";
}
$OldWas = $Was;
}
}
echo "
\n";
// old table, remove later
mysqli_free_result($db_erg);
?>