<?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 sozkom_admin_rechte, sozkom_admin_rechte_zuord , sozkom_admin where sozkom_admin_rechte.sozkom_admin_rolle = sozkom_admin_rechte_zuord.sozkom_admin_rolle AND sozkom_admin_rechte_zuord.faid = sozkom_admin.faid AND sozkom_admin.user = '$user_admin' AND sozkom_admin_rechte_zuord.sozkom_admin_rolle = 'a_uebersp'");
$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 Soziale Kompetenze des Studienjahrgangs $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=\"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 die Soziale Kompetenzen 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=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"90%\" id=\"AutoNumber1\">
                    <tr>
                    <td width=\"5%\">
                    <p align=\"center\"><b>Nr.</b></p>
                    </td>
                    <td width=\"45%\">
                    <b>Bezeichnung</b>
                    </td>
                    <td width=\"10%\">
                    <p align=\"left\"><b>Prio 0 (admin)</b>
                    </td>
                    <td width=\"10%\">
                    <p align=\"left\"><b>Prio 1</b></p>
                    </td>
                    <td width=\"10%\">
                    <p align=\"left\"><b>Prio 2</b></p>
                    </td>
                    <td width=\"10%\">
                    <p align=\"left\"><b>Prio 3</b></p>
                    </td>
                    <td width=\"10%\">
                    <p align=\"left\"><b>Prio 4</b></p>
                    </td>
                    </tr>";
    $db = dbconnect();
//    $query = "SELECT id, FPRNr, Bezeichnung, TN_max, bemerkung FROM sozkom_kompetenz where order by FPRNr asc";
  $query = "SELECT id, FPRNr, Bezeichnung, TN_max, bemerkung FROM sozkom_kompetenz where Jahr=\"$jahrgang\" order by FPRNr asc";
    $result = $db->query($query)
           or die ("Cannot execute query");
   while ($row = $result->fetch_array()){
   echo "
                        <tr>
                      <td valign=\"top\" 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\">
                      <p align=\"center\">
                      $row[FPRNr]</p>
                      </td>
                      <td valign=\"top\" width=\"45%\" 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\">
                      $row[Bezeichnung]<br>
                      <span class=\"bemerkung\">$row[bemerkung]</span>
                      </td>
                      <td valign=\"top\" width=\"10%\" 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=\"left\">";
                        $query0 = "SELECT vorname, nachname 
                                     FROM stud, sozkom_wunsch
                                    WHERE stud.uid = sozkom_wunsch.uid
                                      AND sozkom_wunsch.id = $row[id]
                                      AND sozkom_wunsch.prioritaet =0
                                    ORDER BY nachname ASC";
                        $result0 = $db->query($query0)
		                 or die ("Cannot execute query");
                        while ($row0 = $result0->fetch_array()){
                         echo "$row0[vorname]&nbsp;$row0[nachname]<br>";
                        }
                      echo"
                      </td>
                      <td valign=\"top\" width=\"10%\" 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=\"left\">";
                        $query0 = "SELECT vorname, nachname 
                                     FROM stud, sozkom_wunsch
                                    WHERE stud.uid = sozkom_wunsch.uid
                                      AND sozkom_wunsch.id = $row[id]
                                      AND sozkom_wunsch.prioritaet =1
                                    ORDER BY nachname ASC";
                        $result0 = $db->query($query0)
		                 or die ("Cannot execute query");
                        while ($row0 = $result0->fetch_array()){
                         echo "$row0[vorname]&nbsp;$row0[nachname]<br>";
                        }
                      echo"
                      </td>
                      <td valign=\"top\" width=\"10%\" 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=\"left\">";
                        $query0 = "SELECT vorname, nachname 
                                     FROM stud, sozkom_wunsch
                                    WHERE stud.uid = sozkom_wunsch.uid
                                      AND sozkom_wunsch.id = $row[id]
                                      AND sozkom_wunsch.prioritaet =2
                                    ORDER BY nachname ASC";
                        $result0 = $db->query($query0)
		                 or die ("Cannot execute query");
                        while ($row0 = $result0->fetch_array()){
                         echo "$row0[vorname]&nbsp;$row0[nachname]<br>";
                        }
                      echo"
                      </td>
                      <td valign=\"top\" width=\"10%\" 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=\"left\">";
                        $query0 = "SELECT vorname, nachname 
                                     FROM stud, sozkom_wunsch
                                    WHERE stud.uid = sozkom_wunsch.uid
                                      AND sozkom_wunsch.id = $row[id]
                                      AND sozkom_wunsch.prioritaet =3
                                    ORDER BY nachname ASC";
                        $result0 = $db->query($query0)
		                 or die ("Cannot execute query");
                        while ($row0 = $result0->fetch_array()){
                         echo "$row0[vorname]&nbsp;$row0[nachname]<br>";
                        }
                      echo"
                      </td>
                      <td valign=\"top\" width=\"10%\" 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=\"left\">";
                        $query0 = "SELECT vorname, nachname 
                                     FROM stud, sozkom_wunsch
                                    WHERE stud.uid = sozkom_wunsch.uid
                                      AND sozkom_wunsch.id = $row[id]
                                      AND sozkom_wunsch.prioritaet =4
                                    ORDER BY nachname ASC";
                        $result0 = $db->query($query0)
		                 or die ("Cannot execute query");
                        while ($row0 = $result0->fetch_array()){
                         echo "$row0[vorname]&nbsp;$row0[nachname]<br>";
                        }
                      echo"
                      </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>
        </div>
        </td>
    </tr>
</table>

</body>

</html>";
?>
