<?php
$user_admin=$_COOKIE["user_admin"];
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_neubel'");
$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>>Student neu belegen</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\">Student neu belegen</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></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=beleg1"; 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;
                          </td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\"colspan=\"2\">&nbsp;</td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\" colspan=\"2\">
                          <p align=\"center\">
                          ";
                          $db = dbconnect();
                          $query = "SELECT uid, nachname, vorname, durchgefallen from stud order by nachname";
                          $result = $db->query ($query)
                             or die ("Cannot execute query");
                          echo "<select size=\"5\" name=\"studbe\">";
                          while ($row = $result->fetch_array()){
                          echo "
                          <option value=\"".$row[0]."\">
                          ".$row['nachname'].",&nbsp;"
                           .$row['vorname']."";
                          IF ($row[durchgefallen] == "Y")
                            echo " *";

                          echo "
                           &nbsp;&nbsp;</option>\n";
                          }
                          echo "</select>
                          </td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          &nbsp;</td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          <input type=\"submit\" value=\"Assistent starten\" name=\"B1\"></td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          &nbsp;</td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          * = ausgeschieden
                          </td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"100%\" colspan=\"4\" align=\"center\">
                          <br>
                          Ist ein Student nicht im System vorhanden kann er &uuml;ber das Modul <br><a href=registrierung.php>Student anlegen</a><br>erfasst werden!
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">&nbsp;</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 "beleg1":
setcookie("ck_studbe","");
setcookie("ck_studbe",$_POST[studbe]);

$db = dbconnect();
$bearb_stud = $db->query ("SELECT uid, nachname, vorname, mtknr, stg, poplz, poOrt, poStrasse, AG, Jahrgang, Pwd, Mail, durchgefallen 
                              FROM stud
                             WHERE uid=\"". $_POST['studbe']."\"");
$stud = $bearb_stud->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>>Student bearbeiten</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\">Student neu belegen</font><br>
                    <font class=\"sh\">Passen sie die aktiven Felder ggf. an</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></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=beleg2"; echo" method=\"POST\" name=\"beleg\">
                      <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"246\">
                        <tr>
                          <td width=\"40%\">
                          <b>Vorname:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"vorname\"  value=\"$stud[vorname]\"size=\"40\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Nachname:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"nachname\"  value=\"$stud[nachname]\" size=\"40\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Stra&szlig;e:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"strasse\" value=\"$stud[poStrasse]\" size=\"40\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>PLZ:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"plz\"  value=\"$stud[poplz]\" size=\"5\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Ort:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"ort\" value=\"$stud[poOrt]\" size=\"40\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\" valign=\"top\">
                          <b>Studienzweig*:</b><br>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <select size=\"5\" name=\"zweig\">
                            <option value=\"F\""; if ($stud[stg] == 'F'){echo " selected";} echo ">Finanzverwaltung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"R\""; if ($stud[stg] == 'R'){echo " selected";} echo ">Rentenversicherung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"I\""; if ($stud[stg] == 'I'){echo " selected";} echo ">Innenverwaltung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"S\""; if ($stud[stg] == 'S'){echo " selected";} echo ">Steuerverwaltung &nbsp;&nbsp;&nbsp;</option>
                          </select>
                          </td>
                        </tr>
                        <tr>
                          <tr>
                          <td width=\"40%\">
                          <b>AG neu:</b>
                          </td>
                          <td width=\"60%\">
                            <input type=\"text\" name=\"ag\" value=\"$stud[AG]\" size=\"1\"> / 
                            <input type=\"text\" name=\"jahr\" value=\"$stud[Jahrgang]\" size=\"2\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Matrikelnr.:</b>
                          </td>
                          <td width=\"60%\">
                            <input type=\"text\" name=\"mtknr\" value=\"$stud[mtknr]\" size=\"6\" disabled>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Benutzerkennung:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"ort\" value=\"$stud[uid]\" size=\"40\" disabled>
                          </td>
                        </tr>
                        <tr>
                            <td>
                            <b>E-Mail Adresse:</b>
                            </td>
                            <td>
                            <input type=\"text\" name=\"mail\" value=\"$stud[Mail]\"size=\"40\">
                            </td>
                          </tr>
                          <tr>
                            <td>
                            <b>Ausgeschieden:</b>
                            </td>
                            <td>
		              <input type=\"text\" name=\"ort\" value=\"N\" size=\"1\" disabled> wird automatisch auf Nein gesetzt
                            </td>
                          </tr>
                      </table>
                      <br>
                      <br>
                        <input type=\"submit\" value=\"Weiter\" name=\"B1\">
                    </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 "beleg2":

if ($_POST[zweig] ==  "" or $_POST[ag] ==  "" or $_POST[jahr] == ""  or $_POST[mail] ==  "" ){
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>Eingabefehler</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\">Eingabefehler</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\"><b>Es m&uuml;ssen mindestens die Pflichtfelder ausgef&uuml;llt werden!</b>

                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>

                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>

                    </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>";
exit;
} // Ende If


if ($_POST['zweig']== 'F'){ $stgtext ='Finanzverwaltung';}
if ($_POST['zweig']== 'R'){ $stgtext ='Rentenversicherung';}
if ($_POST['zweig']== 'I'){ $stgtext ='Innenverwaltung';}
if ($_POST['zweig']== 'S'){ $stgtext ='Steuerverwaltung';}


$db = dbconnect();


