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

Last change on this file since 426 was 407, checked in by roby, 9 months ago
  • ADMIN

-- aggiunto il controllo per la visualizzazione della proiezione del consiglio comunale
-- bloccato l'inserimento dati nelle consultazioni chiuse

  • CLIENT

-- in tema bsitalia: sistemato il fondo giallo nel blocco sezioni scrutinate
-- sistemato il pdf dell'elenco affluenze
-- sistemato il link per il passaggio da mobile a desktop

File size: 22.7 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'])) $descr_comu=addslashes($param['descr_comu']); else $descr_comu='';
42if (isset($_GET['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;
58if (isset($_GET['proiezione'])) $proiezione=intval($_GET['proiezione']); else $proiezione=0;
59
60$offset=15;
61$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
62
63
64 /******************************************************/
65 /*Funzione di visualizzazione globale */
66 /*****************************************************/
67 //
68 function all() {
69 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,$genere,$proiezione;
70$aid=$_SESSION['aid'];
71$prefix=$_SESSION['prefix'];
72############# Controllo flag per cancellazione consultazione
73 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
74 ."//-->\n";
75 echo "function del_cons() {\n";
76 echo "if (document.getElementById('pwd3').checked==false) {\n";
77 echo "if (document.getElementById('chiusa').selectedIndex==3) document.getElementById('chiusa').options[0].selected=true \n";
78 echo "document.getElementById('pwd4').checked=false \n";
79 echo "document.getElementById('trspunta').style.visibility='hidden' \n";
80 echo "} \n";
81 echo "else document.getElementById('trspunta').style.visibility='visible' \n";
82 echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n";
83 echo "document.getElementById('add').value=\""._MODIFY."\" \n";
84 echo "document.getElementById('do').value=\"update\" \n";
85 echo "}else{\n";
86 echo "if (document.getElementById('pwd4').checked==false) \n";
87 echo "document.getElementById('add').value=\""._DELETE." "._DATI."\" \n";
88 echo "else document.getElementById('add').value=\""._DELETE." "._CONSULTA."\" \n";
89 echo "document.getElementById('do').value=\"delete\" \n";
90 echo "} \n";
91 echo "} \n";
92 echo "</script>\n";
93
94echo "<script type=\"text/javascript\" language=\"JavaScript\" >\n\n<!--\n"
95 ."//-->\n";
96echo "function showdate(str,posiz,tempo)\n";
97echo "{\n";
98echo "if (str==\"\")\n";
99echo " {\n";
100echo " document.getElementById(posiz).innerHTML=\"\";\n";
101echo " return;\n";
102echo " }\n";
103echo "if (window.XMLHttpRequest)\n";
104echo " {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
105echo " xmlhttp=new XMLHttpRequest();\n";
106echo " }\n";
107echo "else\n";
108echo " {// code for IE6, IE5\n";
109echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
110echo " }\n";
111echo "xmlhttp.onreadystatechange=function()\n";
112echo " {\n";
113echo " if (xmlhttp.readyState==4 && xmlhttp.status==200 && posiz!=null)\n";
114echo " {\n";
115echo " document.getElementById(posiz).innerHTML=xmlhttp.responseText;\n";
116echo " }\n";
117echo " }\n";
118echo "xmlhttp.open(\"GET\",str,true);\n";
119echo "xmlhttp.send();\n";
120
121echo "}\n";
122echo "</script>\n";
123
124#########################
125 if ($help) include("language/$language/ele_associazioni.html");
126 OpenTable();
127 echo "<tr><td><hr><br>";
128 $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
129 $res = $dbi->prepare("$sql");
130 $res->execute();
131 list ($descr_cons) = $res->fetch(PDO::FETCH_NUM);
132//inserire avviso su mancanza dei permessi
133 echo "<form name=\"model\" action=\"admin.php\">";
134 echo "<table width=\"100%\" border=\"3\">";
135 echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
136 echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
137 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
138 echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
139 if($tipo_cons==3){
140 echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
141 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
142 echo "<td bgcolor=\"$bgcolor1\"><b>"._PROIEZIONE."</b></td>";
143 }
144 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
145 $sql = "SELECT * from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons_comu'";
146 $rescomu = $dbi->prepare("$sql");
147 $rescomu->execute();
148 $tardi=$rescomu->rowCount();
149 if (!$tardi && $genere==5){
150 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
151 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
152 }
153 echo "</tr>";
154 echo "<tr align=\"center\"><td>";
155 echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
156 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
157 $sql = "SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc";
158 $rescomu = $dbi->prepare("$sql");
159 $rescomu->execute();
160 echo "<td>";
161 if($idcomune) {
162 while ($listele=$rescomu->fetch(PDO::FETCH_BOTH))
163 if($listele['id_comune']==$idcomune) {
164 echo $listele['descrizione'];
165 echo "<input type=\"hidden\" name=\"idcomunenew\" value=\"$idcomune\">";
166 }
167
168 }else{
169 echo "<select name=\"idcomunenew\">";
170 echo "<option value=\"0\"> ";
171 while(list($id,$descr_comu)=$rescomu->fetch(PDO::FETCH_NUM)){
172 $sel= ($id == $idcomune) ? "selected":"";
173 echo "<option value=\"$id\" $sel>$descr_comu";
174 }
175 echo "</select>";
176 }
177 echo "</td>";
178 echo "<td><input type=\"text\" name=\"preferenze\" value=\"$preferenze\" size=\"2\"></td>";
179 $selez['0']='';
180 $selez['1']='';
181 $selez['2']='';
182 $selez['3']='';
183 $selez[$chiusa]="selected";
184 echo "<td><select name=\"chiusa\" id=\"chiusa\" onChange=\"javascript:del_cons()\">";
185 echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
186 echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
187 echo "<option value=\"2\" ".$selez[2].">"._NULLA;
188
189 if($idcomune) echo "<option value=\"3\" ".$selez[3].">"._ELIMINA;
190 echo "</select></td>";
191 if($tipo_cons==3){
192 if($idcomune) {
193 $sql="SELECT id_fascia,proiezione from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'";
194 $rescomu = $dbi->prepare("$sql");
195 $rescomu->execute();
196 if($rescomu->rowCount())
197 list($fasciacom,$proiezione)=$rescomu->fetch(PDO::FETCH_NUM);
198 else $fasciacom=0;
199 } else $fasciacom=0;
200 $sql="SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc";
201 $rescomu = $dbi->prepare("$sql");
202 $rescomu->execute();
203 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');\">";
204 echo "<option value=\"0\"> ";
205 while(list($id,$descr_conf)=$rescomu->fetch(PDO::FETCH_NUM)){
206 $sel='';
207 if ($idcomune and $id == $id_conf) $sel="selected";
208 echo "<option value=\"$id\" $sel>$descr_conf";
209 }
210 echo "</select></td>";
211 if(!$id_conf) $id_conf=1;
212 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
213 $rescomu = $dbi->prepare("$sql");
214 $rescomu->execute();
215
216 echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
217 echo "<option value=\"0\"> ";
218 $inffascia=0;
219 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
220 $sel='';
221 if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
222 echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
223 $inffascia=$abitanti;
224 }
225 echo "</select></td>";
226 echo "<td id=\"proiezione\"><select name=\"proiezione\">";
227 if ($proiezione) {$sel0='';$sel1='selected';} else {$sel1='';$sel0='selected';}
228 echo "<option value=\"0\" $sel0>No";
229 echo "<option value=\"1\" $sel1>Si";
230 echo "</select></td>";
231
232 }
233 unset($sel);
234 $sql = "SELECT vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'";
235 $rescomu = $dbi->prepare("$sql");
236 $rescomu->execute();
237 list($vismf,$sg,$disgiunto)=$rescomu->fetch(PDO::FETCH_NUM);
238 echo "<td><select name=\"vismf\">";
239 if ($vismf==0) $sel="selected"; else $sel="";
240 echo "<option value=\"0\" $sel>No";
241 if ($vismf==1) $sel="selected"; else $sel="";
242 echo "<option value=\"1\" $sel>Si";
243 echo "</select></td>";
244 $sql = "SELECT * from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons_comu'";
245 $rescomu = $dbi->prepare("$sql");
246 $rescomu->execute();
247 if (!$tardi &&$genere==5){
248 echo "<td><select name=\"sg\">";
249 if ($sg==0) $sel="selected"; else $sel="";
250 echo "<option value=\"0\" $sel>No";
251 if ($sg==1) $sel="selected"; else $sel="";
252 echo "<option value=\"1\" $sel>Si";
253 echo "</select></td>";
254 echo "<td><select name=\"disgiunto\">";
255 if ($disgiunto==0) $sel="selected"; else $sel="";
256 echo "<option value=\"0\" $sel>No";
257 if ($disgiunto==1) $sel="selected"; else $sel="";
258 echo "<option value=\"1\" $sel>Si";
259 echo "</select></td>";
260 }
261 echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
262 if ($tardi && $genere==5) echo "<input type=\"hidden\" name=\"sg\" value=$sg><input type=\"hidden\" name=\"disgiunto\" value=$disgiunto>";
263 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
264 if ($idcomune) {
265 echo "<input type=\"hidden\" id=\"do\" name=\"do\" value=\"update\">";
266 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
267 echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
268 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>";
269 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>";
270 }else{
271 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
272 echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\">";
273 }
274 $i=0;
275 echo "</td></tr></table></form>";
276 echo "<hr><br><table width=\"100%\" border=\"3\">";
277 echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
278 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
279 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
280 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
281 if($tipo_cons==3){
282 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
283 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
284 echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._PROIEZIONE."</b></td>";
285 }
286 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
287 if ($genere==5){
288 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
289 echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
290 }
291 echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</b></td></tr>";
292
293 $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,t1.proiezione 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";
294 $resmod = $dbi->prepare("$sql");
295 $resmod->execute();
296 while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2,$proiezione) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti
297 $sql="SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'";
298 $resconf = $dbi->prepare("$sql");
299 $resconf->execute();
300 list($descr_conf) = $resconf->fetch(PDO::FETCH_NUM);
301 $i++;
302 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
303 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
304 echo "<td><b>$descr_cons</b></td>";
305 echo "<td><b>$descr_comu</b></td>";
306 echo "<td><b>$preferenze2</b></td>";
307 $stato['0']=_ATTIVA;
308 $stato['1']=_CHIUSA;
309 $stato['2']=_NULLA;
310 echo "<td><b>".$stato[$chiusa]."</b></td>";
311 if($tipo_cons==3){
312 echo "<td><b>".$descr_conf."</b></td>";
313 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
314 $rescomu = $dbi->prepare("$sql");
315 $rescomu->execute();
316 $inffascia=0;
317 if ($rescomu->rowCount()==0) echo "<td></td>";
318 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
319 $sel='';
320 if ($id == $fasciacom)
321 echo "<td>$inffascia - $abitanti</td>";
322 $inffascia=$abitanti;
323 }
324 if($proiezione) $sceltapro='Si'; else $sceltapro='No';
325 echo "<td>".$sceltapro."</td>";
326
327 }
328 if ($vismf2==0) $sel=_NO; else $sel=_SI;
329 echo "<td>$sel</td>";
330 if ($genere==5){
331 if ($sg2==0) $sel=_NO; else $sel=_SI;
332 echo "<td>$sel</td>";
333 if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
334 echo "<td>$sel</td>";
335 }
336 echo "<td>";
337 echo "<form name=\"modello$i\" action=\"admin.php\">"
338 ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
339 echo "<input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\">";
340 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
341 echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
342 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
343 echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
344 echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
345 echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
346 echo "<input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
347 ."</form></td></tr>\n";
348 }
349 echo "</table></td></tr></table>";
350 CloseTable();
351 }
352
353function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
354 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg,$disgiunto,$proiezione;
355 $delcons=0;
356 if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
357 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
358 $rescomu = $dbi->prepare("$sql");
359 $rescomu->execute();
360 $max = $rescomu->rowCount(); //esiste autorizzazione?
361 list($delcons)=$rescomu->fetch(PDO::FETCH_NUM);
362 if (!$max){ //se no la inserisce
363 $sql="insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo,disgiunto,proiezione) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg','$disgiunto','$proiezione')";
364 $result = $dbi->prepare("$sql");
365 $result->execute();
366 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
367 $rescomu = $dbi->prepare("$sql");
368 $rescomu->execute();
369 list($id_cons_comu)=$rescomu->fetch(PDO::FETCH_NUM);
370 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' ";
371 $res = $dbi->prepare("$sql");
372 $res->execute();
373 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
374 if (!$id_cons_pred) {
375 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' ";
376 $res = $dbi->prepare("$sql");
377 $res->execute();
378 }
379 }
380 if ($do == "update") {
381 if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
382 else $newid='';
383 $sql="update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
384 $result = $dbi->prepare("$sql");
385 $result->execute();
386 $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',proiezione='$proiezione' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
387 $result = $dbi->prepare("$sql");
388 $result->execute();
389 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
390 }elseif ($do == "add") {
391 if ($id_collegio){
392 $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')";
393 $result = $dbi->prepare("$sql");
394 $result->execute();
395 }
396 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
397 }elseif ($do == "delete" and $delcons>0) {
398 $idcns=$delcons;
399 $sql="delete from ".$prefix."_ele_voti_ref where id_cons=$idcns";
400 $result = $dbi->prepare("$sql");
401 $result->execute();
402 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns";
403 $result = $dbi->prepare("$sql");
404 $result->execute();
405 $sql="delete from ".$prefix."_ele_voti_lista where id_cons=$idcns";
406 $result = $dbi->prepare("$sql");
407 $result->execute();
408 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns";
409 $result = $dbi->prepare("$sql");
410 $result->execute();
411 $sql="delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns";
412 $result = $dbi->prepare("$sql");
413 $result->execute();
414 $sql="delete from ".$prefix."_ele_controlli where id_cons=$idcns";
415 $result = $dbi->prepare("$sql");
416 $result->execute();
417 if ($pwd4==1){
418 $sql="delete from ".$prefix."_ele_candidati where id_cons=$idcns";
419 $result = $dbi->prepare("$sql");
420 $result->execute();
421 $sql="delete from ".$prefix."_ele_lista where id_cons=$idcns";
422 $result = $dbi->prepare("$sql");
423 $result->execute();
424 $sql="delete from ".$prefix."_ele_gruppo where id_cons=$idcns";
425 $result = $dbi->prepare("$sql");
426 $result->execute();
427 $sql="delete from ".$prefix."_ele_sezioni where id_cons=$idcns";
428 $result = $dbi->prepare("$sql");
429 $result->execute();
430 $sql="delete from ".$prefix."_ele_cons_comune where id_cons=$idcns";
431 $result = $dbi->prepare("$sql");
432 $result->execute();
433 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
434 $res = $dbi->prepare("$sql");
435 $res->execute();
436 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
437 if ($idcns==$id_cons_pred) {
438 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1";
439 $res = $dbi->prepare("$sql");
440 $res->execute();
441 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
442 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' ";
443 $res = $dbi->prepare("$sql");
444 $res->execute();
445 }
446 }else{
447 $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', colore='' where id_cons=$idcns";
448 $result = $dbi->prepare("$sql");
449 $result->execute();
450 }
451 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
452 }
453 }
454}
455
456
457
458
459
460//****************************
461// switch
462//****************************
463 if ($op=="associazioni"){
464 associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf,$preferenze);
465 }
466 ele();
467 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
468 all();
469 include("footer.php");
470
471?>
472
473
Note: See TracBrowser for help on using the repository browser.