<?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
require("FCKeditor/fckeditor.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 skik_admin_rechte, skik_admin_rechte_zuord , skik_admin where skik_admin_rechte.skik_admin_rolle = skik_admin_rechte_zuord.skik_admin_rolle AND skik_admin_rechte_zuord.faid = skik_admin.faid AND skik_admin.user = '$user_admin' AND skik_admin_rechte_zuord.skik_admin_rolle = 'a_prsbearb'");
$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>Sprachkurse / Interkulturelle Kompetenzen 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=\"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\">SK/IK bearbeiten</font><br>
                    <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=bearbeiten"; echo" method=\"POST\" name=\"PSN_bearb\">
                    <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>Nr.</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 skik_kurs 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(skik_wunsch.uid) from skik_wunsch left join stud using (uid) where skik_wunsch.id=$row[id] and skik_wunsch.Prioritaet=\"0\" and stud.durchgefallen !=\"Y\" order by skik_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=\"aus_bearb\" 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 "bearbeiten":

$db = dbconnect();
$sel_pros = $db->query("SELECT * FROM skik_kurs where id='$_POST[aus_bearb]'");
$pros = $sel_pros->fetch_array();
setcookie("ck_prosbearbeiten", $_POST[aus_bearb]);
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>SK/IK bearbeiten</title>
</head>
<body onload=\"if(document.skik_erf)document.skik_erf.FPR_Nr.focus();return false;\">
<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=\"650\" 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\">SK/IK bearbeiten</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=bearbeiten1"; echo" method=\"POST\" name=\"skik_erf\">
                      <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-width:0; border-collapse: collapse\" bordercolor=\"#111111\" width=\"102%\" id=\"AutoNumber1\" height=\"18\">
                        <tr>
                          <td width=\"40%\">
                          <b>PSN Nr*:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='FPR_Nr' value='$pros[FPRNr]' size=\"3\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Bezeichnung*:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='Bezeichnung' value='$pros[Bezeichnung]' size=\"40\">
                          </td>
                        </tr>

                        <tr>
                          <td width=\"40%\">
                          <b>Ansprechpartner:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='Ansprechpartner' value='$pros[Ansprechpart]' size=\"40\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">

                          <b>Minimale Teilnehmer:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='min_t' value='$pros[TN_min]' size=\"2\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Maximale Teilnehmer*:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='max_t' value='$pros[TN_max]'  size=\"2\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Jahrgang*:</b>
                          <font size=\"1\">(z.B. 03)</font>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='jahr' value='$pros[Jahr]' size=\"2\"><font size=\"1\"> 2-stellige Jahresangabe!</font>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\" valign=\"top\">
                          <b>zugelassene Zweige*:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"checkbox\"";
                          $db = dbconnect();
						  $result1 = $db->query("SELECT id, zweig FROM skik_kurs where zweig like \"%I%\" and id=\"". $_POST['aus_bearb']."\"");
						  $row1 = $result1->fetch_array();
                          if ($row1[0] >= 1) echo " checked";  echo "
                          name=\"I\" value=\"I\"> Innenverwaltung</td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          &nbsp;</td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"checkbox\"";
                          $db = dbconnect();
						  $result3 = $db->query("SELECT id, zweig FROM skik_kurs where zweig like \"%R%\" and id=\"". $_POST['aus_bearb']."\"");
						  $row3 = $result3->fetch_array();
                          if ($row3[0] >= 1) echo " checked";  echo "
                          name=\"R\" value=\"R\"> Rentenversicherung</td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          &nbsp;</td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"checkbox\"";
                          $db = dbconnect();
						  $result4 = $db->query("SELECT id, zweig FROM skik_kurs where zweig like \"%F%\" and id=\"". $_POST['aus_bearb']."\"");
						  $row4 = $result4->fetch_array();
                          if ($row4[0] >= 1) echo " checked";  echo "
                          name=\"F\" value=\"F\"> Allgemeine Finanzverwaltung</td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          &nbsp;</td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"checkbox\"";
                          $db = dbconnect();
						  $result5 = $db->query("SELECT id, zweig FROM skik_kurs where zweig like \"%S%\" and id=\"". $_POST['aus_bearb']."\"");
						  $row5 = $result5->fetch_array();
                          if ($row5[0] >= 1) echo " checked";  echo "
                          name=\"S\" value=\"S\"> Steuerverwaltung</td>
                        </tr>
                        <tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Art*:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                           <label for=\"r1\"><input type=\"radio\" id='r1' name=\"art\"";if($pros[art] == 'SK'){echo " checked ";} echo" value='SK' size=\"55\"> Sprachkurs</label><br>
                           <label for=\"r2\"><input type=\"radio\" id='r2' name=\"art\"";if($pros[art] == 'IK'){echo " checked ";} echo" value='IK' size=\"55\"> Interkulturelle Kompetenzen</label><br>
                          </td>
                        </tr>
                        <tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Niveau (* bei Sprachkursen):</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          ";
                          $db = dbconnect();
                          $result5a = $db->query("SELECT niveau FROM skik_kurs where id=\"". $_POST['aus_bearb']."\"");
			  $row5a = $result5a->fetch_array()
                             or die ("Cannot execute query");
                          echo "<select size=\"4\" name=\"niveau\">"; // In Dozent[] werden die ausgew&auml;hlen Values gespeichert: Bsp. [1], [3], [4]
                          echo "<option value='A2 - B1'";if ($row5a['niveau'] == 'A2 - B1') echo " selected";  echo ">A2 - B1&nbsp;&nbsp;&nbsp;</option>\n";
                          echo "<option value='B1 - B2'";if ($row5a['niveau'] == 'B1 - B2') echo " selected";  echo ">B1 - B2&nbsp;&nbsp;&nbsp;</option>\n";
                          echo "<option value='B2 - C1'";if ($row5a['niveau'] == 'B2 - C1') echo " selected";  echo ">B2 - C1&nbsp;&nbsp;&nbsp;</option>\n";
                          echo "<option value='C1 - C2'";if ($row5a['niveau'] == 'C1 - C2') echo " selected";  echo ">C1 - C2&nbsp;&nbsp;&nbsp;</option>\n";
                          echo "</select>";
                          echo "

                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Anzahl der Gruppen:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                           <input type=\"text\" name='gruppen' value='$pros[gruppen]' size=\"55\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\" valign=\"top\">
                          <b>Dozent*:</b><br>
                          <font size=\"1\">(Strg-Taste f&uuml;r Mehrfachauswahl)</font>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          ";
                          $db = dbconnect();
                                $query = "SELECT doz_nr, doz_name, doz_vorname, doz_titel FROM doz order by doz_name";
                          $result = $db->query ($query)
                             or die ("Cannot execute query");
                          echo "<select size=\"4\" name=\"Dozent[]\" multiple>"; // In Dozent[] werden die ausgew&auml;hlen Values gespeichert: Bsp. [1], [3], [4]
                          while ($row = $result->fetch_array()){

                          		$result4 = $db->query("SELECT doz_nr FROM skik_doz where doz_nr=\"$row[doz_nr]\" and id=\"". $_POST['aus_bearb']."\"");
						  		$row4 = $result4->fetch_array();

                          echo "<option value=\"".$row['doz_nr']."\"";
                          if ($row[0] == $row4[0]) echo " selected";  echo ">
                          ".$row['doz_name'].",&nbsp;".$row['doz_vorname'].",&nbsp;&nbsp;&nbsp;".$row['doz_titel']."&nbsp;&nbsp;&nbsp;</option>\n";
                          }
                          echo "</select>";
                          echo "
                          </select><br>
                          <a href=\"doz_anleg.php\">Dozent erfassen</a>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\" valign='top'>
                          <b>Termine / Zeitraum:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <input type=\"text\" name='termine' value='$pros[termine]' size=\"55\"><br>";
                          if($pros['termin_ausserhalb'] == 'X'){
                            $status= 'checked';
                          }
                          
                          if($pros['reisekosten'] == 'X'){
                            $status1= 'checked';
                          }
                          echo"
                          <table>
                          <tr>
                            <td><input type=\"checkbox\" name=\"termin_ausserhalb\" $status value=\"X\"></td><td>Die Veranstaltungstermine werden möglicherweise außerhalb der Hochschule Ludwigsburg stattfinden.</td>
                           </tr>
                          <tr>
                            <td><input type=\"checkbox\" name=\"reisekosten\" $status1 value=\"X\"></td><td>Reisekosten können erstattet werden.</td>
                           </tr>
                           </table>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Inhaltsbeschreibung:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">";
                          $oFCKeditor = new FCKeditor('kurzbeschreibung') ;
			  $oFCKeditor->BasePath = './FCKeditor/';
			  #$oFCKeditor->Value = 'Default text in editor';
			  $oFCKeditor->ToolbarSet = 'Basic';
			  $oFCKeditor->Value = $pros['beschreibung'];
			  $oFCKeditor->Width  = '100%' ;
			  $oFCKeditor->Height = '150' ;
			  $oFCKeditor->Create() ;
                          echo"
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Bemerkung:</b>
                          </td>
                          <td width=\"60%\" align=\"left\">
                           <input type=\"text\" name='bemerkung' value='$pros[bemerkung]' size=\"55\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          * = Pflichtfelder
                          </td>
                          <td width=\"60%\" align=\"left\">
                          &nbsp;
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          &nbsp;
                          </td>
                          <td width=\"60%\" align=\"left\">
                          &nbsp;
                          </td>
                        </tr>
                      </table>
                    &nbsp; <input type=\"submit\" value=\"Abschicken\" name=\"B1\">
                      <input type=\"reset\" value=\"Zur&uuml;cksetzen\" name=\"B2\"></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 "bearbeiten1":
