source: trunk/admin/temi/Futura2/index.php@ 358

Last change on this file since 358 was 358, checked in by roby, 3 years ago

Admin: aggiunta la funzione di gestione dello spoglio per la singola sezione tramite tema per cellulari

File size: 60.8 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8
9if (!defined('ADMIN_FILE')) {
10 die ("You can't access this file directly...");
11}
12$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
13foreach($param as $key=>$val) {
14 if($key=='ops') $ops=$val;
15 if($key=='id_lista') $id_lista=$val;
16}
17include("header.php");
18$nometema=$tema;
19
20#require_once("class/db/db.php"); //classe db
21global $tema,$id_comune,$descr_cons,$multicomune,$dbi,$prefix,$currentlang,$ops,$id_sez;
22include_once("modules/Elezioni/query.sql");
23if(($tema='Futura2' and !$id_sez) or $_SESSION['id_cons']!=$id_cons) {Header("Location: admin.php?id_comune=$id_comune&op=logout&is=$id_sez"); die();}
24
25$row=setconsultazione();
26if(isset($row[0])) {
27 $tipo_cons=$row[0]; $descr_cons=$row[1]; $id_cons_gen=$row[2];
28} else {
29 $tipo_cons=0; $descr_cons=''; $id_cons_gen=0;
30}
31$row=tipocons();
32if(isset($row[0])) {
33 $genere=$row[0];$votog=$row[1];$votol=$row[2];$votoc=$row[3];$conscirc=$row[4];
34} else {
35 $genere=0;$votog=0;$votol=0;$votoc=0;$conscirc=0;
36}
37
38# colore tema mobile
39
40
41include("temi/$tema/config.php");
42
43#if($colortheme=='')$colortheme="c";
44# descrizione comune
45if(!$id_comune or $id_comune=='') $id_comune=$siteistat;
46$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
47 $res = $dbi->prepare("$sql");
48 $res->execute();
49
50list($descr_com) = $res->fetch(PDO::FETCH_NUM);
51
52
53####################################
54function testata(){
55####################################
56
57global $op,$tema,$dbi,$nometema,$file,$bgcolor,$sitename,$prefix,$blocco,$lang,$siteistat,$id_cons_gen,$descr_cons,$minsez,$offsetsez,$multicomune,$id_comune,$multicomune,$rss,$colortheme,$descr_com;
58global $id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$votog,$genere,$aid,$bgcolor1;
59include("temi/$tema/function_theme.php");
60#$op='informazioni';
61#$logo= "<img src=\"admin.php?name=Elezioni&amp;file=foto&amp;id_comune=".$id_comune."\" alt=\"logo\" width=\"70\" align=\"left\"/>";
62$logo='';
63#echo"togliere combo consultazioni e impostare su consultazione predefinita e sezione fissata su autorizza operatori (nuovo tipo: per unica sezione - spostare voci di menu, affluenze, gruppi. liste al posto della combo e togliere menu verticale)";
64$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
65 $res = $dbi->prepare("$sql");
66 $res->execute();
67
68 list($descr_com) = $res->fetch(PDO::FETCH_NUM);
69 $descr_com =stripslashes($descr_com);
70
71echo '
72<div data-role="page" data-theme="a">
73 <div data-role="header" data-position="inline">';
74
75 /*
76 if($op!="gruppo")
77 echo '<a href="#" onClick="javascript:history.back()" data-role="button" data-icon="arrow-left">indietro</a>';
78 else echo '<a href="modules.php?tema=facebook" target="_blank" data-icon="off" data-role="button">Vers Web</a>';
79 */
80 //
81 # se aperta o sezioni scrutinate
82 # se non Ú il menu di config o about sceglie elezione
83
84 echo '<h2>Elezioni on line</h2>';
85
86# echo '<a href="admin.php?name=Elezioni&op=about&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" data-theme="c" data-icon="user">About</a>';
87
88
89####### menu in alto
90# definizione attivo
91#echo "TEST: ".$_SESSION['BASE'];
92#echo "TEST: ".$_SERVER['REQUEST_URI'];
93#echo "TEST: ".$_SERVER['PHP_SELF'];
94 $sql="select tipo from ".$prefix."_ele_controlli where id_sez='$id_sez' group by tipo";
95 $rese = $dbi->prepare("$sql");
96 $rese->execute();
97 $bordoa='';
98 $bordog='';
99 $bordol='';
100 while (list($tipo)=$rese->fetch(PDO::FETCH_NUM)) {
101 if ($tipo=='affluenze') $bordoa="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
102 if ($tipo=='gruppo') $bordog="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
103 if ($tipo=='lista') $bordol="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
104 }
105 if($rese->rowCount()) $segna="style=\"background-color: #dd0000;\""; else $segna='';
106if($ops=="4" ) {$bgcolorg="yellow"; $tcolorg='blue';} else {$bgcolorg="grey"; $tcolorg='white';} #$active_gruppo=" class=\"ui-btn-active\""; else $active_gruppo='';
107if($ops=="3") {$bgcolorl="yellow"; $tcolorl='blue';} else {$bgcolorl="grey"; $tcolorl='white';} # $active_lista=" class=\"ui-btn-active\""; else $active_lista='';
108if($ops=="1") {$bgcolora="yellow"; $tcolora='blue';} else {$bgcolora="grey"; $tcolora='white';} # $active_aff=" class=\"ui-btn-active\""; else $active_aff='';
109/*if($op=="risultati" || $op=="affluenze_all" || $op=="gruppo_mob" || $op=="candidato_mob" || $op=="liste_mob" || $op=="votanti_mob") $active_ris=" class=\"ui-btn-active\""; else $active_ris='';
110if($op=="conf_mob" ) $active_conf=" class=\"ui-btn-active\""; else $active_conf='';
111if($op=="grafica_mob" ) $active_graf=" class=\"ui-btn-active\""; else $active_graf='';
112
113*/
114echo "</div>";
115
116
117# se non Ú il menu di config o about sceglie elezione
118#if($op!="conf_mob" and $op!="about"){
119 echo'<div data-role="fieldcontain" style="text-align:center;">
120 <span style="text-align:center;width:100%;height:110px;background-color:#fff;color:#000;">'.$logo.' Comune di '.$descr_com.' <br>Consultazione: '.$descr_cons.'</span></div>';
121
122
123###############
124 //************************************
125 // Menu spoglio
126 //************************************
127#echo "TEST : select id_sez from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'";
128 $sql="select id_sez from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'";
129 $sth = $dbi->prepare("$sql"); #echo $sql;
130 $sth->execute();
131 list($id_sez)=$sth->fetch(PDO::FETCH_NUM);
132 $sql="select id_cons,id_sez,id_sede,num_sez, maschi, femmine, colore from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
133 $result = $dbi->prepare("$sql");#echo $sql;
134 $result->execute();
135 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine, $colore) = $result->fetch(PDO::FETCH_NUM);
136 echo "<div data-role=\"content\" data-theme=\"a\"><hr><table><tr><td align=\"center\" width=\"100\" bgcolor=\"$colore\"><font size =\"4\" color=\"black\" align=\"left\"><b>Sezione<br>N. $num_sez</b></font></td><td><table><tr>";
137 echo "\n<td bgcolor=\"$bgcolora\" align=\"center\" $bordoa><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?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\"><font color=\"$tcolora\">"._AFFLUENZE."</font></a></b></p></td>\n";
138 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
139 echo "<td bgcolor=\"$bgcolorg\" align=\"center\" $bordog><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?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\"><font color=\"$tcolorg\">"._GRUPPO."</font></a></b></p></td>\n";
140 }
141 if($genere==2 and $votog)
142 echo "<td bgcolor=\"$bgcolorg\" align=\"center\" $bordog><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?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\"><font color=\"$tcolorg\">"._GRUPPO."</font></a></b></p></td>\n";
143 elseif(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
144 echo "<td bgcolor=\"$bgcolorl\" align=\"center\"$bordol><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?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\"><font color=\"$tcolorl\">"._LISTA."</font></a></b></p></td>\n";
145 }
146 echo "</tr></table></td></tr></table><hr></div>\n";
147
148
149if($ops=="1")votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
150elseif($ops=="3")preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
151elseif($ops=="4")preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
152
153
154footer_mon();
155
156die();
157}
158########################################
159
160function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
161//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
162 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune,$ops;
163
164$bgcolor1="#7777ff";
165$bgcolor2=$_SESSION['bgcolor2'];
166#OpenTable();
167$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
168$res = $dbi->prepare("$sql");
169$res->execute();
170
171if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
172$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
173$res = $dbi->prepare("$sql");
174$res->execute();
175
176echo "<table><tr><td>";
177$num = $res->rowCount();
178$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
179$ressez = $dbi->prepare("$sql");
180$ressez->execute();
181##################
182echo "<style>";
183echo "DIV.table";
184echo "{
185 display:table;
186}
187FORM.tr
188{
189 display:table-row;
190 text-align: center;
191}
192DIV.tr
193{
194 display:table-row;
195 background-color: #D3D3D3;
196 text-align: center;
197}
198SPAN.tdm
199{
200 display:table-cell;
201 border: 1px solid black;
202 padding: 5px;
203}
204SPAN.td
205{
206 display:table-cell;
207}";
208echo "</style>";
209
210##################
211
212list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
213$y=0;
214echo "<div class=\"table\">";
215$riga=array();
216$rigat=array();
217while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
218 $y++;
219 $rigat[$y]='';
220 $riga[$y]='';
221 $rigat[$y]= "<div class=\"tr\">";
222 if ($genere==0){ //e' un referendum
223 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
224 }
225 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
226 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
227 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
228 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
229 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
230 if ($genere==0){
231 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
232 $res2 = $dbi->prepare("$sql");
233 $res2->execute();
234 $max = $res2->rowCount();
235 }else{ $max=1;}
236 $op="rec_add_votanti";
237 $rigat[$y].= "</div>";
238 for ($i=1;$i<=$max;$i++){
239 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
240 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
241 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
242 if ($genere==0){
243 $query.=" and t2.num_gruppo=$i";
244 }
245 $sql=$query;
246 $result = $dbi->prepare("$sql");
247 $result->execute();
248 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
249 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
250 $res2 = $dbi->prepare("$sql");
251 $res2->execute();
252 $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
253 $resril = $dbi->prepare("$sql");
254 $resril->execute();
255 list($numril)=$resril->fetch(PDO::FETCH_NUM);
256 if ($res2)
257 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
258 else
259 $gruppo=0;
260 if (!$gruppo>0) {
261 $gruppo=$i;
262 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
263 $res3 = $dbi->prepare("$sql");
264 $res3->execute();
265 if ($res3)
266 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
267 }
268 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
269 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
270 $precede[$id_gruppo]=$voti_t;
271 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
272 $riga[$y].= "<form class=\"tr\" data-ajax=\"false\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
273 }else{
274 $riga[$y].= "<form class=\"tr\" data-ajax=\"false\" action=\"modules/Elezioni/salva_aff.php\">";
275 }
276 if ($genere==0){ // e' un referendum
277 $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
278 }
279 $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
280 $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
281 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
282 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
283 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
284 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
285 list ($anno,$mese,$di)=explode('-',$giorno);
286 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
287 if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
288 else $riga[$y].= "<span class=\"td\" align=\"center\">";
289 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\"";
290 $riga[$y].= " size=\"5\"/></span>";
291 if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
292 else $riga[$y].= "<span class=\"td\" align=\"center\">";
293 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\"";
294 $riga[$y].= " size=\"5\"/></span>";
295 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\"/>";
296 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\"/>";
297 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
298 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
299 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
300 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
301 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
302 $riga[$y].= "</span>";
303 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>";
304 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
305 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
306 $riga[$y].= "</form>";
307
308 }
309 echo "</div>";
310 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
311 $compl = $dbi->prepare("$sql");
312 $compl->execute();
313 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
314 }
315 foreach($riga as $key=>$val){
316 echo $rigat[$key];
317 echo $riga[$key];
318 }
319 echo "</div></td></tr></table>";
320}
321
322
323########################################
324function footer_mon(){
325global $id_comune,$id_cons_gen,$tema,$colortheme,$rss;
326
327echo '
328<div data-role="footer" data-theme="a" style="margin:0 auto; text-align:center;">
329 <div data-role="footer" data-position="inline" data-icon="cogs">';
330
331 echo ' <h5><a href="http://www.eleonline.it" target="_blank">Eleonline</a> <span style="font-size:12px;"> di luciano apolito & roberto gigli</span></h5></div>';
332
333
334 echo "<a href=\"admin.php?op=logout&id_comune=$id_comune\" data-ajax=\"false\">"._ESCI."</a>";
335# echo '&nbsp;<a href="admin.php?name=Elezioni&tema=facebook&nocell=1" data-rel="external" data-ajax="false" >Versione Desktop</a>';
336
337}
338
339
340
341//////////////////////////////////////////////////////////////////////
342// da qui va la sezione per le preferenze candidati consiglieri
343//////////////////////////////////////////////////////////////////////
344function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
345 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
346global $tipo_cons,$limite,$dettnulli,$disgiunto;
347$bgcolor1="#7777ff";
348$bgcolor2=$_SESSION['bgcolor2'];
349 echo "<SCRIPT type=\"text/javascript\">\n";
350 echo "function vai_lista(){\n";
351 echo "var element=document.getElementById('pag')\n";
352 echo "var elista=document.getElementById('id_lista')\n";
353 echo "var url=element.value+elista.value\n";
354 echo "window.document.location.href=url \n";
355 echo "}\n";
356 echo "</script>\n";
357if ($genere==4){
358 $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";
359 $result = $dbi->prepare("$sql");
360 $result->execute();
361
362
363 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
364 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
365 ."<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>"
366 ."<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>";
367 echo "</table>";
368}
369$sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
370$result = $dbi->prepare("$sql");
371$result->execute();
372list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
373if($v1+$v2+$v3+$v4>0){
374 //controlla se sono stati inseriti i votanti
375$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
376$result = $dbi->prepare("$sql");
377$result->execute();
378
379
380list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
381$dettnulli=$flagsg;
382####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
383if ($circo and $id_lista){
384 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
385 $res_lis = $dbi->prepare("$sql");
386 $res_lis->execute();
387 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
388}
389
390if(!$votog and ($genere==3 or $genere==5)){
391 $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' ";
392$result = $dbi->prepare("$sql");
393$result->execute();
394
395
396}else{
397 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
398$result = $dbi->prepare("$sql");
399$result->execute();
400}
401
402 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
403 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
404 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
405$res_lis = $dbi->prepare("$sql");
406$res_lis->execute();
407
408
409 $num_liste = $res_lis->rowCount();
410 $ele_lista='';
411 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
412 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
413 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo limit 0,1";
414$result = $dbi->prepare("$sql");
415$result->execute();
416
417
418 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
419 }
420 echo "<td colspan=\"2\">";
421 echo "<form name=\"liste\" data-ajax=\"false\" action=\"admin.php\">"; # data-ajax=\"false\"
422 echo "<input type=\"hidden\" id=\"pag\" name=\"pag\" value=\"admin.php?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=\">";
423 echo "<select id=\"id_lista\" name=\"id_lista\" onChange=\"vai_lista();\">";
424 if ($id_lista){
425 echo "<option value=\"0\">"._VOTI_LISTA;
426 $ele_lista=" and t1.id_lista='$id_lista' ";
427 }else{
428 echo "<option value=\"0\" selected>"._VOTI_LISTA;
429 $ele_lista=" group by t1.id_lista ";
430if(!isset($votolista)) $votolista=0;
431
432 }
433 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
434 $segna='';
435 $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";
436$result = $dbi->prepare("$sql");
437$result->execute();
438
439
440 list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
441 $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";
442$result = $dbi->prepare("$sql");
443$result->execute();
444
445
446 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
447 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
448 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
449$result = $dbi->prepare("$sql");
450$result->execute();
451 }else{
452 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
453$result = $dbi->prepare("$sql");
454$result->execute();
455 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
456 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
457$result = $dbi->prepare("$sql");
458$result->execute();
459 }
460 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
461 if($votisezcand>($votisezlis*$numprefs))
462 {$segna="style=\"background-color: #dd0000;\"";}
463 elseif($ctrvoticand)
464 $segna="style=\"background-color: #99CC33;\"";
465 $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'";
466$res4 = $dbi->prepare("$sql");
467$res4->execute();
468
469
470 $errcand[$id_rif]=array();
471 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
472 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
473
474 $sel = ($id_rif == $id_lista) ? "selected" : "";
475 echo "<option $segna value=\"$id_rif\" $sel>";
476 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
477 echo $num_lis.") ".substr($descrizione,0,30);
478 }
479 echo "</select></form></td></tr><tr><td style=\"vertical-align: top;\">&nbsp;</td>\n";
480 }else {
481 $id_lista=0;
482 }
483 echo "<td style=\"vertical-align: top;\">";
484
485 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
486if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
487 $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";
488$result = $dbi->prepare("$sql");
489$result->execute();
490
491
492}else{
493 $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";
494$result = $dbi->prepare("$sql");
495$result->execute();
496}
497
498// 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
499 $isscr= $result->rowCount();
500 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
501 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
502 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
503$resg = $dbi->prepare("$sql");
504$resg->execute();
505
506
507 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
508 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>";
509 }
510 $valista=$validi2;
511 if(!$id_lista or $genere==3){ //controllo di congruenza
512 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
513$res2 = $dbi->prepare("$sql");
514$res2->execute();
515
516
517 list($tot) = $res2->fetch(PDO::FETCH_NUM);
518####### controlli
519 $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
520 $resc = $dbi->prepare("$sql");
521 $resc->execute();
522if($resc->rowCount()){ if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
523 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>";
524 }
525
526 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
527 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>";
528 }
529 }elseif($genere==5){
530 $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'";
531$result = $dbi->prepare("$sql");
532$result->execute();
533
534
535 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
536 if(($fascia>$limite or $disgiunto) or !$id_conf){
537 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
538$result = $dbi->prepare("$sql");
539$result->execute();
540
541
542 }else{
543
544 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
545$result = $dbi->prepare("$sql");
546$result->execute();
547
548
549 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
550 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
551$result = $dbi->prepare("$sql");
552$result->execute();
553
554
555 }
556 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
557 if($votisezcand>($votisezlis*$numprefs))
558 {
559 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>";
560 }
561 }
562#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
563 $errgrulis=array();
564 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
565 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
566$resref = $dbi->prepare("$sql");
567$resref->execute();
568
569
570 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
571$res4 = $dbi->prepare("$sql");
572$res4->execute();
573
574
575 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
576 if ($sezscrl)
577
578 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
579 {
580 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
581$res3 = $dbi->prepare("$sql");
582$res3->execute();
583
584
585 $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')";
586$res4 = $dbi->prepare("$sql");
587$res4->execute();
588
589
590 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
591 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
592 if($vliste>$vgruppo)
593 {
594 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
595$result = $dbi->prepare("$sql");
596$result->execute();
597
598
599 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
600 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>";
601 $errgrulis[$id_gruppo]=1;
602 }
603 elseif($vliste<$vgruppo)
604 {
605 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
606$result = $dbi->prepare("$sql");
607$result->execute();
608
609
610 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
611 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>";
612 $errgrulis[$id_gruppo]=1;
613 }
614 }
615 }
616}
617
618
619 echo "\n<form name=\"sezioni\" data-ajax=\"false\" action=\"modules/Elezioni/salva_liste.php\">"
620 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
621 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
622 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
623 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
624 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
625 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
626 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
627 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
628 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
629 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
630 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
631 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
632 if ($genere<4){
633// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
634 }
635 echo "<b>"._NUM."</b></td>";
636 if($id_lista){
637 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
638 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
639 }else{
640 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
641 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
642#funzione di inserimento del dettaglio di voti nulli sospesa, non ritenuta utile
643# if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
644# echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
645 if($disgiunto){
646 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
647 }
648 }
649 echo "</tr>\n";
650
651
652if($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";
653else $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";
654$result = $dbi->prepare("$sql");
655$result->execute();
656
657
658 $max = $result->rowCount();
659 $tot_pref=0;
660 $i=1;
661
662 if($id_lista) {
663 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
664 // dati lista
665 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
666$result1 = $dbi->prepare("$sql");
667$result1->execute();
668
669
670 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
671 // dati gruppo
672 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
673$result2 = $dbi->prepare("$sql");
674$result2->execute();
675
676
677 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
678
679 echo "<tr bgcolor=\"$bgcolor2\">";
680 if ($genere<4){
681 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
682 }
683 echo "<td align=\"center\"><b> $num_cand </b></td>"
684 ."<td align=\"left\"><b>$cognome $nome</b></td>";
685 $cond_sele="and id_cand=$id_cand";
686 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
687$res = $dbi->prepare("$sql");
688$res->execute();
689
690
691 list($voti)= $res->fetch(PDO::FETCH_NUM);
692 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
693 echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
694 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
695 $i++;
696 $tot_pref+=$voti;
697 }
698 }else {
699 if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
700 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
701 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
702 where t1.id_cons='$id_cons'
703 and t1.id_lista=t2.id_lista
704 and t2.id_sez=$id_sez
705 $circot1
706 order by t1.num_lista";
707
708 try {
709 $result1 = $dbi->prepare("$sql");
710 $result1->execute();
711
712 }
713 catch(PDOException $e)
714 {
715 echo $sql . "<br>" . $e->getMessage();
716 }
717
718 $num_lista=$result1->rowCount();
719 if (!$num_lista){
720 $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
721 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
722 order by num_lista";
723 $result1 = $dbi->prepare("$sql");
724 $result1->execute();
725 }
726 $tvnpl=0;
727 $tslpl=0;
728 while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
729 echo "<tr bgcolor=\"$bgcolor2\">";
730// if ($genere<4 or $votoc){
731// }
732
733 $sql="select * from ".$prefix."_ele_controlli where tipo='lista' and id_sez='$id_sez' and id='$id_lista3'";
734 $rese = $dbi->prepare("$sql");
735 $rese->execute();
736 if($rese->rowCount()) $segna="style=\"background-color: #dd0000;\""; else $segna='';
737 $errcolor='';
738 if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
739 echo "<td align=\"center\" $segna><b> $num_lista </b></td>"
740 ."<td align=\"left\"><b> $descr_lista</b></td>";
741 $cond_sele="and id_lista=$id_lista3";
742 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
743#funzione non ritenuta utile
744# 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;}
745 if($disgiunto) {echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\">"; $tslpl+=$slpl;}
746 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
747// echo "<td align=\"right\">$sgpl";
748 echo "</tr>\n";
749 $i++;
750 $tot_pref+=$voti;
751 }
752 }
753 if(!$id_lista) {
754 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>";
755# if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
756# echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
757 if($disgiunto)
758 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
759 echo "</tr>";
760 }
761 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
762 // toglie ai candidati la visual... del solo_gruppo
763 if(!$votog) {
764 if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
765 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>";
766 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\">";
767 if(defined('_NULLISTA'))
768 echo "<input type=\"hidden\" name=\"votinulli\" value=\"$votinulli\"><input type=\"hidden\" name=\"contestati\" value=\"$contestati\"></td></tr>";
769 else
770 echo "</td></tr><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\">"
771 ."</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>";
772
773 }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
774 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
775 }
776######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
777elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
778$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
779$resvg = $dbi->prepare("$sql");
780$resvg->execute();
781
782
783list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
784$sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
785$resvg = $dbi->prepare("$sql");
786$resvg->execute();
787
788
789 list($voti_sind) = $resvg->fetch(PDO::FETCH_NUM);
790
791echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
792}
793###### fine modifica del 16-04-2009
794
795 }
796 echo "<tr>";
797 echo "<td></td><td></td>";
798 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
799 echo "</tr></table>";
800 if(chisei($id_cons_gen)>=64){
801 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
802 } # onclick=\"javascript:del_dati()\"
803 echo "</form></tr></table>";
804
805
806
807}
808#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
809 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
810 }
811
812
813function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
814 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
815////////////////////////////////////////////
816// da qua va la sezione per i voti finali
817///////////////////////////////////////////
818$bgcolor1="#7777ff";
819$bgcolor2=$_SESSION['bgcolor2'];
820
821
822
823 echo "<form name=\"spogliovoti\" data-ajax=\"false\" action=\"modules/Elezioni/salva_voti.php\">"
824 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
825 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
826 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
827 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
828 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
829 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
830
831 echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
832/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
833 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
834 else */
835 echo "<td width=\"15%\"><b>"._VALIDI."</b></td>";
836 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
837 ."<td><b>"._BIANCHI."</b></td>"
838 ."<td width=\"82\"><b>"._VOTINULLI."</b></td>"
839 ."<td><b>"._CONTESTATI."</b></td>"
840 ."<td><b>"._TOTNON."</b></td>"
841 ."<td><b>"._TOTALEVOTI."</b></td>"
842 ."<td bgcolor=\"#ffffff\"></td> </tr>";
843/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
844 $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' ";
845$res = $dbi->prepare("$sql");
846$res->execute();
847
848
849else */
850 $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' ";
851$result = $dbi->prepare("$sql");
852$result->execute();
853
854
855 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
856 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
857 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
858// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
859
860
861 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"7\" style=\"text-align:right\">";
862/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
863 echo "</td><td>$nulli"
864 ."</td><td>$bianchi";
865 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
866 }else{ */
867 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
868 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
869// }
870 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" style=\"text-align:right;\">"
871 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
872 ."</td><td>$tot_nulli"
873 ."</td><td>$tot_voti</td><td>"
874 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
875 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
876 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
877 ."</td></tr></table></form>"; //</td></tr>";
878
879
880// echo "</table>";
881/* echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
882 if (!$validi) {
883 echo "document.spogliovoti.validi.focus()\n";
884 echo "document.spogliovoti.validi.select()\n";
885 }
886 echo "//-->\n"
887 ."</script>\n"; */
888
889
890 }
891
892
893function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
894 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
895////////////////////////////////////////////
896// da qua va la sezione per le preferenze ai gruppi
897///////////////////////////////////////////
898// Controllo immmissioni
899
900$bgcolor1="#7777ff";
901$bgcolor2=$_SESSION['bgcolor2'];
902$sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
903$res = $dbi->prepare("$sql");
904$res->execute();
905
906
907 $max = $res->rowCount();
908 $max = $max-1;
909/* echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
910 if ($genere==0) {
911 echo "document.sezioni.si1.focus()\n";
912 echo "document.sezioni.si1.select()\n";
913 } else {
914 echo "document.sezioni.voti1.focus()\n"
915 ."document.sezioni.voti1.select()\n";
916 }
917 echo "//-->\n"
918 ."</script>\n"; */
919// tabella votanti
920 echo "<center>";
921 if ($genere!=0){
922 $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";
923$result = $dbi->prepare("$sql");
924$result->execute();
925
926
927 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
928 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
929 ."<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>"
930 ."<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>";
931 echo "</table>";
932 }
933 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
934 if ($genere==0){
935 $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' ";
936$res = $dbi->prepare("$sql");
937$res->execute();
938
939
940 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
941 if ($voti_parz!=$validi){
942 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
943$res2 = $dbi->prepare("$sql");
944$res2->execute();
945
946
947 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
948 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>";
949 }
950 $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' ";
951$res2 = $dbi->prepare("$sql");
952$res2->execute();
953
954
955 list($tot) = $res2->fetch(PDO::FETCH_NUM);
956 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
957 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
958$res2 = $dbi->prepare("$sql");
959$res2->execute();
960
961
962 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
963 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>";
964 }
965 }
966 }else{
967 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
968 $result = $dbi->prepare("$sql");
969 $result->execute();
970 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
971 $dettnulli=$flagsg;
972 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
973 $res = $dbi->prepare("$sql");
974 $res->execute();
975 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
976 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
977 $res = $dbi->prepare("$sql");
978 $res->execute();
979 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
980 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
981 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>";
982 }
983 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
984 $res2 = $dbi->prepare("$sql");
985 $res2->execute();
986
987
988 list($tot) = $res2->fetch(PDO::FETCH_NUM);
989 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
990 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>";
991 }
992 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
993 $resg = $dbi->prepare("$sql");
994 $resg->execute();
995
996
997 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
998 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
999
1000 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
1001 $resg = $dbi->prepare("$sql");
1002 $resg->execute();
1003
1004
1005 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
1006 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
1007 $resg = $dbi->prepare("$sql");
1008 $resg->execute();
1009
1010
1011 list($sg)=$resg->fetch(PDO::FETCH_NUM);
1012 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>";
1013 }
1014#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
1015if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
1016$sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
1017$resref = $dbi->prepare("$sql");
1018$resref->execute();
1019
1020
1021 $errgrulis=array();
1022 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
1023 $res4 = $dbi->prepare("$sql");
1024 $res4->execute();
1025
1026
1027 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
1028 if ($sezscrl)
1029 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
1030 {
1031 if($disgiunto || $flagsg){
1032 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1033 $res3 = $dbi->prepare("$sql");
1034 $res3->execute();
1035 if($flagsg){
1036 $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')";
1037 $res4 = $dbi->prepare("$sql");
1038 $res4->execute();
1039 }else{
1040 $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')";
1041 $res4 = $dbi->prepare("$sql");
1042 $res4->execute();
1043 }
1044 }else{
1045 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1046 $res3 = $dbi->prepare("$sql");
1047 $res3->execute();
1048 $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')";
1049 $res4 = $dbi->prepare("$sql");
1050 $res4->execute();
1051 }
1052 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1053 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
1054 if($vliste>$vgruppo and !$disgiunto )
1055 {
1056 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1057 $result = $dbi->prepare("$sql");
1058 $result->execute();
1059 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1060 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>";
1061 $errgrulis[$id_gruppo]=1;
1062 }
1063 elseif($vliste<$vgruppo and $disgiunto )
1064 {
1065 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1066 $result = $dbi->prepare("$sql");
1067 $result->execute();
1068 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1069 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>";
1070 $errgrulis[$id_gruppo]=1;
1071 }
1072 }
1073 }
1074
1075 }
1076 if(!isset($votinulli)) $votinulli=0;
1077 echo "<tr><td></td></tr></table>";
1078 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1079 if($genere==0) echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" data-ajax=\"false\" action=\"modules/Elezioni/salva_ref.php\">";
1080 else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" data-ajax=\"false\" action=\"modules/Elezioni/salva_gruppi.php\">";
1081 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
1082 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1083 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
1084 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1085 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1086 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1087 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
1088 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
1089 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1090
1091 if ($genere==0){
1092 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1093 ."<td colspan=\"6\"><b>"._GRUPPO."</b></td></tr>";
1094 $campitesta= "<tr align=\"center\" bgcolor=\"$bgcolor1\"><td><b>Votanti "._SI."</b></td>"
1095 ."<td><b>Votanti "._NO."</b></td>"
1096 ."<td><b>"._VALIDI."</b></td>"
1097 ."<td><b>"._BIANCHI."</b></td>"
1098 ."<td><b>"._CONTESTATI."</b></td>"
1099 ."<td><b>"._NULLI."</b></td></tr>";
1100
1101 $campiriep="<tr style=\"background-color: $bgcolor1; text-align:center\"><td colspan=\"2\"><b>"._TOTNON."</b></td>"
1102 ."<td colspan=\"2\"><b>"._TOTALEVOTI."</b></td>"
1103 ."<td colspan=\"2\"><b>"._VOTANTI."</b></td></tr>";
1104 }else{
1105 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1106 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1107 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1108 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1109 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1110 echo "</tr>";
1111 }
1112 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1113$res = $dbi->prepare("$sql");
1114$res->execute();
1115
1116
1117 $max = $res->rowCount();
1118 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1119 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1120$result = $dbi->prepare("$sql");
1121$result->execute();
1122
1123
1124 $i=1;
1125 $tot_pref=0;
1126 $totsg=0;
1127 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
1128
1129 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1130 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1131
1132 ."//-->\n";
1133 echo "function controlloref$i() {\n";
1134 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";
1135 echo "}\n";
1136 echo "</script>\n";
1137
1138 if ($num_gruppo != ''){
1139 if ($genere==0){
1140 $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' ";
1141$res = $dbi->prepare("$sql");
1142$res->execute();
1143
1144
1145 list($tot) = $res->fetch(PDO::FETCH_NUM);
1146 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1147$res = $dbi->prepare("$sql");
1148$res->execute();
1149
1150
1151 $pro= $res->fetch(PDO::FETCH_BOTH);
1152 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)){
1153 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1154 }else{
1155 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1156 }
1157 $descr = explode('.',$descr_gruppo, 100);
1158 echo "<td colspan=\"6\" align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo) </b>"
1159 ."<b> $descr[0] </b></td></tr>";
1160 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1161 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1162 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1163 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1164 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1165 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
1166 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
1167 $tot_voti=intval($pro['validi'])+$tot_nulli;
1168 echo $campiriep; # style=\"text-align: center; border: 1px; border-color: black; border-collaps:collaps;\"
1169 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td colspan=\"2\" >$tot_nulli</td>";
1170 echo "<td colspan=\"2\">$tot_voti</td>";
1171 echo "<td colspan=\"2\">$tot</td></tr>";
1172 echo $campitesta;
1173 echo "<tr><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1174 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i()></td>";
1175 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1176 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1177 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1178 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1179
1180
1181 }else{
1182 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>"
1183 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1184 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1185 $res = $dbi->prepare("$sql");
1186 $res->execute();
1187
1188 $pro= $res->fetch(PDO::FETCH_BOTH);
1189 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
1190 $errcolor='';
1191 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1192 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
1193
1194 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']);}
1195 $tot_pref += intval($pro['voti']);
1196 echo "</tr>";
1197 }
1198
1199 $i++;
1200 }
1201
1202 }
1203 if ($genere!=0) {
1204 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1205$res = $dbi->prepare("$sql");
1206$res->execute();
1207
1208
1209 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1210 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1211$res = $dbi->prepare("$sql");
1212$res->execute();
1213
1214
1215 list($sololis)=$res->fetch(PDO::FETCH_NUM);
1216 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
1217 if($dettnulli) echo "<td>$totsg</td>";
1218 echo "</tr>";
1219 if($disgiunto)
1220 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>";
1221 }
1222
1223 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1224
1225 echo "</tr></table></form></td></tr>";
1226 if(chisei($id_cons_gen)>=64){
1227 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1228 }
1229
1230 echo "</td></tr></table></center>";
1231 }
1232 if ($genere!=0){
1233 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1234 }
1235}
1236
1237
1238
1239
1240?>
Note: See TracBrowser for help on using the repository browser.