source: trunk/admin/modules/Elezioni/ele_voti.php@ 335

Last change on this file since 335 was 329, checked in by roby, 4 years ago
File size: 69.5 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Roberto Gigli & Luciano Apolito */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8/* Modulo Inserimento dati */
9/* Amministrazione */
10/************************************************************************/
11
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15global $dbi;
16$aid=$_SESSION['aid'];
17$prefix=$_SESSION['prefix'];
18$currentlang=$_SESSION['lang'];
19$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
20$vari= implode(',',$_GET);//param);
21$id_comune=$_SESSION['id_comune'];
22$id_cons_gen=intval($_GET['id_cons_gen']);
23$perms=ChiSei($id_cons_gen);
24if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
25if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
26//if (isset($param['id_cons'])) $id_cons=intval($param['id_cons']); else $id_cons='';
27if (isset($param['ops'])) $ops=intval($param['ops']); else $ops='';
28if (isset($param['min'])) $min=intval($param['min']); else $min=0;
29if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
30if (isset($param['ov'])) $ov=intval($param['ov']); else $ov='';
31if (isset($param['mv'])) $mv=intval($param['mv']); else $mv='';
32if (isset($param['gv'])) $gv=intval($param['gv']); else $gv='';
33if (isset($param['msv'])) $msv=intval($param['msv']); else $msv='';
34if (isset($param['av'])) $av=intval($param['av']); else $av='';
35if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else
36 if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='0';
37if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
38if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
39if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='0';
40if (isset($param['prev_sez'])) $prev_sez=intval($param['prev_sez']); else $prev_sez='0';
41if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='0';
42if (isset($param['update'])) $update=intval($param['update']); else $update='';
43include("modules/Elezioni/funzionidata.php");
44include("modules/Elezioni/ele.php");
45global $votolista, $limite, $dettnulli,$disgiunto;
46if(!isset($votolista)) $votolista=0;
47$sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" ;
48$res = $dbi->prepare("$sql");
49$res->execute();
50
51
52list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
53if ($tipo_cons!=3 or $votolista==1) $limite=0; #die ("limite: $limite");}
54$sql="SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
55$res = $dbi->prepare("$sql");
56$res->execute();
57
58
59list($num_circ)=$res->fetch(PDO::FETCH_NUM);
60$sql="SELECT solo_gruppo,disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
61$res = $dbi->prepare("$sql");
62$res->execute();
63
64
65list($dettnulli,$disgiunto)=$res->fetch(PDO::FETCH_NUM);
66if ($conscirc){ // or $num_circ==1
67 if (!$id_circ){
68 if (!$id_sez){
69 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='1'";
70$res = $dbi->prepare("$sql");
71$res->execute();
72
73
74 list($id_sez)=$res->fetch(PDO::FETCH_NUM);
75 }
76 $sql="SELECT t1.id_circ FROM ".$prefix."_ele_sede as t1 left join ".$prefix."_ele_sezioni as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and t2.id_sez='$id_sez'";
77$res = $dbi->prepare("$sql");
78$res->execute();
79
80
81 #$sql="SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1";
82$res = $dbi->prepare("$sql");
83$res->execute();
84
85
86 if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
87 list($id_circ)=$res->fetch(PDO::FETCH_NUM);
88 $_SESSION['id_circ']=$id_circ;
89 }
90 $sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'";
91$result = $dbi->prepare("$sql");
92$result->execute();
93
94
95 $i=0;
96 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
97 unset($idsedi);$i=0;$idsezi=array();unset($result);
98 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)";
99$result = $dbi->prepare("$sql");
100$result->execute();
101
102
103 unset($tmp);
104 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsezi[$i++]=$tmp;
105 $tmp=implode (",",$idsezi);
106 $sezi = "and id_sez in ($tmp)";
107 $circo = "and id_circ='$id_circ'";
108}else{
109 $sezi='';
110 $circo='';
111}
112
113// Offset - visualizza il numero di elementi per pagina
114$offset=2;
115if (!isset($min)) $min=0;
116$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
117
118function numeri_sezione($nums) {
119// tabella visualizzazione sezioni per numero
120global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$id_cons,$id_lista,$ops, $perms,$id_sez,$num_ril,$status,$idrefgruppo,$votog,$votol,$votoc;
121$idrefgruppo='';
122 $solosede='';
123 if ($perms<32) {
124 $sql="SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons";
125$res = $dbi->prepare("$sql");
126$res->execute();
127
128
129 if ($res) {
130 list($solouna)=$res->fetch(PDO::FETCH_NUM);
131 if ($solouna>0) $solosede="and id_sede='$solouna'";
132 }
133 }
134 $sql="SELECT num_sez, id_sez ,id_sede,colore FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
135$res = $dbi->prepare("$sql");
136$res->execute();
137
138
139 $max = $res->rowCount();
140 //if ($max>=64){
141 $i=0;
142 echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
143
144
145 echo "<div id=\"navmenu\"> <ul>";
146 while(list($sez_num, $sez_id ,$sede_id,$colore) = $res->fetch(PDO::FETCH_NUM)) {
147# $ops='';
148 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
149 $i++;
150 $sql="SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
151$result = $dbi->prepare("$sql");
152$result->execute();
153
154
155 list($circ_id) = $result->fetch(PDO::FETCH_NUM);
156
157 if(!$ops) $ops=1;
158 $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";
159$res2 = $dbi->prepare("$sql");
160$res2->execute();
161
162
163 list($numero_sez) = $res2->fetch(PDO::FETCH_NUM);
164 if ($sez_num==$numero_sez) {
165 $cursez= "style=\" background: $colore; border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";}
166 else $cursez="style=\" background: $colore; \"";
167 echo "\n<li $cursez><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$circ_id&amp;id_sede=$sede_id&amp;id_sez=$sez_id&amp;ops=$ops&amp;do=spoglio&amp;id_lista=$id_lista\">$sez_num</a></b></li>\n";
168 }
169 //}
170echo "</ul></div></td></tr></table>\n";
171 //}// fine tabella per numero sezioni
172}
173///////////////////////////////////////////////////////////////////////////////////
174
175
176function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
177 global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez,$ops;
178
179 echo "<table border=\"0\" width=\"760\" align=\"left\"><tr>";
180 echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
181 numeri_sezione(22);
182 echo "\n</td></tr><tr><td>\n";
183
184
185 ///////////////////////
186 // Circoscrizione : scelta
187 ///////////////////////
188
189 $sql="SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
190 ".$prefix."_ele_sede as t2
191 where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'";
192$resoper = $dbi->prepare("$sql");
193$resoper->execute();
194
195
196 list($id_sede2,$id_circ2) = $resoper->fetch(PDO::FETCH_NUM);
197 if ($id_sede2 and !($id_sede==$id_sede2)) {
198 $id_sede=$id_sede2;
199 $id_circ=$id_circ2;
200 $do="spoglio";
201 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede=$id_sede order by num_sez limit 0,1";
202$res = $dbi->prepare("$sql");
203$res->execute();
204
205
206 list($id_sez) = $res->fetch(PDO::FETCH_NUM);
207 }
208 if ($do == "circo") {
209 OpenTable();
210 echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
211 ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
212 ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
213 // Circoscrizione: lista
214 //**************************************
215 .""._CIRCO.": "
216 ."<select name=\"id_circ\">";
217 $sql="SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ";
218$res = $dbi->prepare("$sql");
219$res->execute();
220
221
222 while(list($id,$descr) = $res->fetch(PDO::FETCH_NUM)) {
223 if ($descr!="Tutte"){
224 if ($id == $id_circ) {
225 $sel = "selected";
226 } else {
227 $sel = "";
228 }
229 echo "<option value=\"$id\" $sel>$descr";
230 }
231 }
232 echo "</select>"
233 //***********************************
234 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
235 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
236 ."</form></td></tr>";
237 CloseTable();
238 }
239
240 ///////////////////////
241 // sede : scelta
242 ///////////////////////
243
244
245 if ($do == "sede") {
246 OpenTable();
247 echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
248 $sql="SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ";
249$res = $dbi->prepare("$sql");
250$res->execute();
251
252
253 list( $descr_circ) = $res->fetch(PDO::FETCH_NUM);
254 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=circo\">"._CIRCO."</a> $descr_circ ->";
255 echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
256 ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
257
258 // Indirizzo: lista
259 //**************************************
260 .""._INDIRIZZO.": "
261 ."<select name=\"id_sede\">";
262 $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo";
263$res = $dbi->prepare("$sql");
264$res->execute();
265
266
267// echo "$id_circ - $id_cons";
268 while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
269 if ($id == $id_sede) {
270 $sel = "selected";
271 } else {
272 $sel = "";
273 }
274 echo "<option value=\"$id\" $sel>$indir";
275 }
276 echo "</select>"
277 //*************************************
278 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
279 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
280 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
281 ."</form></td></tr>\n";
282 CloseTable();
283 }
284
285 ///////////////////////
286 // sezione : scelta
287 ///////////////////////
288 if ($do == "spoglio") {
289
290
291 //************************************
292 // Menu spoglio
293 //************************************
294 $sql="select id_cons,id_sez,id_sede,num_sez, maschi, femmine from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
295$result = $dbi->prepare("$sql");
296$result->execute();
297
298
299 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
300
301 echo "<hr><table><tr><td width=\"200\"><font size =\"4\" color=\"black\" align=\"left\"><b>Sezione N. $num_sez</b></font></td><td><table><tr>";
302 echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=1\">"._AFFLUENZE."</a></b></p></td>\n";
303 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
304 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=4\">"._GRUPPO."</a></b></p></td>\n";
305 }
306 if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
307 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3\">"._LISTA."</a></b></p></td>\n";
308 }
309 echo "</tr></table></td></tr></table><hr>\n";
310
311#############
312# posizionamento in mancanza di scelta
313#############
314if (!$ops){
315 if (!$id_sez) { echo"";#import( pagina di help );
316 } else{
317 $sql="SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
318$res = $dbi->prepare("$sql");
319$res->execute();
320
321
322 list($data,$orario)=$res->fetch(PDO::FETCH_NUM);
323 $sql="SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'";
324$res = $dbi->prepare("$sql");
325$res->execute();
326
327
328 list($voti) = $res->fetch(PDO::FETCH_NUM);
329 if (!$voti) $ops=1;
330 else {
331 if($genere<4){
332 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
333$res = $dbi->prepare("$sql");
334$res->execute();
335
336
337 list($voti) = $res->fetch(PDO::FETCH_NUM);
338 if ($voti==0 or $genere<3) $ops=4;
339 }
340 if(!$ops) $ops=3;
341 }
342
343 }
344}
345############ fine posizionamento
346
347 ///////////////////////////////////////////
348 // opzioni per le funzioni di immissione
349
350 if ($ops == 1) {
351 votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
352 }else{
353############# Controllo flag per cancellazione consultazione
354 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
355 ."//-->\n";
356 echo "function del_dati() {\n";
357 echo "if (document.getElementById('pwd3').checked==false) {\n";
358 echo "document.getElementById('update').value=\""._OK."\" \n";
359 echo "document.getElementById('do').value=\"0\" \n";
360 echo "}else{\n";
361 echo "document.getElementById('update').value=\""._DELETE."\" \n";
362 echo "document.getElementById('do').value=\"1\" \n";
363 echo "} \n";
364 echo "} \n";
365 echo "</script>\n";
366 }
367 if ($ops == 3) {
368 preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
369 }
370 if ($ops == 4) {
371 preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
372
373 }
374
375 }
376 CloseTable();
377
378}
379////////////////////////////////////////////////////////////////////////////////
380// FUNZIONI DI IMMISSIONE
381// - preferenze (candidati consiglieri)
382// - preferenze_gruppi
383// - votanti
384////////////////////////////////////////////////////////////////////////////////
385
386//////////////////////////////////////////////////////////////////////
387// da qui va la sezione per le preferenze candidati consiglieri
388//////////////////////////////////////////////////////////////////////
389function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
390 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
391global $tipo_cons,$limite,$dettnulli,$disgiunto;
392$bgcolor1="#7777ff";
393$bgcolor2=$_SESSION['bgcolor2'];
394
395if ($genere==4){
396 $sql="SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' order by data desc,orario desc limit 0,1";
397 $result = $dbi->prepare("$sql");
398 $result->execute();
399
400
401 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
402 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
403 ."<tr><td></td><td align=\"center\"></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIU."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTID."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIT."</td></tr>"
404 ."<tr><td></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._TOT_ULT."</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_u</td><td align=\"center\" bgcolor=\"$bgcolor2\">$voti_d</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_t</td></tr>";
405 echo "</table>";
406}
407$sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
408$result = $dbi->prepare("$sql");
409$result->execute();
410list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
411if($v1+$v2+$v3+$v4>0){
412 //controlla se sono stati inseriti i votanti
413$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
414$result = $dbi->prepare("$sql");
415$result->execute();
416
417
418list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
419
420####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
421if ($circo and $id_lista){
422 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
423$res_lis = $dbi->prepare("$sql");
424$res_lis->execute();
425
426
427 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
428 $sql="SELECT id_lista from ".$prefix."_ele_lista where num_lista=$num_lista and id_cons='$id_cons' $circo";
429$res_lis = $dbi->prepare("$sql");
430$res_lis->execute();
431
432
433 list($id_lista)=$res_lis->fetch(PDO::FETCH_NUM);
434}
435
436if(!$votog and ($genere==3 or $genere==5)){
437 $sql="select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
438$result = $dbi->prepare("$sql");
439$result->execute();
440
441
442}else{
443 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
444$result = $dbi->prepare("$sql");
445$result->execute();
446}
447
448 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
449 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
450 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
451$res_lis = $dbi->prepare("$sql");
452$res_lis->execute();
453
454
455 $num_liste = $res_lis->rowCount();
456 $ele_lista='';
457 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
458 if(($genere==5 and $id_conf and $fascia<=$limite and !$disgiunto) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
459 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1";
460$result = $dbi->prepare("$sql");
461$result->execute();
462
463
464 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
465 }
466 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
467 echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
468 echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3&amp;id_lista=\">";
469 echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
470 if ($id_lista){
471 echo "<option value=\"0\">"._VOTI_LISTA;
472 $ele_lista=" and t1.id_lista='$id_lista' ";
473 }else{
474 echo "<option value=\"0\" selected>"._VOTI_LISTA;
475 $ele_lista=" group by t1.id_lista ";
476if(!isset($votolista)) $votolista=0;
477
478 }
479 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
480 $segna='';
481 $sql="SELECT count(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif";
482$result = $dbi->prepare("$sql");
483$result->execute();
484
485
486 list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
487 $sql="SELECT sum(t1.voti),0,0 from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif";
488$result = $dbi->prepare("$sql");
489$result->execute();
490
491
492 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
493 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
494 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
495$result = $dbi->prepare("$sql");
496$result->execute();
497 }else{
498 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
499$result = $dbi->prepare("$sql");
500$result->execute();
501 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
502 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
503$result = $dbi->prepare("$sql");
504$result->execute();
505 }
506 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
507 if($votisezcand>($votisezlis*$numprefs))
508 {$segna="style=\"background-color: #dd0000;\"";}
509 elseif($ctrvoticand)
510 $segna="style=\"background-color: #99CC33;\"";
511 $sql="SELECT t1.voti,t2.num_cand FROM ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on t1.id_cand=t2.id_cand where t1.id_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$id_rif'";
512$res4 = $dbi->prepare("$sql");
513$res4->execute();
514
515
516 $errcand[$id_rif]=array();
517 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
518 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
519
520 $sel = ($id_rif == $id_lista) ? "selected" : "";
521 echo "<option $segna value=\"$id_rif\" $sel>";
522 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
523 echo $num_lis.") ".substr($descrizione,0,30);
524 }
525 echo "</select></form></td>\n";
526 }else {
527 $id_lista=0;
528 }
529 echo "<td style=\"vertical-align: top;\">";
530
531 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
532if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
533 $sql="SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,t2.contestati,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez";
534$result = $dbi->prepare("$sql");
535$result->execute();
536
537
538}else{
539 $sql="SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,t2.solo_gruppo,t1.id_sez from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez,t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,t2.solo_gruppo";
540$result = $dbi->prepare("$sql");
541$result->execute();
542}
543
544// aggiunte le variabili $sgpl e $vnulli2 per la gestione dei voti 1) al solo presidente per singola lista - 2) al solo presidente per singola lista perché nullo o contestato quello di lista
545 $isscr= $result->rowCount();
546 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
547 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
548 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
549$resg = $dbi->prepare("$sql");
550$resg->execute();
551
552
553 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
554 if ($sg != $sgpl) echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></table>";
555 }
556 $valista=$validi2;
557 if(!$id_lista or $genere==3){ //controllo di congruenza
558 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
559$res2 = $dbi->prepare("$sql");
560$res2->execute();
561
562
563 list($tot) = $res2->fetch(PDO::FETCH_NUM);
564####### controlli
565 $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
566 $resc = $dbi->prepare("$sql");
567 $resc->execute();
568if($resc->rowCount()){ if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
569 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2)."</b><br></td></table>";
570 }
571
572 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
573 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".($voti_sez)." "._NO_VAL_VOTI." ".$validi2."</b><br></td></tr></table>";
574 }
575 }elseif($genere==5){
576 $sql="SELECT sum(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_lista";
577$result = $dbi->prepare("$sql");
578$result->execute();
579
580
581 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
582 if(($fascia>$limite or $disgiunto) or !$id_conf){
583 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
584$result = $dbi->prepare("$sql");
585$result->execute();
586
587
588 }else{
589
590 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
591$result = $dbi->prepare("$sql");
592$result->execute();
593
594
595 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
596 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
597$result = $dbi->prepare("$sql");
598$result->execute();
599
600
601 }
602 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
603 if($votisezcand>($votisezlis*$numprefs))
604 {
605 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti di preferenza $votisezcand <br/>superano i voti di lista $votisezlis</b><br></td></tr></table>";
606 }
607 }
608#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
609 $errgrulis=array();
610 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
611 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
612$resref = $dbi->prepare("$sql");
613$resref->execute();
614
615
616 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
617$res4 = $dbi->prepare("$sql");
618$res4->execute();
619
620
621 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
622 if ($sezscrl)
623
624 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
625 {
626 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
627$res3 = $dbi->prepare("$sql");
628$res3->execute();
629
630
631 $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
632$res4 = $dbi->prepare("$sql");
633$res4->execute();
634
635
636 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
637 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
638 if($vliste>$vgruppo)
639 {
640 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
641$result = $dbi->prepare("$sql");
642$result->execute();
643
644
645 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
646 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate<br/> superano i voti assegnati al gruppo $dgruppo </b><br></td></tr></table>";
647 $errgrulis[$id_gruppo]=1;
648 }
649 elseif($vliste<$vgruppo)
650 {
651 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
652$result = $dbi->prepare("$sql");
653$result->execute();
654
655
656 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
657 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr></table>";
658 $errgrulis[$id_gruppo]=1;
659 }
660 }
661 }
662}
663
664
665 echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
666 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
667 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
668 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
669 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
670 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
671 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
672 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
673 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
674 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
675 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
676 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
677 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
678 if ($genere<4){
679// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
680 }
681 echo "<b>"._NUM."</b></td>";
682 if($id_lista){
683 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
684 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
685 }else{
686 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
687 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
688 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
689 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
690 if($disgiunto){
691 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
692 }
693 }
694 echo "</tr>\n";
695
696
697
698
699
700if($id_lista) $sql="select t1.* from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on (t1.id_lista=t2.id_lista) WHERE t1.id_cons=$id_cons and t1.id_cons=t2.id_cons $ele_lista $circo ORDER BY t2.num_lista,t1.num_cand";
701else $sql="select 0,'$id_cons',t1.id_lista,'','','','','',0 from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on (t1.id_lista=t2.id_lista) WHERE t1.id_cons=$id_cons and t1.id_cons=t2.id_cons $ele_lista $circo ORDER BY t2.num_lista";
702$result = $dbi->prepare("$sql");
703$result->execute();
704
705
706 $max = $result->rowCount();
707 $tot_pref=0;
708 $i=1;
709
710 if($id_lista) {
711 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
712 // dati lista
713 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
714$result1 = $dbi->prepare("$sql");
715$result1->execute();
716
717
718 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
719 // dati gruppo
720 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
721$result2 = $dbi->prepare("$sql");
722$result2->execute();
723
724
725 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
726
727 echo "<tr bgcolor=\"$bgcolor2\">";
728 if ($genere<4){
729 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
730 }
731 echo "<td align=\"center\"><b> $num_cand </b></td>"
732 ."<td align=\"left\"><b>$cognome $nome</b></td>";
733 $cond_sele="and id_cand=$id_cand";
734 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
735$res = $dbi->prepare("$sql");
736$res->execute();
737
738
739 list($voti)= $res->fetch(PDO::FETCH_NUM);
740 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
741 echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
742 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
743 $i++;
744 $tot_pref+=$voti;
745 }
746 }else {
747 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
748 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
749 where t1.id_cons='$id_cons'
750 and t1.id_lista=t2.id_lista
751 and t2.id_sez=$id_sez
752 order by t1.num_lista";
753
754 try {
755 $result1 = $dbi->prepare("$sql");
756 $result1->execute();
757
758 }
759 catch(PDOException $e)
760 {
761 echo $sql . "<br>" . $e->getMessage();
762 }
763
764 $num_lista=$result1->rowCount();
765 if (!$num_lista){
766 $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
767 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
768 order by num_lista";
769 $result1 = $dbi->prepare("$sql");
770 $result1->execute();
771 }
772 $tvnpl=0;
773 $tslpl=0;
774 while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
775 echo "<tr bgcolor=\"$bgcolor2\">";
776// if ($genere<4 or $votoc){
777// }
778 $errcolor='';
779 if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
780 echo "<td align=\"center\"><b> $num_lista </b></td>"
781 ."<td align=\"left\"><b> $descr_lista</b></td>";
782 $cond_sele="and id_lista=$id_lista3";
783 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
784 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19) { echo "</td><td align=\"right\"><input name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\" style=\"text-align:right\">"; $tvnpl+=$vnpl;}
785 if($disgiunto) {echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\">"; $tslpl+=$slpl;}
786 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
787// echo "<td align=\"right\">$sgpl";
788 echo "</tr>\n";
789 $i++;
790 $tot_pref+=$voti;
791 }
792 }
793 if(!$id_lista) {
794 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><font size=\"3\">"._TOT._VOTI_LISTA."</font></td><td align=\"center\"><font size=\"3\">$tot_pref</font></td>";
795 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
796 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
797 if($disgiunto)
798 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
799 echo "</tr>";
800 }
801 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
802 // toglie ai candidati la visual... del solo_gruppo
803 if(!$votog) {
804 if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
805 echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._VALIDI_LISTA."</b></td><td align=\"center\"><input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"><input name=\"valista\" value=\"$valista\" size=\"5\" style=\"text-align:right\"></td></tr>";
806 echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input name=\"sg\" value=\"$sg\" size=\"5\" style=\"text-align:right\"></td></tr>";
807 echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._NULLI_LISTE."</b></td><td align=\"center\"><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
808 ."</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._CONTESTATI_LISTE."</b></td><td align=\"center\"><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\"></td></tr>";
809
810 }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
811 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
812 }
813######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
814elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
815$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
816$resvg = $dbi->prepare("$sql");
817$resvg->execute();
818
819
820list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
821$sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
822$resvg = $dbi->prepare("$sql");
823$resvg->execute();
824
825
826 list($voti_sind) = $resvg;
827
828echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
829}
830###### fine modifica del 16-04-2009
831
832 }
833 echo "<tr>";
834 echo "<td></td><td></td>";
835 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
836 echo "</tr></table>";
837 if(chisei($id_cons_gen)>=64){
838 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
839 } # onclick=\"javascript:del_dati()\"
840 echo "</form></tr></table>";
841 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
842 ."document.sezioni.voti1.focus()\n"
843 ."document.sezioni.voti1.select()\n"
844 ."//-->\n";
845 echo "function vai_lista() {\n";
846 echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
847 echo "}\n";
848 echo "</script>\n";
849}
850#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
851 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
852 }
853
854
855////////////////////////////////////////////
856// da qua va la sezione per i votanti
857///////////////////////////////////////////
858
859function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
860//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
861 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
862$bgcolor1=$_SESSION['bgcolor2'];
863
864#OpenTable();
865$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
866$res = $dbi->prepare("$sql");
867$res->execute();
868
869
870if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
871$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
872$res = $dbi->prepare("$sql");
873$res->execute();
874
875echo "<table><tr><td>";
876$num = $res->rowCount();
877$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
878$ressez = $dbi->prepare("$sql");
879$ressez->execute();
880##################
881echo "<style>";
882echo "DIV.table";
883echo "{
884 display:table;
885}
886FORM.tr
887{
888 display:table-row;
889 text-align: center;
890}
891DIV.tr
892{
893 display:table-row;
894 background-color: #D3D3D3;
895 text-align: center;
896}
897SPAN.tdm
898{
899 display:table-cell;
900 border: 1px solid black;
901 padding: 5px;
902}
903SPAN.td
904{
905 display:table-cell;
906}";
907echo "</style>";
908
909/*
910 echo "<form class=\"tr\" name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
911 echo "<span class=\"td\"><input type=\"text\"/></span>";
912 <span class="td"><input type="text"/></span>
913 </form>
914 <div class="tr">
915 <span class="td">(cell data)</span>
916 <span class="td">(cell data)</span>
917 </div>
918 ...
919</div>
920*/
921##################
922
923list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
924$y=0;
925echo "<div class=\"table\">";
926#echo "<tr><td>&nbsp;</td></tr>";
927$riga=array();
928$rigat=array();
929while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
930 $y++;
931 $rigat[$y]='';
932 $riga[$y]='';
933# echo "\n<tr><td>";
934# echo "<form name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
935# echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
936$rigat[$y]= "<div class=\"tr\">";
937 if ($genere==0){ //e' un referendum
938# echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
939 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
940 }
941 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
942 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
943 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
944 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
945 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
946 if ($genere==0){
947 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
948$res2 = $dbi->prepare("$sql");
949$res2->execute();
950
951
952 $max = $res2->rowCount();
953 }else{ $max=1;} $op="rec_add_votanti";
954 $rigat[$y].= "</div>";
955
956 for ($i=1;$i<=$max;$i++){
957 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
958 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
959 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
960 if ($genere==0){
961 $query.=" and t2.num_gruppo=$i";
962 }
963 $sql=$query;
964$result = $dbi->prepare("$sql");
965$result->execute();
966
967
968 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
969 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
970$res2 = $dbi->prepare("$sql");
971$res2->execute();
972
973
974 $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
975$resril = $dbi->prepare("$sql");
976$resril->execute();
977
978
979 list($numril)=$resril->fetch(PDO::FETCH_NUM);
980 if ($res2)
981 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
982 else
983 $gruppo=0;
984 if (!$gruppo>0) {
985 $gruppo=$i;
986 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
987$res3 = $dbi->prepare("$sql");
988$res3->execute();
989
990
991 if ($res3)
992 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
993 }
994 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
995 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
996 $precede[$id_gruppo]=$voti_t;
997 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
998# echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
999 $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
1000 }else{
1001 $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
1002 }
1003 if ($genere==0){ // e' un referendum
1004 $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
1005 }
1006
1007
1008 $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
1009 $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
1010 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
1011 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
1012 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
1013 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
1014#$riga[$y].= "</span>";
1015 list ($anno,$mese,$di)=explode('-',$giorno);
1016 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
1017 if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
1018 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1019 if ($y<$num and $vismf==0 and $voti_u==0) { $riga[$y].= "<input type=\"hidden\" id=\"voti_u$y$i\" name=\"voti_u\" value=\"'$voti_u'\"";}else $riga[$y].= "<input type=\"text\" style=\"text-align:right\" id=\"voti_u$y$i\" name=\"voti_u\" value=\"$voti_u\"";
1020 $riga[$y].= " size=\"5\"/></span>";
1021 if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
1022 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1023 if ($y<$num and $vismf==0 and $voti_d==0) { $riga[$y].= "<input type=\"hidden\" id=\"voti_d$y$i\" name=\"voti_d\" value=\"'$voti_d'\"";}else $riga[$y].= "<input type=\"text\" style=\"text-align:right\" id=\"voti_d$y$i\" name=\"voti_d\" value=\"$voti_d\"";
1024 $riga[$y].= " size=\"5\"/></span>";
1025 if ($voti_t > ($maschi+$femmine)) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\" ><input type=\"text\" id=\"voti_t$y$i\" name=\"voti_t\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\"/>";
1026 else $riga[$y].= "<span class=\"td\" align=\"center\"><input id=\"voti_t$y$i\" name=\"voti_t\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\"/>";
1027 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
1028 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
1029 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
1030 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
1031 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
1032 $riga[$y].= "</span>";
1033
1034 if (chisei($id_cons_gen)>=64 and $y==$numril) $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"/></span>";
1035 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
1036 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
1037 $riga[$y].= "</form>";
1038
1039 }
1040# echo "</table></form>";
1041 echo "</div>";
1042
1043
1044 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
1045$compl = $dbi->prepare("$sql");
1046$compl->execute();
1047
1048
1049 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
1050 if (!$complessivi)
1051 {
1052 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1053 $numy=$y.'1';
1054 if ($y==$num) {
1055 echo "document.votanti$y.voti_u$numy.focus()\n";
1056 echo "document.votanti$y.voti_u$numy.select()\n";
1057 }else{
1058 echo "this.voti_t$numy.focus()\n";
1059 echo "this.voti_t$numy.select()\n";
1060 }
1061 echo "//-->\n"
1062 ."</script>\n";
1063 break;
1064 }
1065# echo "</td></tr>";
1066 }
1067#CloseTable();
1068foreach($riga as $key=>$val){
1069 echo $rigat[$key];
1070 echo $riga[$key];
1071}
1072echo "</div></td></tr></table>";
1073}
1074
1075
1076
1077function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1078 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
1079////////////////////////////////////////////
1080// da qua va la sezione per i voti finali
1081///////////////////////////////////////////
1082$bgcolor1="#7777ff";
1083$bgcolor2=$_SESSION['bgcolor2'];
1084
1085
1086
1087 echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
1088 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
1089 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1090 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1091 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1092 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1093 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1094
1095 echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
1096/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1097 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
1098 else */
1099 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
1100 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
1101 ."<td><b>"._BIANCHI."</b></td>"
1102 ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
1103 ."<td><b>"._CONTESTATI."</b></td>"
1104 ."<td><b>"._TOTNON."</b></td>"
1105 ."<td><b>"._TOTALEVOTI."</b></td>"
1106 ."<td bgcolor=\"#ffffff\"></td> </tr>";
1107/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1108 $result = mysql_query("select id_cons,id_sez,validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista,solo_gruppo,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
1109$res = $dbi->prepare("$sql");
1110$res->execute();
1111
1112
1113else */
1114 $sql = "select id_cons,id_sez,validi,nulli,bianchi,contestati,voti_nulli,'0','0','0',solo_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
1115$result = $dbi->prepare("$sql");
1116$result->execute();
1117
1118
1119 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
1120 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
1121 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
1122// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
1123
1124
1125 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
1126/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
1127 echo "</td><td>$nulli"
1128 ."</td><td>$bianchi";
1129 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
1130 }else{ */
1131 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
1132 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
1133// }
1134 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
1135 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
1136 ."</td><td>$tot_nulli"
1137 ."</td><td>$tot_voti</td><td>"
1138 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1139 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
1140 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
1141 ."</td></tr></table></form>"; //</td></tr>";
1142
1143
1144// echo "</table>";
1145 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1146 if (!$validi) {
1147 echo "document.spogliovoti.validi.focus()\n";
1148 echo "document.spogliovoti.validi.select()\n";
1149 }
1150 echo "//-->\n"
1151 ."</script>\n";
1152
1153
1154 }
1155
1156
1157function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1158 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
1159////////////////////////////////////////////
1160// da qua va la sezione per le preferenze ai gruppi
1161///////////////////////////////////////////
1162// Controllo immmissioni
1163
1164$bgcolor1="#7777ff";
1165$bgcolor2=$_SESSION['bgcolor2'];
1166 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
1167$res = $dbi->prepare("$sql");
1168$res->execute();
1169
1170
1171 $max = $res->rowCount();
1172 $max = $max-1;
1173 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1174 if ($genere==0) {
1175 echo "document.sezioni.si1.focus()\n";
1176 echo "document.sezioni.si1.select()\n";
1177 } else {
1178 echo "document.sezioni.voti1.focus()\n"
1179 ."document.sezioni.voti1.select()\n";
1180 }
1181 echo "//-->\n"
1182 ."</script>\n";
1183// tabella votanti
1184 echo "<center>";
1185 if ($genere!=0){
1186 $sql="SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' order by data desc,orario desc limit 0,1";
1187$result = $dbi->prepare("$sql");
1188$result->execute();
1189
1190
1191 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
1192 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
1193 ."<tr><td></td><td align=\"center\"></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIU."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTID."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIT."</td></tr>"
1194 ."<tr><td></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._TOT_ULT."</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_u</td><td align=\"center\" bgcolor=\"$bgcolor2\">$voti_d</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_t</td></tr>";
1195 echo "</table>";
1196 }
1197 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
1198 if ($genere==0){
1199 $sql="SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' ";
1200$res = $dbi->prepare("$sql");
1201$res->execute();
1202
1203
1204 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
1205 if ($voti_parz!=$validi){
1206 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
1207$res2 = $dbi->prepare("$sql");
1208$res2->execute();
1209
1210
1211 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1212 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI_REF." $num_gruppo: ".$voti_parz." "._NO_VAL_VOTI.": ".$validi."</b><br></td></tr>";
1213 }
1214 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1215$res2 = $dbi->prepare("$sql");
1216$res2->execute();
1217
1218
1219 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1220 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
1221 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
1222$res2 = $dbi->prepare("$sql");
1223$res2->execute();
1224
1225
1226 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1227 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI_REF." $num_gruppo: ".$tot." "._NO_SOMMA." ".($validi+$nulli+$bianchi+$contestati)."</b><br></td></tr>";
1228 }
1229 }
1230 }else{
1231 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1232$result = $dbi->prepare("$sql");
1233$result->execute();
1234
1235
1236 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
1237 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
1238$res = $dbi->prepare("$sql");
1239$res->execute();
1240
1241
1242 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
1243 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
1244$res = $dbi->prepare("$sql");
1245$res->execute();
1246
1247
1248 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
1249 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
1250 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".($validi-$solo_lista)."</b><br></td><tr>";
1251 }
1252 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
1253$res2 = $dbi->prepare("$sql");
1254$res2->execute();
1255
1256
1257 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1258 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
1259 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi+$nulli+$bianchi+$contestati+$votinulli)."</b><br></td></tr>";
1260 }
1261 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
1262$resg = $dbi->prepare("$sql");
1263$resg->execute();
1264
1265
1266 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
1267 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
1268
1269 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
1270$resg = $dbi->prepare("$sql");
1271$resg->execute();
1272
1273
1274 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
1275 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
1276$resg = $dbi->prepare("$sql");
1277$resg->execute();
1278
1279
1280 list($sg)=$resg->fetch(PDO::FETCH_NUM);
1281 if ($sg != $sgpl) echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></tr>";
1282 }
1283#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
1284if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
1285 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
1286$resref = $dbi->prepare("$sql");
1287$resref->execute();
1288
1289
1290 $errgrulis=array();
1291 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
1292$res4 = $dbi->prepare("$sql");
1293$res4->execute();
1294
1295
1296 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
1297 if ($sezscrl)
1298 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
1299 {
1300 if($disgiunto || $flagsg){
1301 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1302 $res3 = $dbi->prepare("$sql");
1303 $res3->execute();
1304 if($flagsg){
1305 $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
1306 $res4 = $dbi->prepare("$sql");
1307 $res4->execute();
1308 }else{
1309 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
1310 $res4 = $dbi->prepare("$sql");
1311 $res4->execute();
1312 }
1313 }else{
1314 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1315 $res3 = $dbi->prepare("$sql");
1316 $res3->execute();
1317 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
1318 $res4 = $dbi->prepare("$sql");
1319 $res4->execute();
1320 }
1321 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1322 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
1323 if($vliste>$vgruppo and !$disgiunto )
1324 {
1325 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1326 $result = $dbi->prepare("$sql");
1327 $result->execute();
1328 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1329 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate $vliste<br/> superano i voti assegnati al gruppo $dgruppo $vgruppo</b><br></td></tr></table>";
1330 $errgrulis[$id_gruppo]=1;
1331 }
1332 elseif($vliste<$vgruppo and $disgiunto )
1333 {
1334 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1335 $result = $dbi->prepare("$sql");
1336 $result->execute();
1337 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1338 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr></table>";
1339 $errgrulis[$id_gruppo]=1;
1340 }
1341 }
1342/* {
1343 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1344$res3 = $dbi->prepare("$sql");
1345$res3->execute();
1346
1347
1348 $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
1349$res4 = $dbi->prepare("$sql");
1350$res4->execute();
1351
1352
1353 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1354 list($vliste)=$res4->fetch(PDO::FETCH_NUM); //($tipo_cons=18 or $tipo_cons=19))
1355 if($vliste>$vgruppo and !$disgiunto)
1356 {
1357 $errgrulis[$id_gruppo]=1;
1358 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1359$result = $dbi->prepare("$sql");
1360$result->execute();
1361
1362
1363 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1364 echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate<br/> superano i voti assegnati al gruppo $dgruppo </b><br></td></tr>";
1365 }
1366 elseif($vliste<$vgruppo and !($tipo_cons=18 or $tipo_cons=19))
1367 {
1368 $errgrulis[$id_gruppo]=1;
1369 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1370$result = $dbi->prepare("$sql");
1371$result->execute();
1372
1373
1374 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1375 echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo <br/> superano i voti delle liste collegate</b><br></td></tr>";
1376 }
1377 }*/
1378}
1379
1380 }
1381 if(!isset($votinulli)) $votinulli=0;
1382 echo "<tr><td></td></tr></table>";
1383 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1384 if($genere==0) echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_ref.php\">";
1385 else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
1386 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
1387 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1388 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1389 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1390 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1391 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1392 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
1393 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1394 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1395 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1396 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1397 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1398 if ($genere==0){
1399 echo "<td><b>"._SI."</b></td>"
1400 ."<td><b>"._NO."</b></td>"
1401 ."<td><b>"._VALIDI."</b></td>"
1402 ."<td><b>"._BIANCHI."</b></td>"
1403 ."<td><b>"._CONTESTATI."</b></td>"
1404 ."<td><b>"._NULLI."</b></td>"
1405 ."<td><b>"._TOTNON."</b></td>"
1406 ."<td><b>"._TOTALEVOTI."</b></td>"
1407 ."<td><b>"._VOTANTI."</b></td>";
1408 }else{
1409 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1410 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1411 }
1412 echo "</tr>";
1413 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
1414$res = $dbi->prepare("$sql");
1415$res->execute();
1416
1417
1418 $max = $res->rowCount();
1419 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1420 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1421$result = $dbi->prepare("$sql");
1422$result->execute();
1423
1424
1425 $i=1;
1426 $tot_pref=0;
1427 $totsg=0;
1428 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
1429
1430 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1431 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1432
1433 ."//-->\n";
1434 echo "function controlloref$i() {\n";
1435 echo "var a=Number(window.document.sezioni.si$i.value); var b=Number(window.document.sezioni.no$i.value); if(a=='NaN') {a=0} if(b=='NaN') {b=0} var c=a + b; window.document.sezioni.val$i.value=c\n";
1436 echo "}\n";
1437 echo "</script>\n";
1438
1439 if ($num_gruppo != ''){
1440 if ($genere==0){
1441 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1442$res = $dbi->prepare("$sql");
1443$res->execute();
1444
1445
1446 list($tot) = $res->fetch(PDO::FETCH_NUM);
1447 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1448$res = $dbi->prepare("$sql");
1449$res->execute();
1450
1451
1452 $pro= $res->fetch(PDO::FETCH_BOTH);
1453
1454 if ($pro['si']+$pro['no']!=$pro['validi'] or ($pro['validi']+$pro['nulli']+$pro['bianchi']+$pro['contestati']!=$tot and $pro['validi']+$pro['nulli']+$pro['bianchi']+$pro['contestati']!=0)){
1455 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1456 }else{
1457 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1458 }
1459 $descr = explode('.',$descr_gruppo, 100);
1460 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1461 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
1462 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1463 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1464 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1465 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1466 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1467 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
1468 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
1469 $tot_voti=intval($pro['validi'])+$tot_nulli;
1470 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1471 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1472 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1473 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1474 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1475 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1476 echo "</td><td align=\"right\">$tot_nulli</td>";
1477 echo "</td><td align=\"right\">$tot_voti</td>";
1478 echo "</td><td align=\"right\">$tot</td>";
1479 }else{
1480 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td align=\"center\"><input type=\"hidden\" name=\"num_gruppo$i\" value=\"$num_gruppo\"><b>$num_gruppo</b>"
1481 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1482 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1483$res = $dbi->prepare("$sql");
1484$res->execute();
1485
1486
1487 $pro= $res->fetch(PDO::FETCH_BOTH);
1488 $errcolor='';
1489 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1490 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
1491
1492 if($dettnulli) {echo "<td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\" style=\"text-align:right\"></td>"; $totsg+=$pro['solo_gruppo'];}
1493 $tot_pref += $pro['voti'];
1494 echo "</tr>";
1495 }
1496
1497 $i++;
1498 }
1499
1500 }
1501 if ($genere!=0) {
1502 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1503$res = $dbi->prepare("$sql");
1504$res->execute();
1505
1506
1507 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1508 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1509$res = $dbi->prepare("$sql");
1510$res->execute();
1511
1512
1513 list($sololis)=$res->fetch(PDO::FETCH_NUM);
1514 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
1515 if($dettnulli) echo "<td>$totsg</td>";
1516 echo "</tr>";
1517 if($disgiunto)
1518 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._SOLOLIS."</td><td><input name=\"sololista\" value=\"".$sololis."\" size=\"7\" style=\"text-align:right\"></td></tr>";
1519 }
1520
1521 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1522
1523 echo "</tr></table></form></td></tr>";
1524 if(chisei($id_cons_gen)>=64){
1525 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1526 }
1527
1528 echo "</td></tr></table></center>";
1529 }
1530 if ($genere!=0){
1531 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1532 }
1533}
1534
1535
1536
1537
1538 if (!preg_match("/rec/",$op)) {
1539 ele(); //menu
1540/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
1541 numeri_sezione(8);
1542 echo "<td></td></tr></table>\n";*/
1543 echo"</td></tr></table>";
1544 }
1545
1546 switch ($op){
1547 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
1548# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1549 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1550 break;
1551 case "rec_add_votanti":
1552 rec_add_votanti($vari);
1553 break;
1554 default :
1555 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
1556 }
1557echo"</td></tr></table>";
1558 include_once("modules/Elezioni/language/lang-$currentlang.php");
1559 include ("footer.php");
1560?>
1561
Note: See TracBrowser for help on using the repository browser.