<?php
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php

$db = dbconnect();
$ansp = $db->query("SELECT wert1, wert2 FROM parameter WHERE pid='2'");
$uhd = $ansp->fetch_array();
$ansprechpart = "$uhd[wert1]"; // Ansprechpartner bei Probleme
$helpmail = "$uhd[wert2]";     // Kontaktmailadresse bei Problemen

if ($_COOKIE["uid1"] == ""){ include("kurs/anmeldefehler_subdir.php"); exit;} //Wenn man nicht angemeldet ist soll man nichts ausw&auml;hlen k&ouml;nnen
$uid1=$_COOKIE["uid1"];

require("check_zweig.php");                 // Prüft, ob Innenverwaltung angemeldet ist: setzt datenbankanbindung.php voraus
require("check_weitere_daten.php");
include("kurs/sta/stan_useronline_write.php");     // F&uuml;r Statistik, wieviele User online sind





// &Uuml;Berpr&uuml;fung, ob die Anmeldefrist &uuml;berschritten ist
$heute  = mktime(0, 0, 0, date("m"), date("d"), date("Y"));  // heutiges Datum
$heute_format = date("Y-m-d", $heute);  // ISO-8601 Format wie in der Datenbank: Formatierung f&uuml;r Vergleiche erforderlich

$res = $db->query("SELECT Jahrgang FROM stud WHERE uid=\"$uid1\"");
$stud_jahr = $res->fetch_array();

$anm_schluss = $db->query("SELECT DATE_Format(anmeldebeginn, '%Y-%m-%d')AS beginndatum, DATE_Format(anmeldebeginn, '%d.%m.%Y um %H:%i:%s Uhr')AS beginnform, DATE_Format(anmeldeschluss, '%Y-%m-%d')AS enddatum 
                              FROM stan_frist
                             WHERE jahrgang=\"$stud_jahr[Jahrgang]\"");
$row_schluss = $anm_schluss->fetch_array(); // Herausfinden des Beginn- Schlussdatums

$a = strtotime ($heute_format); //Umrechnung des Fristgrenztages in eine Zahl
$b = strtotime ($row_schluss[enddatum]); // Umrechnung des Enddatums in eine Zahl
$c = strtotime ($row_schluss[beginndatum]); // Umrechnung des Beginndatums in eine Zahl

