[362] | 1 | <?php |
---|
[427] | 2 | /* alkisnamstruk.php |
---|
[362] | 3 | |
---|
[427] | 4 | ALKIS-Auskunft |
---|
| 5 | Author: Frank JÀger, Kommunales Rechenzentrum Minden-Ravensberg/Lippe (Lemgo) |
---|
[362] | 6 | |
---|
[427] | 7 | Namens- und Adressdaten fÃŒr einen EigentÃŒmer aus ALKIS PostNAS |
---|
| 8 | |
---|
[362] | 9 | Version: |
---|
[425] | 10 | 2016-02-24 Version fÃŒr norGIS-ALKIS-Import |
---|
[422] | 11 | ... |
---|
| 12 | 2020-02-20 Authentifizierung ausgelagert in Function darf_ich() |
---|
| 13 | 2020-12-03 function selbstverlinkung() statt $_SERVER['PHP_SELF'] |
---|
| 14 | 2020-12-15 Input-Validation und Strict Comparisation (===) |
---|
[425] | 15 | 2021-12-09 Neue Parameter: $katAmtMix (Kataster-Amt-Mix), $PrntBtn (Drucken-SchaltflÀche). Gruppenwechsel Bezirk. |
---|
[427] | 16 | 2022-01-13 Neue Functions LnkStf(), DsKy() |
---|
[362] | 17 | */ |
---|
[422] | 18 | ini_set("session.cookie_httponly", 1); |
---|
[362] | 19 | session_start(); |
---|
[402] | 20 | $multiadress="n"; $showkey="n"; $nodebug=""; // Var. aus Parameter initalisieren |
---|
[387] | 21 | $cntget = extract($_GET); // Parameter in Variable umwandeln |
---|
| 22 | |
---|
| 23 | // strikte Validierung aller Parameter |
---|
[422] | 24 | if (isset($gmlid)) { |
---|
| 25 | if (!preg_match('#^[0-9A-Za-z]{16}$#', $gmlid)) {die("Eingabefehler gmlid");} |
---|
| 26 | } else { |
---|
| 27 | die("Fehlender Parameter"); |
---|
| 28 | } |
---|
| 29 | if (isset($gkz)) { |
---|
| 30 | if (!preg_match('#^[0-9]{3}$#', $gkz)) {die("Eingabefehler gkz");} |
---|
| 31 | } else { |
---|
| 32 | die("Fehlender Parameter"); |
---|
| 33 | } |
---|
[387] | 34 | if (!preg_match('#^[j|n]{0,1}$#', $showkey)) {die ("Eingabefehler showkey");} |
---|
[422] | 35 | if ($showkey === "j") {$showkey=true;} else {$showkey=false;} |
---|
[387] | 36 | if (!preg_match('#^[j|n]{0,1}$#', $multiadress)) {die ("Eingabefehler multiadress");} |
---|
[402] | 37 | if (!preg_match('#^j{0,1}$#', $nodebug)) {die("Eingabefehler nodebug");} |
---|
[387] | 38 | |
---|
[362] | 39 | require_once("alkis_conf_location.php"); |
---|
| 40 | include("alkisfkt.php"); |
---|
| 41 | ?> |
---|
[377] | 42 | <!doctype html> |
---|
| 43 | <html lang="de"> |
---|
[362] | 44 | <head> |
---|
[377] | 45 | <meta charset="utf-8"> |
---|
[387] | 46 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
---|
[362] | 47 | <title>ALKIS Person und Adresse</title> |
---|
| 48 | <link rel="stylesheet" type="text/css" href="alkisauszug.css"> |
---|
| 49 | <link rel="shortcut icon" type="image/x-icon" href="ico/Eigentuemer_2.ico"> |
---|
| 50 | <script type="text/javascript"> |
---|
| 51 | function ALKISexport() { |
---|
| 52 | window.open(<?php echo "'alkisexport.php?gkz=".$gkz."&tabtyp=person&gmlid=".$gmlid."'"; ?>); |
---|
| 53 | } |
---|
| 54 | </script> |
---|
| 55 | </head> |
---|
| 56 | <body> |
---|
[422] | 57 | <?php |
---|
| 58 | $erlaubnis = darf_ich(); if ($erlaubnis === 0) { die('<p class="stop1">Abbruch</p></body>'); } |
---|
[427] | 59 | $dbg=$debug; |
---|
[425] | 60 | if ($nodebug === "j") {$dbg=0;} |
---|
[362] | 61 | |
---|
[427] | 62 | echo "<p class='balken nakennz'>ALKIS Name id=".$gmlid." </p>\n" |
---|
[387] | 63 | ."\n<h2><img src='ico/Eigentuemer.png' width='16' height='16' alt=''> Person</h2>"; |
---|
[377] | 64 | $con = pg_connect($dbconn." options='--application_name=ALKIS-Auskunft_alkisnamstruk.php'"); |
---|
[387] | 65 | if (!$con) "\n<p class='err'>Fehler beim Verbinden der DB</p>"; |
---|
[362] | 66 | |
---|
[412] | 67 | $sql="SELECT p.nachnameoderfirma, p.anrede, p.vorname, p.geburtsname, to_char(cast(p.geburtsdatum AS date),'DD.MM.YYYY') AS geburtsdatum, |
---|
| 68 | p.namensbestandteil, p.akademischergrad, a.beschreibung AS anrv |
---|
| 69 | FROM ax_person p LEFT JOIN ax_anrede_person a ON p.anrede = a.wert WHERE gml_id= $1 AND p.endet IS NULL;"; |
---|
[362] | 70 | |
---|
| 71 | $v = array($gmlid); |
---|
| 72 | $res = pg_prepare("", $sql); |
---|
| 73 | $res = pg_execute("", $v); |
---|
| 74 | |
---|
| 75 | if (!$res) { |
---|
[387] | 76 | echo "\n<p class='err'>Fehler bei Zugriff auf Namensnummer</p>"; |
---|
[425] | 77 | if ($dbg > 2) {echo "\n<p class='dbg'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
[362] | 78 | } |
---|
[425] | 79 | if ($dbg > 0) { |
---|
| 80 | $zeianz=pg_num_rows($res); |
---|
| 81 | if ($zeianz > 1){ |
---|
| 82 | echo "\n<p class='err'>Die Abfrage liefert mehr als eine Person!</p>"; |
---|
| 83 | if ($dbg > 2) {echo "\n<p class='dbg'>SQL=<br>".htmlentities(str_replace("$1","'".$gmlid."'",$sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
| 84 | } |
---|
| 85 | } |
---|
[402] | 86 | if ($row = pg_fetch_assoc($res)) { |
---|
[362] | 87 | $vor=htmlentities($row["vorname"], ENT_QUOTES, "UTF-8"); |
---|
| 88 | $nam=htmlentities($row["nachnameoderfirma"], ENT_QUOTES, "UTF-8"); |
---|
| 89 | $geb=htmlentities($row["geburtsname"], ENT_QUOTES, "UTF-8"); |
---|
| 90 | $anrk=$row["anrede"]; // Key |
---|
| 91 | $anr=$row["anrv"]; // Value |
---|
[387] | 92 | $nbest=htmlentities($row["namensbestandteil"], ENT_QUOTES, "UTF-8"); |
---|
| 93 | $aka=htmlentities($row["akademischergrad"], ENT_QUOTES, "UTF-8"); |
---|
[362] | 94 | |
---|
[387] | 95 | echo "<table>" |
---|
[427] | 96 | ."\n\t<tr><td class='nhd'>Anrede:</td><td class='nam'>".DsKy($anrk, '* der Anrede-Kennung').$anr."</td></tr>" |
---|
[387] | 97 | ."\n\t<tr><td class='nhd'>Nachname oder Firma:</td><td class='nam'>".$nam."</td></tr>" |
---|
| 98 | ."\n\t<tr><td class='nhd'>Vorname:</td><td class='nam'>".$vor." </td></tr>" |
---|
| 99 | ."\n\t<tr><td class='nhd'>Geburtsname:</td><td class='nam'>".$geb." </td></tr>" |
---|
| 100 | ."\n\t<tr><td class='nhd'>Geburtsdatum:</td><td class='nam'>".$row["geburtsdatum"]." </td></tr>" |
---|
| 101 | ."\n\t<tr><td class='nhd'>Namensbestandteil:</td><td class='nam'>".$nbest." </td></tr>" |
---|
| 102 | ."\n\t<tr><td class='nhd'>akademischer Grad:</td><td class='nam'>".$aka." </td></tr>" |
---|
| 103 | ."\n</table>\n<hr>"; |
---|
[362] | 104 | |
---|
| 105 | // A d r e s s e |
---|
[422] | 106 | if ($multiadress === "j") {$plural="n";} else {$plural="";} |
---|
[398] | 107 | echo "\n\n<h3><img src='ico/Strasse_mit_Haus.png' width='16' height='16' alt=''> Adresse".$plural."</h3>"; |
---|
| 108 | // Es können redundante Adressen vorhanden sein, z.B. aus Migration, temporÀr aus LBESAS. |
---|
[412] | 109 | // Im Normalfall nur die "letzte" davon anzeigen. Auf Wunsch alle anzeigen, dazu den Anlass und das Datum um das zu bewerten. |
---|
| 110 | $sqla ="SELECT a.gml_id, w.value AS anltxt, a.anlass, to_char(cast(a.beginnt AS date),'DD.MM.YYYY') AS datum, a.ort_post, a.postleitzahlpostzustellung AS plz, a.strasse, a.hausnummer, a.bestimmungsland " |
---|
[398] | 111 | ."FROM ax_anschrift a JOIN ax_person p ON a.gml_id=ANY(p.hat) " |
---|
[412] | 112 | ."LEFT JOIN aa_anlassart w ON w.id = ANY(a.anlass) " |
---|
[398] | 113 | ."WHERE p.gml_id= $1 AND a.endet IS NULL AND p.endet IS NULL ORDER BY a.beginnt DESC ;"; |
---|
[362] | 114 | |
---|
| 115 | $v = array($gmlid); |
---|
| 116 | $resa = pg_prepare("", $sqla); |
---|
| 117 | $resa = pg_execute("", $v); |
---|
| 118 | if (!$resa) { |
---|
[387] | 119 | echo "\n<p class='err'>Fehler bei Adressen</p>"; |
---|
[425] | 120 | if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>". str_replace("$1", "'".$gmlid."'", $sqla)."</p>";} |
---|
[362] | 121 | } |
---|
| 122 | |
---|
| 123 | $j=0; |
---|
| 124 | // Parameter $multiadress = j zeigt ALLE Adressen an |
---|
[402] | 125 | while($rowa = pg_fetch_assoc($resa)) { |
---|
[362] | 126 | $j++; |
---|
[422] | 127 | if ($multiadress === "j" OR $j === 1) { |
---|
[362] | 128 | $gmla=$rowa["gml_id"]; |
---|
| 129 | $plz=$rowa["plz"]; |
---|
| 130 | $ort=htmlentities($rowa["ort_post"], ENT_QUOTES, "UTF-8"); |
---|
| 131 | $str=htmlentities($rowa["strasse"], ENT_QUOTES, "UTF-8"); |
---|
| 132 | $hsnr=$rowa["hausnummer"]; |
---|
| 133 | $land=htmlentities($rowa["bestimmungsland"], ENT_QUOTES, "UTF-8"); |
---|
[398] | 134 | $anlass=trim($rowa["anlass"], "{}"); // Key |
---|
| 135 | $anltxt=$rowa["anltxt"]; // Value |
---|
| 136 | $datum=$rowa["datum"]; |
---|
| 137 | echo "<table>\n"; |
---|
[422] | 138 | if ($multiadress === "j" OR $showkey) { |
---|
[425] | 139 | if ($dbg > 0) { // nur Entw.: Sortierung gml_id vs. beginnt? |
---|
[398] | 140 | echo "\t<tr><td class='dbg'>gml_id:</td><td class='dbg'>".$rowa["gml_id"]."</td></tr>\n"; |
---|
| 141 | } |
---|
| 142 | echo "\t<tr><td class='nhd'>Datum:</td><td class='nam'>".$datum."</td></tr>\n" |
---|
[427] | 143 | ."\t<tr><td class='nhd'>Anlass:</td><td class='nam'>".DsKy($anlass, 'Anlass-*').$anltxt."</td></tr>\n"; |
---|
[398] | 144 | } |
---|
| 145 | echo "\t<tr><td class='nhd'>PLZ:</td><td class='nam'>".$plz."</td></tr>\n" |
---|
[362] | 146 | ."\t<tr><td class='nhd'>Ort:</td><td class='nam'>".$ort."</td></tr>\n" |
---|
| 147 | ."\t<tr><td class='nhd'>Strasse:</td><td class='nam'>".$str."</td></tr>\n" |
---|
| 148 | ."\t<tr><td class='nhd'>Hausnummer:</td><td class='nam'>".$hsnr."</td></tr>\n" |
---|
| 149 | ."\t<tr><td class='nhd'>Land:</td><td class='nam'>".$land."</td></tr>\n" |
---|
[387] | 150 | ."\n</table>\n<br>"; |
---|
[362] | 151 | |
---|
[427] | 152 | // Name und Adresse Kompakt (im Rahmen) - Alles was man fÃŒr ein Anschreiben braucht |
---|
[387] | 153 | echo "\n<img src='ico/Namen.png' width='16' height='16' alt='Brief' title='Anschrift'>" |
---|
| 154 | ."\n<div class='adr' title='Anschrift'>\n\t".$anr." ".$aka." ".$vor." ".$nbest." ".$nam."<br>" |
---|
| 155 | ."\n\t".$str." ".$hsnr."<br>" |
---|
| 156 | ."\n\t".$plz." ".$ort."\n</div>"; |
---|
[362] | 157 | } |
---|
| 158 | } |
---|
| 159 | pg_free_result($resa); |
---|
[422] | 160 | if ($j === 0) { |
---|
[387] | 161 | echo "\n<p class='err'>Keine Adressen.</p>"; |
---|
[362] | 162 | } elseif ($j > 1) { |
---|
| 163 | echo "\n\t\t<p class='nwlink noprint'>" |
---|
[427] | 164 | ."\n\t\t\t<a href='".selbstverlinkung(). "?gkz=".$gkz."&gmlid=".$gmlid.LnkStf(); |
---|
[422] | 165 | if ($multiadress === "j") { |
---|
[362] | 166 | echo "&multiadress=n' title='mehrfache Adressen unterdrücken'>erste Adresse "; |
---|
| 167 | } else { |
---|
| 168 | echo "&multiadress=j' title='Adressen ggf. mehrfach vorhanden'>alle Adressen "; |
---|
| 169 | } |
---|
| 170 | echo "\n\t\t\t</a>" |
---|
| 171 | ."\n\t\t</p>"; |
---|
| 172 | } |
---|
| 173 | |
---|
[427] | 174 | // G R U N D B U C H |
---|
[387] | 175 | echo "\n<hr>\n<h3><img src='ico/Grundbuch_zu.png' width='16' height='16' alt=''> Grundbücher</h3>"; |
---|
[362] | 176 | // person <benennt< namensnummer >istBestandteilVon> Buchungsblatt |
---|
| 177 | // >bestehtAusRechtsverhaeltnissenZu> namensnummer (Nebenzweig/SonderfÀlle?) |
---|
| 178 | |
---|
[412] | 179 | $sqlg ="SELECT n.gml_id AS gml_n, n.laufendenummernachdin1421 AS lfd, n.zaehler, n.nenner, g.gml_id AS gml_g, g.bezirk, g.buchungsblattnummermitbuchstabenerweiterung as nr, g.blattart, wb.beschreibung AS blattartv, b.bezeichnung AS beznam " |
---|
[387] | 180 | ."FROM ax_person p JOIN ax_namensnummer n ON p.gml_id=n.benennt " |
---|
| 181 | ."JOIN ax_buchungsblatt g ON g.gml_id=n.istbestandteilvon " |
---|
[425] | 182 | ."LEFT JOIN ax_buchungsblattbezirk b ON g.land=b.land AND g.bezirk=b.bezirk ".UnqKatAmt("g","b") |
---|
[412] | 183 | ."LEFT JOIN ax_blattart_buchungsblatt wb ON g.blattart = wb.wert " |
---|
[389] | 184 | ."WHERE p.gml_id= $1 AND p.endet IS NULL AND n.endet IS NULL AND b.endet IS NULL " |
---|
[387] | 185 | ."ORDER BY b.bezeichnung, g.buchungsblattnummermitbuchstabenerweiterung, n.laufendenummernachdin1421;"; |
---|
[362] | 186 | |
---|
| 187 | $v = array($gmlid); |
---|
| 188 | $resg = pg_prepare("", $sqlg); |
---|
| 189 | $resg = pg_execute("", $v); |
---|
| 190 | |
---|
| 191 | if (!$resg) { |
---|
[387] | 192 | echo "\n<p class='err'>Fehler bei Grundbuch</p>"; |
---|
[425] | 193 | if ($dbg > 2) { |
---|
[422] | 194 | echo "\n<p class='err'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sqlg ), ENT_QUOTES, "UTF-8")."</p>"; |
---|
[387] | 195 | } |
---|
[362] | 196 | } |
---|
| 197 | echo "<table class='eig'>" |
---|
| 198 | ."\n<tr>" |
---|
[377] | 199 | ."\n\t<td class='heads'>Bezirk<img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'></td>" |
---|
[362] | 200 | ."\n\t<td class='head'>Blattart</td>" |
---|
[377] | 201 | ."\n\t<td class='heads'>Blatt<img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'></td>" |
---|
| 202 | ."\n\t<td class='heads'>Namensnummer<img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'></td>" |
---|
[362] | 203 | ."\n\t<td class='head'>Anteil</td>" |
---|
[387] | 204 | ."\n\t<td class='head nwlink noprint' title='Verlinkung zu anderen Nachweis-Arten und verbundenen Objekten'>weitere Auskunft</td>" |
---|
[362] | 205 | ."\n</tr>"; |
---|
| 206 | |
---|
| 207 | $i=0; |
---|
[387] | 208 | $zpaar=false; |
---|
[425] | 209 | $gwbeznam=''; |
---|
[402] | 210 | while($rowg = pg_fetch_assoc($resg)) { |
---|
[362] | 211 | $gmln=$rowg["gml_n"]; |
---|
| 212 | $gmlg=$rowg["gml_g"]; |
---|
| 213 | $namnum=kurz_namnr($rowg["lfd"]); |
---|
| 214 | $zae=$rowg["zaehler"]; |
---|
| 215 | $blattkey=$rowg["blattart"]; // Key |
---|
| 216 | $blattart=$rowg["blattartv"]; // Value |
---|
[387] | 217 | if ($zpaar) {$trclass='paa';} else {$trclass='unp';} |
---|
[425] | 218 | $beznam=$rowg["beznam"]; |
---|
[387] | 219 | $zpaar=!$zpaar; |
---|
| 220 | echo "\n<tr class='".$trclass."'>" |
---|
[427] | 221 | ."\n\t<td>".DsKy($rowg["bezirk"], 'Grundbuch-Bezirks-*'); |
---|
| 222 | if ($gwbeznam != $beznam){ |
---|
| 223 | echo "<b>".$beznam."</b>"; |
---|
| 224 | $gwbeznam=$beznam; |
---|
| 225 | } else { |
---|
| 226 | echo $beznam; |
---|
| 227 | } |
---|
[425] | 228 | echo "</td>"; |
---|
[362] | 229 | |
---|
[427] | 230 | echo "\n\t<td>".DsKy($blattkey, 'Blattart-*').$blattart."</td>"; |
---|
| 231 | echo "\n\t<td><span class='wichtig'>".$rowg["nr"]."</span></td>";// Blatt |
---|
[362] | 232 | |
---|
[387] | 233 | echo "\n\t<td>"; // Namensnummer |
---|
[427] | 234 | if ($namnum == "") { |
---|
| 235 | echo " "; |
---|
| 236 | } else { |
---|
| 237 | echo $namnum; |
---|
| 238 | } |
---|
[362] | 239 | echo "</td>"; |
---|
| 240 | |
---|
[387] | 241 | echo "\n\t<td>"; // Anteil |
---|
[427] | 242 | if ($zae == '') { |
---|
| 243 | echo " "; |
---|
| 244 | } else { |
---|
| 245 | echo $zae."/".$rowg["nenner"]." Anteil"; |
---|
| 246 | } |
---|
[362] | 247 | echo "</td>" |
---|
[387] | 248 | ."\n\t<td>" |
---|
[427] | 249 | ."\n\t\t<p class='nwlink noprint'>" |
---|
| 250 | ."\n\t\t\t<a href='alkisbestnw.php?gkz=".$gkz."&gmlid=".$gmlg.LnkStf()."' title='Bestandsnachweis'>".$blattart |
---|
| 251 | ."\n\t\t\t<img src='ico/GBBlatt_link.png' width='16' height='16' alt=''></a>" |
---|
| 252 | ."\n\t\t</p>" |
---|
[362] | 253 | ."\n\t</td>" |
---|
| 254 | ."\n</tr>"; |
---|
| 255 | // +++ >bestehtAusRechtsverhaeltnissenZu> namensnummer ? |
---|
| 256 | // z.B. eine Namennummer "Erbengemeinschaft" zeigt auf Namensnummern mit EigentÃŒmern |
---|
| 257 | $i++; |
---|
| 258 | } |
---|
| 259 | pg_free_result($resg); |
---|
| 260 | echo "</table>"; |
---|
[422] | 261 | if ($i === 0) {echo "\n<p class='err'>Kein Grundbuch.</p>";} |
---|
[362] | 262 | } else { |
---|
[425] | 263 | echo "\n\t<p class='err'>Fehler! Kein Treffer für Person".$gmlid."</p>\n"; |
---|
[362] | 264 | } |
---|
[425] | 265 | pg_free_result($res); |
---|
[362] | 266 | |
---|
[425] | 267 | echo "\n<div class='buttonbereich noprint'>\n<hr>" |
---|
| 268 | ."\n\t<a title='zurück' href='javascript:history.back()'><img src='ico/zurueck.png' width='16' height='16' alt='zurück'></a> "; |
---|
| 269 | if ($PrntBtn==true){echo "\n\t<a title='Drucken' href='javascript:window.print()'><img src='ico/print.png' width='16' height='16' alt='Drucken'></a> ";} |
---|
| 270 | echo "\n\t<a title='Export als CSV' href='javascript:ALKISexport()'><img src='ico/download.png' width='16' height='16' alt='Export'></a> " |
---|
| 271 | ."\n</div>"; |
---|
[362] | 272 | |
---|
[425] | 273 | footer($gmlid, selbstverlinkung()."?", ""); |
---|
| 274 | ?> |
---|
[362] | 275 | |
---|
| 276 | </body> |
---|
| 277 | </html> |
---|