<?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 stan_admin_rechte, stan_admin_rechte_zuord , stan_admin where stan_admin_rechte.stan_admin_rolle = stan_admin_rechte_zuord.stan_admin_rolle AND stan_admin_rechte_zuord.said = stan_admin.said AND stan_admin.user = '$user_admin' AND stan_admin_rechte_zuord.stan_admin_rolle = 'a_pulist'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende

 
$sort = $_GET["sort"];

if(!isset($sort)){
 $sort = "nachname";
}


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 zugewiesene PU-Standorte $stud_jahr[Jahrgang]</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"90%\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" 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 zugewiesene PU-Standorte Studienjahrgang $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=\"30%\" 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\">
                  ";
                  if($sort == 'nachname'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=nachname><b>Name, Vorname</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=nachname>Name, Vorname</a></font>";
                  }
                  echo"
                </td>
                <td width=\"30%\" 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\">
                  ";
                  if($sort == 'poStrasse'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poStrasse><b>Straße</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poStrasse>Straße</a></font>";
                  }
                  echo"
                </td>
                <td width=\"5%\" 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\">
                  ";
                  if($sort == 'poplz'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poplz><b>PLZ</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poplz>PLZ</a></font>";
                  }
                  echo"
                </td>
                <td width=\"15%\" 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\">
                  ";
                  if($sort == 'poOrt'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poOrt><b>Ort</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=poOrt>Ort</a></font>";
                  }
                  echo"
                </td>
                <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\">
                  ";
                  if($sort == 'geburtstag'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=geburtstag><b>Geburtstag</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=geburtstag>Geburtstag</a></font>";
                  }
                  echo"
                </td>
                <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\">
                  ";
                  if($sort == 'geburtsort'){
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=geburtsort><b>Geburtsort</b></a></font>";
                  }else{
                    echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=geburtsort>Geburtsort</a></font>";
                  }
                  echo"
                </td>
                <td width=\"8%\" 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\">
                ";
                if($sort == 'ag'){
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=ag><b>AG</b></a></font>";
                }else{
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=ag>AG</a></font>";
                }
                echo"
                </td>
                <td width=\"8%\" 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\">
                ";
                if($sort == 'stg'){
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=stg><b>Zweig</b></a></font>";
                }else{
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=stg>Zweig</a></font>";
                }
                echo"
                </td>
                <td width=\"30%\" align=\"left\" 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\">
                ";
                if($sort == 'bezeichnung'){
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=bezeichnung><b>PU-Ort</b></a></font>";
                }else{
                  echo"<font size=\"2\"><a href=$_SERVER[PHP_SELF]?sort=bezeichnung>PU-Ort</a></font>";
                }
                echo"
                </td>
              </tr>";


                $db = dbconnect();
                $query = "SELECT a.uid, a.nachname, a.vorname, a.ag, a.jahrgang, a.stg,poOrt, poplz, poStrasse, Date_format(a.geburtstag, '%d.%m.%Y') geb_form, a.geburtstag, a.geburtsort, b.bezeichnung
                            FROM stud a, stan_pu_standorte b, stan_pu_wunsch c
                           WHERE a.uid = c.uid
                             AND b.pusoid = c.ort 
                             AND c.prioritaet = '0' 
                             AND a.jahrgang='$jahrgang'
                             AND a.durchgefallen='N'
                           ORDER BY $sort, nachname";
                $result = $db->query($query)
                       or die ("Cannot execute query");
               while ($row = $result->fetch_array()){

                echo "
              <tr>
                <td width=\"30%\" 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=\"30%\" 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[poStrasse]</font>
                </td>
                <td width=\"5%\" 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[poplz]</font>
                </td>
                <td width=\"15%\" 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[poOrt]</font>
                </td>
                <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\">
                <font size=\"2\">$row[geb_form]</font>
                </td>
                <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\">
                <font size=\"2\">$row[geburtsort]</font>
                </td>
                <td width=\"8%\" 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=\"8%\" 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=\"30%\" align=\"left\" 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[bezeichnung]</font></td>
              </tr>";
                   }

            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>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
?>