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