<?php
$jahrgang=$_COOKIE["jahrgang"];
$standort=$_COOKIE["ck_standort"];
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
$uid1=$_COOKIE["uid1"];
if (isset($_GET['action']))
   $action = $_GET['action'];
else
   $action = "";

switch($action){
default:

$db = dbconnect();
include("kurs/sta/stan_soadmonline_write.php");     // F&uuml;r Statistik, wieviele User online sind


echo"
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Studentenjahrgang w&auml;hlen</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Studentenjahrgang und Standortw&auml;hlen</font><br>
                    <font class=\"sh\">Schritt 1 von 2</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=jahr"; echo" method=\"POST\">";
                      $db = dbconnect();
                      $query = "SELECT Jahrgang FROM stud GROUP BY Jahrgang ORDER BY jahrgang DESC";
                      $result = $db->query ($query)
                         or die ("Cannot execute query");
                      echo "<p align=\"center\"><select size=\"5\" name=\"jahr\">";
                      while ($row = $result->fetch_array()){
                      echo "<option value='$row[Jahrgang]'";if ($row[Jahrgang] == $jahrgang){echo " selected";} echo ">".$row['Jahrgang']."&nbsp;&nbsp;</option>\n";
                      }
                      echo "</select>";
                      echo "
                   <br>
                      <br>
                    <input type=\"submit\" value=\"Weiter\" name=\"B1\"> </p>
                    </form>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
break;
case "jahr":



setcookie("jahrgang","");
setcookie("jahrgang",$_POST['jahr']);



echo"
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Studentenjahrgang w&auml;hlen</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Studentenjahrgang und Standortw&auml;hlen</font><br>
                    <font class=\"sh\">Schritt 2 von 2</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=jahr2"; echo" method=\"POST\">

                    <br>
                    <p align=\"center\">";
                      $db = dbconnect();
                      $query = "SELECT a.sid, a.standort, block, abdatum, pendler
                                  FROM stan_standort a, stan_standort_admin b, stan_standort_zuord c, stan_ag_standort d
                                 WHERE b.seaid = c.seaid
                                   AND a.sid = c.sid
                                   AND a.sid = d.sid
                                   AND d.jahr = '$_POST[jahr]'
                                   AND b.uid='$uid1'
                                 ORDER BY standort ASC
                                ";
                                
                      $result = $db->query ($query)
                         or die ("Cannot execute query");
                      echo "<p align=\"center\"><select size=\"5\" name=\"standort\">";
                      while ($row = $result->fetch_array()){
                      echo "<option value='$row[sid]'";if ($row[sid] == $standort){echo " selected";} echo ">$row[standort] (Block $row[block]) ab $row[abdatum] ($row[pendler])&nbsp;&nbsp;</option>\n";
                      }
                      echo "</select>";
                      echo "
                      <br>
                      <br>
                      <br>
                    <input type=\"submit\" value=\"Abschicken\" name=\"B1\"> </p>
                    </form>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
break;
case "jahr2":

setcookie("ck_standort","");
setcookie("ck_standort",$_POST['standort']);

echo "
  <meta http-equiv=\"refresh\" content=\"0; URL=hauptframe_jahr.php\">
";
} // Ende Action script

?>