source: trunk/admin/modules/Elezioni/ele_associazioni.php@ 282

Last change on this file since 282 was 282, checked in by roby, 6 years ago
File size: 21.5 KB
Line 
1<?php
2
3/************************************************************************/
4/* Eleonline - Raccolta e diffusione dei dati elettorali */
5/* by Roberto Gigli & Luciano Apolito */
6/* http://www.eleonline.it */
7/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
8/************************************************************************/
9/* Modulo Autorizzazione Comuni */
10/* Amministrazione */
11/************************************************************************/
12# e' l'unico file in cui Ú presente un controllo su tipo_cons, per ora va bene così. Per toglierlo va inserito un campo-flag in ele_tipo per indicare se per il tipo di consultazione si dovra' procedere al calcolo dell'assegnazione dei seggi
13if (!defined('ADMIN_FILE')) {
14 die ("You can't access this file directly...");
15}
16global $dbi;
17$aid=$_SESSION['aid'];
18$prefix=$_SESSION['prefix'];
19$id_comune=$_SESSION['id_comune'];
20$sql = $dbi->prepare("SELECT * FROM ".$prefix."_config");
21$sql->execute();
22$riga = $sql->fetchAll(PDO::FETCH_ASSOC);
23$row=$riga[0];
24$language = $row['language'];
25$id_cons_gen=intval($_GET['id_cons_gen']);
26$perms=ChiSei(0);
27if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
28$sql="SELECT t1.tipo_cons,t1.descrizione,t2.id_cons,t2.id_conf FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' ";
29$res = $dbi->prepare("$sql");
30$res->execute();
31# $gru = $sth->fetch(PDO::FETCH_BOTH);
32list($tipo_cons,$descr_cons,$id_cons,$id_conf) = $res->fetch(PDO::FETCH_NUM);
33
34$sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
35$res = $dbi->prepare("$sql");
36$res->execute();
37list($genere) = $res->fetch(PDO::FETCH_NUM);
38
39include("modules/Elezioni/funzionidata.php");
40include("modules/Elezioni/ele.php");
41if (isset($_GET['descr_comu'])) get_magic_quotes_gpc() ? $descr_comu=$param['descr_comu']:$descr_comu=addslashes($param['descr_comu']); else $descr_comu='';
42if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
43if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
44if (isset($_GET['id_cons_comu'])) $id_cons_comu=intval($_GET['id_cons_comu']); else $id_cons_comu='0';
45if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']); else $id_collegio='0';
46if (isset($_GET['idcomune'])) $idcomune=intval($_GET['idcomune']); else $idcomune='';
47if (isset($_GET['idcomunenew'])) $idcomunenew=intval($_GET['idcomunenew']); else $idcomunenew='0';
48if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa='0';
49if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']); else $id_conf=0;
50if (isset($_GET['idfascia'])) $idfascia=intval($_GET['idfascia']); else $idfascia=0;
51if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
52if (isset($_GET['help'])) $help=intval($_GET['help']); else $help='';
53if (isset($_GET['pwd4'])) $pwd4=intval($_GET['pwd4']); else $pwd4='';
54if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1;
55if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0;
56if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg=0;
57if (isset($_GET['disgiunto'])) $disgiunto=intval($_GET['disgiunto']); else $disgiunto=0;
58
59$offset=15;
60$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
61
62
63 /******************************************************/
64 /*Funzione di visualizzazione globale */
65 /*****************************************************/
66 //
67 function all() {
68 global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf,$sg,$disgiunto,$id_cons_comu;
69$aid=$_SESSION['aid'];
70$prefix=$_SESSION['prefix'];
71############# Controllo flag per cancellazione consultazione
72 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
73 ."//-->\n";
74 echo "function del_cons() {\n";
75 echo "if (document.getElementById('pwd3').checked==false) {\n";
76 echo "if (document.getElementById('chiusa').selectedIndex==3) document.getElementById('chiusa').options[0].selected=true \n";
77 echo "document.getElementById('pwd4').checked=false \n";
78 echo "document.getElementById('trspunta').style.visibility='hidden' \n";
79 echo "} \n";
80 echo "else document.getElementById('trspunta').style.visibility='visible' \n";
81 echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n";
82 echo "document.getElementById('add').value=\""._MODIFY."\" \n";
83 echo "document.getElementById('do').value=\"update\" \n";
84 echo "}else{\n";
85 echo "if (document.getElementById('pwd4').checked==false) \n";
86 echo "document.getElementById('add').value=\""._DELETE." "._DATI."\" \n";
87 echo "else document.getElementById('add').value=\""._DELETE." "._CONSULTA."\" \n";
88 echo "document.getElementById('do').value=\"delete\" \n";
89 echo "} \n";
90 echo "} \n";
91 echo "</script>\n";
92
93echo "<script type=\"text/javascript\" language=\"JavaScript\" >\n\n<!--\n"
94 ."//-->\n";
95echo "function showdate(str,posiz,tempo)\n";
96echo "{\n";
97echo "if (str==\"\")\n";
98echo " {\n";
99echo " document.getElementById(posiz).innerHTML=\"\";\n";
100echo " return;\n";
101echo " }\n";
102echo "if (window.XMLHttpRequest)\n";
103echo " {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
104echo " xmlhttp=new XMLHttpRequest();\n";
105echo " }\n";
106echo "else\n";
107echo " {// code for IE6, IE5\n";
108echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
109echo " }\n";
110echo "xmlhttp.onreadystatechange=function()\n";
111echo " {\n";
112echo " if (xmlhttp.readyState==4 && xmlhttp.status==200 && posiz!=null)\n";
113echo " {\n";
114echo " document.getElementById(posiz).innerHTML=xmlhttp.responseText;\n";
115echo " }\n";
116echo " }\n";
117echo "xmlhttp.open(\"GET\",str,true);\n";
118echo "xmlhttp.send();\n";
119
120echo "}\n";
121echo "</script>\n";
122
123#########################
124 if ($help) include("language/$language/ele_associazioni.html");
125 OpenTable();
126 echo "<tr><td><hr><br>";
127 $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
128 $res = $dbi->prepare("$sql");
129 $res->execute();
130 list ($descr_cons) = $res->fetch(PDO::FETCH_NUM);
131//inserire avviso su mancanza dei permessi
132 echo "<form name=\"model\" action=\"admin.php\">";
133 echo "<table width=\"100%\" border=\"3\">";
134 echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
135 echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
136 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
137 echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
138 if($tipo_cons==3){
139 echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
140 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
141 }
142 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
143 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
144 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
145 echo "</tr>";
146 echo "<tr align=\"center\"><td>";
147 echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
148 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
149 $sql = "SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc";
150 $rescomu = $dbi->prepare("$sql");
151 $rescomu->execute();
152 echo "<td>";
153 if($idcomune) {
154 while ($listele=$rescomu->fetch(PDO::FETCH_BOTH))
155 if($listele['id_comune']==$idcomune) {
156 echo $listele['descrizione'];
157 echo "<input type=\"hidden\" name=\"idcomunenew\" value=\"$idcomune\">";
158 }
159
160 }else{
161 echo "<select name=\"idcomunenew\">";
162 echo "<option value=\"0\"> ";
163 while(list($id,$descr_comu)=$rescomu->fetch(PDO::FETCH_NUM)){
164 $sel= ($id == $idcomune) ? "selected":"";
165 echo "<option value=\"$id\" $sel>$descr_comu";
166 }
167 echo "</select>";
168 }
169 echo "</td>";
170 echo "<td><input type=\"text\" name=\"preferenze\" value=\"$preferenze\" size=\"2\"></td>";
171 $selez['0']='';
172 $selez['1']='';
173 $selez['2']='';
174 $selez['3']='';
175 $selez[$chiusa]="selected";
176 echo "<td><select name=\"chiusa\" id=\"chiusa\" onChange=\"javascript:del_cons()\">";
177 echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
178 echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
179 echo "<option value=\"2\" ".$selez[2].">"._NULLA;
180
181 if($idcomune) echo "<option value=\"3\" ".$selez[3].">"._ELIMINA;
182 echo "</select></td>";
183 if($tipo_cons==3){
184 if($idcomune) {
185 $sql="SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'";
186 $rescomu = $dbi->prepare("$sql");
187 $rescomu->execute();
188 if($rescomu->rowCount())
189 list($fasciacom)=$rescomu->fetch(PDO::FETCH_NUM);
190 } else $fasciacom=0;
191 $sql="SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc";
192 $rescomu = $dbi->prepare("$sql");
193 $rescomu->execute();
194 echo "<td><select name=\"id_conf\" id=\"id_conf\" onchange=\"javascript:showdate('modules/Elezioni/ele_desc_fasce.php?fascia=$fasciacom&id_conf=' + model.id_conf.options[model.id_conf.selectedIndex].value,'fasceconf');\">";
195 echo "<option value=\"0\"> ";
196 while(list($id,$descr_conf)=$rescomu->fetch(PDO::FETCH_NUM)){
197 $sel='';
198 if ($idcomune and $id == $id_conf) $sel="selected";
199 echo "<option value=\"$id\" $sel>$descr_conf";
200 }
201 echo "</select></td>";
202 if(!$id_conf) $id_conf=1;
203 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
204 $rescomu = $dbi->prepare("$sql");
205 $rescomu->execute();
206
207 echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
208 echo "<option value=\"0\"> ";
209 $inffascia=0;
210 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
211 $sel='';
212 if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
213 echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
214 $inffascia=$abitanti;
215 }
216 echo "</select></td>";
217
218
219 }
220 unset($sel);
221 $sql = "SELECT vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'";
222 $rescomu = $dbi->prepare("$sql");
223 $rescomu->execute();
224 list($vismf,$sg,$disgiunto)=$rescomu->fetch(PDO::FETCH_NUM);
225 echo "<td><select name=\"vismf\">";
226 if ($vismf==0) $sel="selected"; else $sel="";
227 echo "<option value=\"0\" $sel>No";
228 if ($vismf==1) $sel="selected"; else $sel="";
229 echo "<option value=\"1\" $sel>Si";
230 echo "</select></td>";
231 echo "<td><select name=\"sg\">";
232 if ($sg==0) $sel="selected"; else $sel="";
233 echo "<option value=\"0\" $sel>No";
234 if ($sg==1) $sel="selected"; else $sel="";
235 echo "<option value=\"1\" $sel>Si";
236 echo "</select></td>";
237 echo "<td><select name=\"disgiunto\">";
238 if ($disgiunto==0) $sel="selected"; else $sel="";
239 echo "<option value=\"0\" $sel>No";
240 if ($disgiunto==1) $sel="selected"; else $sel="";
241 echo "<option value=\"1\" $sel>Si";
242 echo "</select></td>";
243
244 echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
245 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
246 if ($idcomune) {
247 echo "<input type=\"hidden\" id=\"do\" name=\"do\" value=\"update\">";
248 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
249 echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
250 echo "<tr><td colspan=\"5\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov1\">"._SPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_cons()\"></label></fieldset></td></tr>";
251 echo "<tr id=\"trspunta\" style=\"visibility:hidden\"><td colspan=\"4\"><fieldset><legend>"._SPUNTALABEL2."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd4\" name=\"pwd4\" value=\"1\" onclick=\"javascript:del_cons()\"></label></fieldset>";
252 }else{
253 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
254 echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\">";
255 }
256 $i=0;
257 echo "</td></tr></table></form>";
258 echo "<hr><br><table width=\"100%\" border=\"3\">";
259 echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
260 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
261 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
262 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
263 if($tipo_cons==3){
264 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
265 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
266 }
267 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
268 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
269 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
270 echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</b></td></tr>";
271
272 $sql="SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione";
273 $resmod = $dbi->prepare("$sql");
274 $resmod->execute();
275 while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti
276 $sql="SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'";
277 $resconf = $dbi->prepare("$sql");
278 $resconf->execute();
279 list($descr_conf) = $resconf->fetch(PDO::FETCH_NUM);
280 $i++;
281 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
282 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
283 echo "<td><b>$descr_cons</b></td>";
284 echo "<td><b>$descr_comu</b></td>";
285 echo "<td><b>$preferenze2</b></td>";
286 $stato['0']=_ATTIVA;
287 $stato['1']=_CHIUSA;
288 $stato['2']=_NULLA;
289 echo "<td><b>".$stato[$chiusa]."</b></td>";
290 if($tipo_cons==3){
291 echo "<td><b>".$descr_conf."</b></td>";
292 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
293 $rescomu = $dbi->prepare("$sql");
294 $rescomu->execute();
295 $inffascia=0;
296 if ($rescomu->rowCount()==0) echo "<td></td>";
297 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
298 $sel='';
299 if ($id == $fasciacom)
300 echo "<td>$inffascia - $abitanti</td>";
301 $inffascia=$abitanti;
302 }
303
304 }
305 if ($vismf2==0) $sel=_NO; else $sel=_SI;
306 echo "<td>$sel</td>";
307 if ($sg2==0) $sel=_NO; else $sel=_SI;
308 echo "<td>$sel</td>";
309 if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
310 echo "<td>$sel</td>";
311 echo "<td>";
312 echo "<form name=\"modello$i\" action=\"admin.php\">"
313 ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
314 echo "<input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\">";
315 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
316 echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
317 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
318 echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
319 echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
320 echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
321 echo "<input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
322 ."</form></td></tr>\n";
323 }
324 echo "</table></td></tr></table>";
325 CloseTable();
326 }
327
328function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
329 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg,$disgiunto;
330 $delcons=0;
331 if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
332 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
333 $rescomu = $dbi->prepare("$sql");
334 $rescomu->execute();
335 $max = $rescomu->rowCount(); //esiste autorizzazione?
336 list($delcons)=$rescomu->fetch(PDO::FETCH_NUM);
337 if (!$max){ //se no la inserisce
338 $sql="insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo,disgiunto) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg','$disgiunto')";
339 $result = $dbi->prepare("$sql");
340 $result->execute();
341 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
342 $rescomu = $dbi->prepare("$sql");
343 $rescomu->execute();
344 list($id_cons_comu)=$rescomu->fetch(PDO::FETCH_NUM);
345 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' ";
346 $res = $dbi->prepare("$sql");
347 $res->execute();
348 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
349 if (!$id_cons_pred) {
350 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' ";
351 $res = $dbi->prepare("$sql");
352 $res->execute();
353 }
354 }
355 if ($do == "update") {
356 if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
357 else $newid='';
358 $sql="update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
359 $result = $dbi->prepare("$sql");
360 $result->execute();
361 $sql="update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf',solo_gruppo='$sg',disgiunto='$disgiunto' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
362 $result = $dbi->prepare("$sql");
363 $result->execute();
364 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
365 }elseif ($do == "add") {
366 if ($id_collegio){
367 $sql="insert into ".$prefix."_ele_comu_collegi (id_collegio,id_cons,id_comune,id_cons_gen) values ('$id_collegio','$id_cons_comu','$idcomunenew','$id_cons_gen')";
368 $result = $dbi->prepare("$sql");
369 $result->execute();
370 }
371 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
372 }elseif ($do == "delete" and $delcons>0) {
373 $idcns=$delcons;
374 $sql="delete from ".$prefix."_ele_voti_ref where id_cons=$idcns";
375 $result = $dbi->prepare("$sql");
376 $result->execute();
377 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns";
378 $result = $dbi->prepare("$sql");
379 $result->execute();
380 $sql="delete from ".$prefix."_ele_voti_lista where id_cons=$idcns";
381 $result = $dbi->prepare("$sql");
382 $result->execute();
383 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns";
384 $result = $dbi->prepare("$sql");
385 $result->execute();
386 $sql="delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns";
387 $result = $dbi->prepare("$sql");
388 $result->execute();
389 $sql="delete from ".$prefix."_ele_controllosez where id_cons=$idcns";
390 $result = $dbi->prepare("$sql");
391 $result->execute();
392 if ($pwd4==1){
393 $sql="delete from ".$prefix."_ele_candidati where id_cons=$idcns";
394 $result = $dbi->prepare("$sql");
395 $result->execute();
396 $sql="delete from ".$prefix."_ele_lista where id_cons=$idcns";
397 $result = $dbi->prepare("$sql");
398 $result->execute();
399 $sql="delete from ".$prefix."_ele_gruppo where id_cons=$idcns";
400 $result = $dbi->prepare("$sql");
401 $result->execute();
402 $sql="delete from ".$prefix."_ele_sezioni where id_cons=$idcns";
403 $result = $dbi->prepare("$sql");
404 $result->execute();
405 $sql="delete from ".$prefix."_ele_cons_comune where id_cons=$idcns";
406 $result = $dbi->prepare("$sql");
407 $result->execute();
408 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
409 $res = $dbi->prepare("$sql");
410 $res->execute();
411 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
412 if ($idcns==$id_cons_pred) {
413 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1";
414 $res = $dbi->prepare("$sql");
415 $res->execute();
416 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
417 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' ";
418 $res = $dbi->prepare("$sql");
419 $res->execute();
420 }
421 }else{
422 $sql="update ".$prefix."_ele_sezioni set validi='0', nulli='0', bianchi='0', contestati='0', solo_gruppo='0', autorizzati_m='0', autorizzati_f='0', voti_nulli='0', validi_lista='0', contestati_lista='0', voti_nulli_lista='0' where id_cons=$idcns";
423 $result = $dbi->prepare("$sql");
424 $result->execute();
425 }
426 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
427 }
428 }
429}
430
431
432
433
434
435//****************************
436// switch
437//****************************
438 if ($op=="associazioni"){
439 associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf,$preferenze);
440 }
441 ele();
442 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
443 all();
444 include("footer.php");
445
446?>
447
448
Note: See TracBrowser for help on using the repository browser.