if ($a < $c){
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>Anmeldungen noch nicht m&ouml;glich!</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\">Anmeldungen noch nicht m&ouml;glich!</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>Antr&auml;ge können erst ab $row_schluss[beginnform] bearbeitet werden!</b>
                    </p>
                    <p align=\"center\"><a href=\"hauptframe.php\">
                    <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 &Uuml;berpr&uuml;fung der Zeit&uuml;berschreitung

if ($a >= $b){
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>Anmeldezeit vertstrichen</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\">Anmeldezeit vertstrichen</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\">Antr&auml;ge können nicht mehr bearbeitet werden!<br>Es sind nur noch <a href=\"antrag_aend.php\">Änderungsanträge</a> möglich
                    </p>
                    <p align=\"center\"><a href=\"hauptframe.php\">
                    <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 &Uuml;berpr&uuml;fung der Zeit&uuml;berschreitung

#################



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>Anträge 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 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\">Anträge bearbeiten</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=\"100%\" id=\"AutoNumber1\">
                    <tr>
                    <td width=\"20%\">
                    <b>Bereich</b>
                    </td>
                    <td width=\"40%\">
                    <b>Ort</b>
                    </td>
                    <td width=\"30%\">
                    <b>Zeitraum</b>
                    </td>
                    <td width=\"5%\">
                    <p align=\"center\"><b>bearbeiten</b>
                    </td>
                    <td width=\"5%\">
                    <p align=\"center\"><b>l&ouml;schen</b></p>
                    </td>
                    </tr>";

                        
                    $db = dbconnect();
                                             
                                                                                                              
                    $query = "SELECT t1.saaid, t1.ort, DATE_Format(t1.beginn, '%d.%m.%Y') beginn
                                   , DATE_Format(t1.ende, '%d.%m.%Y') ende, DATE_Format(t1.beginn, '%Y%m%d') beginnform
                                   , stan_stellenbereiche.bezeichnung, t1.bearbeitung
                                FROM stan_antrag t1, stan_stellenbereiche
                               WHERE t1.status = (
                                                  SELECT MAX(t2.status)
                                                    FROM stan_antrag t2
                                                   WHERE t1.aendid = t2.aendid
                                                  )
                                 AND t1.uid = '$uid1'
                                 AND t1.status = '0'
                                 AND stan_stellenbereiche.sbid = t1.sachbereich
                                 AND (t1.zuweisung is NULL OR t1.zuweisung='Z')
                               ORDER BY beginnform ASC
                             ";
                             
                    $result = $db->query ($query)
                       or die ("Cannot execute query");
                    
                    while ($row = $result->fetch_array()){


                               echo "
                               <tr>
                                 <td width=\"20%\" 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>
                                 </td>
                                 <td width=\"40%\" 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[ort]
                                 </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\">
                                   $row[beginn] - $row[ende]
                                 </td>
                                 ";
                                 
                                 if($row[bearbeitung] == 'Y'){
                                 echo"
                                 <td valign=\"middle\" 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\">
                                 
                                       <a href=".$_SERVER['PHP_SELF'] ."?action=bearbeiten&ID=$row[saaid]>
	                               <img title = \"Antrag bearbeiten\"border=\"0\" src=\"../images/edit.png\"></a>
                                 </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\">
                                 <p align=\"center\" style=\"margin-top: 4; margin-bottom: 4\">
                                       <a href=".$_SERVER['PHP_SELF'] ."?action=del&ID=$row[saaid]>
                                       <img title = \"Antrag l&ouml;schen\"border=\"0\" src=\"../images/drop.png\"></a>
                                 </p>
                                 </td>";
                                 }else{
                                 echo"
                                 <td valign=\"middle\" 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\">
                                   <img title = \"Antrag bearbeiten nicht möglich\"border=\"0\" src=\"../images/edit_grey.png\">
                                 </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\">
                                 <p align=\"center\" style=\"margin-top: 4; margin-bottom: 4\">
                                   <img title = \"Antrag l&ouml;schen nicht möglich\"border=\"0\" src=\"../images/drop_grey.png\">
                                 </p>
                                 </td>";
                                 
                                 }
                               echo"
                               </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>";

break;
case "bearbeiten":


$staID = $_GET['ID'];
setcookie("ck_staID","");
setcookie("ck_staID",$staID);





$db = dbconnect();

$result = $db->query("SELECT nachname, vorname, jahrgang, stg FROM stud WHERE uid=\"$uid1\"");
$row = $result->fetch_array();

$anm_schluss = $db->query("SELECT DATE_Format(anmeldeschluss, '%d.%m.%Y um %H:%i:%s Uhr') anmeldeschluss
                              FROM stan_frist
                             WHERE jahrgang='$row[jahrgang]'");
$row_schluss = $anm_schluss->fetch_array(); // Auslesen des Datenbankdatum, um davon ein Tag abziehen zu k&ouml;nnen


$sperr_pu = $db->query("SELECT DATE_Format(beginn, '%d.%m.%Y') beginn, DATE_Format(ende, '%d.%m.%Y') ende
                           FROM stan_sperrzeit
                          WHERE kennung = '$row[stg]'
                            AND jahrgang='$row[jahrgang]'");
$row_sperrpu = $sperr_pu->fetch_array(); // Sperrzeiten PU

$sperr_ausl = $db->query("SELECT DATE_Format(beginn, '%d.%m.%Y') beginn, DATE_Format(ende, '%d.%m.%Y') ende
                           FROM stan_sperrzeit
                          WHERE kennung = 'A'
                            AND jahrgang='$row[jahrgang]'");
$row_sperrausl = $sperr_ausl->fetch_array(); // Sperrzeiten Auslandspraktikum

$result2 = $db->query("SELECT art
                             , bezeichnung
                             , bereich
                             , ansprechpartner 
                             , funktion 
                             , str 
                             , plz 
                             , ort
                             , zuw_bezeichnung
                             , zuw_ansprechpartner
                             , zuw_str
                             , zuw_plz
                             , zuw_ort
                             , land
                             , telefon 
                             , mail
                             , einver_dsts
                             , sachbereich 
                             , DATE_Format(beginn, '%d')AS beg_tag
                             , DATE_Format(beginn, '%m')AS beg_mon
                             , DATE_Format(beginn, '%Y')AS beg_jahr
                             , DATE_Format(ende, '%d')AS end_tag
                             , DATE_Format(ende, '%m')AS end_mon
                             , DATE_Format(ende, '%Y')AS end_jahr
                          FROM stan_antrag
                         WHERE saaid='$staID'");
$row3 = $result2->fetch_array();

echo "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
<link rel='stylesheet' href='../styles_pc.css' type='text/css'>
<style type='text/css'>
select{
	width:323px;
}
</style>
<title>weitere Daten</title>
<SCRIPT LANGUAGE=\"JavaScript\"><!--
function initForm()
 {
       // Wenn man mit history.back zur&uuml;ckgeht werden wurden die disabled Felder ignoriert, daher nochmals pr&uuml;fen,
       
       if(document.pers_daten.zuw_adr_chk.checked)
       {
          document.pers_daten.zuw_bezeichnung.disabled=true;
          document.pers_daten.zuw_ansppart.disabled=true;
          document.pers_daten.zuw_str.disabled=true;
	  document.pers_daten.zuw_plz.disabled=true;
          document.pers_daten.zuw_ort.disabled=true;
       }
       
 }
//-->
</SCRIPT>
</head>
<body onload=initForm()>
<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='80%' border='0'>
				<tr>
					<td nowrap='nowrap' align='left' width='1%' background='../images/box_e1a.gif'>
					<img height='16' src='../images/blank.gif' width='22'></td>
					<td nowrap='nowrap' align='left' width='98%' background='../images/box_top1.gif'>
					<img height='16' src='../images/blank.gif' width='8'></td>
					<td nowrap='nowrap' align='right' width='1%' background='../images/box_e2a.gif'>
					<img height='16' 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>
					<b>Sperrzeiten beachten!</b>
					<table>
					<tr>
					  <td>
					    <font color='red'>Praxisbegleitender Unterricht:</font>
					  </td>
					  <td>
					    <font color='red'><b>$row_sperrpu[beginn] - $row_sperrpu[ende]</b></font>
					  </td
					</tr>
					<tr>
					  <td>
					    <font color='red'>Auslandspraktikum:</font>
					  </td>
					  <td>
					    <font color='red'><b>$row_sperrausl[beginn] - $row_sperrausl[ende]</b></font>
					  </td
					</tr>
					
					";
					
					$db = dbconnect();
                                                                 
                                                                                                                                  
                                        $query = "SELECT t1.saaid
                                                       , t1.sachbereich
                                                       , t1.ort
                                                       , DATE_Format(t1.beginn, '%d.%m.%Y') beginn
                                                       , DATE_Format(t1.ende, '%d.%m.%Y') ende
                                                       , DATE_FORMAT(t1.beginn, '%Y%m%d') beginnform
                                                    FROM stan_antrag t1
                                                    WHERE t1.status = (
                                                                       SELECT MAX(t2.status)
                                                                         FROM stan_antrag t2
                                                                        WHERE t1.aendid = t2.aendid
                                                                       )
                                                     AND t1.uid = '$uid1'
                                                     AND (t1.zuweisung is NULL OR t1.zuweisung='Z')
                                                   ORDER BY beginnform ASC
                                                 ";
                                                 
                                        $result = $db->query ($query)
                                           or die ("Cannot execute query");
                                        
                                        while ($row2 = $result->fetch_array()){
                                        echo "<tr><td>$row2[ort]:</td><td><b>$row2[beginn] - $row2[ende]</b></td></tr>";
                                        }
					
					echo"
					</table>
					<td width='1%' background='../images/box_r.gif'>
					<img height='1' src='../images/blank.gif' width='22'></td>
					</font></span><br>

				</tr>
				<tr>
					<td nowrap='nowrap' align='left' width='1%' background='../images/box_e3.gif'>
					<img height='16' src='../images/blank.gif' width='22'></td>
					<td nowrap='nowrap' align='left' width='98%' background='../images/box_bottom.gif'>
					<img height='16' src='../images/blank.gif' width='8'></td>
					<td nowrap='nowrap' align='right' width='1%' background='../images/box_e4.gif'>
					<img height='16' src='../images/blank.gif' width='22'> </td>
				</tr>
			</table>
			<br>
			<table cellspacing='0' cellpadding='0' width='80%' 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\">Stellenantrag bearbeiten für $row[vorname] $row[nachname]</font><br>
                                        <span class='sh'>Anträge können bis zum <font color='red'><b>$row_schluss[0]</b></font> abgegeben werden</span>
                                        <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>
					                       <SCRIPT LANGUAGE=\"JavaScript\">
					                       function codename() {
					                       
					                       if(document.pers_daten.zuw_adr_chk.checked)
					                       {
					                          document.pers_daten.zuw_bezeichnung.disabled=true;
					                          document.pers_daten.zuw_ansppart.disabled=true;
					                          document.pers_daten.zuw_str.disabled=true;
					                          document.pers_daten.zuw_plz.disabled=true;
					                          document.pers_daten.zuw_ort.disabled=true;
					                         }
					                         else
					                         {
					                          document.pers_daten.zuw_bezeichnung.disabled=false;
					                          document.pers_daten.zuw_ansppart.disabled=false;
					                          document.pers_daten.zuw_str.disabled=false;
					                          document.pers_daten.zuw_plz.disabled=false;
					                          document.pers_daten.zuw_ort.disabled=false;
					                         }
					                       }
					                       //-->
					                       </SCRIPT>
					<form action="; echo $_SERVER['PHP_SELF'] . "?action=antrag"; echo" method=\"POST\" name=\"pers_daten\">
						<table border='0' cellpadding='0' cellspacing='0' style='border-width:0; border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber1' height='142'>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Art der Praxisstelle*:</b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <p><br>
								  ";
                                  
                                                                 $db = dbconnect();
                                                                 
                                                                                                                                  
                                                                 $query1 = "SELECT artid, bezeichnung
                                                                             FROM stan_stellenart
                                                                            ORDER BY bezeichnung ASC
                                                                          ";
                                                                          
                                                                 $result1 = $db->query ($query1)
                                                                    or die ("Cannot execute query");
                                                                 echo "<select size=\"5\" name=\"stellenart\">";
                                                                 while ($row1 = $result1->fetch_array()){
                                                                 echo "<option value='$row1[artid]'"; if($row1[artid] == $row3[art]){echo "selected";} echo">$row1[bezeichnung]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>\n";
                                                                 }
                                
                                                                 echo"
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b><u>1.) Praxisstelle (z.B. Jugendamt)</u><br><br>
								  Bezeichnung der Praxisstelle*:</b> 
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <p>
								  <br><br>
								  <input type='text' name='stellenbezeichnung' size='50' value='$row3[bezeichnung]'></p>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Bezeichnung des Bereichs bei der Praxisstelle*: </b> 
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <p>
								  <input type='text' name='bereich' size='50' value='$row3[bereich]'></p>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Name des Ansprechpartners bei der Praxisstelle*: </b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='ansprechpartner' size='50' value='$row3[ansprechpartner]'>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Funktion des Ansprechpartners bei der Praxisstelle*: </b>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='funktion_ansprechpartner' size='50' value='$row3[funktion]'>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Straße und Hausnummer der Praxisstelle*:</b>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='str' size='50' value='$row3[str]'>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>PLZ und Ort der Praxisstelle*:</b> 
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='plz' size='5' value='$row3[plz]'>&nbsp;
								  <input type='text' name='ort' size='40' value='$row3[ort]'></td>
							</tr>
							
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								   &nbsp;
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								   &nbsp;
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								 <b><u>2.) Versandadresse (z.B. Personalamt)</u>
								 <br>
							         Bitte bei Ihrer Praxisstelle erfragen!!<br><br>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								   &nbsp;
								</td>
							</tr>";
							if($row3[zuw_str] == $row3[str] AND $row3[zuw_plz] == $row3[plz] AND $row3[zuw_ort] == $row3[ort] AND $row3[zuw_ansprechpartner] == $row3[ansprechpartner] AND $row3[zuw_bezeichnung] == $row3[bezeichnung]){
							  $check = "checked";
							  $zuw_bezeichnung = "";
							  $zuw_ansppart = "";
							  $zuw_str = "";
							  $zuw_plz = "";
							  $zuw_ort = "";
							}else{
							  $check = "";
							  $zuw_bezeichnung = "$row3[zuw_bezeichnung]";
							  $zuw_ansppart = "$row3[zuw_ansprechpartner]";
							  $zuw_str = "$row3[zuw_str]";
							  $zuw_plz = "$row3[zuw_plz]";
							  $zuw_ort = "$row3[zuw_ort]";
							}
							
							echo"
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								Das Zuweisungsschreiben soll an Adresse/Ansprechpartner<br>
								wie unter 1.) versandt werden (falls ja, bitte ankreuzen)? 
								<br><br>
								Falls gesonderte Adresse, bitte hier angeben:
								</td>
								<td width='50%' valign='top' align='left' style='border-style: none; border-width: medium' height='32'>
								   <label for=\"zuw_adr_chk\"><input type=\"checkbox\" $check onclick=\"codename()\" name=\"zuw_adr_chk\" value=\"zuw_same\" id=\"zuw_adr_chk\"></label>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								<b>Bezeichnung der Zuweisungsstelle:
								</b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								<input type='text' name='zuw_bezeichnung' value='$zuw_bezeichnung' size='50'></td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								<b>Name des Ansprechpartners des Zuweisungsempfängers:
								</b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								<input type='text' name='zuw_ansppart' value='$zuw_ansppart' size='50'></td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								<b>Straße und Hausnummer des Zuweisungsempfängers:
								</b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								<input type='text' name='zuw_str' value='$zuw_str' size='50'></td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								<b>PLZ und Ort des Zuweisungsempfängers: </b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								<input type='text' name='zuw_plz' value='$zuw_plz' size='5'>&nbsp;
								<input type='text' name='zuw_ort' value='$zuw_ort' size='40'></td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								   &nbsp;
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								   &nbsp;
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Land der Praxisstelle:</b> 
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='land' size='50' value='$row3[land]'></td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Telefon Ansprechpartner*:</b>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='telefon' size='50' value='$row3[telefon]'>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Mail Ansprechpartner*:</b>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <input type='text' name='mail' size='50' value='$row3[mail]'>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Einverständniserklärung der Praxisstelle liegt vor*: </b> 
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  <label for=\"r1\"><input type=\"radio\" name=\"einverstanden\" value=\"Y\" id=\"r1\"";if($row3[einver_dsts] == 'Y'){ echo"checked";} echo"> Ja</label><br>
								  <label for=\"r2\"><input type=\"radio\" name=\"einverstanden\" value=\"N\" id=\"r2\"";if($row3[einver_dsts] == 'N'){ echo"checked";} echo"> Nein</label>
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  &nbsp;
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  &nbsp;
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Sachbereich*:</b> </td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								<p>";
                                  
                                                                 $db = dbconnect();
                                                                 
                                                                                                                                  
                                                                 $query = "SELECT sbid, bezeichnung
                                                                             FROM stan_stellenbereiche
                                                                            WHERE (kennung = '$row[stg]' OR kennung = 'A')
                                                                              AND jahrgang = '$row[jahrgang]'
                                                                            ORDER BY bezeichnung ASC
                                                                          ";
                                                                          
                                                                 $result = $db->query ($query)
                                                                    or die ("Cannot execute query");
                                                                 echo "<select size=\"5\" name=\"sachbereich\">";
                                                                 while ($row = $result->fetch_array()){
                                                                 echo "<option value='$row[sbid]'"; if($row[sbid] == $row3[sachbereich]){echo "selected";} echo">$row[bezeichnung]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>\n";
                                                                 }
                                
                                                                 echo"
                                                                 </p>
								</td>
							</tr>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  &nbsp;
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								  &nbsp;
								</td>
							</tr>
							<tr>
								<td width='50%' style='border-style: none; border-width: medium' height='32'>
								  <b>Zeitraum der praktischen Ausbildung bei dieser Praxisstelle*:</b>
								</td>
								<td width='50%' align='left' style='border-style: none; border-width: medium' height='32'>
								 von
								  <input type=\"text\" name=\"beg_tag\" ID=\"text\" size=\"1\" value=$row3[beg_tag] >.<input type=\"text\" name=\"beg_mon\"  size=\"1\" value=$row3[beg_mon]>.<input type=\"text\" name=\"beg_jahr\" ID=\"text2\"  size=\"3\"value=$row3[beg_jahr]>
								 bis
								  <input type=\"text\" name=\"ende_tag\" ID=\"text\" size=\"1\" value=$row3[end_tag] >.<input type=\"text\" name=\"ende_mon\" size=\"1\" value=$row3[end_mon]>.<input type=\"text\" name=\"ende_jahr\" ID=\"text2\" size=\"3\" value=$row3[end_jahr]>
								</td>
							</tr>
							<tr>
								<td width='28%' style='border-style: none; border-width: medium' height='25'>&nbsp;</td>
								<td width='72%' align='left' style='border-style: none; border-width: medium' height='25'>&nbsp;</td>
							</tr>";
							  $db = dbconnect();
							  $tel = $db->query("SELECT wert1 FROM parameter WHERE pid='5'");
							  $hotline = $tel->fetch_array();

							echo"
                                                        <tr>
                                                                <td align='center' colspan=2 width=\"28%\" style=\"border-style: none; border-width: medium\" height=\"25\">
                                                                  <font color=red>Bei auftretenden Problemen mit der Eingabe von Zeiträumen<br>bitte folgende Hotline anrufen: $hotline[wert1]</font></td>
                                                                <td width=\"72%\" align=\"left\" style=\"border-style: none; border-width: medium\" height=\"25\">&nbsp;</td>
                                                        </tr>
							<tr>
								<td width='28%' style='border-style: none; border-width: medium' height='25'>&nbsp;</td>
								<td width='72%' align='left' style='border-style: none; border-width: medium' height='25'>&nbsp;</td>
							</tr>
							<tr>
								<td width='98%' style='border-style: none; border-width: medium' height='25' colspan='2'>
								* Pflichtfelder </td>
							</tr>
							<tr>
								<td width='28%' style='border-style: none; border-width: medium' height='25'>
								<p>&nbsp;</p>
								</td>
								<td width='72%' align='left' style='border-style: none; border-width: medium' height='25'>
								<p>&nbsp;</p>
								</td>
							</tr>
						</table>
						<input type='submit' value='Abschicken' name='B1' size='20'></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 "antrag":



$saaid = $_COOKIE['ck_staID'];


require('check_erstantrag.php');  // Überprüft, ob Krieterien erfüllt sind: Ausgegeliedert damit sie fürs bearbeiten/Antrag stellen ebenfalls verwendet werden können

$beginndatum = $_POST[beg_jahr].'-'.$_POST[beg_mon].'-'.$_POST[beg_tag];
$enddatum = $_POST[ende_jahr].'-'.$_POST[ende_mon].'-'.$_POST[ende_tag];

$db = dbconnect();


if($_POST[zuw_adr_chk] == 'zuw_same'){
  $zuw_bezeichnung = $_POST[stellenbezeichnung];
  $zuw_ansppart = $_POST[ansprechpartner];
  $zuw_str = $_POST[str];
  $zuw_plz = $_POST[plz];
  $zuw_ort = $_POST[ort];
}else{
  $zuw_bezeichnung = $_POST[zuw_bezeichnung];
  $zuw_ansppart = $_POST[zuw_ansppart];
  $zuw_str = $_POST[zuw_str];
  $zuw_plz = $_POST[zuw_plz];
  $zuw_ort = $_POST[zuw_ort];
}


$sql = $db->query ("DELETE FROM stan_antrag WHERE saaid='$saaid' AND status = '0'");
$sql = $db->query ("INSERT INTO stan_antrag (saaid, uid, art, bezeichnung, bereich, ansprechpartner
                                           , funktion, str, plz, ort, zuw_bezeichnung, zuw_ansprechpartner, zuw_str, zuw_plz, zuw_ort, land, telefon, mail, einver_dsts
                                           , sachbereich, beginn, ende, aendid, status
                                           , bearbeitung, zuweisung
                                           ) VALUES ( 
                                             $saaid, '$uid1', '$_POST[stellenart]', '$_POST[stellenbezeichnung]'
                                          , '$_POST[bereich]', '$_POST[ansprechpartner]', '$_POST[funktion_ansprechpartner]'
                                          , '$_POST[str]', '$_POST[plz]', '$_POST[ort]','$zuw_bezeichnung', '$zuw_ansppart', '$zuw_str', '$zuw_plz', '$zuw_ort', '$_POST[land]', '$_POST[telefon]'
                                          , '$_POST[mail]', '$_POST[einverstanden]', '$_POST[sachbereich]'
                                          , '$beginndatum', '$enddatum', '$saaid', '0', 'Y', NULL)");

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>Antrag bearbeitet</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\">Antrag bearbeitet</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>Der Antrag wurde erfolgreich bearbeitet!</b>
                    </p>
                    <p align=\"center\"><a href=".$_SERVER['PHP_SELF'] .">
                    <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>";
}else{
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>Antrag nicht bearbeitet</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\">Antrag nicht bearbeitet</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 ist ein Fehler aufgetreten. Sie müssen den Antrag erneut stellen!</b>
                    </p>
                    <p align=\"center\"><a href=".$_SERVER['PHP_SELF'] .">
                    <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>";
}


break;
Case "del":

$staID = $_GET['ID'];
setcookie("ck_staID","");
setcookie("ck_staID",$staID);


$res = $db->query("SELECT ort FROM stan_antrag WHERE saaid='$staID'");
$row = $res->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>Datensatz l&ouml;schen</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=\"70%\" 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\">Datensatz l&ouml;schen</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\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
                    <tr>
                      <td width=\"100%\">
                        <p align=\"center\">
                        M&ouml;chten sie den Antrag<br><b>$row[ort]</b><br>wirklich löschen?<br><br>
                            <a href=".$_SERVER['PHP_SELF'] ."?action=del3>
	                    <img title = \"Abbrechen\"border=\"0\" src=\"../images/nein.gif\"></a>
	                     &nbsp;
                            <a href=".$_SERVER['PHP_SELF'] ."?action=del2>
	                    <img title = \"Antrag l&ouml;schen\"border=\"0\" src=\"../images/ja.gif\"></a>
                      </td>
                      </tr>
                    </table>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
</body>
</html>";

break;
case "del2":

$saaid = $_COOKIE['ck_staID'];

//Nochmals &uuml;berpr&uuml;fen, ob L&ouml;schung noch zul&auml;ssig ist! Falls jemand die Seite vor Fristablauf schon ge&ouml;ffnet hat
$heute_format = date("Y-m-d H:i:s",time());
$anm_schluss = $db->query("SELECT DATE_Format(anmeldeschluss, '%Y-%m-%d %H:%i:%s')AS Anmeldeschluss
                              FROM stan_frist , stud
                             WHERE stan_frist.jahrgang = stud.jahrgang
                               AND stud.uid = '$uid1'");
$row_schluss = $anm_schluss->fetch_array(); // Herausfinden der Anmeldefrist des vom Studenten gew&auml;hlten Kurses
$a = strtotime ($heute_format); //Umrechnung des Fristgrenztages in eine Zahl
$b = strtotime ($row_schluss[Anmeldeschluss]); // Umrechnung des Enddatums in eine Zahl

if($a>=$b)
{
  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>L&ouml;schrist abgelaufen</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\">L&ouml;schrist abgelaufen</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>Eine L&ouml;schung f&uuml;r diese Veranstaltung ist nicht mehr m&ouml;glich</b>
                      </p>
                      <p align=\"center\"><a href=\"hauptframe.php\">
                      <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;
}

$sql = $db->query ("DELETE FROM stan_antrag WHERE saaid='$saaid'");

if ($sql)  // Best&auml;tigungsseite bei Erfolg sonst Nichterfolgsmeldung
  {
    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>Datensatz gelöscht</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\">Datensatz gelöscht</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>Der Datensatz wurde gelöscht!</b>
                      </p>
                      <p align=\"center\"><a href=\"hauptframe.php\">
                      <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>";
  }else{
    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>unerwarteter Fehler</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\">unerwarteter Fehler</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 ist ein interner Fehler aufgetreten!<br>
                      Wenden Sie sich bitte umgehend an
                      <a href=\"mailto:$_POST[helpmail]?subject=Fehler bei der Antragsbearbeitung im Stellenatragssystem\">$_POST[ansprechpart]</a></b>
                      </p>
                      <p align=\"center\"><a href=\"hauptframe.php\">
                      <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>";
  }

break;
case "del3":

$Link = basename($_SERVER['PHP_SELF']);
echo "
  <meta http-equiv=\"refresh\" content=\"0; URL=$Link\">
";
 
}
?>