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

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

Segue modifiche per la compatibilità php7.x

File size: 67.8 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($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 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
304 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>";
305 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";
306 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($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=4\">"._GRUPPO."</a></b></p></td>\n";
308 }
309 if($genere==2 and $votog)
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 elseif(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
312 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";
313 }
314 echo "</tr></table></td></tr></table><hr>\n";
315
316#############
317# posizionamento in mancanza di scelta
318#############
319if (!$ops){
320 if (!$id_sez) { echo"";#import( pagina di help );
321 } else{
322 $sql="SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
323 $res = $dbi->prepare("$sql");
324 $res->execute();
325 list($data,$orario)=$res->fetch(PDO::FETCH_NUM);
326 $sql="SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'";
327 $res = $dbi->prepare("$sql");
328 $res->execute();
329 list($voti) = $res->fetch(PDO::FETCH_NUM);
330 if (!$voti) $ops=1;
331 else {
332 if($genere<4){
333 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
334 $res = $dbi->prepare("$sql");
335 $res->execute();
336 list($voti) = $res->fetch(PDO::FETCH_NUM);
337 if ($voti==0 or $genere<3) $ops=4;
338 }
339 if(!$ops) $ops=3;
340 }
341
342 }
343}
344############ fine posizionamento
345
346 ///////////////////////////////////////////
347 // opzioni per le funzioni di immissione
348
349 if ($ops == 1) {
350 votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
351 }else{
352############# Controllo flag per cancellazione consultazione
353 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
354 ."//-->\n";
355 echo "function del_dati() {\n";
356 echo "if (document.getElementById('pwd3').checked==false) {\n";
357 echo "document.getElementById('update').value=\""._OK."\" \n";
358 echo "document.getElementById('do').value=\"0\" \n";
359 echo "}else{\n";
360 echo "document.getElementById('update').value=\""._DELETE."\" \n";
361 echo "document.getElementById('do').value=\"1\" \n";
362 echo "} \n";
363 echo "} \n";
364 echo "</script>\n";
365 }
366 if ($ops == 3) {
367 preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
368 }
369 if ($ops == 4) {
370 preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
371
372 }
373
374 }
375 CloseTable();
376
377}
378////////////////////////////////////////////////////////////////////////////////
379// FUNZIONI DI IMMISSIONE
380// - preferenze (candidati consiglieri)
381// - preferenze_gruppi
382// - votanti
383////////////////////////////////////////////////////////////////////////////////
384
385//////////////////////////////////////////////////////////////////////
386// da qui va la sezione per le preferenze candidati consiglieri
387//////////////////////////////////////////////////////////////////////
388function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
389 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
390global $tipo_cons,$limite,$dettnulli,$disgiunto;
391$bgcolor1="#7777ff";
392$bgcolor2=$_SESSION['bgcolor2'];
393
394if ($genere==4){
395 $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";
396 $result = $dbi->prepare("$sql");
397 $result->execute();
398
399
400 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
401 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
402 ."<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>"
403 ."<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>";
404 echo "</table>";
405}
406$sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
407$result = $dbi->prepare("$sql");
408$result->execute();
409list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
410if($v1+$v2+$v3+$v4>0){
411 //controlla se sono stati inseriti i votanti
412$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
413$result = $dbi->prepare("$sql");
414$result->execute();
415
416
417list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
418
419####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
420if ($circo and $id_lista){
421 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
422 $res_lis = $dbi->prepare("$sql");
423 $res_lis->execute();
424 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
425}
426
427if(!$votog and ($genere==3 or $genere==5)){
428 $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' ";
429$result = $dbi->prepare("$sql");
430$result->execute();
431
432
433}else{
434 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
435$result = $dbi->prepare("$sql");
436$result->execute();
437}
438
439 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
440 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
441 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
442$res_lis = $dbi->prepare("$sql");
443$res_lis->execute();
444
445
446 $num_liste = $res_lis->rowCount();
447 $ele_lista='';
448 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
449 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
450 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo limit 0,1";
451$result = $dbi->prepare("$sql");
452$result->execute();
453
454
455 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
456 }
457 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
458 echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
459 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=\">";
460 echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
461 if ($id_lista){
462 echo "<option value=\"0\">"._VOTI_LISTA;
463 $ele_lista=" and t1.id_lista='$id_lista' ";
464 }else{
465 echo "<option value=\"0\" selected>"._VOTI_LISTA;
466 $ele_lista=" group by t1.id_lista ";
467if(!isset($votolista)) $votolista=0;
468
469 }
470 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
471 $segna='';
472 $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";
473$result = $dbi->prepare("$sql");
474$result->execute();
475
476
477 list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
478 $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";
479$result = $dbi->prepare("$sql");
480$result->execute();
481
482
483 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
484 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
485 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
486$result = $dbi->prepare("$sql");
487$result->execute();
488 }else{
489 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
490$result = $dbi->prepare("$sql");
491$result->execute();
492 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
493 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
494$result = $dbi->prepare("$sql");
495$result->execute();
496 }
497 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
498 if($votisezcand>($votisezlis*$numprefs))
499 {$segna="style=\"background-color: #dd0000;\"";}
500 elseif($ctrvoticand)
501 $segna="style=\"background-color: #99CC33;\"";
502 $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'";
503$res4 = $dbi->prepare("$sql");
504$res4->execute();
505
506
507 $errcand[$id_rif]=array();
508 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
509 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
510
511 $sel = ($id_rif == $id_lista) ? "selected" : "";
512 echo "<option $segna value=\"$id_rif\" $sel>";
513 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
514 echo $num_lis.") ".substr($descrizione,0,30);
515 }
516 echo "</select></form></td>\n";
517 }else {
518 $id_lista=0;
519 }
520 echo "<td style=\"vertical-align: top;\">";
521
522 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
523if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
524 $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";
525$result = $dbi->prepare("$sql");
526$result->execute();
527
528
529}else{
530 $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";
531$result = $dbi->prepare("$sql");
532$result->execute();
533}
534
535// 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
536 $isscr= $result->rowCount();
537 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
538 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
539 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
540$resg = $dbi->prepare("$sql");
541$resg->execute();
542
543
544 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
545 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>";
546 }
547 $valista=$validi2;
548 if(!$id_lista or $genere==3){ //controllo di congruenza
549 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
550$res2 = $dbi->prepare("$sql");
551$res2->execute();
552
553
554 list($tot) = $res2->fetch(PDO::FETCH_NUM);
555####### controlli
556 $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
557 $resc = $dbi->prepare("$sql");
558 $resc->execute();
559if($resc->rowCount()){ if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
560 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>";
561 }
562
563 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
564 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>";
565 }
566 }elseif($genere==5){
567 $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";
568$result = $dbi->prepare("$sql");
569$result->execute();
570
571
572 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
573 if(($fascia>$limite or $disgiunto) or !$id_conf){
574 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
575$result = $dbi->prepare("$sql");
576$result->execute();
577
578
579 }else{
580
581 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
582$result = $dbi->prepare("$sql");
583$result->execute();
584
585
586 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
587 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
588$result = $dbi->prepare("$sql");
589$result->execute();
590
591
592 }
593 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
594 if($votisezcand>($votisezlis*$numprefs))
595 {
596 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>";
597 }
598 }
599#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
600 $errgrulis=array();
601 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
602 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
603$resref = $dbi->prepare("$sql");
604$resref->execute();
605
606
607 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
608$res4 = $dbi->prepare("$sql");
609$res4->execute();
610
611
612 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
613 if ($sezscrl)
614
615 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
616 {
617 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
618$res3 = $dbi->prepare("$sql");
619$res3->execute();
620
621
622 $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')";
623$res4 = $dbi->prepare("$sql");
624$res4->execute();
625
626
627 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
628 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
629 if($vliste>$vgruppo)
630 {
631 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
632$result = $dbi->prepare("$sql");
633$result->execute();
634
635
636 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
637 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>";
638 $errgrulis[$id_gruppo]=1;
639 }
640 elseif($vliste<$vgruppo)
641 {
642 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
643$result = $dbi->prepare("$sql");
644$result->execute();
645
646
647 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
648 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>";
649 $errgrulis[$id_gruppo]=1;
650 }
651 }
652 }
653}
654
655
656 echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
657 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
658 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
659 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
660 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
661 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
662 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
663 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
664 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
665 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
666 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
667 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
668 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
669 if ($genere<4){
670// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
671 }
672 echo "<b>"._NUM."</b></td>";
673 if($id_lista){
674 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
675 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
676 }else{
677 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
678 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
679 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
680 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
681 if($disgiunto){
682 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
683 }
684 }
685 echo "</tr>\n";
686
687
688
689
690
691if($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";
692else $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";
693$result = $dbi->prepare("$sql");
694$result->execute();
695
696
697 $max = $result->rowCount();
698 $tot_pref=0;
699 $i=1;
700
701 if($id_lista) {
702 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
703 // dati lista
704 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
705$result1 = $dbi->prepare("$sql");
706$result1->execute();
707
708
709 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
710 // dati gruppo
711 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
712$result2 = $dbi->prepare("$sql");
713$result2->execute();
714
715
716 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
717
718 echo "<tr bgcolor=\"$bgcolor2\">";
719 if ($genere<4){
720 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
721 }
722 echo "<td align=\"center\"><b> $num_cand </b></td>"
723 ."<td align=\"left\"><b>$cognome $nome</b></td>";
724 $cond_sele="and id_cand=$id_cand";
725 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
726$res = $dbi->prepare("$sql");
727$res->execute();
728
729
730 list($voti)= $res->fetch(PDO::FETCH_NUM);
731 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
732 echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
733 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
734 $i++;
735 $tot_pref+=$voti;
736 }
737 }else {
738 if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
739 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
740 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
741 where t1.id_cons='$id_cons'
742 and t1.id_lista=t2.id_lista
743 and t2.id_sez=$id_sez
744 $circot1
745 order by t1.num_lista";
746
747 try {
748 $result1 = $dbi->prepare("$sql");
749 $result1->execute();
750
751 }
752 catch(PDOException $e)
753 {
754 echo $sql . "<br>" . $e->getMessage();
755 }
756
757 $num_lista=$result1->rowCount();
758 if (!$num_lista){
759 $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
760 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
761 order by num_lista";
762 $result1 = $dbi->prepare("$sql");
763 $result1->execute();
764 }
765 $tvnpl=0;
766 $tslpl=0;
767 while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
768 echo "<tr bgcolor=\"$bgcolor2\">";
769// if ($genere<4 or $votoc){
770// }
771 $errcolor='';
772 if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
773 echo "<td align=\"center\"><b> $num_lista </b></td>"
774 ."<td align=\"left\"><b> $descr_lista</b></td>";
775 $cond_sele="and id_lista=$id_lista3";
776 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
777 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;}
778 if($disgiunto) {echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\">"; $tslpl+=$slpl;}
779 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
780// echo "<td align=\"right\">$sgpl";
781 echo "</tr>\n";
782 $i++;
783 $tot_pref+=$voti;
784 }
785 }
786 if(!$id_lista) {
787 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>";
788 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
789 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
790 if($disgiunto)
791 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
792 echo "</tr>";
793 }
794 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
795 // toglie ai candidati la visual... del solo_gruppo
796 if(!$votog) {
797 if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
798 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>";
799 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>";
800 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\">"
801 ."</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>";
802
803 }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
804 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
805 }
806######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
807elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
808$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
809$resvg = $dbi->prepare("$sql");
810$resvg->execute();
811
812
813list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
814$sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
815$resvg = $dbi->prepare("$sql");
816$resvg->execute();
817
818
819 list($voti_sind) = $resvg->fetch(PDO::FETCH_NUM);
820
821echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
822}
823###### fine modifica del 16-04-2009
824
825 }
826 echo "<tr>";
827 echo "<td></td><td></td>";
828 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
829 echo "</tr></table>";
830 if(chisei($id_cons_gen)>=64){
831 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
832 } # onclick=\"javascript:del_dati()\"
833 echo "</form></tr></table>";
834 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
835 ."document.sezioni.voti1.focus()\n"
836 ."document.sezioni.voti1.select()\n"
837 ."//-->\n";
838 echo "function vai_lista() {\n";
839 echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
840 echo "}\n";
841 echo "</script>\n";
842}
843#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
844 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
845 }
846
847
848////////////////////////////////////////////
849// da qua va la sezione per i votanti
850///////////////////////////////////////////
851
852function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
853//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
854 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
855$bgcolor1=$_SESSION['bgcolor2'];
856
857#OpenTable();
858$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
859$res = $dbi->prepare("$sql");
860$res->execute();
861
862
863if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
864$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
865$res = $dbi->prepare("$sql");
866$res->execute();
867
868echo "<table><tr><td>";
869$num = $res->rowCount();
870$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
871$ressez = $dbi->prepare("$sql");
872$ressez->execute();
873##################
874echo "<style>";
875echo "DIV.table";
876echo "{
877 display:table;
878}
879FORM.tr
880{
881 display:table-row;
882 text-align: center;
883}
884DIV.tr
885{
886 display:table-row;
887 background-color: #D3D3D3;
888 text-align: center;
889}
890SPAN.tdm
891{
892 display:table-cell;
893 border: 1px solid black;
894 padding: 5px;
895}
896SPAN.td
897{
898 display:table-cell;
899}";
900echo "</style>";
901
902/*
903 echo "<form class=\"tr\" name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
904 echo "<span class=\"td\"><input type=\"text\"/></span>";
905 <span class="td"><input type="text"/></span>
906 </form>
907 <div class="tr">
908 <span class="td">(cell data)</span>
909 <span class="td">(cell data)</span>
910 </div>
911 ...
912</div>
913*/
914##################
915
916list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
917$y=0;
918echo "<div class=\"table\">";
919#echo "<tr><td>&nbsp;</td></tr>";
920$riga=array();
921$rigat=array();
922while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
923 $y++;
924 $rigat[$y]='';
925 $riga[$y]='';
926# echo "\n<tr><td>";
927# echo "<form name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
928# echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
929$rigat[$y]= "<div class=\"tr\">";
930 if ($genere==0){ //e' un referendum
931# echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
932 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
933 }
934 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
935 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
936 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
937 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
938 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
939 if ($genere==0){
940 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
941$res2 = $dbi->prepare("$sql");
942$res2->execute();
943
944
945 $max = $res2->rowCount();
946 }else{ $max=1;}
947 $op="rec_add_votanti";
948 $rigat[$y].= "</div>";
949
950 for ($i=1;$i<=$max;$i++){
951 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
952 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
953 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
954 if ($genere==0){
955 $query.=" and t2.num_gruppo=$i";
956 }
957 $sql=$query;
958$result = $dbi->prepare("$sql");
959$result->execute();
960
961
962 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
963 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
964$res2 = $dbi->prepare("$sql");
965$res2->execute();
966
967
968 $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
969$resril = $dbi->prepare("$sql");
970$resril->execute();
971
972
973 list($numril)=$resril->fetch(PDO::FETCH_NUM);
974 if ($res2)
975 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
976 else
977 $gruppo=0;
978 if (!$gruppo>0) {
979 $gruppo=$i;
980 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
981$res3 = $dbi->prepare("$sql");
982$res3->execute();
983
984
985 if ($res3)
986 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
987 }
988 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
989 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
990 $precede[$id_gruppo]=$voti_t;
991 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
992# echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
993 $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
994 }else{
995 $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
996 }
997 if ($genere==0){ // e' un referendum
998 $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
999 }
1000
1001
1002 $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
1003 $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
1004 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
1005 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
1006 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
1007 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
1008#$riga[$y].= "</span>";
1009 list ($anno,$mese,$di)=explode('-',$giorno);
1010 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
1011 if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
1012 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1013 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\"";
1014 $riga[$y].= " size=\"5\"/></span>";
1015 if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
1016 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1017 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\"";
1018 $riga[$y].= " size=\"5\"/></span>";
1019 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\"/>";
1020 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\"/>";
1021 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
1022 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
1023 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
1024 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
1025 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
1026 $riga[$y].= "</span>";
1027
1028 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>";
1029 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
1030 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
1031 $riga[$y].= "</form>";
1032
1033 }
1034# echo "</table></form>";
1035 echo "</div>";
1036
1037
1038 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
1039$compl = $dbi->prepare("$sql");
1040$compl->execute();
1041
1042
1043 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
1044 if (!$complessivi)
1045 {
1046 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1047 $numy=$y.'1';
1048 if ($y==$num) {
1049 echo "document.votanti$y.voti_u$numy.focus()\n";
1050 echo "document.votanti$y.voti_u$numy.select()\n";
1051 }else{
1052 echo "this.voti_t$numy.focus()\n";
1053 echo "this.voti_t$numy.select()\n";
1054 }
1055 echo "//-->\n"
1056 ."</script>\n";
1057 break;
1058 }
1059# echo "</td></tr>";
1060 }
1061#CloseTable();
1062foreach($riga as $key=>$val){
1063 echo $rigat[$key];
1064 echo $riga[$key];
1065}
1066echo "</div></td></tr></table>";
1067}
1068
1069
1070
1071function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1072 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
1073////////////////////////////////////////////
1074// da qua va la sezione per i voti finali
1075///////////////////////////////////////////
1076$bgcolor1="#7777ff";
1077$bgcolor2=$_SESSION['bgcolor2'];
1078
1079
1080
1081 echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
1082 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
1083 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1084 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1085 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1086 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1087 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1088
1089 echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
1090/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1091 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
1092 else */
1093 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
1094 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
1095 ."<td><b>"._BIANCHI."</b></td>"
1096 ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
1097 ."<td><b>"._CONTESTATI."</b></td>"
1098 ."<td><b>"._TOTNON."</b></td>"
1099 ."<td><b>"._TOTALEVOTI."</b></td>"
1100 ."<td bgcolor=\"#ffffff\"></td> </tr>";
1101/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1102 $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' ";
1103$res = $dbi->prepare("$sql");
1104$res->execute();
1105
1106
1107else */
1108 $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' ";
1109$result = $dbi->prepare("$sql");
1110$result->execute();
1111
1112
1113 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
1114 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
1115 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
1116// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
1117
1118
1119 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
1120/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
1121 echo "</td><td>$nulli"
1122 ."</td><td>$bianchi";
1123 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
1124 }else{ */
1125 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
1126 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
1127// }
1128 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
1129 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
1130 ."</td><td>$tot_nulli"
1131 ."</td><td>$tot_voti</td><td>"
1132 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1133 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
1134 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
1135 ."</td></tr></table></form>"; //</td></tr>";
1136
1137
1138// echo "</table>";
1139 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1140 if (!$validi) {
1141 echo "document.spogliovoti.validi.focus()\n";
1142 echo "document.spogliovoti.validi.select()\n";
1143 }
1144 echo "//-->\n"
1145 ."</script>\n";
1146
1147
1148 }
1149
1150
1151function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1152 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
1153////////////////////////////////////////////
1154// da qua va la sezione per le preferenze ai gruppi
1155///////////////////////////////////////////
1156// Controllo immmissioni
1157
1158$bgcolor1="#7777ff";
1159$bgcolor2=$_SESSION['bgcolor2'];
1160$sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
1161$res = $dbi->prepare("$sql");
1162$res->execute();
1163
1164
1165 $max = $res->rowCount();
1166 $max = $max-1;
1167 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1168 if ($genere==0) {
1169 echo "document.sezioni.si1.focus()\n";
1170 echo "document.sezioni.si1.select()\n";
1171 } else {
1172 echo "document.sezioni.voti1.focus()\n"
1173 ."document.sezioni.voti1.select()\n";
1174 }
1175 echo "//-->\n"
1176 ."</script>\n";
1177// tabella votanti
1178 echo "<center>";
1179 if ($genere!=0){
1180 $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";
1181$result = $dbi->prepare("$sql");
1182$result->execute();
1183
1184
1185 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
1186 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
1187 ."<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>"
1188 ."<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>";
1189 echo "</table>";
1190 }
1191 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
1192 if ($genere==0){
1193 $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' ";
1194$res = $dbi->prepare("$sql");
1195$res->execute();
1196
1197
1198 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
1199 if ($voti_parz!=$validi){
1200 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
1201$res2 = $dbi->prepare("$sql");
1202$res2->execute();
1203
1204
1205 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1206 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>";
1207 }
1208 $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' ";
1209$res2 = $dbi->prepare("$sql");
1210$res2->execute();
1211
1212
1213 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1214 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
1215 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
1216$res2 = $dbi->prepare("$sql");
1217$res2->execute();
1218
1219
1220 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1221 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>";
1222 }
1223 }
1224 }else{
1225 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1226$result = $dbi->prepare("$sql");
1227$result->execute();
1228
1229
1230 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
1231 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
1232$res = $dbi->prepare("$sql");
1233$res->execute();
1234
1235
1236 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
1237 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
1238$res = $dbi->prepare("$sql");
1239$res->execute();
1240
1241
1242 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
1243 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
1244 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>";
1245 }
1246 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
1247$res2 = $dbi->prepare("$sql");
1248$res2->execute();
1249
1250
1251 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1252 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
1253 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>";
1254 }
1255 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
1256 $resg = $dbi->prepare("$sql");
1257 $resg->execute();
1258
1259
1260 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
1261 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
1262
1263 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
1264 $resg = $dbi->prepare("$sql");
1265 $resg->execute();
1266
1267
1268 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
1269 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
1270 $resg = $dbi->prepare("$sql");
1271 $resg->execute();
1272
1273
1274 list($sg)=$resg->fetch(PDO::FETCH_NUM);
1275 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>";
1276 }
1277#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
1278if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
1279$sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
1280$resref = $dbi->prepare("$sql");
1281$resref->execute();
1282
1283
1284 $errgrulis=array();
1285 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
1286 $res4 = $dbi->prepare("$sql");
1287 $res4->execute();
1288
1289
1290 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
1291 if ($sezscrl)
1292 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
1293 {
1294 if($disgiunto || $flagsg){
1295 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1296 $res3 = $dbi->prepare("$sql");
1297 $res3->execute();
1298 if($flagsg){
1299 $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')";
1300 $res4 = $dbi->prepare("$sql");
1301 $res4->execute();
1302 }else{
1303 $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')";
1304 $res4 = $dbi->prepare("$sql");
1305 $res4->execute();
1306 }
1307 }else{
1308 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1309 $res3 = $dbi->prepare("$sql");
1310 $res3->execute();
1311 $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')";
1312 $res4 = $dbi->prepare("$sql");
1313 $res4->execute();
1314 }
1315 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1316 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
1317 if($vliste>$vgruppo and !$disgiunto )
1318 {
1319 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1320 $result = $dbi->prepare("$sql");
1321 $result->execute();
1322 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1323 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>";
1324 $errgrulis[$id_gruppo]=1;
1325 }
1326 elseif($vliste<$vgruppo and $disgiunto )
1327 {
1328 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1329 $result = $dbi->prepare("$sql");
1330 $result->execute();
1331 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1332 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>";
1333 $errgrulis[$id_gruppo]=1;
1334 }
1335 }
1336 }
1337
1338 }
1339 if(!isset($votinulli)) $votinulli=0;
1340 echo "<tr><td></td></tr></table>";
1341 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1342 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\">";
1343 else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
1344 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
1345 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1346 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1347 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1348 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1349 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1350 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
1351 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1352 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1353 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1354 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1355 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1356 if ($genere==0){
1357 echo "<td><b>"._SI."</b></td>"
1358 ."<td><b>"._NO."</b></td>"
1359 ."<td><b>"._VALIDI."</b></td>"
1360 ."<td><b>"._BIANCHI."</b></td>"
1361 ."<td><b>"._CONTESTATI."</b></td>"
1362 ."<td><b>"._NULLI."</b></td>"
1363 ."<td><b>"._TOTNON."</b></td>"
1364 ."<td><b>"._TOTALEVOTI."</b></td>"
1365 ."<td><b>"._VOTANTI."</b></td>";
1366 }else{
1367 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1368 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1369 }
1370 echo "</tr>";
1371 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1372$res = $dbi->prepare("$sql");
1373$res->execute();
1374
1375
1376 $max = $res->rowCount();
1377 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1378 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1379$result = $dbi->prepare("$sql");
1380$result->execute();
1381
1382
1383 $i=1;
1384 $tot_pref=0;
1385 $totsg=0;
1386 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
1387
1388 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1389 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1390
1391 ."//-->\n";
1392 echo "function controlloref$i() {\n";
1393 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";
1394 echo "}\n";
1395 echo "</script>\n";
1396
1397 if ($num_gruppo != ''){
1398 if ($genere==0){
1399 $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' ";
1400$res = $dbi->prepare("$sql");
1401$res->execute();
1402
1403
1404 list($tot) = $res->fetch(PDO::FETCH_NUM);
1405 $sql="SELECT * FROM ".$prefix."_ele_voti_ref 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 $pro= $res->fetch(PDO::FETCH_BOTH);
1411
1412 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)){
1413 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1414 }else{
1415 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1416 }
1417 $descr = explode('.',$descr_gruppo, 100);
1418 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1419 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
1420 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1421 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1422 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1423 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1424 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1425 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
1426 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
1427 $tot_voti=intval($pro['validi'])+$tot_nulli;
1428 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1429 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1430 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1431 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1432 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1433 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1434 echo "</td><td align=\"right\">$tot_nulli</td>";
1435 echo "</td><td align=\"right\">$tot_voti</td>";
1436 echo "</td><td align=\"right\">$tot</td>";
1437 }else{
1438 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>"
1439 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1440 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1441 $res = $dbi->prepare("$sql");
1442 $res->execute();
1443
1444 $pro= $res->fetch(PDO::FETCH_BOTH);
1445 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
1446 $errcolor='';
1447 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1448 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
1449
1450 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']);}
1451 $tot_pref += intval($pro['voti']);
1452 echo "</tr>";
1453 }
1454
1455 $i++;
1456 }
1457
1458 }
1459 if ($genere!=0) {
1460 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1461$res = $dbi->prepare("$sql");
1462$res->execute();
1463
1464
1465 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1466 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1467$res = $dbi->prepare("$sql");
1468$res->execute();
1469
1470
1471 list($sololis)=$res->fetch(PDO::FETCH_NUM);
1472 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
1473 if($dettnulli) echo "<td>$totsg</td>";
1474 echo "</tr>";
1475 if($disgiunto)
1476 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>";
1477 }
1478
1479 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1480
1481 echo "</tr></table></form></td></tr>";
1482 if(chisei($id_cons_gen)>=64){
1483 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1484 }
1485
1486 echo "</td></tr></table></center>";
1487 }
1488 if ($genere!=0){
1489 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1490 }
1491}
1492
1493
1494
1495
1496 if (!preg_match("/rec/",$op)) {
1497 ele(); //menu
1498/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
1499 numeri_sezione(8);
1500 echo "<td></td></tr></table>\n";*/
1501 echo"</td></tr></table>";
1502 }
1503
1504 switch ($op){
1505 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
1506# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1507 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1508 break;
1509 case "rec_add_votanti":
1510 rec_add_votanti($vari);
1511 break;
1512 default :
1513 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
1514 }
1515echo"</td></tr></table>";
1516 include_once("modules/Elezioni/language/lang-$currentlang.php");
1517 include ("footer.php");
1518?>
1519
Note: See TracBrowser for help on using the repository browser.