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