<?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_liste'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende


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 Proseminare des Studienjahrgangs $stud_jahr[Jahrgang]</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"614\" 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\">&Uuml;bersicht &uuml;ber die Proseminare des Studienjahrgangs $jahrgang</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>
            <table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\">
              <tr>
                <td width=\"384\" 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><font size=\"2\">Name, Vorname</font></b>
                </td>
                <td width=\"75\" 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\">
                <b><font size=\"2\">AG</font></b></td>
                <td width=\"76\" 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\">
                <b><font size=\"2\">Zweig</font></b></td>
                <td width=\"76\" 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\">
                <b><font size=\"2\">FPRNr</font></b></td>
              </tr>";


                $db = dbconnect();
                $query = "SELECT stud.nachname, stud.vorname, stud.ag, stud.jahrgang, stud.stg, pros_proseminar.FPRNr FROM stud, pros_proseminar, pros_wunsch WHERE stud.uid = pros_wunsch.uid AND pros_wunsch.id = pros_proseminar.id AND pros_wunsch.prioritaet = \"0\" and pros_proseminar.jahr=\"$jahrgang\" and stud.durchgefallen != 'Y' ORDER  BY stud.nachname";
                $result = $db->query($query)
                       or die ("Cannot execute query");
               while ($row = $result->fetch_array()){

                echo "
              <tr>
                <td width=\"384\" 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\">
                <font size=\"2\">$row[nachname], $row[vorname]</font>
                </td>
                <td width=\"75\" 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\">
                <font size=\"2\">$row[ag]/$row[jahrgang]</font></td>
                <td width=\"76\" 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\">
                <font size=\"2\">$row[stg]</font></td>
                <td width=\"76\" 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\">
                <font size=\"2\">$row[FPRNr]</font></td>
              </tr>";
                   }

            if ( $res1=$db->query("select count(stg) from stud left join pros_wunsch using (uid) where (stud.stg='I' OR stud.stg='V' OR stud.stg='W') and stud.uid=pros_wunsch.uid and pros_wunsch.prioritaet=0 and stud.jahrgang=$jahrgang and stud.durchgefallen!='Y'") ){
            if ( $row1=$res1->fetch_array() ) {
            $result1=$row1[0];
            } else $result1=0;
            } else $result1=0;


            if ( $res3=$db->query("select count(stg) from stud left join pros_wunsch using (uid) where stud.stg=\"F\" and stud.uid=pros_wunsch.uid and pros_wunsch.prioritaet=0 and stud.jahrgang=$jahrgang and stud.durchgefallen!='Y'") ){
            if ( $row3=$res3->fetch_array() ) {
            $result3=$row3[0];
            } else $result3=0;
            } else $result3=0;

            if ( $res4=$db->query("select count(stg) from stud left join pros_wunsch using (uid) where stud.stg=\"R\" and stud.uid=pros_wunsch.uid and pros_wunsch.prioritaet=0 and stud.jahrgang=$jahrgang and stud.durchgefallen!='Y'") ){
            if ( $row4=$res4->fetch_array() ) {
            $result4=$row4[0];
            } else $result4=0;
            } else $result4=0;

            if ( $res5=$db->query("select count(stg) from stud left join pros_wunsch using (uid) where stud.stg=\"S\" and stud.uid=pros_wunsch.uid and pros_wunsch.prioritaet=0 and stud.jahrgang=$jahrgang and stud.durchgefallen!='Y'") ){
            if ( $row5=$res5->fetch_array() ) {
            $result5=$row5[0];
            } else $result5=0;
            } else $result5=0;



            echo "
              </table>
                     </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>
<br>
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"614\" 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\">Summen der Studienzweige</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>
             <table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\">
                <tr>
                    <td width=\"382\" 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\">
                    <font  size=\"2\">Innenverwaltung</font>
                    </td>
                    <td width=\"115\" 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\">
                    <font size=\"2\">$result1</font>
                    </td>
                    <td width=\"115\" 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\">
                    <font size=\"2\"></font>
                    </td>
                </tr>
                <tr>
                    <td width=\"382\" 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\">
                    <font  size=\"2\">Finanzverwaltung</font>
                    </td>
                    <td width=\"115\" 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\">
                    <font  size=\"2\">$result3</font>
                    </td>
                    <td width=\"115\" 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\">
                    &nbsp;
                    </td>
                </tr>
                <tr>
                    <td width=\"382\" 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\">
                    <font  size=\"2\">Rentenversicherung</font>
                    </td>
                    <td width=\"115\" 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\">
                    <font  size=\"2\">$result4</font>
                    </td>
                    <td width=\"115\" 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\">
                    &nbsp;
                    </td>
                </tr>
                </table>
                     </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>";
?>