-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnctr_soggetto_multi_unito.php
executable file
·305 lines (225 loc) · 9.7 KB
/
nctr_soggetto_multi_unito.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<html>
<meta charset="UTF-8">
<body>
<head>
<link rel="stylesheet" href="cxc.css" type="text/css" media="all">
</head>
<script>
function f_nctr() {
var x = document.getElementById('NCTR');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
</script>
<script>
function f_nceu() {
var x = document.getElementById('NCEU');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
</script>
<?php
#$idSog=trim($_GET["idSog"]);
#print ($_REQUEST['idSogList']);
// print var_dump($_POST["idSogList"]);
//print_r($_POST);
// $denomin=htmlspecialchars($_POST["nSogList"]);
include './testata.php';
function SqliteNumRows($ris){
$numRows = 0;
while($row = $ris->fetchArray()){
++$numRows;
}
return $numRows;
}
$a=0;
// estraggo l'array dal form name_list_results.php
$List=$_POST["idSogList"];
//print $List;
// estraggo i dati idsoggetto|nominativo
$SogList=explode(",", $List);
#print $SogList[2];
#print "$SogList : ".$SogList."<br>";
$totSelect=(count($SogList));
//print $totSelect;
$idSoggs="";
while ($a<$totSelect-1) {
// print $SogList[$i];
$idSog=$SogList[$a];
$b=$a+1;
$idSoggs=$idSoggs . $idSog . ",";
$a=$a+2;
}
#tolgo virgola finale
$idSoggs=rtrim(trim($idSoggs),",");
$db = new SQLite3('catasto.db');
$denomin="Risultato unito multi intestatari";
dettaglio_terreni($db ,$idSoggs,$denomin );
dettaglio_urbano( $db ,$idSoggs,$denomin );
$db->close();
print "<br><br>";
#################################################################################################
########################## --> CERCA IN NUOVO CATASTO TERRENI <-- ###############################
#################################################################################################
function dettaglio_terreni($db,$idSoggs,$denomin ) {
// 25.03.2017 modificata query con distict e GROUP BY, per evidenziare le particelle una sola volta anche quando idSoggetto compare più volte
$query="select
distinct tit.idParticella as idPart,
tit.idSoggetto,
ltrim(pa.foglio,'0') as fg,
ltrim(pa.numero,'0') as map,
CQ.decodifica as qualita,
ltrim(CP.classe,'0') as cl,
CP.ettari*10000+CP.are*100+CP.centiare as superf,
CP.redditoDomEuro as RD,
CP.redditoAgrEuro as RA,
CD.decodifica as diritto,
tit.quotaNum ||'/'|| tit.quotaDen as quota
From TITOLARITA as tit, PARTICELLA as pa
left join CARATTERISTICHE_PARTICELLA as CP on CP.idParticella=idPart
left join COD_DIRITTO as CD on tit.codDiritto=CD.codice
left join COD_QUALITA as CQ on CP.codQualita=CQ.codice
where tit.idSoggetto in(".$idSoggs.") and tit.idParticella=pa.idParticella
GROUP BY idPart
ORDER BY fg ASC, map ASC
";
## imposto il limite di tempo, in secondi, per eseguire la query . Di default è 30s
set_time_limit(420);
$risultato = $db->query($query);
$totRows=SqliteNumRows($risultato);
if ($totRows>0) {
echo "<hr>";
print "<h4>Nuovo Catasto Terreni Revisionato </h4>";
print "<span style='font-size:13px'><b>Risultati per gli identificativi: <b>".$idSoggs." " . $denomin . "</b></span></b>";
if ($totRows>1) {
print "<p>estratti da terreni ". $totRows . " elementi </p>";
/*
?>
<button onclick="f_nctr()">mostra/nascondi</button>
<?php
*/
}
print "<p> <a href=\"catasto_particelle_2geojson.php?idSog=$idSoggs&n=$denomin\" target=\"_blank\"> mappa...</a></p>";
print "<div id=\"NCTR\">";
print "<table>";
print "<tr ><th></th><th></th><th></th><th>foglio</th><th>map</th><th>qualita</th><th>cl</th><th>superf</th><th>RD</th><th>RA</th><th>diritto</th><th>quota</th></tr>";
$num=1;
while ($table = $risultato->fetchArray(SQLITE3_ASSOC)) {
$idPart=$table['idPart'];
$f=$table['fg'];
$m=$table['map'];
//$idParticella=$table['idParticella'];
print "<tr style='vertical-align:middle';>";
print "<td></td>";
print "<td style='text-align:right';><p><small>" . $num .")</small></p></td>";
print "<td style='text-align:left';>" . "<p><a href=\"nctr_results.php?f=$f&m=$m&n=$denomin\" target=\"_self\">visura</a></p>" . "</td>";
print "<td><b>" . $table['fg'] . "</b></td>";
print "<td><b>" . $table['map'] . "</b></td>";
#print "<td style='text-align:left';>" . $table['denomin'] . "</td>";
print "<td>" . $table['qualita'] . "</td>";
print "<td>" . $table['cl'] . "</td>";
print "<td>" . $table['superf'] . "</td>";
print "<td>" . $table['RD'] . "</td>";
print "<td>" . $table['RA'] . "</td>";
print "<td>" . $table['diritto'] . "</td>";
print "<td>" . $table['quota'] . "</td>";
print "</tr>";
++$num;
} # end table
print "</table>";
}
}
#################################################################################################
########################## --> NUOVO CATASTO EDILIZIO URBANO <-- ################################
#################################################################################################
function dettaglio_urbano($db,$idSoggs,$denomin ) {
$query_nceu="
select
UI.IdMutazioneFinale,
tit.idSoggetto,
tit.idImmobile as idImm,
ltrim(II.foglio,'0') as fg,
ltrim(II.numero,'0') as map,
ltrim(II.subalterno,'0') as sub,
ltrim(UI.zona,'0') as zona,
CASE
WHEN 'UI'.'categoria'<>'A10'
THEN replace( 'UI'.'categoria', '0', '/' )
ELSE replace( 'UI'.'categoria', '10', '/10' )
END as categoria,
CASE
WHEN substr('UI'.'categoria',1,1)='A'
THEN ('UI'.'consistenza'||' vani')
WHEN substr('UI'.'categoria',1,1)='B'
THEN ('UI'.'consistenza'||' mc')
WHEN substr('UI'.'categoria',1,1)='C'
THEN ('UI'.'consistenza'||' mq')
ELSE ''
END as consistenza,
(ltrim('UI'.'piano1','0')||' '||ltrim('UI'.'piano2','0')||' '||ltrim('UI'.'piano3','0')||' '||ltrim('UI'.'piano4','0')) as piano,
'CT'.'decodifica'||' '||'INDIRIZZI'.'indirizzo'||' ' ||ltrim('INDIRIZZI'.'civico1','0')||' ' ||ltrim('INDIRIZZI'.'civico2','0')||' ' ||ltrim('INDIRIZZI'.'civico3','0') as indirizzo,
UI.renditaEuro as rendita,
CD.decodifica as diritto,
tit.quotaNum||'/'||tit.quotaDen as quota
From TITOLARITA as tit, IDENTIFICATIVI_IMMOBILIARI as II
left join INDIRIZZI on INDIRIZZI.idImmobile=II.idImmobile
left join COD_DIRITTO as CD on CD.codice = tit.codDiritto
left join UNITA_IMMOBILIARI as UI on UI.idImmobile=tit.idImmobile and UI.IdMutazioneFinale=''
left join COD_TOPONIMO as CT on INDIRIZZI.toponimo=CT.codice
where tit.idSoggetto in(".$idSoggs.") and II.idImmobile = tit.idImmobile AND categoria!=''
ORDER BY fg ASC, map ASC, sub ASC";
$risultato_nceu = $db->query($query_nceu);
$totRows_nceu=SqliteNumRows($risultato_nceu);
if ($totRows_nceu>0){
echo "<hr>";
print "<h4>Nuovo Catasto Edilizio Urbano</h4>";
print "<span style='font-size:13px'><b>Risultati gli identificativi <b><small>".$idSoggs."</small> " . $denomin . "</b></span></b>";
if ($totRows_nceu>1) {
print "<p>estratti da urbano ". $totRows_nceu ." elementi -</p> ";
/*
?>
<button onclick="f_nceu()">mostra/nascondi</button>
<?php
*/
}
print "<p></p><a href=\"catasto_nceu_2geojson.php?idSog=$idSoggs&n=$denomin\" target=\"_blank\">mappa...</a></p>";
print "<div id=\"NCEU\">";
echo "<hr>";
//print "<span style='font-size:10px'><h4>ricerca per foglio <b>" . per . "</h4></span></b>";
print "<table>";
print "<tr ><th></th><th></th><th>foglio</th><th>map</th><th>sub</th><th>zona</th><th>cat</th><th>consistenza</th><th>piano</th><th>indirizzo</th><th>rendita</th><th>diritto</th><th>quota</th></tr>";
## imposto il limite di tempo, in secondi, per eseguire la query . Di default è 30 s
set_time_limit(360);
$num=1;
while ($table = $risultato_nceu->fetchArray(SQLITE3_ASSOC)) {
//$idParticella=$table['idParticella'];
print "<tr>";
print "<td style='text-align:right';><p><small>" . $num .")</small></p></td>";
print "<td style='text-align:left';>" . "<p><a href=\"nceu_results.php?id=". $table['idImm'] . "\" target=\"_self\">visura</a></p>" . "</td>";
print "<td><b>" . $table['fg'] . "</b></td>";
print "<td><b>" . $table['map'] . "</b></td>";
//print "<td style='text-align:left';>" . $table['denomin'] . "</td>";
print "<td><b>" . $table['sub'] . "</b></td>";
print "<td>" . $table['zona'] . "</td>";
print "<td>" . $table['categoria'] . "</td>";
print "<td>" . $table['consistenza'] . "</td>";
print "<td>" . $table['piano'] . "</td>";
print "<td>" . $table['indirizzo'] . "</td>";
print "<td>" . $table['rendita'] . "</td>";
print "<td>" . $table['diritto'] . "</td>";
print "<td>" . $table['quota'] . "</td>";
print "</tr>";
++$num;
} # end while table
print "</table>";
} #
}
?>
</body>
</html>