-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathname_list_results.php
335 lines (227 loc) · 8.92 KB
/
name_list_results.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<html>
<meta charset="UTF-8">
<body onLoad="contaselected('ListaIdForm',null)">
<head>
<link href="https://fonts.googleapis.com/css?family=Slabo+27px" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="cxc.css" type="text/css" media="all">
<script type="text/javascript" language="javascript">// <![CDATA[
function checkAll(formname, elem, modo)
{
var checkboxes = new Array();
var nck = 0 ;
var totnck = 0 ;
checkboxes = document[formname].getElementsByTagName('input');
for (var i=0; i<checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox' && checkboxes[i].id=='cbdet' ) {
totnck=totnck+1;
if (modo=='toggle') {
checkboxes[i].checked = !checkboxes[i].checked;
}
if (modo=='sel_unsel_all') {
checkboxes[i].checked = elem.checked;
}
if (checkboxes[i].checked) {
nck=nck+1;
}
}
}
document.getElementById('textsele').textContent = nck + "/" + totnck;
}
function contaselected(formname, elem)
{
var checkboxes = new Array();
var nck = 0 ;
var totnck = 0 ;
checkboxes = document[formname].getElementsByTagName('input');
for (var i=0; i<checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox' && checkboxes[i].id=='cbdet' ) {
totnck=totnck+1;
if (checkboxes[i].checked) {
nck=nck+1;
}
}
}
document.getElementById('textsele').textContent = nck + "/" + totnck;
if (totnck<1) {
document.getElementById('buttonClass').style.visibility = 'hidden';
} else {
document.getElementById('buttonClass').style.visibility = 'visible';
}
}
// ]]></script>
<script type="text/javascript">
window.onclick = function(e) {
// alert(e.target.parentNode);
if (e.target.id == 'cbdet') {
contaselected('ListaIdForm',null);
}
};
</script>
</head>
<?php
$n=trim(htmlspecialchars($_GET["n"]));
$ritorna=$n;
include "testata.php";
//print "<br>";
function SqliteNumRows($ris){
$numRows = 0;
while($row = $ris->fetchArray()){
++$numRows;
}
return $numRows;
}
$db = new SQLite3('catasto.db');
//$db->loadExtension('mod_spatialite.so');
$query="
select
DISTINCT tit.idSoggetto as idSog,
tit.titoloNonCod as titplus,
tit.tipoSoggetto as tipsog,
CASE
WHEN tit.tipoSoggetto='P'
THEN per.cognome||' '||per.nome
WHEN tit.tipoSoggetto='G'
THEN giu.denominazione
END as denomin,
CC.decodifica as lnasc,
substr('per'.'dataNascita',9,2)||'/'||substr('per'.'dataNascita',6,2)||'/'||substr('per'.'dataNascita',1,4) as dnasc,
CASE
WHEN tit.tipoSoggetto='P'
THEN trim(per.codFiscale)
WHEN tit.tipoSoggetto='G'
THEN trim(giu.codFiscale)
END as codice_fiscale
From titolarita as tit
left join persona_fisica as per On tit.idSoggetto = per.idSoggetto
left join persona_giuridica as giu On tit.idSoggetto = giu.idSoggetto
left join COD_COMUNE as CC On per.luogoNascita = CC.codice
where denomin like '%" . $n . "%'
GROUP BY idSog
ORDER BY denomin ASC, substr('per'.'dataNascita',1,4) DESC, idSog ASC ";
## imposto il limite di tempo, in secondi, per eseguire la query . Di default è 30 s
set_time_limit(360);
//$risultato = $db->query($query);
$risultato = $db->query($query);
$totRows=SqliteNumRows($risultato);
if ($totRows>0)
{
echo "<hr>";
print "<h3>ricerca per</h3><p>" . $n . "</p>";
// se il risultato e' maggiore di 1
if ($totRows>1)
{
print "<p>restituiti " . $totRows . " risultati</p>";
}
echo "<hr>";
print "<form id=\"ListaIdForm\" name=\"ListaIdForm\" method=\"POST\" action=\"nctr_soggetto_multi.php\">";
print "<div id=\"checkboxlist\">";
print "<table>";
print "<tr ><th>
<p>tutti</p>
<input type=\"checkbox\" onclick=\"javascript:checkAll('ListaIdForm', this, 'sel_unsel_all');\" href=\"javascript:void();\" /> <br><div id='textsele'></div>
</th><th style=\"text-align:left\";><b></b></th><th style='text-align:left';>denominazione</th><th style='text-align:left';>luogo di<br>nascita</th><th style='text-align:left';>data di<br>nascita</th><th>codice<br>fiscale</th></tr>";
while ($table = $risultato->fetchArray(SQLITE3_ASSOC))
{
$idSog= $table['idSog'];
$tipo=$table['tipsog'];
$nomin=$table['denomin'];
$denomin=$table['denomin'] ." " . $table['titplus']. " " .$table['lnasc']. " " .$table['dnasc']." ".$table['codice_fiscale'];
print "<tr>";
print "<td><div><input type=\"checkbox\" id=\"cbdet\" value=\"" . $idSog . "," . $denomin . "\" class=\"chk\">
<input method=\"Get\" type=\"hidden\" value=\"". $n ."\" name=\"n\";>
</div></td>\n";
?>
<?php
print "<td>" . "<p><a href=\"nctr_soggetto.php?idSog=$idSog&ricerca=$n&tipo=$tipo&n=$denomin\" target=\"_self\">".$idSog."</a></p>" . "</td>";
print "<td style='text-align:left';>" . $nomin . "</td>";
print "<td style='text-align:left';>" . $table['lnasc'] . "</td>";
print "<td style='text-align:left';>" . $table['dnasc'] . "</td>";
print "<td>" . $table['codice_fiscale'] . "</td>";
print "</tr>";
}
print "</table>";
print "</div>";
print '<input type="hidden" id="idSogList" name="idSogList" value="" />';
#print '<input type="hidden" id="nSogList" name="nSogList" value="" />';
print '<input type="submit" value="Cerca i valori selezionati" id="buttonClass"> ';
print ' </div>';
print "</form>";
?>
<script type="text/javascript">
/* if the page has been fully loaded we add two click handlers to the button */
$(document).ready(function () {
/* Get the checkboxes values based on the class attached to each check box */
$("#buttonClass").click(function() {
getValueUsingClass();
});
/* Get the checkboxes values based on the parent div id */
$("#buttonParent").click(function() {
getValueUsingParentTag();
});
});
function getValueUsingClass(){
/* declare an checkbox array */
var chkArray = [];
/* look for all checkboes that have a class 'chk' attached to it and check if it was checked */
$(".chk:checked").each(function() {
chkArray.push($(this).val());
//document.getElementById('idSogList').push($(this).val());
});
/* we join the array separated by the comma */
var selected;
selected = chkArray.join(',') + ",";
document.getElementById('idSogList').value = selected;
/* check if there is selected checkboxes, by default the length is 1 as it contains one single comma */
if(selected.length > 1){
//alert("valore della variabile document.getElementById('idSogList').value " + document.getElementById('idSogList').value);
//open("./nctr_soggetto_multi.php?idSogList=" + selected + "&n=Selezione multivalore")
// document.ListaIdForm.idSogList.value = chkArray;
// document.forms["ListaIdForm"].submit();
// document.ListaIdForm.idSogList.value = idSogList;
//open("./nctr_soggetto_multi.php?idSogList" + "&n=Selezione multivalore")
}else{
alert("Selezionate almeno una riga tramite il checkbox");
return false;
}
}
function getValueUsingParentTag(){
var chkArray = [];
/* look for all checkboes that have a parent id called 'checkboxlist' attached to it and check if it was checked */
$("#checkboxlist input:checked").each(function() {
chkArray.push($(this).val());
});
/* we join the array separated by the comma */
var selected;
selected = chkArray.join(',') + ",";
/* check if there is selected checkboxes, by default the length is 1 as it contains one single comma */
if(selected.length > 1){
alert("You have selected " + selected);
}else{
alert("Please at least one of the checkbox");
}
}
</script>
<?php
}ELSE {
?>
<!-- se il risultato della ricerca non è > 0 esegue lo java script... e riporta alla pagina di ricerca -->
<script type="text/javascript">
function doRedirect() {
//Genera il link alla pagina che si desidera raggiungere
location.href = "cerca_nominativo.php"
}
//Questo è il messaggio di attesa di redirect in corso…
document.write("Nessun risultato... sarai riportato alla maschera di ricerca");
//Fa partire il redirect dopo 10 secondi da quando l'intermprete JavaScript ha rilevato la funzione
//Fa partire il redirect dopo 2 secondi da quando l'intermprete JavaScript ha rilevato la funzione
window.setTimeout("doRedirect()", 2000);
</script>
<!-- FINE java -->
<?php
}
echo "<br>";
?>
</body>
</html>