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