$uid = $_COOKIE["ck_studbe"]; //Cookie in Variable schreiben
$jahr_neu = $_POST[jahr];
$stg = $_POST[zweig];

$sql = $db->query ("UPDATE stud SET
                              stg='$stg'
                            , stgtext='$stgtext'
                            , AG=\"". $_POST['ag']."\"
                            , Jahrgang='$jahr_neu'
                            , Mail=\"". $_POST['mail']."\"
                            , durchgefallen='N'
                        WHERE uid=\"$uid\"");




if (!$sql)
{
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>Aktualisierung fehlgeschlagen</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\">Aktualisierung fehlgeschlagen</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\"><b>Die &Auml;nderungen konnten nicht gespeichert werdeb!</b>

                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>

                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>

                    </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>";
exit;
}

########################### AUSWAHL DER PASSENDEN WPF DES NEUEN JAHRGANGS ###########################

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>Auswahl des neuen Soziale Kompetenze</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\">Auswahl des neuen Soziale Kompetenzs f&uuml;r den Jahrgang $jahr_neu</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></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=beleg3"; echo" method=\"POST\" name=\"auswahl\">
                    <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
                    <tr>
                      <td width=\"5%\">
                      <p align=\"center\"><b>
                      Nr.</b></p>
                      </td>
                      <td width=\"75%\">
                      <p style=\"margin-left: 6; margin-top:4; margin-bottom:4\"><b>Bezeichnung</b></p>
                      </td>
                      <td width=\"10%\" align=\"center\" height=\"18\">
                      <b>Teilnahme<br>Ist / Max</b></p>
                      </td>
                      <td width=\"10%\" align=\"center\">
                      <b>Auswahl</b></p>
                      </td>";
                        $db = dbconnect();

                        $query = "SELECT id, FPRNr, Bezeichnung, TN_max 
                                    FROM sozkom_kompetenz
                                   WHERE Jahr='$jahr_neu' 
                                     AND Zweig LIKE '%$stg%' 
                                   ORDER BY FPRNr asc";

                        $result = $db->query($query)
                        or die ("Cannot execute query");
                        while ($row = $result->fetch_array())
                        {
                            echo "
                                </tr>
                                <tr>
                                  <td width=\"5%\" valign=\"middle\" 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\">
                                    $row[FPRNr]
                                  </td>
                                  <td width=\"75%\" 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 width=\"10%\" 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 ( $res=$db->query("SELECT count(sozkom_wunsch.uid) from sozkom_wunsch left join stud using (uid) where sozkom_wunsch.id=$row[id] and sozkom_wunsch.Prioritaet=\"0\" and stud.durchgefallen !=\"Y\" order by sozkom_wunsch.uid") ){
                                    if ( $row1=$res->fetch_array() ) {
                                    $result1=$row1[0];
                                    } else $result1=0;
                                    } else $result1=0;
                                    
                                    echo "
                                    $result1 / $row[TN_max]
                                  </td>
                                  <td width=\"10%\" 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\">
                                    <input type=\"radio\" value=\"$row[id]\" name=\"FPRNr_Prio0\">
                                  </td>
                                </tr>";
                        }
                    echo "
                    </table>
                    <br>
                    <br>
                      <input type=\"submit\" value=\"Weiter\">
                      </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 "beleg3":

$Prio0 = $_POST[FPRNr_Prio0];

if($Prio0 == "")
{
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>keine Auswahl</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\">keine Auswahl</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\"><b>Sie m&ouml;ssen eine Auswahl treffen!</b>

                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>

                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>

                    </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>";
exit;
}

$uid = $_COOKIE["ck_studbe"];

$sql1 = $db->query("DELETE 
                      FROM sozkom_wunsch
                     WHERE prioritaet = '0'
                       AND uid='$uid'");
                     
$sql2 = $db->query("INSERT INTO sozkom_wunsch (UID, ID, PRIORITAET) VALUES ('$uid', '$Prio0', '0')");

$res = $db->query("SELECT vorname, nachname, ag, jahrgang, FPRNr, Bezeichnung
                      FROM stud, sozkom_wunsch, sozkom_kompetenz
                     WHERE stud.uid = sozkom_wunsch.uid
                       AND sozkom_wunsch.id = sozkom_kompetenz.id
                       AND sozkom_wunsch.prioritaet = 0
                       AND stud.uid='$uid'");
$row = $res->fetch_array();

if (!$sql1 or !$sql2)
{
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>keine Aktualisierung</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\">keine Aktualisierung</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\"><b>Es trat ein interner Fehler auf!</b>

                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </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>";
exit;
}

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>Auswahl des neuen Soziale Kompetenzs</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=\"40%\" 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\">Auswahl des neuen Wahlpflichtfaches</font><br>
                    <font class=\"sh\">F&uuml;r $row[vorname] $row[nachname]</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></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\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\">
                        <p>
                        <br>
                        <tr>
                          <td width=\"15%\" align='center'>
                            <b>FPRNr</b>
                          </td>
                          <td width=\"15%\">
                          </td>
                          <td width=\"70%\">
                            <b>Bezeichnung</b>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"15%\" align='center'>
                            <br>$row[FPRNr]
                          </td>
                          <td width=\"15%\">
                          </td>
                          <td width=\"70%\">
                            <br>$row[Bezeichnung]
                          </td>
                        </tr>
                        
                    </table>
                    <br>
                    <br>
                      <p align=\"center\"><a href=\"hauptframe_jahr.php\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </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>";



} // Ende Action script
?>