<?PHP
#######################
## Check der Antragsdaten
## - Pflichtfelder
## - richtige Datumseingabe
## - Überschneidung PU
## - Überschneidung andere Praxisstellen
## - Beantragter Zeitraum ist über/unter dem Anmeldezeitraum (31.08.- 01.09.)
#######################

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

$res = $db->query("SELECT artid FROM `stan_stellenart` 
                     WHERE merkmal = 'A'");
$ausland = $res->fetch_array();


if($_POST[stellenart] != $ausland[artid]){ # or $_POST[sachbereich] == ''

   if ($_POST[stellenart] == '' or $_POST[stellenbezeichnung] == '' or $_POST[bereich] == '' or $_POST[ansprechpartner] == '' or $_POST[funktion_ansprechpartner] == '' or $_POST[str] == '' or $_POST[plz] == '' 
    or $_POST[ort] == '' or $_POST[telefon] == '' or $_POST[mail] == '' or $_POST[einverstanden] == '' or $_POST[sachbereich] == '' or $_POST[beg_tag] == '' or $_POST[beg_tag] == 'TT'
    or $_POST[beg_mon] == '' or $_POST[beg_mon] == 'MM' or $_POST[beg_jahr] == '' or $_POST[beg_jahr] == 'JJJJ' or $_POST[ende_tag] == '' 
    or $_POST[ende_tag] == 'TT' or $_POST[ende_mon] == '' or $_POST[ende_mon] == 'MM' or $_POST[ende_jahr] == '' or $_POST[ende_jahr] == 'JJJJ')
   {
    echo"
    <html>
    <head>
    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
    <link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
    <title>Eingabefehler</title>
    </head>
    <body>
    <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
        <tr>
            <td>
            <div align=\"center\">
                <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                    <tr>
                        <td width=\"10\" background=\"../images/box_e1.gif\">
                        <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                        <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                        <td width=\"95%\" background=\"../images/box_top.gif\">
                        <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                        <span class=\"sh\">Eingabefehler</span><br>
                        <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                        <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                        <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    </tr>
                    <tr>
                        <td width=\"1%\" background=\"../images/box_l.gif\">
                        <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                        <td colspan=\"2\"><br>
                        <p align=\"center\">Bitte füllen Sie die Pflichtfelder aus!</p>
                        </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;
    }
}else{

   if ($_POST[sachbereich] == '' or $_POST[beg_tag] == '' or $_POST[beg_tag] == 'TT'
    or $_POST[beg_mon] == '' or $_POST[beg_mon] == 'MM' or $_POST[beg_jahr] == '' or $_POST[beg_jahr] == 'JJJJ' or $_POST[ende_tag] == '' 
    or $_POST[ende_tag] == 'TT' or $_POST[ende_mon] == '' or $_POST[ende_mon] == 'MM' or $_POST[ende_jahr] == '' or $_POST[ende_jahr] == 'JJJJ')
   {
    echo"
    <html>
    <head>
    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
    <link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
    <title>Eingabefehler</title>
    </head>
    <body>
    <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
        <tr>
            <td>
            <div align=\"center\">
                <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                    <tr>
                        <td width=\"10\" background=\"../images/box_e1.gif\">
                        <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                        <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                        <td width=\"95%\" background=\"../images/box_top.gif\">
                        <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                        <span class=\"sh\">Eingabefehler</span><br>
                        <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                        <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                        <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    </tr>
                    <tr>
                        <td width=\"1%\" background=\"../images/box_l.gif\">
                        <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                        <td colspan=\"2\"><br>
                        <p align=\"center\">Bitte füllen Sie die Pflichtfelder Ausland aus!</p>
                        </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_mon], $_POST[beg_tag], $_POST[beg_jahr]) == 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\">Die Datumseingabe beim Beginndatum ist falsch!<br>Geben das Datum im Format <b>TT.MM.JJJJ</b> ein!</p>
                      </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 (@checkdate($_POST[ende_mon], $_POST[ende_tag], $_POST[ende_jahr]) == 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\">Die Datumseingabe beim Enddatum ist falsch!<br>Geben das Datum im Format <b>TT.MM.JJJJ</b> ein!</p>
                      </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


# Daten überprüfen


// &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


#########################
## Überschneidung PU
#########################

$db = dbconnect();

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

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

$begin_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[beg_mon], $_POST[beg_tag], $_POST[beg_jahr])));
$ende_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[ende_mon], $_POST[ende_tag], $_POST[ende_jahr])));
$begin_pu = strtotime(date("d.m.Y", mktime(0, 0, 0, $row_sperrpu[beginn_mon], $row_sperrpu[beginn_tag], $row_sperrpu[beginn_jahr])));
$ende_pu = strtotime(date("d.m.Y", mktime(0, 0, 0, $row_sperrpu[ende_mon], $row_sperrpu[ende_tag], $row_sperrpu[ende_jahr])));

if(($begin_stud >= $begin_pu AND $begin_stud <=$ende_pu)   // Wenns beginndatum zwischen beginn und Ende PU liegt
   OR ($ende_stud >= $begin_pu AND $ende_stud <=$ende_pu)  // Wenns enddatum zwischen beginn und Ende PU liegt
   OR ($begin_stud <= $begin_pu AND $ende_stud >=$ende_pu) // Wenns PU-Datum zwischen einem Zeitraum liegt
  ){
  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>Belegter Zeitraum</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\">Belegter Zeitraum</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\">In diesem Zeitraum findet Praxisbegleitender Unterricht statt
                      </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;
}


