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