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

Last change on this file since 339 was 339, checked in by roby, 4 years ago

integrazione della rev 338

File size: 67.7 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
65
66list($dettnulli,$disgiunto)=$res->fetch(PDO::FETCH_NUM);
67
68$sql="SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
69$res = $dbi->prepare("$sql");
70$res->execute();
71list($conscirc)=$res->fetch(PDO::FETCH_NUM);
72if ($conscirc){ // or $num_circ==1
73 if (!$id_circ){
74 if (!$id_sez){
75 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='1'";
76$res = $dbi->prepare("$sql");
77$res->execute();
78
79
80 list($id_sez)=$res->fetch(PDO::FETCH_NUM);
81 }
82 $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'";
83$res = $dbi->prepare("$sql");
84$res->execute();
85
86
87 #$sql="SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1";
88//$res = $dbi->prepare("$sql");
89//$res->execute();
90
91
92 if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
93 list($id_circ)=$res->fetch(PDO::FETCH_NUM);
94 $_SESSION['id_circ']=$id_circ;
95 }
96 $sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'";
97$result = $dbi->prepare("$sql");
98$result->execute();
99
100
101 $i=0;
102 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
103 unset($idsedi);$i=0;$idsezi=array();unset($result);
104 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)";
105$result = $dbi->prepare("$sql");
106$result->execute();
107
108
109 unset($tmp);
110 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsezi[$i++]=$tmp;
111 $tmp=implode (",",$idsezi);
112 $sezi = "and id_sez in ($tmp)";
113 $circo = "and id_circ=$id_circ";
114}else{
115 $sezi='';
116 $circo='';
117}
118
119// Offset - visualizza il numero di elementi per pagina
120$offset=2;
121if (!isset($min)) $min=0;
122$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
123
124function numeri_sezione($nums) {
125// tabella visualizzazione sezioni per numero
126global $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;
127$idrefgruppo='';
128 $solosede='';
129 if ($perms<32) {
130 $sql="SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons";
131$res = $dbi->prepare("$sql");
132$res->execute();
133
134
135 if ($res) {
136 list($solouna)=$res->fetch(PDO::FETCH_NUM);
137 if ($solouna>0) $solosede="and id_sede='$solouna'";
138 }
139 }
140 $sql="SELECT num_sez, id_sez ,id_sede,colore FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
141$res = $dbi->prepare("$sql");
142$res->execute();
143
144
145 $max = $res->rowCount();
146 //if ($max>=64){
147 $i=0;
148 echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
149
150
151 echo "<div id=\"navmenu\"> <ul>";
152 while(list($sez_num, $sez_id ,$sede_id,$colore) = $res->fetch(PDO::FETCH_NUM)) {
153# $ops='';
154 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
155 $i++;
156 $sql="SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
157$result = $dbi->prepare("$sql");
158$result->execute();
159
160
161 list($circ_id) = $result->fetch(PDO::FETCH_NUM);
162
163 if(!$ops) $ops=1;
164 $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";
165$res2 = $dbi->prepare("$sql");
166$res2->execute();
167
168
169 list($numero_sez) = $res2->fetch(PDO::FETCH_NUM);
170 if ($sez_num==$numero_sez) {
171 $cursez= "style=\" background: $colore; border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";}
172 else $cursez="style=\" background: $colore; \"";
173 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";
174 }
175 //}
176echo "</ul></div></td></tr></table>\n";
177 //}// fine tabella per numero sezioni
178}
179///////////////////////////////////////////////////////////////////////////////////
180
181
182function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
183 global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez,$ops,$circo;
184
185 echo "<table border=\"0\" width=\"760\" align=\"left\"><tr>";
186 echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
187 numeri_sezione(22);
188 echo "\n</td></tr><tr><td>\n";
189
190
191 ///////////////////////
192 // Circoscrizione : scelta
193 ///////////////////////
194
195 $sql="SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
196 ".$prefix."_ele_sede as t2
197 where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'";
198$resoper = $dbi->prepare("$sql");
199$resoper->execute();
200
201
202 list($id_sede2,$id_circ2) = $resoper->fetch(PDO::FETCH_NUM);
203 if ($id_sede2 and !($id_sede==$id_sede2)) {
204 $id_sede=$id_sede2;
205 $id_circ=$id_circ2;
206 $do="spoglio";
207 $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";
208$res = $dbi->prepare("$sql");
209$res->execute();
210
211
212 list($id_sez) = $res->fetch(PDO::FETCH_NUM);
213 }
214 if ($do == "circo") {
215 OpenTable();
216 echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
217 ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
218 ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
219 // Circoscrizione: lista
220 //**************************************
221 .""._CIRCO.": "
222 ."<select name=\"id_circ\">";
223 $sql="SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ";
224$res = $dbi->prepare("$sql");
225$res->execute();
226
227
228 while(list($id,$descr) = $res->fetch(PDO::FETCH_NUM)) {
229 if ($descr!="Tutte"){
230 if ($id == $id_circ) {
231 $sel = "selected";
232 } else {
233 $sel = "";
234 }
235 echo "<option value=\"$id\" $sel>$descr";
236 }
237 }
238 echo "</select>"
239 //***********************************
240 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
241 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
242 ."</form></td></tr>";
243 CloseTable();
244 }
245
246 ///////////////////////
247 // sede : scelta
248 ///////////////////////
249
250
251 if ($do == "sede") {
252 OpenTable();
253 echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
254 $sql="SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ";
255$res = $dbi->prepare("$sql");
256$res->execute();
257
258
259 list( $descr_circ) = $res->fetch(PDO::FETCH_NUM);
260 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=circo\">"._CIRCO."</a> $descr_circ ->";
261 echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
262 ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
263
264 // Indirizzo: lista
265 //**************************************
266 .""._INDIRIZZO.": "
267 ."<select name=\"id_sede\">";
268 $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo";
269$res = $dbi->prepare("$sql");
270$res->execute();
271
272
273// echo "$id_circ - $id_cons";
274 while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
275 if ($id == $id_sede) {
276 $sel = "selected";
277 } else {
278 $sel = "";
279 }
280 echo "<option value=\"$id\" $sel>$indir";
281 }
282 echo "</select>"
283 //*************************************
284 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
285 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
286 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
287 ."</form></td></tr>\n";
288 CloseTable();
289 }
290
291 ///////////////////////
292 // sezione : scelta
293 ///////////////////////
294 if ($do == "spoglio") {
295
296
297 //************************************
298 // Menu spoglio
299 //************************************
300 $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'";
301$result = $dbi->prepare("$sql");
302$result->execute();
303
304
305 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
306
307 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>";
308 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";
309 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
310 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";
311 }
312 if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
313 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";
314 }
315 echo "</tr></table></td></tr></table><hr>\n";
316
317#############
318# posizionamento in mancanza di scelta
319#############
320if (!$ops){
321 if (!$id_sez) { echo"";#import( pagina di help );
322 } else{
323 $sql="SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
324$res = $dbi->prepare("$sql");
325$res->execute();
326
327
328 list($data,$orario)=$res->fetch(PDO::FETCH_NUM);
329 $sql="SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'";
330$res = $dbi->prepare("$sql");
331$res->execute();
332
333
334 list($voti) = $res->fetch(PDO::FETCH_NUM);
335 if (!$voti) $ops=1;
336 else {
337 if($genere<4){
338 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
339$res = $dbi->prepare("$sql");
340$res->execute();
341
342
343 list($voti) = $res->fetch(PDO::FETCH_NUM);
344 if ($voti==0 or $genere<3) $ops=4;
345 }
346 if(!$ops) $ops=3;
347 }
348
349 }
350}
351############ fine posizionamento
352
353 ///////////////////////////////////////////
354 // opzioni per le funzioni di immissione
355
356 if ($ops == 1) {
357 votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
358 }else{
359############# Controllo flag per cancellazione consultazione
360 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
361 ."//-->\n";
362 echo "function del_dati() {\n";
363 echo "if (document.getElementById('pwd3').checked==false) {\n";
364 echo "document.getElementById('update').value=\""._OK."\" \n";
365 echo "document.getElementById('do').value=\"0\" \n";
366 echo "}else{\n";
367 echo "document.getElementById('update').value=\""._DELETE."\" \n";
368 echo "document.getElementById('do').value=\"1\" \n";
369 echo "} \n";
370 echo "} \n";
371 echo "</script>\n";
372 }
373 if ($ops == 3) {
374 preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
375 }
376 if ($ops == 4) {
377 preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
378
379 }
380
381 }
382 CloseTable();
383
384}
385////////////////////////////////////////////////////////////////////////////////
386// FUNZIONI DI IMMISSIONE
387// - preferenze (candidati consiglieri)
388// - preferenze_gruppi
389// - votanti
390////////////////////////////////////////////////////////////////////////////////
391
392//////////////////////////////////////////////////////////////////////
393// da qui va la sezione per le preferenze candidati consiglieri
394//////////////////////////////////////////////////////////////////////
395function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
396 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
397global $tipo_cons,$limite,$dettnulli,$disgiunto;
398$bgcolor1="#7777ff";
399$bgcolor2=$_SESSION['bgcolor2'];
400
401if ($genere==4){
402 $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";
403 $result = $dbi->prepare("$sql");
404 $result->execute();
405
406
407 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
408 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
409 ."<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>"
410 ."<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>";
411 echo "</table>";
412}
413$sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
414$result = $dbi->prepare("$sql");
415$result->execute();
416list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
417if($v1+$v2+$v3+$v4>0){
418 //controlla se sono stati inseriti i votanti
419$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
420$result = $dbi->prepare("$sql");
421$result->execute();
422
423
424list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
425
426####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
427if ($circo and $id_lista){
428 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
429 $res_lis = $dbi->prepare("$sql");
430 $res_lis->execute();
431 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
432}
433
434if(!$votog and ($genere==3 or $genere==5)){
435 $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' ";
436$result = $dbi->prepare("$sql");
437$result->execute();
438
439
440}else{
441 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
442$result = $dbi->prepare("$sql");
443$result->execute();
444}
445
446 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
447 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
448 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
449$res_lis = $dbi->prepare("$sql");
450$res_lis->execute();
451
452
453 $num_liste = $res_lis->rowCount();
454 $ele_lista='';
455 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
456 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
457 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo limit 0,1";
458$result = $dbi->prepare("$sql");
459$result->execute();
460
461
462 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
463 }
464 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
465 echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
466 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=\">";
467 echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
468 if ($id_lista){
469 echo "<option value=\"0\">"._VOTI_LISTA;
470 $ele_lista=" and t1.id_lista='$id_lista' ";
471 }else{
472 echo "<option value=\"0\" selected>"._VOTI_LISTA;
473 $ele_lista=" group by t1.id_lista ";
474if(!isset($votolista)) $votolista=0;
475
476 }
477 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
478 $segna='';
479 $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";
480$result = $dbi->prepare("$sql");
481$result->execute();
482
483
484 list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
485 $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";
486$result = $dbi->prepare("$sql");
487$result->execute();
488
489
490 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
491 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
492 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
493$result = $dbi->prepare("$sql");
494$result->execute();
495 }else{
496 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
497$result = $dbi->prepare("$sql");
498$result->execute();
499 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
500 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
501$result = $dbi->prepare("$sql");
502$result->execute();
503 }
504 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
505 if($votisezcand>($votisezlis*$numprefs))
506 {$segna="style=\"background-color: #dd0000;\"";}
507 elseif($ctrvoticand)
508 $segna="style=\"background-color: #99CC33;\"";
509 $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'";
510$res4 = $dbi->prepare("$sql");
511$res4->execute();
512
513
514 $errcand[$id_rif]=array();
515 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
516 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
517
518 $sel = ($id_rif == $id_lista) ? "selected" : "";
519 echo "<option $segna value=\"$id_rif\" $sel>";
520 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
521 echo $num_lis.") ".substr($descrizione,0,30);
522 }
523 echo "</select></form></td>\n";
524 }else {
525 $id_lista=0;
526 }
527 echo "<td style=\"vertical-align: top;\">";
528
529 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
530if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
531 $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";
532$result = $dbi->prepare("$sql");
533$result->execute();
534
535
536}else{
537 $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";
538$result = $dbi->prepare("$sql");
539$result->execute();
540}
541
542// 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
543 $isscr= $result->rowCount();
544 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
545 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
546 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
547$resg = $dbi->prepare("$sql");
548$resg->execute();
549
550
551 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
552 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>";
553 }
554 $valista=$validi2;
555 if(!$id_lista or $genere==3){ //controllo di congruenza
556 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
557$res2 = $dbi->prepare("$sql");
558$res2->execute();
559
560
561 list($tot) = $res2->fetch(PDO::FETCH_NUM);
562####### controlli
563 $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
564 $resc = $dbi->prepare("$sql");
565 $resc->execute();
566if($resc->rowCount()){ if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
567 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>";
568 }
569
570 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
571 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>";
572 }
573 }elseif($genere==5){
574 $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";
575$result = $dbi->prepare("$sql");
576$result->execute();
577
578
579 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
580 if(($fascia>$limite or $disgiunto) or !$id_conf){
581 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
582$result = $dbi->prepare("$sql");
583$result->execute();
584
585
586 }else{
587
588 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
589$result = $dbi->prepare("$sql");
590$result->execute();
591
592
593 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
594 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
595$result = $dbi->prepare("$sql");
596$result->execute();
597
598
599 }
600 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
601 if($votisezcand>($votisezlis*$numprefs))
602 {
603 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>";
604 }
605 }
606#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
607 $errgrulis=array();
608 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
609 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
610$resref = $dbi->prepare("$sql");
611$resref->execute();
612
613
614 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
615$res4 = $dbi->prepare("$sql");
616$res4->execute();
617
618
619 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
620 if ($sezscrl)
621
622 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
623 {
624 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
625$res3 = $dbi->prepare("$sql");
626$res3->execute();
627
628
629 $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')";
630$res4 = $dbi->prepare("$sql");
631$res4->execute();
632
633
634 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
635 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
636 if($vliste>$vgruppo)
637 {
638 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
639$result = $dbi->prepare("$sql");
640$result->execute();
641
642
643 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
644 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>";
645 $errgrulis[$id_gruppo]=1;
646 }
647 elseif($vliste<$vgruppo)
648 {
649 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
650$result = $dbi->prepare("$sql");
651$result->execute();
652
653
654 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
655 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>";
656 $errgrulis[$id_gruppo]=1;
657 }
658 }
659 }
660}
661
662
663 echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
664 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
665 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
666 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
667 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
668 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
669 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
670 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
671 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
672 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
673 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
674 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
675 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
676 if ($genere<4){
677// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
678 }
679 echo "<b>"._NUM."</b></td>";
680 if($id_lista){
681 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
682 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
683 }else{
684 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
685 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
686 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
687 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
688 if($disgiunto){
689 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
690 }
691 }
692 echo "</tr>\n";
693
694
695
696
697
698if($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";
699else $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";
700$result = $dbi->prepare("$sql");
701$result->execute();
702
703
704 $max = $result->rowCount();
705 $tot_pref=0;
706 $i=1;
707
708 if($id_lista) {
709 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
710 // dati lista
711 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
712$result1 = $dbi->prepare("$sql");
713$result1->execute();
714
715
716 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
717 // dati gruppo
718 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
719$result2 = $dbi->prepare("$sql");
720$result2->execute();
721
722
723 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
724
725 echo "<tr bgcolor=\"$bgcolor2\">";
726 if ($genere<4){
727 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
728 }
729 echo "<td align=\"center\"><b> $num_cand </b></td>"
730 ."<td align=\"left\"><b>$cognome $nome</b></td>";
731 $cond_sele="and id_cand=$id_cand";
732 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
733$res = $dbi->prepare("$sql");
734$res->execute();
735
736
737 list($voti)= $res->fetch(PDO::FETCH_NUM);
738 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
739 echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
740 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
741 $i++;
742 $tot_pref+=$voti;
743 }
744 }else {
745 if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
746 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
747 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
748 where t1.id_cons='$id_cons'
749 and t1.id_lista=t2.id_lista
750 and t2.id_sez=$id_sez
751 $circot1
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->fetch(PDO::FETCH_NUM);
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' $circo ";
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' $circo";
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
1344 }
1345 if(!isset($votinulli)) $votinulli=0;
1346 echo "<tr><td></td></tr></table>";
1347 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1348 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\">";
1349 else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
1350 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
1351 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1352 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1353 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1354 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1355 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1356 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
1357 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1358 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1359 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1360 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1361 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1362 if ($genere==0){
1363 echo "<td><b>"._SI."</b></td>"
1364 ."<td><b>"._NO."</b></td>"
1365 ."<td><b>"._VALIDI."</b></td>"
1366 ."<td><b>"._BIANCHI."</b></td>"
1367 ."<td><b>"._CONTESTATI."</b></td>"
1368 ."<td><b>"._NULLI."</b></td>"
1369 ."<td><b>"._TOTNON."</b></td>"
1370 ."<td><b>"._TOTALEVOTI."</b></td>"
1371 ."<td><b>"._VOTANTI."</b></td>";
1372 }else{
1373 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1374 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1375 }
1376 echo "</tr>";
1377 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1378$res = $dbi->prepare("$sql");
1379$res->execute();
1380
1381
1382 $max = $res->rowCount();
1383 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1384 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1385$result = $dbi->prepare("$sql");
1386$result->execute();
1387
1388
1389 $i=1;
1390 $tot_pref=0;
1391 $totsg=0;
1392 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
1393
1394 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1395 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1396
1397 ."//-->\n";
1398 echo "function controlloref$i() {\n";
1399 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";
1400 echo "}\n";
1401 echo "</script>\n";
1402
1403 if ($num_gruppo != ''){
1404 if ($genere==0){
1405 $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' ";
1406$res = $dbi->prepare("$sql");
1407$res->execute();
1408
1409
1410 list($tot) = $res->fetch(PDO::FETCH_NUM);
1411 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1412$res = $dbi->prepare("$sql");
1413$res->execute();
1414
1415
1416 $pro= $res->fetch(PDO::FETCH_BOTH);
1417
1418 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)){
1419 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1420 }else{
1421 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1422 }
1423 $descr = explode('.',$descr_gruppo, 100);
1424 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1425 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
1426 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1427 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1428 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1429 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1430 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1431 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
1432 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
1433 $tot_voti=intval($pro['validi'])+$tot_nulli;
1434 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1435 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1436 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1437 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1438 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1439 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1440 echo "</td><td align=\"right\">$tot_nulli</td>";
1441 echo "</td><td align=\"right\">$tot_voti</td>";
1442 echo "</td><td align=\"right\">$tot</td>";
1443 }else{
1444 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>"
1445 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1446 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1447 $res = $dbi->prepare("$sql");
1448 $res->execute();
1449
1450 $pro= $res->fetch(PDO::FETCH_BOTH);
1451 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
1452 $errcolor='';
1453 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1454 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
1455
1456 if($dettnulli) {echo "<td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\" style=\"text-align:right\"></td>"; $totsg+=intval($pro['solo_gruppo']);}
1457 $tot_pref += intval($pro['voti']);
1458 echo "</tr>";
1459 }
1460
1461 $i++;
1462 }
1463
1464 }
1465 if ($genere!=0) {
1466 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1467$res = $dbi->prepare("$sql");
1468$res->execute();
1469
1470
1471 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1472 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1473$res = $dbi->prepare("$sql");
1474$res->execute();
1475
1476
1477 list($sololis)=$res->fetch(PDO::FETCH_NUM);
1478 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
1479 if($dettnulli) echo "<td>$totsg</td>";
1480 echo "</tr>";
1481 if($disgiunto)
1482 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>";
1483 }
1484
1485 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1486
1487 echo "</tr></table></form></td></tr>";
1488 if(chisei($id_cons_gen)>=64){
1489 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1490 }
1491
1492 echo "</td></tr></table></center>";
1493 }
1494 if ($genere!=0){
1495 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1496 }
1497}
1498
1499
1500
1501
1502 if (!preg_match("/rec/",$op)) {
1503 ele(); //menu
1504/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
1505 numeri_sezione(8);
1506 echo "<td></td></tr></table>\n";*/
1507 echo"</td></tr></table>";
1508 }
1509
1510 switch ($op){
1511 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
1512# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1513 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1514 break;
1515 case "rec_add_votanti":
1516 rec_add_votanti($vari);
1517 break;
1518 default :
1519 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
1520 }
1521echo"</td></tr></table>";
1522 include_once("modules/Elezioni/language/lang-$currentlang.php");
1523 include ("footer.php");
1524?>
1525
Note: See TracBrowser for help on using the repository browser.