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

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

seguono modifiche alla rev 238

File size: 67.7 KB
RevLine 
[254]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}
[257]15global $dbi;
[254]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;
[257]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);
[254]53if ($tipo_cons!=3 or $votolista==1) $limite=0; #die ("limite: $limite");}
[257]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
[338]65
[257]66list($dettnulli,$disgiunto)=$res->fetch(PDO::FETCH_NUM);
[338]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);
[254]72if ($conscirc){ // or $num_circ==1
73 if (!$id_circ){
74 if (!$id_sez){
[257]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);
[254]81 }
[257]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";
[338]88//$res = $dbi->prepare("$sql");
89//$res->execute();
[257]90
91
92 if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
93 list($id_circ)=$res->fetch(PDO::FETCH_NUM);
[254]94 $_SESSION['id_circ']=$id_circ;
95 }
[257]96 $sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'";
97$result = $dbi->prepare("$sql");
98$result->execute();
99
100
[254]101 $i=0;
[257]102 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
[254]103 unset($idsedi);$i=0;$idsezi=array();unset($result);
[257]104 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)";
105$result = $dbi->prepare("$sql");
106$result->execute();
107
108
[254]109 unset($tmp);
[257]110 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsezi[$i++]=$tmp;
[254]111 $tmp=implode (",",$idsezi);
112 $sezi = "and id_sez in ($tmp)";
[338]113 $circo = "and id_circ=$id_circ";
[254]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
[329]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;
[254]127$idrefgruppo='';
128 $solosede='';
129 if ($perms<32) {
[257]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
[254]135 if ($res) {
[257]136 list($solouna)=$res->fetch(PDO::FETCH_NUM);
[254]137 if ($solouna>0) $solosede="and id_sede='$solouna'";
138 }
139 }
[258]140 $sql="SELECT num_sez, id_sez ,id_sede,colore FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
[257]141$res = $dbi->prepare("$sql");
142$res->execute();
143
144
145 $max = $res->rowCount();
[254]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>";
[260]152 while(list($sez_num, $sez_id ,$sede_id,$colore) = $res->fetch(PDO::FETCH_NUM)) {
[307]153# $ops='';
[254]154 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
155 $i++;
[258]156 $sql="SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
[257]157$result = $dbi->prepare("$sql");
158$result->execute();
159
160
161 list($circ_id) = $result->fetch(PDO::FETCH_NUM);
[260]162
[254]163 if(!$ops) $ops=1;
[257]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);
[260]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; \"";
[254]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) {
[338]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;
[254]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
[257]195 $sql="SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
[254]196 ".$prefix."_ele_sede as t2
[257]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);
[254]203 if ($id_sede2 and !($id_sede==$id_sede2)) {
204 $id_sede=$id_sede2;
205 $id_circ=$id_circ2;
206 $do="spoglio";
[257]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);
[254]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\">";
[257]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)) {
[254]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\">";
[257]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);
[254]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\">";
[257]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
[254]273// echo "$id_circ - $id_cons";
[257]274 while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
[254]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 //************************************
[257]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();
[254]303
[257]304
305 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
306
[258]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>";
[254]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{
[257]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);
[254]335 if (!$voti) $ops=1;
336 else {
337 if($genere<4){
[257]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);
[254]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;
[339]397global $tipo_cons,$limite,$dettnulli,$disgiunto;
[254]398$bgcolor1="#7777ff";
399$bgcolor2=$_SESSION['bgcolor2'];
[324]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){
[254]418 //controlla se sono stati inseriti i votanti
[257]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();
[254]422
[257]423
424list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
425
[254]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){
[257]428 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
[338]429 $res_lis = $dbi->prepare("$sql");
430 $res_lis->execute();
[257]431 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
[254]432}
[307]433
[258]434if(!$votog and ($genere==3 or $genere==5)){
[257]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
[258]440}else{
[257]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();
[258]444}
[257]445
446 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
[254]447 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
[257]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
[286]452
[257]453 $num_liste = $res_lis->rowCount();
[254]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
[338]457 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo limit 0,1";
[257]458$result = $dbi->prepare("$sql");
459$result->execute();
460
461
462 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
[254]463 }
464 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
[258]465 echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
[254]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 }
[257]477 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
[254]478 $segna='';
[257]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);
[258]491 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
[257]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();
[258]495 }else{
[257]496 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
497$result = $dbi->prepare("$sql");
498$result->execute();
[271]499 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
[257]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();
[254]503 }
[257]504 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
[254]505 if($votisezcand>($votisezlis*$numprefs))
506 {$segna="style=\"background-color: #dd0000;\"";}
507 elseif($ctrvoticand)
508 $segna="style=\"background-color: #99CC33;\"";
[257]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
[254]514 $errcand[$id_rif]=array();
[257]515 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
[254]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";}
[258]530if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
[262]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";
[257]532$result = $dbi->prepare("$sql");
533$result->execute();
534
535
[258]536}else{
[319]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";
[257]538$result = $dbi->prepare("$sql");
539$result->execute();
[258]540}
[309]541
[254]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
[257]543 $isscr= $result->rowCount();
544 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
[254]545 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
[257]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);
[254]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
[257]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);
[309]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){
[254]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){
[257]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);
[258]580 if(($fascia>$limite or $disgiunto) or !$id_conf){
[257]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
[258]586 }else{
[254]587
[257]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
[254]599 }
[257]600 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
[254]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)){
[338]609 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
[257]610$resref = $dbi->prepare("$sql");
611$resref->execute();
612
613
[258]614 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
[257]615$res4 = $dbi->prepare("$sql");
616$res4->execute();
617
618
619 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
[254]620 if ($sezscrl)
621
[257]622 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
[254]623 {
[257]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);
[254]636 if($vliste>$vgruppo)
637 {
[339]638 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
[257]639$result = $dbi->prepare("$sql");
640$result->execute();
641
642
643 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
[254]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 {
[339]649 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
[257]650$result = $dbi->prepare("$sql");
651$result->execute();
652
653
654 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
[254]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 }
[307]660}
[254]661
662
[258]663 echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
[254]664 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
665 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
[258]666 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
[260]667 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
[254]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
[294]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";
[257]700$result = $dbi->prepare("$sql");
701$result->execute();
702
703
704 $max = $result->rowCount();
[254]705 $tot_pref=0;
706 $i=1;
707
708 if($id_lista) {
[264]709 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
[254]710 // dati lista
[257]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);
[254]717 // dati gruppo
[257]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);
[254]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";
[258]732 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
[257]733$res = $dbi->prepare("$sql");
734$res->execute();
735
736
[258]737 list($voti)= $res->fetch(PDO::FETCH_NUM);
[254]738 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
[271]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";
[254]741 $i++;
[258]742 $tot_pref+=$voti;
[254]743 }
744 }else {
[338]745 if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
[258]746 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
[254]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
[338]751 $circot1
[257]752 order by t1.num_lista";
753
[258]754 try {
755 $result1 = $dbi->prepare("$sql");
756 $result1->execute();
[257]757
[258]758 }
759 catch(PDOException $e)
760 {
761 echo $sql . "<br>" . $e->getMessage();
762 }
763
[257]764 $num_lista=$result1->rowCount();
[254]765 if (!$num_lista){
[258]766 $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
[254]767 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
[257]768 order by num_lista";
[288]769 $result1 = $dbi->prepare("$sql");
770 $result1->execute();
[254]771 }
[288]772 $tvnpl=0;
773 $tslpl=0;
[258]774 while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
[254]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";
[258]783 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
[288]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;}
[254]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++;
[258]790 $tot_pref+=$voti;
[254]791 }
792 }
[288]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 }
[254]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) {
[257]815$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
816$resvg = $dbi->prepare("$sql");
817$resvg->execute();
[254]818
[257]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
[337]826 list($voti_sind) = $resvg->fetch(PDO::FETCH_NUM);
[257]827
[254]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>";
[258]836 echo "</tr></table>";
[254]837 if(chisei($id_cons_gen)>=64){
[258]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>";
[254]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";
[324]849}
[254]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){
[258]861 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
[254]862$bgcolor1=$_SESSION['bgcolor2'];
[258]863
864#OpenTable();
[257]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
[258]875echo "<table><tr><td>";
[257]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();
[258]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>";
[257]908
[258]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##################
[257]922
923list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
[254]924$y=0;
[258]925echo "<div class=\"table\">";
926#echo "<tr><td>&nbsp;</td></tr>";
927$riga=array();
928$rigat=array();
[257]929while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
[254]930 $y++;
[258]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>";
[254]940 }
[258]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>";
[254]946 if ($genere==0){
[257]947 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
948$res2 = $dbi->prepare("$sql");
949$res2->execute();
950
951
[258]952 $max = $res2->rowCount();
[340]953 }else{ $max=1;}
954 $op="rec_add_votanti";
[258]955 $rigat[$y].= "</div>";
956
[254]957 for ($i=1;$i<=$max;$i++){
958 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
959 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
960 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
961 if ($genere==0){
962 $query.=" and t2.num_gruppo=$i";
963 }
[257]964 $sql=$query;
965$result = $dbi->prepare("$sql");
966$result->execute();
967
968
969 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
[258]970 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
[257]971$res2 = $dbi->prepare("$sql");
972$res2->execute();
973
974
[258]975 $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
[257]976$resril = $dbi->prepare("$sql");
977$resril->execute();
978
979
980 list($numril)=$resril->fetch(PDO::FETCH_NUM);
[254]981 if ($res2)
[257]982 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
[254]983 else
984 $gruppo=0;
985 if (!$gruppo>0) {
986 $gruppo=$i;
[257]987 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
988$res3 = $dbi->prepare("$sql");
989$res3->execute();
990
991
[254]992 if ($res3)
[257]993 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
[254]994 }
995 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
996 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
997 $precede[$id_gruppo]=$voti_t;
998 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
[258]999# echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
1000 $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
[254]1001 }else{
[258]1002 $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
[254]1003 }
1004 if ($genere==0){ // e' un referendum
[258]1005 $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
[254]1006 }
[258]1007
1008
1009 $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
1010 $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
[262]1011 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
[258]1012 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
1013 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
1014 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
1015#$riga[$y].= "</span>";
1016 list ($anno,$mese,$di)=explode('-',$giorno);
1017 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
1018 if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
1019 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1020 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\"";
1021 $riga[$y].= " size=\"5\"/></span>";
1022 if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
1023 else $riga[$y].= "<span class=\"td\" align=\"center\">";
1024 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\"";
1025 $riga[$y].= " size=\"5\"/></span>";
1026 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\"/>";
1027 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\"/>";
1028 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
1029 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
1030 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
1031 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
1032 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
1033 $riga[$y].= "</span>";
1034
1035 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>";
1036 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
1037 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
1038 $riga[$y].= "</form>";
1039
[254]1040 }
[258]1041# echo "</table></form>";
1042 echo "</div>";
[254]1043
1044
[257]1045 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
1046$compl = $dbi->prepare("$sql");
1047$compl->execute();
1048
1049
1050 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
[254]1051 if (!$complessivi)
1052 {
1053 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
[258]1054 $numy=$y.'1';
1055 if ($y==$num) {
1056 echo "document.votanti$y.voti_u$numy.focus()\n";
1057 echo "document.votanti$y.voti_u$numy.select()\n";
[254]1058 }else{
[258]1059 echo "this.voti_t$numy.focus()\n";
1060 echo "this.voti_t$numy.select()\n";
[254]1061 }
1062 echo "//-->\n"
1063 ."</script>\n";
1064 break;
1065 }
[258]1066# echo "</td></tr>";
[254]1067 }
[258]1068#CloseTable();
1069foreach($riga as $key=>$val){
1070 echo $rigat[$key];
1071 echo $riga[$key];
[254]1072}
[258]1073echo "</div></td></tr></table>";
[254]1074}
1075
1076
1077
1078function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1079 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
1080////////////////////////////////////////////
1081// da qua va la sezione per i voti finali
1082///////////////////////////////////////////
1083$bgcolor1="#7777ff";
1084$bgcolor2=$_SESSION['bgcolor2'];
1085
1086
1087
[258]1088 echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
[254]1089 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
1090 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
[258]1091 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
[254]1092 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1093 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1094 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1095
1096 echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
1097/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1098 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
1099 else */
1100 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
1101 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
1102 ."<td><b>"._BIANCHI."</b></td>"
1103 ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
1104 ."<td><b>"._CONTESTATI."</b></td>"
1105 ."<td><b>"._TOTNON."</b></td>"
1106 ."<td><b>"._TOTALEVOTI."</b></td>"
1107 ."<td bgcolor=\"#ffffff\"></td> </tr>";
1108/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
[257]1109 $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' ";
1110$res = $dbi->prepare("$sql");
1111$res->execute();
1112
1113
[254]1114else */
[257]1115 $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' ";
1116$result = $dbi->prepare("$sql");
1117$result->execute();
1118
1119
1120 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
[254]1121 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
1122 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
1123// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
1124
1125
1126 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
1127/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
1128 echo "</td><td>$nulli"
1129 ."</td><td>$bianchi";
1130 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
1131 }else{ */
1132 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
1133 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
1134// }
1135 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
1136 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
1137 ."</td><td>$tot_nulli"
1138 ."</td><td>$tot_voti</td><td>"
[258]1139 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
[254]1140 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
1141 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
1142 ."</td></tr></table></form>"; //</td></tr>";
1143
1144
1145// echo "</table>";
1146 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1147 if (!$validi) {
1148 echo "document.spogliovoti.validi.focus()\n";
1149 echo "document.spogliovoti.validi.select()\n";
1150 }
1151 echo "//-->\n"
1152 ."</script>\n";
1153
1154
1155 }
1156
1157
1158function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1159 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
1160////////////////////////////////////////////
1161// da qua va la sezione per le preferenze ai gruppi
1162///////////////////////////////////////////
1163// Controllo immmissioni
1164
1165$bgcolor1="#7777ff";
1166$bgcolor2=$_SESSION['bgcolor2'];
[338]1167$sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
[257]1168$res = $dbi->prepare("$sql");
1169$res->execute();
1170
1171
1172 $max = $res->rowCount();
[254]1173 $max = $max-1;
1174 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1175 if ($genere==0) {
1176 echo "document.sezioni.si1.focus()\n";
1177 echo "document.sezioni.si1.select()\n";
1178 } else {
1179 echo "document.sezioni.voti1.focus()\n"
1180 ."document.sezioni.voti1.select()\n";
1181 }
1182 echo "//-->\n"
1183 ."</script>\n";
1184// tabella votanti
1185 echo "<center>";
1186 if ($genere!=0){
[257]1187 $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";
1188$result = $dbi->prepare("$sql");
1189$result->execute();
1190
1191
[258]1192 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
[254]1193 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
1194 ."<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>"
1195 ."<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>";
1196 echo "</table>";
1197 }
1198 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
1199 if ($genere==0){
[257]1200 $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' ";
1201$res = $dbi->prepare("$sql");
1202$res->execute();
1203
1204
1205 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
[254]1206 if ($voti_parz!=$validi){
[257]1207 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
1208$res2 = $dbi->prepare("$sql");
1209$res2->execute();
1210
1211
1212 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
[254]1213 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>";
1214 }
[257]1215 $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' ";
1216$res2 = $dbi->prepare("$sql");
1217$res2->execute();
1218
1219
1220 list($tot) = $res2->fetch(PDO::FETCH_NUM);
[254]1221 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
[257]1222 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
1223$res2 = $dbi->prepare("$sql");
1224$res2->execute();
1225
1226
1227 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
[254]1228 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>";
1229 }
1230 }
1231 }else{
[257]1232 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1233$result = $dbi->prepare("$sql");
1234$result->execute();
1235
1236
1237 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
1238 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
1239$res = $dbi->prepare("$sql");
1240$res->execute();
1241
1242
1243 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
1244 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
1245$res = $dbi->prepare("$sql");
1246$res->execute();
1247
1248
1249 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
[254]1250 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
1251 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>";
1252 }
[257]1253 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
1254$res2 = $dbi->prepare("$sql");
1255$res2->execute();
1256
1257
1258 list($tot) = $res2->fetch(PDO::FETCH_NUM);
[254]1259 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
1260 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>";
1261 }
[257]1262 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
[338]1263 $resg = $dbi->prepare("$sql");
1264 $resg->execute();
[257]1265
1266
[339]1267 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
1268 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
[254]1269
[257]1270 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
[338]1271 $resg = $dbi->prepare("$sql");
1272 $resg->execute();
[257]1273
1274
1275 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
1276 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
[338]1277 $resg = $dbi->prepare("$sql");
1278 $resg->execute();
[257]1279
1280
1281 list($sg)=$resg->fetch(PDO::FETCH_NUM);
[254]1282 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>";
1283 }
1284#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
1285if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
[338]1286$sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
[257]1287$resref = $dbi->prepare("$sql");
1288$resref->execute();
1289
1290
[338]1291 $errgrulis=array();
[257]1292 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
[338]1293 $res4 = $dbi->prepare("$sql");
1294 $res4->execute();
[257]1295
1296
1297 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
[254]1298 if ($sezscrl)
[257]1299 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
[338]1300 {
[315]1301 if($disgiunto || $flagsg){
1302 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1303 $res3 = $dbi->prepare("$sql");
1304 $res3->execute();
1305 if($flagsg){
1306 $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')";
1307 $res4 = $dbi->prepare("$sql");
1308 $res4->execute();
1309 }else{
1310 $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')";
1311 $res4 = $dbi->prepare("$sql");
1312 $res4->execute();
1313 }
1314 }else{
1315 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1316 $res3 = $dbi->prepare("$sql");
1317 $res3->execute();
1318 $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')";
1319 $res4 = $dbi->prepare("$sql");
1320 $res4->execute();
1321 }
1322 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1323 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
1324 if($vliste>$vgruppo and !$disgiunto )
1325 {
1326 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1327 $result = $dbi->prepare("$sql");
1328 $result->execute();
1329 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1330 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>";
1331 $errgrulis[$id_gruppo]=1;
1332 }
1333 elseif($vliste<$vgruppo and $disgiunto )
1334 {
1335 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1336 $result = $dbi->prepare("$sql");
1337 $result->execute();
1338 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1339 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>";
1340 $errgrulis[$id_gruppo]=1;
1341 }
[338]1342 }
1343 }
[257]1344
[254]1345 }
1346 if(!isset($votinulli)) $votinulli=0;
1347 echo "<tr><td></td></tr></table>";
1348 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
[258]1349 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\">";
1350 else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
1351 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
[254]1352 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
[258]1353 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
[254]1354 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1355 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1356 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
[258]1357 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
1358 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
[254]1359 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1360 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1361 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1362 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1363 if ($genere==0){
1364 echo "<td><b>"._SI."</b></td>"
1365 ."<td><b>"._NO."</b></td>"
1366 ."<td><b>"._VALIDI."</b></td>"
1367 ."<td><b>"._BIANCHI."</b></td>"
1368 ."<td><b>"._CONTESTATI."</b></td>"
1369 ."<td><b>"._NULLI."</b></td>"
1370 ."<td><b>"._TOTNON."</b></td>"
1371 ."<td><b>"._TOTALEVOTI."</b></td>"
1372 ."<td><b>"._VOTANTI."</b></td>";
1373 }else{
1374 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1375 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1376 }
1377 echo "</tr>";
[338]1378 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
[257]1379$res = $dbi->prepare("$sql");
1380$res->execute();
1381
1382
1383 $max = $res->rowCount();
[254]1384 //echo "Massimo:$max - id=$id_cons - circo: $circo";
[339]1385 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1386$result = $dbi->prepare("$sql");
1387$result->execute();
[257]1388
[339]1389
[254]1390 $i=1;
1391 $tot_pref=0;
1392 $totsg=0;
[257]1393 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
[254]1394
1395 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
[329]1396 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1397
1398 ."//-->\n";
1399 echo "function controlloref$i() {\n";
1400 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";
1401 echo "}\n";
1402 echo "</script>\n";
[254]1403
1404 if ($num_gruppo != ''){
1405 if ($genere==0){
[257]1406 $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' ";
1407$res = $dbi->prepare("$sql");
1408$res->execute();
1409
1410
1411 list($tot) = $res->fetch(PDO::FETCH_NUM);
1412 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1413$res = $dbi->prepare("$sql");
1414$res->execute();
1415
1416
1417 $pro= $res->fetch(PDO::FETCH_BOTH);
[254]1418
1419 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)){
1420 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1421 }else{
1422 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1423 }
1424 $descr = explode('.',$descr_gruppo, 100);
1425 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1426 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
[328]1427 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1428 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1429 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1430 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1431 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1432 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
[329]1433 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
1434 $tot_voti=intval($pro['validi'])+$tot_nulli;
1435 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1436 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
[254]1437 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1438 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1439 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1440 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1441 echo "</td><td align=\"right\">$tot_nulli</td>";
1442 echo "</td><td align=\"right\">$tot_voti</td>";
1443 echo "</td><td align=\"right\">$tot</td>";
1444 }else{
[258]1445 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>"
[254]1446 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
[257]1447 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
[337]1448 $res = $dbi->prepare("$sql");
1449 $res->execute();
[257]1450
1451 $pro= $res->fetch(PDO::FETCH_BOTH);
[337]1452 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
[254]1453 $errcolor='';
1454 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1455 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
[257]1456
[337]1457 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']);}
1458 $tot_pref += intval($pro['voti']);
[254]1459 echo "</tr>";
1460 }
1461
1462 $i++;
1463 }
1464
1465 }
1466 if ($genere!=0) {
[257]1467 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1468$res = $dbi->prepare("$sql");
1469$res->execute();
1470
1471
1472 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1473 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1474$res = $dbi->prepare("$sql");
1475$res->execute();
1476
1477
1478 list($sololis)=$res->fetch(PDO::FETCH_NUM);
[254]1479 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
1480 if($dettnulli) echo "<td>$totsg</td>";
1481 echo "</tr>";
1482 if($disgiunto)
1483 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>";
1484 }
1485
1486 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1487
1488 echo "</tr></table></form></td></tr>";
1489 if(chisei($id_cons_gen)>=64){
1490 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1491 }
1492
1493 echo "</td></tr></table></center>";
1494 }
1495 if ($genere!=0){
1496 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1497 }
1498}
1499
1500
1501
1502
1503 if (!preg_match("/rec/",$op)) {
1504 ele(); //menu
1505/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
1506 numeri_sezione(8);
1507 echo "<td></td></tr></table>\n";*/
1508 echo"</td></tr></table>";
1509 }
1510
1511 switch ($op){
1512 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
1513# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1514 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1515 break;
[258]1516 case "rec_add_votanti":
1517 rec_add_votanti($vari);
1518 break;
[254]1519 default :
1520 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
1521 }
1522echo"</td></tr></table>";
1523 include_once("modules/Elezioni/language/lang-$currentlang.php");
1524 include ("footer.php");
1525?>
1526
Note: See TracBrowser for help on using the repository browser.