if ($_POST[I] == "" and $_POST[R] == "" and $_POST[F] == "" and $_POST[S] == ""){    // mind. 1 Zweig muss angegeben werden. Getrennt durch and
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 muss mindestens 1 Zweig ausgef&uuml;llt werden</b>
                    </p>
                    <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>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </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;
}


if ($_POST[FPR_Nr] == ""or $_POST[Bezeichnung] == "" or $_POST[art] == "" or $_POST[max_t] == "" or $_POST[Dozent] == "" or $_POST[jahr] == ""){
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>Die Pflichtfelder m&uuml;ssen mindestens ausgef&uuml;llt werden</b>
                    </p>
                    <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>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </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 wenn Pflichtfelder nicht ausgef&uuml;llt wurden


if ($_POST[art] == "SK" AND $_POST[niveau] == ""){
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>Das Niveau bei Sprachkursen darf nicht leer sein!</b>
                    </p>
                    <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>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </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 wenn Pflichtfelder nicht ausgef&uuml;llt wurden




$db = dbconnect();
$ck_prosbearbeiten = $_COOKIE["ck_prosbearbeiten"];

$gruppen = $_POST['gruppen'];
$kurzbeschreibung = mysqli_escape_string($db,stripslashes( $_POST['kurzbeschreibung'] ));
$termine = $_POST['termine'];
$termin_ausserhalb = $_POST['termin_ausserhalb'];
$reisekosten = $_POST['reisekosten'];
$zweig = "$_POST[I]$_POST[R]$_POST[F]$_POST[S]";
$art = $_POST['art'];
$niveau = $_POST['niveau'];

$sql1 = "UPDATE skik_kurs 
            SET FPRNr = '$_POST[FPR_Nr]'
               ,Bezeichnung = '$_POST[Bezeichnung]'
               ,Ansprechpart = '$_POST[Ansprechpartner]'
               ,TN_min = '$_POST[min_t]'
               ,TN_max = '$_POST[max_t]'
               ,Jahr = '$_POST[jahr]'
               ,Zweig= '$zweig'
               ,gruppen = '$gruppen'
               ,niveau = '$niveau'
               ,beschreibung = '$kurzbeschreibung'
               ,termine = '$termine'
               ,termin_ausserhalb = '$termin_ausserhalb'
               ,reisekosten = '$reisekosten'
               ,bemerkung = '$_POST[bemerkung]'
               ,art = '$art'
          WHERE id = '$ck_prosbearbeiten'
        ";

$db->query($sql1);


$sql_del = $db->query("Delete from skik_doz where id = '$ck_prosbearbeiten'"); //vorhandene Dozenten in der Prosem.-Zuordnung l&ouml;schen


$sql_id = $db->query("select id from skik_kurs where FPRNr='$_POST[FPR_Nr]' and Jahr = '$_POST[jahr]'");
$id = $sql_id->fetch_array();


$Dozent = $_POST[Dozent]; // Vom Formular gesendetes Objekt in Variable schreiben

for ($i=0;$i<sizeof($Dozent);$i++) {  // Schleife, der die Dozenten aufaddiert bis alle ausgew&auml;hlen abgearbeitet sind.
     $sql = "INSERT INTO skik_doz ( id , doz_nr )VALUES ( '$id[id]', '$Dozent[$i]' )";
      $db->query($sql);
}

echo "
<meta http-equiv=\"refresh\" content=\"2; URL=skik_bearbeiten.php\">
<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</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</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>SK/IK wurde aktualisiert!</b>
                    </p>
                    <p></p>
                    <p><br>
                    </p>
                    </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>
";

} //Ende Action Abfrage
?>
