<html>
<head>
  <title>Admin Stochercon</title>

  <link rel="stylesheet" href="style_desktop.css" media="screen and (min-width:781px)"/>
  <link rel="stylesheet" href="style_mobile.css" media="screen and (max-width:780px)"/>
  <link rel="stylesheet" href="style_print.css" media="print"/>

<meta name="viewport" content="width=480" />
</head>
<body>


<div style="width: 100%;">

<?php

SESSION_START();

require_once('../hidden/konfiguration.php');
include 'SQL.php';

$db_link = mysqli_connect (
			MYSQL_HOST,
			MYSQL_BENUTZER,
			MYSQL_KENNWORT,
			MYSQL_DATENBANK
			);
DatenbankAufDeutsch($db_link);

include '_login.php';


?>

<?php
setlocale (LC_ALL, 'de_DE.UTF-8') or die("Locale not installed");

$unixtime=strtotime('2023-09-15');
for($day=0; $day<3; $day++)
{
    $datestring=date('Y-m-d',$unixtime+$day*24*60*60);
    echo "<h1>".strftime('%A, %e. %B %Y',$unixtime+$day*24*60*60)."</h1>";
    $db_erg = GetDiensteForDay($db_link,2,$datestring);
    while ($zeile = mysqli_fetch_array( $db_erg, MYSQLI_ASSOC))
    {
        $db_erg2 = GetSchichtenForDienstForDay($db_link,$zeile["DienstId"],$datestring);
        echo "<table id='customers'>";
        echo "<tr><th colspan=3>".$zeile["Was"]."</th></tr>";
        $schichten=0;
        $OldVon=0;
        $OldSoll=0;
        while($zeile2 = mysqli_fetch_array($db_erg2, MYSQLI_ASSOC))
	{
            if($zeile2["Von"]!=$OldVon && $schichten!=0)
            {
                while($schichten<$OldSoll)
                {
                    $schichten++;
                    echo "<tr>";
                    echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$OldSoll."</strong> ".date('H:i',strtotime($OldVon))." - ".date('H:i',strtotime($OldBis))."</td>";
                    echo "<td rowspan='3' valign='top'></td>";
                    echo "<td width='50%'>".strftime('%a %H:%M',strtotime($OldVon))." <strong>".$zeile["Was"]."</strong></td>";
                    echo "</tr>";
                    echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
                    echo "<tr><td>".$zeile["Info"]."</td></tr>";
                    echo "<tr height='10mm'></tr>";
                }
                $schichten=0;
            }
            $schichten++;
            echo "<tr>";
            echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$zeile2["Soll"]."</strong> ".date('H:i',strtotime($zeile2["Von"]))." - ".date('H:i',strtotime($zeile2["Bis"]))."</td>";
            echo "<td rowspan='3' valign='top'><strong>".$zeile2["Name"]."</strong> ".$zeile2["Handy"]."</td>";
            echo "<td width='50%'>".strftime('%a %H:%M',strtotime($zeile2["Von"]))." <strong>".$zeile["Was"]."</strong></td>";
            echo "</tr>";
            echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
            echo "<tr><td>".$zeile["Info"]."</td></tr>";
            echo "<tr height='10mm'></tr>";
            $OldVon = $zeile2["Von"];
            $OldBis = $zeile2["Bis"];
            $OldSoll = $zeile2["Soll"];
            if(empty($zeile2["Name"]))
            {
                while($schichten<$OldSoll)
                {
                    $schichten++;
                    echo "<tr>";
                    echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$OldSoll."</strong> ".date('H:i',strtotime($OldVon))." - ".date('H:i',strtotime($OldBis))."</td>";
                    echo "<td rowspan='3' valign='top'></td>";
                    echo "<td width='50%'>".strftime('%a %H:%M',strtotime($OldVon))." <strong>".$zeile["Was"]."</strong></td>";
                    echo "</tr>";
                    echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
                    echo "<tr><td>".$zeile["Info"]."</td></tr>";
                    echo "<tr height='10mm'></tr>";
                }
            }
        }
        
        echo "</table>";
    } 
}

$unixtime=strtotime('2023-09-15');
for($day=0; $day<3; $day++)
{
    $datestring=date('Y-m-d',$unixtime+$day*24*60*60);
    echo "<h1>".strftime('%A, %e. %B %Y',$unixtime+$day*24*60*60)."</h1>";
    $db_erg = GetDiensteForDay($db_link,1,$datestring);
    while ($zeile = mysqli_fetch_array( $db_erg, MYSQLI_ASSOC))
    {
        $db_erg2 = GetSchichtenForDienstForDay($db_link,$zeile["DienstId"],$datestring);
        echo "<table id='customers'>";
        echo "<tr><th colspan=3>".$zeile["Was"]."</th></tr>";
        $schichten=0;
        $OldVon=0;
        $OldSoll=0;
        while($zeile2 = mysqli_fetch_array($db_erg2, MYSQLI_ASSOC))
	{
            if($zeile2["Von"]!=$OldVon && $schichten!=0)
            {
                while($schichten<$OldSoll)
                {
                    $schichten++;
                    echo "<tr>";
                    echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$OldSoll."</strong> ".date('H:i',strtotime($OldVon))." - ".date('H:i',strtotime($OldBis))."</td>";
                    echo "<td rowspan='3' valign='top'></td>";
                    echo "<td width='50%'>".strftime('%a %H:%M',strtotime($OldVon))." <strong>".$zeile["Was"]."</strong></td>";
                    echo "</tr>";
                    echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
                    echo "<tr><td>".$zeile["Info"]."</td></tr>";
                    echo "<tr height='10mm'></tr>";
                }
                $schichten=0;
            }
            $schichten++;
            echo "<tr>";
            echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$zeile2["Soll"]."</strong> ".date('H:i',strtotime($zeile2["Von"]))." - ".date('H:i',strtotime($zeile2["Bis"]))."</td>";
            echo "<td rowspan='3' valign='top'><strong>".$zeile2["Name"]."</strong> ".$zeile2["Handy"]."</td>";
            echo "<td width='50%'>".strftime('%a %H:%M',strtotime($zeile2["Von"]))." <strong>".$zeile["Was"]."</strong></td>";
            echo "</tr>";
            echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
            echo "<tr><td>".$zeile["Info"]."</td></tr>";
            echo "<tr height='10mm'></tr>";
            $OldVon = $zeile2["Von"];
            $OldBis = $zeile2["Bis"];
            $OldSoll = $zeile2["Soll"];
            if(empty($zeile2["Name"]))
            {
                while($schichten<$OldSoll)
                {
                    $schichten++;
                    echo "<tr>";
                    echo "<td rowspan='3' style='width:0.1%; white-space:nowrap;' valign='top'><strong>".$schichten."/".$OldSoll."</strong> ".date('H:i',strtotime($OldVon))." - ".date('H:i',strtotime($OldBis))."</td>";
                    echo "<td rowspan='3' valign='top'></td>";
                    echo "<td width='50%'>".strftime('%a %H:%M',strtotime($OldVon))." <strong>".$zeile["Was"]."</strong></td>";
                    echo "</tr>";
                    echo "<tr><td><i>".$zeile["Wo"]."</i></td></tr>";
                    echo "<tr><td>".$zeile["Info"]."</td></tr>";
                    echo "<tr height='10mm'></tr>";
                }
            }
        }
        
        echo "</table>";
    } 
}

?>

</body>
</html>
