<?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 pros_admin_rechte, pros_admin_rechte_zuord , pros_admin where pros_admin_rechte.pros_admin_rolle = pros_admin_rechte_zuord.pros_admin_rolle AND pros_admin_rechte_zuord.faid = pros_admin.faid AND pros_admin.user = '$user_admin' AND pros_admin_rechte_zuord.pros_admin_rolle = 'a_aush'");
$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>Ausdruck Aushang</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=\"100%\" border=\"0\">
                <tr>
                    <td align=\"left\" width=\"1%\" width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td align=\"left\" width=\"98%\" background=\"../images/box_top.gif\" valign=\"top\" colspan=\"2\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Ausdruck Aushang</font>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td 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\">
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=aushang"; echo" method=\"POST\" name=\"Aushang\">
                    <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\">
                        <tr>
                            <td width=\"8%\" rowspan=\"2\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p align=\"center\"><b>FPRNr</b></p>
                            </td>
                            <td width=\"56%\" rowspan=\"2\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <b>
                            <p>Bezeichnung</p>
                            </b></td>
                            <td width=\"24%\" style=\"border-top-color: #111111; border-top-width: 1; border-bottom-style: none; border-bottom-width: medium; border-right-style:none; border-right-width:medium\">
                            <b>
                            <p align=\"center\">Teilnehmer</p>
                            </b></td>
                            <td width=\"12%\" align=\"center\" rowspan=\"2\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <b>Auswahl</b></td>
                        </tr>
                        <tr>
                            <td width=\"24%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p align=\"center\"><b>Ist / Max </b></p>
                            </td>
                        </tr>";
                        $db = dbconnect();
                        $query = "SELECT id, FPRNr, Bezeichnung, bemerkung, TN_max FROM pros_proseminar where Jahr=\"$jahrgang\" order by FPRNr asc";
                        $result = $db->query($query)
                               or die ("Cannot execute query");
                        while ($row = $result->fetch_array()){

                        if ( $res=$db->query("SELECT count(pros_wunsch.uid) from pros_wunsch left join stud using (uid) where pros_wunsch.id=$row[id] and pros_wunsch.Prioritaet=\"0\" and stud.durchgefallen !=\"Y\" order by pros_wunsch.uid") ){
                        if ( $row1=$res->fetch_array() ) {
                        $result_ist=$row1[0];
                        } else $result_ist=0;
                        } else $result_ist=0;

                        echo "
                        <tr>
                            <td width=\"8%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p align=\"center\">$row[FPRNr]</p>
                            </td>
                            <td width=\"56%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p>$row[Bezeichnung]<span class=\"bemerkung\"><br>
                            $row[bemerkung]</span></p>
                            </td>
                            <td width=\"24%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p align=\"center\">$result_ist&nbsp;&nbsp; /&nbsp;&nbsp;
                            $row[TN_max]</p>
                            </td>
                            <td width=\"12%\" align=\"center\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                            <p>
                            <input type=\"radio\" value=\"$row[id]\" name=\"ausw_ausg\" size=\"20\">
                            </td>
                        </tr>";
                           }
                      echo "
                      </table>
                      <br>
                      <input type=\"submit\" value=\"Abschicken\" name=\"B1\" size=\"20\"></p>
                      </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\" 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 "aushang":

$db = dbconnect();
$sel_pros = $db->query("SELECT FPRNr, Bezeichnung FROM pros_proseminar where id=\"". $_POST['ausw_ausg']."\"");
$pros = $sel_pros->fetch_array();
echo "

<html>
<head>
<meta http-equiv=\"Content-Language\" content=\"de\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Proseminar Nr $pros[FPRNr]</title>
</head>

<body>

<div align=\"center\">
  <table class=\"MsoTableGrid\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse: collapse; border-left-width:0; border-right-width:0; border-top-width:0\" height=\"147\">
    <tr>
      <td width=\"614\" colspan=\"2\" valign=\"top\" style=\"width: 460.6pt; border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top: medium none #000000; border-bottom-style: none; border-bottom-width: medium; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm\" height=\"94\">
      <p class=\"MsoNormal\" align=\"center\" style=\"text-align: center\">
      <br>
&nbsp;<b>Proseminar Nr. $pros[FPRNr]<br>
&nbsp;$pros[Bezeichnung]<br>
      <![if !supportLineBreakNewLine]><br>
&nbsp;<![endif]></b></p>
      </td>
    </tr>
    <tr>
      <td width=\"499\" valign=\"top\" style=\"border-style:solid; border-width:1; width: 374.4pt; padding-left: 5pt; padding-right: 5pt; padding-top: 0cm; padding-bottom: 0cm; \" height=\"28\" class=\"contentfarbe\">
      <p class=\"MsoNormal\" style=\"margin: 3.0pt 4.5pt\"><b>Name</b></p>
      </td>
      <td width=\"115\" valign=\"top\" style=\"width: 86.2pt; border-right-style: solid; border-right-width: 1; border-top-style: solid; border-top-width: 1; padding-left: 5pt; padding-right: 5pt; padding-top: 0cm; padding-bottom: 0cm; border-bottom-style:solid; border-bottom-width:1\" height=\"28\" class=\"contentfarbe\">
      <p class=\"MsoNormal\" align=\"center\" style=\"text-align: center; margin: 3.0pt 4.5pt\">
      <b>AG</b></p>
      </td>
    </tr>";
    $db = dbconnect();
    $result = $db->query("SELECT stud.uid, id, Prioritaet from pros_wunsch, stud where id=\"". $_POST['ausw_ausg']."\" and Prioritaet=\"0\" AND pros_wunsch.uid = stud.uid AND stud.durchgefallen !='Y' order by stud.uid");
    while ($row = $result->fetch_array()){
    $select = $db->query("SELECT Vorname, Nachname, AG, Jahrgang from stud where uid=\"$row[uid]\" ORDER BY Nachname ASC");
    $res_ausg = $select->fetch_array();
    echo "
    <tr>
      <td width=\"499\" valign=\"top\" style=\"width: 374.4pt; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm; border-left-style:solid; border-left-width:1; border-right-style:solid; border-right-width:1; border-bottom-style:solid; border-bottom-width:1\" height=\"25\">
      <p class=\"MsoNormal\" style=\"margin:4 6; \">$res_ausg[Nachname], $res_ausg[Vorname]</p>
      </td>
      <td width=\"115\" valign=\"top\" style=\"width: 86.2pt; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm; border-right-style:solid; border-right-width:1; border-bottom-style:solid; border-bottom-width:1\" height=\"25\">
      <p class=\"MsoNormal\" style=\"margin: 4 6; \" align=\"center\">
      $res_ausg[AG]/$res_ausg[Jahrgang]</p>
      </td>";
    }
    echo "
    </tr>
  </table>
</div>

</body>

</html>";

} //Ende Action Abfrage
?>