#########################
## Überschneidung PU Ende
#########################

#########################
## Überschneidung andere Praxisstellen
#########################

$db = dbconnect();

                            
$query = "SELECT DATE_Format(t1.beginn, '%d') beginn_tag
               , DATE_Format(t1.beginn, '%m') beginn_mon
               , DATE_Format(t1.beginn, '%Y') beginn_jahr
               , DATE_Format(t1.ende, '%d') ende_tag
               , DATE_Format(t1.ende, '%m') ende_mon
               , DATE_Format(t1.ende, '%Y') ende_jahr
               , t1.ort
            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')
         ";
      
if(isset($saaid)){
$query = $query." AND t1.saaid != $saaid";#--> Nur beim bearbeiten relevant, damit der zu bearbeitende Zeitraum ebenfalls nicht berücksichtigt wird
}

                                               
$result = $db->query ($query)
          or die ("Cannot execute query");
                                        
while ($row3 = $result->fetch_array()){



$begin_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[beg_mon], $_POST[beg_tag], $_POST[beg_jahr])));
$ende_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[ende_mon], $_POST[ende_tag], $_POST[ende_jahr])));
$begin_praxis = strtotime(date("d.m.Y", mktime(0, 0, 0, $row3[beginn_mon], $row3[beginn_tag], $row3[beginn_jahr])));
$ende_praxis = strtotime(date("d.m.Y", mktime(0, 0, 0, $row3[ende_mon], $row3[ende_tag], $row3[ende_jahr])));

if(($begin_stud >= $begin_praxis AND $begin_stud <=$ende_praxis)   // Wenns beginndatum zwischen beginn und Ende PU liegt
   OR ($ende_stud >= $begin_praxis AND $ende_stud <=$ende_praxis)  // Wenns enddatum zwischen beginn und Ende PU liegt
   OR ($begin_stud <= $begin_praxis AND $ende_stud >=$ende_praxis) // Wenns PU-Datum zwischen einem Zeitraum liegt
  ){
  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>Belegter Zeitraum</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\">Belegter Zeitraum</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\">Dieser Zeitraum ist durch die Praxisstelle \"$row3[ort]\" belegt
                      </p>
                      <p align=\"center\"><a href=\"javascript:history.back()\">
                      <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                      </p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p><br>
                      </p>
                      </td>
                      <td width=\"1%\" background=\"../images/box_r.gif\">
                      <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                  </tr>
                  <tr>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                      <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                  </tr>
              </table>
          </div>
          </td>
      </tr>
  </table>
  </body>
</html>";
  exit;
} // Ende wenn Belegter Zeitraum
} // Ende While

#########################
## Überschneidung andere Praxisstellen Ende
#########################

#########################
## Sperrfrist außerhalb Zeitraum des Praxisjahres
#########################

$db = dbconnect();

$result = $db->query("SELECT jahrgang FROM stud where uid=\"$uid1\"");
$row = $result->fetch_array();

$sperr_prxjahr = $db->query("SELECT DATE_Format(antrag_von, '%d') beginn_tag
                                   , DATE_Format(antrag_von, '%m') beginn_mon
                                   , DATE_Format(antrag_von, '%Y') beginn_jahr
                                   , DATE_Format(antrag_bis, '%d') ende_tag
                                   , DATE_Format(antrag_bis, '%m') ende_mon
                                   , DATE_Format(antrag_bis, '%Y') ende_jahr
                                   , DATE_Format(antrag_von, '%d.%m.%Y') beginn_prx
                                   , DATE_Format(antrag_bis, '%d.%m.%Y') ende_prx
                                FROM stan_frist
                               WHERE jahrgang='$row[jahrgang]'");
$row_sperrprx = $sperr_prxjahr->fetch_array(); // Sperrzeiten Ausland

$begin_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[beg_mon], $_POST[beg_tag], $_POST[beg_jahr])));
$ende_stud = strtotime(date("d.m.Y", mktime(0, 0, 0, $_POST[ende_mon], $_POST[ende_tag], $_POST[ende_jahr])));
$begin_prx = strtotime(date("d.m.Y", mktime(0, 0, 0, $row_sperrprx[beginn_mon], $row_sperrprx[beginn_tag], $row_sperrprx[beginn_jahr])));
$ende_prx = strtotime(date("d.m.Y", mktime(0, 0, 0, $row_sperrprx[ende_mon], $row_sperrprx[ende_tag], $row_sperrprx[ende_jahr])));

if($begin_stud < $begin_prx OR $ende_stud < $begin_prx OR $begin_stud > $ende_prx OR $ende_stud > $ende_prx){
  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>Gesperrter Zeitraum</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\">Gesperrter Zeitraum</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\">Das Datum liegt außerhalb des Praxisjahres!<br>Das Praxisjahr geht von $row_sperrprx[beginn_prx] bis $row_sperrprx[ende_prx]
                      </p>
                      <p align=\"center\"><a href=\"javascript:history.back()\">
                      <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                      </p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p><br>
                      </p>
                      </td>
                      <td width=\"1%\" background=\"../images/box_r.gif\">
                      <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                  </tr>
                  <tr>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                      <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                  </tr>
              </table>
          </div>
          </td>
      </tr>
  </table>
  </body>
</html>";
  exit;
} // Ende wenn Sperrzeitverletzung


#########################
## Sperrfrist außerhalb Zeitraum des Praxisjahres: Ende
#########################

?>