<?php
$jahrgang=$_COOKIE["jahrgang"];
$standort=$_COOKIE["ck_standort"];
if ($jahrgang == "" AND $standort == ""){ echo "<meta http-equiv=\"refresh\" content=\"0; URL=jahrgang.php\">";} //Wenn man kein Jahrgang ausgew&auml;hlt hat wird die Jahrgangsauswahlseite geladen

include_once("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
require_once("./FCKeditor/fckeditor.php") ;

$uid1=$_COOKIE["uid1"];
$ck_beg_std=$_COOKIE["ck_beg_std"];
$ck_beg_min=$_COOKIE["ck_beg_min"];
$ck_vert=$_COOKIE["ck_vert"];
$ck_adresse=$_COOKIE["ck_adresse"];
$ck_hinweis=$_COOKIE["ck_hinweis"];


#echo"
#Ausgabe Cookis für Fehlersuche:<br>
#uid --> $uid1<br>
#jahrgang --> $jahrgang<br>
#standort --> $standort<br>
#<br>
#<b>Die Ausgabe ist kein Fehler!</b><br><br>
#";

if (isset($_GET['action']))
   $action = $_GET['action'];
else
   $action = "";

switch($action){
default:

$vert1 = $_COOKEI[ck_vert1];

$db = dbconnect();
include("kurs/sta/stan_soadmonline_write.php");     // F&uuml;r Statistik, wieviele User online sind

echo "

<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<!-- Kalender Beginn // -->
	<link rel='stylesheet' href='dynCalendar.css' type='text/css' media='screen'>
	<script src='browserSniffer.js' type='text/javascript' language='javascript'></script>
	<script src='dynCalendar.js' type='text/javascript' language='javascript'></script>
	<script type='text/javascript'>
	<!--
		// Calendar callback. When a date is clicked on the calendar
		// this function is called so you can do as you want with it
		function calendarCallback(date, month, year, pos)
		{
		    if(date<10){date='0'+date;}
		    if(month<10){month='0'+month;}
			date_tag = date;
			date_mon = month;
			date_jahr = year;
			document.getElementById('beg_tag'+pos).value = date_tag;
			document.getElementById('beg_mon'+pos).value = date_mon;
			document.getElementById('beg_jahr'+pos).value = date_jahr;
		}

	// -->
	</script>
<!-- Kalender Ende // -->

<title>Terminverwaltung</title>
</head>
<body onload=\"if(document.ver_erf)document.ver_erf.beg_tag.focus();return false;\">
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"90%\" 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\">Terminverwaltung</font><br>
                    <font class=\"sh\">$info[Bezeichnung]</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=bearb2"; echo" method=\"POST\" name=\"ver_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=\"30%\">
                          <b>Beginn*:</b>
                          </td>
                          <td width=\"70%\" align=\"left\">
                          <input type='text' name='beg_tag1' id='beg_tag1' value='$beg_tag' size=1>.<input type='text' name='beg_mon1' id='beg_mon1'value='$beg_mon' size=1>.<input type='text' name='beg_jahr1' id='beg_jahr1' value='$beg_jahr' size=3>
			  	    	
			  	    	<script language='JavaScript' type='text/javascript'>
			  	        <!--
			  	        	beg_cal1 = new dynCalendar('beg_cal1', 'calendarCallback', 'images/', '', '1');
			  	        //-->
			                 </script>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"30%\">
                          <b>Uhrzeit*:</b>
                          </td>
                          <td width=\"70%\" align=\"left\">
                           <input type=\"text\" name=\"beg_std\" size=\"1\" value='$ck_beg_std'>:<input type=\"text\" name=\"beg_min\" size=\"1\" value='$ck_beg_min'> Uhr
                          </td>
                        </tr>
                        <tr>
                          <td width=\"30%\">
                          <b>Vertiefungsbereich*:</b>
                          </td>
                          <td width=\"70%\" align=\"left\">";
                          $db = dbconnect();
     
     
                            $result1a = $db->query ("SELECT count(*) Anz
                                                        FROM stan_vertiefungsbereich a, stan_ag_standort b
                                                       WHERE a.vbid=b.vbid
                                                         AND b.sid='$standort'
                                                         AND b.jahr='$jahrgang'
                                                       ORDER BY bezeichnung ASC
                                                    ");
                            $row_anz = $result1a->fetch_array();                    
                                                   
                                     
                            $query1 = "SELECT a.vbid, a.bezeichnung
                                         FROM stan_vertiefungsbereich a, stan_ag_standort b
                                        WHERE a.vbid=b.vbid
                                          AND b.sid='$standort'
                                          AND b.jahr='$jahrgang'
                                        ORDER BY bezeichnung ASC
                                     ";
                            $result1 = $db->query ($query1)
                               or die ("Cannot execute query");
                            echo "<select class='select_form' size=\"2\" name=\"vert\">";

                            while ($row1 = $result1->fetch_array()){
                              if($row_anz[Anz] != '1'){
                                echo "<option value='$row1[vbid]'";if($row1[vbid] == $ck_vert){echo " selected ";} echo">$row1[bezeichnung]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>\n";
                              }else{
                                echo "<option value='$row1[vbid]' selected>$row1[bezeichnung]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>\n";
                              }
                            }
                            echo"</select>   
                          </td>
                        </tr>
                        <tr>
                          <td width=\"30%\">
                          <b>Adresse/Raum:</b>
                          </td>
                          <td width=\"70%\" align=\"left\">
                          ";
			    $oFCKeditor = new FCKeditor('Raum') ;
			    $oFCKeditor->BasePath = './FCKeditor/';
			    $oFCKeditor->Value = "$ck_adresse";
			    $oFCKeditor->ToolbarSet = 'Basic';
			    $oFCKeditor->Width  = '100%' ;
			    $oFCKeditor->Height = '100' ;
			    $oFCKeditor->Create() ;
                          echo"
                          </td>
                        </tr>
                        <tr>
                          <td width=\"30%\">
                          <b>Allgemeine Terminhinweise:</b>
                          </td>
                          <td width=\"70%\" align=\"left\">
                          ";
			    $oFCKeditor = new FCKeditor('hinweis') ;
			    $oFCKeditor->BasePath = './FCKeditor/';
			    $oFCKeditor->Value = "$ck_hinweis";
			    $oFCKeditor->ToolbarSet = 'Basic';
			    $oFCKeditor->Width  = '100%' ;
			    $oFCKeditor->Height = '100' ;
			    $oFCKeditor->Create() ;
                          echo"
                          </td>
                        </tr>
                      </table>
                    <br>
                    <p align = \"center\">*=Pflichtfelder<br><br><input type=\"submit\" value=\"Abschicken\" name=\"B1\"></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\">
                    <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>

<br>
<br>
<br>

<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Erfasste Termine</title>
</head>
<body onload=\"if(document.ver_erf)document.ver_erf.beg_tag.focus();return false;\">
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\"id=\"table2\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"95%\" 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\">Erfasste Termine</font>
                    <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-width:0; border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"18\">
                        <tr>
                          <td width=\"5%\">
                          <b>Nr</b>
                          </td>
                          <td width=\"25%\">
                          <b>Beginn</b>
                          </td>
                          <td width=\"25%\" align=\"left\">
                           <b>Adresse</b>
                          </td>
                          <td width=\"20%\" align=\"left\">
                           <b>Allg. Hinweise</b>
                          </td>
                          <td width=\"20%\" align=\"left\">
                           <b>Vertiefungsbereich</b>
                          </td>
                          <td width=\"10%\" align=\"center\">
                           <b>Löschen</b>
                          </td>
                        </tr>";
                          $db = dbconnect();
                        $ln_zaehler = 1; // Z&auml;hler f&uuml;r Anzahl der Termine
                        
                        
                         $query = "SELECT  DATE_Format(datum, '%d.%m.%y') Datum_von
                                         , DATE_Format(datum, '%H:%i') Zeit_von
                                         , DATE_Format(datum, '%d') tag_von
                                         , DATE_Format(datum, '%m') mon_von
                                         , DATE_Format(datum, '%y') jahr_von
                                         , oertlichkeit
                                         , hinweis
                                         , status
                                         , c.bezeichnung
                                         , DatID
                                      FROM stan_ag_standort_termine a, stan_ag_standort b, stan_vertiefungsbereich c
                                     WHERE a.fagsid = b.agsid
                                       AND c.vbid = b.vbid
                                       AND b.jahr='$jahrgang'
                                       AND b.sid='$standort'
                                     ORDER BY b.vbid, a.datum ASC";

                          $result = $db->query ($query)
                                    or die ("Cannot execute query");
                         

                        while ($row = $result->fetch_array()){
                        
		          
                        
                          $wochentag_von = date("l", mktime(0,0,0,$row['mon_von'],$row['tag_von'],$row['jahr_von']));
                          switch($wochentag_von)
                          {
                            case 'Sunday':
                                $wochentag_von = "So.";
                                break;
                            case 'Monday':
                                $wochentag_von = "Mo.";
                                break;
                            case 'Tuesday':
                                $wochentag_von = "Di.";
                                break;
                            case 'Wednesday':
                                $wochentag_von = "Mi.";
                                break;
                            case 'Thursday':
                                $wochentag_von = "Do.";
                                break;
                            case 'Friday':
                                $wochentag_von = "Fr.";
                                break;
                            case 'Saturday':
                                $wochentag_von = "Sa.";
                                break;
                          }
                          

                          

                        echo"
                        <tr>
                          <td width=\"5%\">
                          <b>$ln_zaehler</b>
                          </td>
                          <td width=\"25%\">
                          $wochentag_von $row[Datum_von] um $row[Zeit_von] Uhr
                          </td>
                          <td width=\"25%\" align=\"left\">
                           $row[oertlichkeit]
                          </td>
                          <td width=\"20%\" align=\"left\">
                           $row[hinweis]
                          </td>
                          <td width=\"20%\" align=\"left\">
                           $row[bezeichnung]
                          </td>
                          <td width=\"15%\" align=\"center\">
                           <a href=".$_SERVER['PHP_SELF'] ."?action=del&ID=$row[DatID]>
                           <img title = \"Datum l&ouml;schen\"border=\"0\" src=\"../images/drop.png\"></a>
                          </td>
                        </tr>";
                        $ln_zaehler = $ln_zaehler+1;
                       }
                       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>

<br>
<br>
<br>

";


break;
case "bearb2":

$vert = $_POST[vert];
$adresse = stripslashes( $_POST['Raum'] );
$hinweis = stripslashes( $_POST['hinweis'] );
$beg_std = $_POST['beg_std'];
$beg_min = $_POST['beg_min'];
$beg_sek = '00';

setcookie("ck_beg_std","");
setcookie("ck_beg_std","$beg_std");
setcookie("ck_beg_min","");
setcookie("ck_beg_min","$beg_min");
setcookie("ck_vert","");
setcookie("ck_vert","$vert");
setcookie("ck_adresse","");
setcookie("ck_adresse","$adresse");
setcookie("ck_hinweis","");
setcookie("ck_hinweis","$hinweis");

if($_POST[beg_mon1] == '' OR $_POST[beg_tag1] == '' OR $_POST[beg_jahr1] == '' or $beg_std == '' or $beg_min == '' or $vert == ''){
  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>Falsches Datum</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\">Pflichtfelder ausfüllen</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>Bitte füllen Sie alle Pflichtfelder aus!</p></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 (@checkdate($_POST[beg_mon1], $_POST[beg_tag1], $_POST[beg_jahr1]) == 0) { // checkdate liefert 0 & 1 zur&uuml;ck: 0 wenn Datum falsch, 1 wenn Datum richtig
  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>Falsches Datum</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\">Falsches Datum</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 Datumseingabe beim Anmeldebeginn ist falsch!</p></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 Datums&uuml;berpr&uuml;fung




  if ($beg_std < 0 or $beg_std > 23
      or $beg_min < 0 or $beg_min > 59
      or $beg_sek < 0 or $beg_sek > 59)
  {
  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>Falsches Datum</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\">Falsche Zeit</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 Beginnzeit ist falsch!</p></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;
  }


$beg_dat = "$_POST[beg_jahr1]-$_POST[beg_mon1]-$_POST[beg_tag1] $beg_std:$beg_min:$beg_sek";

$db = dbconnect();
$result = $db->query ("SELECT agsid
                          FROM stan_ag_standort
                         WHERE sid='$standort'
                           AND jahr='$jahrgang'
                           AND vbid='$vert'");
$row_fagsid = $result->fetch_array();




  $sql = "INSERT INTO stan_ag_standort_termine
          (fagsid, datum, oertlichkeit, hinweis, status)
          VALUES
          ('$row_fagsid[agsid]', '$beg_dat','$adresse','$hinweis','A')
         ";

  $sql[0] = $db->query($sql);

  if (!$sql[0])
  {
  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>Fehlgeschlagen</title>
  </head>
  <body>
  <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
      <tr>
          <td>
          <div align=\"center\">
              <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                  <tr>
                      <td width=\"10\" background=\"../images/box_e1.gif\">
                      <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                      <td width=\"95%\" background=\"../images/box_top.gif\">
                      <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                      <span class=\"sh\">Fehlgeschlagen</span><br>
                      <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                      <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                      <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                  </tr>
                  <tr>
                      <td width=\"1%\" background=\"../images/box_l.gif\">
                      <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td colspan=\"2\"><br>
                      <p align=\"center\"><b>Das hinzuf&uuml;gen eines Termines ist fehlgeschlagen!</b>
                      <br><br>
                      <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><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 IF wenn Insert Fehlgeschlagen



echo "<meta http-equiv=\"refresh\" content=\"0; URL=".$_SERVER['PHP_SELF'] ."?action=default\">";

break;
case "del":


$DatID=$_GET['ID'];

$db = dbconnect();
$sql = $db->query ("DELETE FROM stan_ag_standort_termine WHERE DatID=$DatID");
if ($sql)  // Best&auml;tigungsseite bei Erfolg sonst Nichterfolgsmeldung
  {
    echo "
      <meta http-equiv=\"refresh\" content=\"0; URL=".$_SERVER['PHP_SELF'] ."?action=bearb&erfassen=$VerID\">
    ";
  }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!</b>
                      </p>
                      <p align=\"center\"><a href=\"hauptframe_jahr.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>";
  }

} //Ende Action Abfrage
?>