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