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

#$saaid=$_GET['saaid1'];



$db = dbconnect();

$result3 = $db->query("SELECT saaid, uid, pos, vert_bereich, art, dst_id, date_format(beginn, '%d.%m.%Y') beginn, date_format(ende, '%d.%m.%Y') ende, abteilung, tel_abteilung, aendid
                          FROM stan_antrag
                         WHERE saaid='$saaid'");
$row3 = $result3->fetch_array();


$res_zuw = $db->query("SELECT a.standort
                              FROM stan_standort a, stan_ag_standort b, stan_ag_standort_wunsch c
                             WHERE a.sid=b.sid
                               AND b.agsid=c.wagsid
                               AND c.prio=0
                               AND c.saaid='$row3[saaid]'");
$row_zuw = $res_zuw->fetch_array();


$result3a = $db->query("SELECT bezeichnung
                          FROM stan_vertiefungsbereich
                         WHERE vbid='$row3[vert_bereich]'");
$row3a = $result3a->fetch_array();


$result3b = $db->query("SELECT artid, bezeichnung
                          FROM stan_stellenart
                         WHERE artid='$row3[art]'");
$row3b = $result3b->fetch_array();

 $result_data2 = $db->query("SELECT distinct 1 FROM stan_dienststellen WHERE dst_id= '$row3[dst_id]'");
 $rowdata2 = $result_data2->fetch_array();

 if($rowdata2[0] == '1'){
   $result_data3c = $db->query("SELECT bez
                                     , str
                                     , plz
                                     , postfach
                                     , plz_postfach
                                     , ort
                                     , bundesland
                                     , staat
                                  FROM stan_dienststellen
                                 WHERE dst_id='$row3[dst_id]'");
    $row3c = $result_data3c->fetch_array();
    
 }else{

    $result_data3c = $db->query("SELECT bez
                                      , str
                                      , plz
                                      , postfach
                                      , plz_postfach
                                      , ort
                                      , bundesland
                                      , staat
                                   FROM stan_dienststellen_tmp
                                  WHERE dst_id='$row3[dst_id]'");
     $row3c = $result_data3c->fetch_array();
  }




## vorheriger Datensatz suchen
$res_alt = $db->query("SELECT saaid, uid, pos, vert_bereich, art, dst_id, date_format(beginn, '%d.%m.%Y') beginn, date_format(ende, '%d.%m.%Y') ende, abteilung, tel_abteilung
                          FROM stan_antrag
                         WHERE saaid<'$row3[saaid]'
                           AND aendid='$row3[aendid]'
                         ORDER BY saaid DESC
                         LIMIT 1");
$row_alt = $res_alt->fetch_array();


$res_alt_zuw = $db->query("SELECT a.standort
                              FROM stan_standort a, stan_ag_standort b, stan_ag_standort_wunsch c
                             WHERE a.sid=b.sid
                               AND b.agsid=c.wagsid
                               AND c.prio=0
                               AND c.saaid='$row_alt[saaid]'");
$row_alt_zuw = $res_alt_zuw->fetch_array();

$res_alta = $db->query("SELECT bezeichnung
                          FROM stan_vertiefungsbereich
                         WHERE vbid='$row_alt[vert_bereich]'");
$row_alta = $res_alta->fetch_array();


$res_altb = $db->query("SELECT artid, bezeichnung
                          FROM stan_stellenart
                         WHERE artid='$row_alt[art]'");
$row_altb = $res_altb->fetch_array();



 $result_data2 = $db->query("SELECT distinct 1 FROM stan_dienststellen WHERE dst_id= '$row_alt[dst_id]'");
 $rowdata2 = $result_data2->fetch_array();

 if($rowdata2[0] == '1'){
   $res_altc = $db->query("SELECT bez
                                     , str
                                     , plz
                                     , postfach
                                     , plz_postfach
                                     , ort
                                     , bundesland
                                     , staat
                                  FROM stan_dienststellen
                                 WHERE dst_id='$row_alt[dst_id]'");
    $row_altc = $res_altc->fetch_array();
    
 }else{

    $res_altc = $db->query("SELECT bez
                                      , str
                                      , plz
                                      , postfach
                                      , plz_postfach
                                      , ort
                                      , bundesland
                                      , staat
                                   FROM stan_dienststellen_tmp
                                  WHERE dst_id='$row_alt[dst_id]'");
     $row_altc = $res_altc->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>Änderungen vergleichen</title>
</head>
<script type=\"text/javascript\">
function cursorhand()
{
    document.body.style.cursor = 'pointer';
}
</script>
<title>In das Fenster klicken um zu schließen</title>
</head>
<body  onMouseover=\"cursorhand()\", onclick=\"window.close();\">
<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=\"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\">Änderungen vergleichen</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>





<table width='100%'>
<tr>
 <td align = 'center' width='50%' style=\"border-right-style: solid; border-right-width: 1px; border-bottom-style: solid; border-bottom-width: 1px\">
  <b>Änderungsantrag</b>
 </td>
 <td align = 'center' width='50%' style=\"border-bottom-style: solid; border-bottom-width: 1px\">
 <b>bisheriger Antrag</b>
 </td>
</tr>
<tr>
 <td width='50%' style=\"border-right-style: solid; border-right-width: 1px;\">
 
 
 
 
<table width='100%'>
 <tr>
   <td width='40%'>
     <b>Vertiefungsbereich</b>
   </td>
   <td width='60%'>";
     if($row3a[bezeichnung] == $row_alta[bezeichnung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3a[bezeichnung]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Art der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3b[bezeichnung] == $row_altb[bezeichnung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3b[bezeichnung]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Bezeichnung der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3c[bez] == $row_altc[bez]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3c[bez]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Straße und Nr. der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3c[str] == $row_altc[str]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3c[str]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>PLZ Ort</b>
   </td>
   <td width='60%'>";
     if($row3c[plz] == $row_altc[plz]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3c[plz]</font>";
     if($row3c[ort] == $row_altc[ort]){
      $color='black';
     }else{
      $color='red';
     }
     echo" <font color='$color'>$row3c[ort]</font>
   </td> 
 </tr>
 <tr>
    <td width='40%'>
      <b>PLZ Postfach</b>
    </td>
    <td width='60%'>";
     if($row3c[plz_postfach] == $row_altc[plz_postfach]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row3c[plz_postfach]</font>";
     if($row3c[postfach] == $row_altc[postfach]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3c[postfach]</font>
    </td> 
 </tr>
 <tr>
     <td width='40%'>
       <b>Bundesland</b>
     </td>
     <td width='60%'>";
     if($row3c[bundesland] == $row_altc[bundesland]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
       <font color='$color'>$row3c[bundesland]</font>
     </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Staat</b>
    </td>
    <td width='60%'>";
     if($row3c[staat] == $row_altc[staat]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row3c[staat]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Zeitraum bei dieser Praxisstelle</b>
    </td>
    <td width='60%'>";
     if($row3[beginn] == $row_alt[beginn]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row3[beginn]</font> - ";
     if($row3[ende] == $row_alt[ende]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row3[ende]</font></font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Abteilung</b>
    </td>
    <td width='60%'>";
     if($row3[abteilung] == $row_alt[abteilung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row3[abteilung]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Tel. der Abteilung</b>
    </td>
    <td width='60%'>";
     if($row3[tel_abteilung] == $row_alt[tel_abteilung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row3[tel_abteilung]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>AG Standort</b>
    </td>
    <td width='60%'>";
     if($row_zuw[standort] == $row_alt_zuw[standort]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_zuw[standort]</font>
    </td> 
 </tr>
</table>
 
</td>
<td width='50%'>


<table width='100%'>
 <tr>
   <td width='40%'>
     <b>Vertiefungsbereich</b>
   </td>
   <td width='60%'>";
     if($row3a[bezeichnung] == $row_alta[bezeichnung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_alta[bezeichnung]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Art der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3b[bezeichnung] == $row_altb[bezeichnung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_altb[bezeichnung]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Bezeichnung der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3c[bez] == $row_altc[bez]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_altc[bez]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>Straße und Nr. der Praxisstelle</b>
   </td>
   <td width='60%'>";
     if($row3c[str] == $row_altc[str]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_altc[str]</font>
   </td> 
 </tr>
 <tr>
   <td width='40%'>
     <b>PLZ Ort</b>
   </td>
   <td width='60%'>";
     if($row3c[plz] == $row_altc[plz]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_altc[plz]</font>";
     if($row3c[ort] == $row_altc[ort]){
      $color='black';
     }else{
      $color='red';
     }
     echo" <font color='$color'>$row_altc[ort]</font>
   </td> 
 </tr>
 <tr>
    <td width='40%'>
      <b>PLZ Postfach</b>
    </td>
    <td width='60%'>";
     if($row3c[plz_postfach] == $row_altc[plz_postfach]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_altc[plz_postfach]</font>";
     if($row3c[postfach] == $row_altc[postfach]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     <font color='$color'>$row_altc[postfach]</font>
    </td> 
 </tr>
 <tr>
     <td width='40%'>
       <b>Bundesland</b>
     </td>
     <td width='60%'>";
     if($row3c[bundesland] == $row_altc[bundesland]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
       <font color='$color'>$row_altc[bundesland]</font>
     </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Staat</b>
    </td>
    <td width='60%'>";
     if($row3c[staat] == $row_altc[staat]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_altc[staat]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Zeitraum bei dieser Praxisstelle</b>
    </td>
    <td width='60%'>";
     if($row3[beginn] == $row_alt[beginn]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_alt[beginn]</font> - ";
     if($row3[ende] == $row_alt[ende]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
     $row_alt[ende]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Abteilung</b>
    </td>
    <td width='60%'>";
     if($row3[abteilung] == $row_alt[abteilung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_alt[abteilung]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>Tel. der Abteilung</b>
    </td>
    <td width='60%'>";
     if($row3[tel_abteilung] == $row_alt[tel_abteilung]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_alt[tel_abteilung]</font>
    </td> 
 </tr>
<tr>
    <td width='40%'>
      <b>AG Standort</b>
    </td>
    <td width='60%'>";
     if($row_zuw[standort] == $row_alt_zuw[standort]){
      $color='black';
     }else{
      $color='red';
     }
     echo"
      <font color='$color'>$row_alt_zuw[standort]</font>
    </td> 
 </tr>
</table>


 </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\" 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>";



?>