<?php
$user_admin=$_COOKIE["user_admin"];
$jahrgang=$_COOKIE["jahrgang"];

if ($jahrgang == ""){ require("jahrgang.php"); exit;} //Wenn man kein Jahrgang ausgew&auml;hlt hat wird die Jahrgangsauswahlseite geladen
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php

// Rechte&uuml;berpr&uuml;fung
$db = dbconnect();
if ($user_admin == ""){ require("index.php"); exit;} //Wenn man nicht angemeldet ist, darf man nicht auf die Seite
$result = $db->query("SELECT 1 FROM skik_admin_rechte, skik_admin_rechte_zuord , skik_admin where skik_admin_rechte.skik_admin_rolle = skik_admin_rechte_zuord.skik_admin_rolle AND skik_admin_rechte_zuord.faid = skik_admin.faid AND skik_admin.user = '$user_admin' AND skik_admin_rechte_zuord.skik_admin_rolle = 'a_studbel'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende


if (isset($_GET['action']))
   $action = $_GET['action'];
else
   $action = "";

switch($action){
default:

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>&Uuml;bersicht &uuml;ber die Sprachkurse / Interkulturelle Kompetenzen Studienjahrgang $stud_jahr[Jahrgang]</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=\"98%\" background=\"../images/box_top.gif\" valign=\"top\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Belegung der Studenten</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>

        <form action="; echo $_SERVER['PHP_SELF'] . "?action=studbeleg"; echo" method=\"POST\" name=\"beleg\">
          <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"115\">
            <tr>
              <td width=\"25%\">
              </td>
              <td width=\"25%\">&nbsp;</td>
              <td width=\"25%\">
              <p>&nbsp;</p>
              </td>
              <td width=\"25%\">
              <p></p>
              </td>
            </tr>
            <tr>
              <td width=\"25%\">
              <p></p>
              </td>
              <td width=\"50%\">&nbsp;</td>
              <td width=\"25%\">
              <p></p>
              </td>
            </tr>
            <tr>
              <td width=\"25%\">
              <p></p>
              </td>
              <td width=\"50%\">
              <p align=\"center\">
              ";


              $db = dbconnect();
              $query = "SELECT stud.uid, nachname, vorname, AG, durchgefallen, Jahrgang FROM stud LEFT JOIN skik_wunsch USING ( uid ) WHERE skik_wunsch.uid IS NOT NULL AND Jahrgang=\"$jahrgang\" GROUP BY stud.uid ORDER  BY Nachname ASC";
              $result = $db->query ($query)
                 or die ("Cannot execute query");
              echo "<select size=\"5\" name=\"studbeleg\">";
              while ($row = $result->fetch_array()){
              echo "<option value=\"".$row[0]."\">".$row['nachname'].",&nbsp;".$row['vorname']."&nbsp;&nbsp;&nbsp;(".$row['AG']."/".$row['Jahrgang'].")"; if ($row[durchgefallen]== 'Y'){echo" *";} echo"&nbsp;&nbsp;</option>\n";
              }
              echo "</select>";
              echo "


              </td>
              <td width=\"25%\">
              <p></p>
              </td>
            </tr>
            <tr>
              <td width=\"25%\">
              <p></p>
              </td>
              <td width=\"50%\">
              &nbsp;</td>
              <td width=\"25%\">
              <p></p>
              </td>
            </tr>
            <tr>
              <td width=\"25%\">
              </td>
              <td width=\"50%\">
                <p align=\"center\"><input type=\"submit\" value=\"Abschicken\" name=\"B1\">
                <br>
                <br>
                * = durchgefallen, ausgeschieden
              </td>
              <td width=\"25%\">
              </td>
            </tr>

          </table>
        </form>
                     </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\">
                    <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 "studbeleg":



$db = dbconnect();
                $ausg_EW = $db->query ("Select uid, id, Prioritaet from skik_wunsch WHERE uid=\"". $_POST['studbeleg']."\" and Prioritaet=\"1\"");
                $EW = $ausg_EW->fetch_array();

                $ausg_ZW = $db->query ("Select uid, id, Prioritaet from skik_wunsch WHERE uid=\"". $_POST['studbeleg']."\" and Prioritaet=\"2\"");
                $ZW = $ausg_ZW->fetch_array();

                $ausg_DW = $db->query ("Select uid, id, Prioritaet from skik_wunsch WHERE uid=\"". $_POST['studbeleg']."\" and Prioritaet=\"3\"");
                $DW = $ausg_DW->fetch_array();

                $ausg_VW = $db->query ("Select uid, id, Prioritaet from skik_wunsch WHERE uid=\"". $_POST['studbeleg']."\" and Prioritaet=\"4\"");
                $VW = $ausg_VW->fetch_array();



                $ausgabe1 = $db->query("SELECT Bezeichnung  FROM skik_kurs where id=\"$EW[id]\"");
                $Psn1 = $ausgabe1->fetch_array();

                $ausgabe2 = $db->query("SELECT Bezeichnung  FROM skik_kurs where id=\"$ZW[id]\"");
                $Psn2 = $ausgabe2->fetch_array();

                $ausgabe3 = $db->query("SELECT Bezeichnung  FROM skik_kurs where id=\"$DW[id]\"");
                $Psn3 = $ausgabe3->fetch_array();

                $ausgabe4 = $db->query("SELECT Bezeichnung  FROM skik_kurs where id=\"$VW[id]\"");
                $Psn4 = $ausgabe4->fetch_array();

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>Wahlergebnis</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>
                    <span class=\"sh\">Wahlergebnis</span><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>
                    <p align=\"center\">

                <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"117\">
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td width=\"22%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\" align=\"left\">&nbsp;</p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" height=\"17\">&nbsp;</td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td valign=\"top\" width=\"22%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><font size=\"2\">Priorit&auml;t 1:</font></p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <b><font  size=\"2\">$Psn1[Bezeichnung]</font></b></td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td valign=\"top\" width=\"22%\" style=\"border-style:none; border-width:medium; \" height=\"17\" align=\"left\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><font  size=\"2\">Priorit&auml;t 2:</font></p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" height=\"17\" align=\"left\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><b><font  size=\"2\">$Psn2[Bezeichnung]</font></b></p>
                    </td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td valign=\"top\" width=\"22%\" style=\"border-style:none; border-width:medium; \" align=\"left\" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><font  size=\"2\">Priorit&auml;t 3:</font></p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" align=\"left\" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><b><font  size=\"2\">$Psn3[Bezeichnung]</font></b></p>
                    </td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"17\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"19\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td valign=\"top\" width=\"22%\" style=\"border-style:none; border-width:medium; \" align=\"left\" height=\"19\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><font  size=\"2\">Priorit&auml;t 4:</font></p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" align=\"left\" height=\"19\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"><b><font  size=\"2\">$Psn4[Bezeichnung]</font></b></p>
                    </td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"19\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                  <tr>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"18\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                    <td width=\"22%\" style=\"border-style:none; border-width:medium; \" align=\"center\" height=\"18\">
                    <p style=\"margin-top: 4; margin-bottom: 4\" align=\"left\">&nbsp;</p>
                    </td>
                    <td width=\"62%\" style=\"border-style:none; border-width:medium; \" align=\"center\" height=\"18\">&nbsp;</td>
                    <td width=\"8%\" style=\"border-style:none; border-width:medium; \" height=\"18\">
                    <p style=\"margin-top: 4; margin-bottom: 4\"></p>
                    </td>
                  </tr>
                </table>
                    </p>
                    <p align=\"center\"><a href=\"hauptframe_jahr.php\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <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>";

} // Ende Action script

?>