source: trunk/admin/modules/Elezioni/ele_spoglio.php@ 369

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

admin:
la consultazione iniziale per utente abilitato a gestire la singola sede non viene fissata correttamente. Risolto
la visualizzazione delle rilevazioni oraire mostra tutti gli orari ma deve mostrare solo il prossimo da inserire. Risolto

File size: 58.1 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
13########################################
14# Affluenze
15function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
16
17global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune,$ops;
18##################
19echo "<style>";
20echo "DIV.table";
21echo "{
22 display:table;
23}
24FORM.tr
25{
26 display:table-row;
27 text-align: center;
28}
29DIV.tr
30{
31 display:table-row;
32 background-color: #D3D3D3;
33 text-align: center;
34}
35SPAN.tdm
36{
37 display:table-cell;
38 border: 1px solid black;
39 padding: 5px;
40}
41SPAN.td
42{
43 display:table-cell;
44}";
45echo "</style>";
46
47
48##################
49$bgcolor1="#7777ff";
50$bgcolor2=$_SESSION['bgcolor2'];
51$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
52$res = $dbi->prepare("$sql");
53$res->execute();
54if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
55$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
56$res = $dbi->prepare("$sql");
57$res->execute();
58$num = $res->rowCount();
59echo "<table><tr><td>";
60$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";#echo $sql;
61$ressez = $dbi->prepare("$sql");
62$ressez->execute();
63list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
64
65$afferr=0;
66$sql="select tipo from ".$prefix."_ele_controlli where id_sez='$id_sez' and tipo='affluenze'";
67$rese = $dbi->prepare("$sql");
68$rese->execute();
69if($rese->rowCount()) $afferr=1;
70
71$y=0;
72
73$riga=array();
74$rigat=array();
75$uscita=0;
76while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
77 $y++;
78 $rigat[$y]='';
79 $riga[$y]='';
80 $rigat[$y]= "<div class=\"tr\">";
81 if ($genere==0){ //e' un referendum
82 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
83 }
84 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
85 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
86 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
87 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
88 ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
89 if ($genere==0){
90 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
91 $res2 = $dbi->prepare("$sql");
92 $res2->execute();
93 $max = $res2->rowCount();
94 }else{ $max=1;}
95 $op="rec_add_votanti";
96 $rigat[$y].= "</div>";
97 $errvot1=0;
98 $numril=0;
99
100 for ($i=1;$i<=$max;$i++){
101 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
102 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
103 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
104 if ($genere==0){
105 $query.=" and t2.num_gruppo=$i";
106 }
107 $sql=$query;
108 $result = $dbi->prepare("$sql");
109 $result->execute();
110 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
111 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
112 $res2 = $dbi->prepare("$sql");
113 $res2->execute();
114 $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
115 $resril = $dbi->prepare("$sql");
116 $resril->execute();
117 list($tmpril)=$resril->fetch(PDO::FETCH_NUM);
118 if($tmpril>$numril) $numril=$tmpril;
119 if ($res2)
120 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
121 else
122 $gruppo=0;
123 if (!$gruppo>0) {
124 $gruppo=$i;
125 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
126 $res3 = $dbi->prepare("$sql");
127 $res3->execute();
128 if ($res3)
129 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
130 }
131 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
132 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
133 $precede[$id_gruppo]=$voti_t;
134 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
135 $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\">";
136 }else{
137 $riga[$y].= "<form class=\"tr\" data-ajax=\"false\" action=\"modules/Elezioni/salva_aff.php\">";
138 }
139 if ($genere==0){ // e' un referendum
140 $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
141 }
142 $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
143 $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
144 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
145 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
146 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
147 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
148 list ($anno,$mese,$di)=explode('-',$giorno);
149 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
150 if ($voti_u > $maschi) {$riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">"; $errvot1=1;}
151 else $riga[$y].= "<span class=\"td\" align=\"center\">";
152 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\" onfocus=\"select();\"";
153 $riga[$y].= " size=\"5\"/></span>";
154 if ($voti_d > $femmine) {$riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">"; $errvot1=1;}
155 else $riga[$y].= "<span class=\"td\" align=\"center\">";
156 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\" onfocus=\"select();\"";
157 $riga[$y].= " size=\"5\"/></span>";
158 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\" onfocus=\"select();\"/>"; $errvot1=1;}
159 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\" onfocus=\"select();\"/>";
160 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
161 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
162 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
163 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
164 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
165 $riga[$y].= "</span>";
166 if (chisei($id_cons_gen)>=64 and ($y==$numril and $voti_t!='')) { $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"/></span>";}
167 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
168 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
169 $riga[$y].= "</form>";
170 if($numril>$uscita) $uscita=$numril;
171 }
172# echo "</div>";
173 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
174 $compl = $dbi->prepare("$sql");
175 $compl->execute();
176 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
177 }
178# echo "Errori:";
179 if($errvot1) echo "<table><tr><td align=\"center\" bgcolor=\"red\"> <h1 style=\"color:white;\">I votanti inseriti superano il numero di elettori</h1></td></tr></table></br>";
180 if($error) echo "<table><tr><td align=\"center\" bgcolor=\"red\"> <h1 style=\"color:white;\">Numero di votanti inferiore della rilevazione precedente</h1></td></tr></table></br>";
181 echo "<table border=\"1\"><tr><td><b>Iscritti nella sezione</b> Maschi: $maschi - Femmine: $femmine - Totale: ".($maschi+$femmine)."</td></tr></table></br>";
182 foreach($riga as $key=>$val){
183 echo $rigat[$key];
184 echo $riga[$key];
185 if($key>$uscita) { break;}
186 }
187 echo "</div></td></tr></table>";
188}
189
190
191//////////////////////////////////////////////////////////////////////
192// da qui va la sezione per le preferenze candidati consiglieri
193//////////////////////////////////////////////////////////////////////
194function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
195 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc,$op;
196global $tipo_cons,$limite,$dettnulli,$disgiunto,$votoc;
197$bgcolor1="#7777ff";
198$bgcolor2=$_SESSION['bgcolor2'];
199echo "<SCRIPT type=\"text/javascript\">\n";
200echo "function vai_lista(idrif){\n";
201echo "var element=document.getElementById('pag')\n";
202echo "var elista=document.getElementById(idrif)\n";
203echo "var url=element.value+elista.value\n";
204echo "window.document.location.href=url \n";
205echo "}\n";
206echo "</script>\n";
207if ($genere==4){
208 $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";
209 $result = $dbi->prepare("$sql");
210 $result->execute();
211
212
213 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
214 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
215 ."<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>"
216 ."<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>";
217 echo "</table>";
218}
219$sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
220$result = $dbi->prepare("$sql");
221$result->execute();
222list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
223if($v1+$v2+$v3+$v4>0){
224 //controlla se sono stati inseriti i votanti
225$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
226$result = $dbi->prepare("$sql");
227$result->execute();
228
229
230list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
231$dettnulli=$flagsg;
232####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
233if ($circo and $id_lista){
234 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
235 $res_lis = $dbi->prepare("$sql");
236 $res_lis->execute();
237 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
238}
239
240if(!$votog and ($genere==3 or $genere==5)){
241 $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' ";
242$result = $dbi->prepare("$sql");
243$result->execute();
244
245
246}else{
247 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
248$result = $dbi->prepare("$sql");
249$result->execute();
250}
251
252 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
253 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
254 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
255$res_lis = $dbi->prepare("$sql");
256$res_lis->execute();
257
258
259 $num_liste = $res_lis->rowCount();
260 $ele_lista='';
261 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
262 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
263 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista limit 0,1";
264$result = $dbi->prepare("$sql");
265$result->execute();
266
267
268 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
269 }
270 echo "<td colspan=\"2\">";
271 echo "<form name=\"liste\" data-ajax=\"false\" action=\"admin.php\">"; # data-ajax=\"false\"
272 echo "<input type=\"hidden\" id=\"pag\" name=\"pag\" value=\"admin.php?id_cons_gen=$id_cons_gen&amp;op=$op&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3&amp;id_lista=\">";
273 echo "<select id=\"id_lista\" name=\"id_lista\" onChange=\"vai_lista('id_lista');\">";
274 if ($id_lista){
275 echo "<option value=\"0\">"._VOTI_LISTA;
276 $ele_lista=" and t1.id_lista='$id_lista' ";
277 }else{
278 echo "<option value=\"0\" selected>"._VOTI_LISTA;
279 $ele_lista=" group by t1.id_lista ";
280 if(!isset($votolista)) $votolista=0;
281 }
282 $preflis[]=array();
283 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
284 $segna='';
285 $sql="SELECT 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 limit 0,1";
286 $result = $dbi->prepare("$sql");
287 $result->execute();
288 if($result->rowCount()) $ctrvoticand=1; else $ctrvoticand=0;
289 $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";
290 $result = $dbi->prepare("$sql");
291 $result->execute();
292 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
293 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
294 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
295 $result = $dbi->prepare("$sql");
296 $result->execute();
297 }else{
298 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
299 $result = $dbi->prepare("$sql");
300 $result->execute();
301 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
302 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
303 $result = $dbi->prepare("$sql");
304 $result->execute();
305 }
306 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
307 $preflis[$id_rif]=$votisezlis;
308 if($votisezcand>($votisezlis*$numprefs))
309 {$segna="style=\"background-color: #dd0000;\""; }#$segna2=$segna;
310 elseif($ctrvoticand)
311 $segna="style=\"background-color: #99CC33;\"";
312 $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'";
313 $res4 = $dbi->prepare("$sql");
314 $res4->execute();
315 $errcand[$id_rif]=array();
316 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
317 {if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}}
318 $sel = ($id_rif == $id_lista) ? "selected" : "";
319 echo "<option $segna value=\"$id_rif\" $sel>";
320 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
321 echo $num_lis.") ".$descrizione;
322# echo $num_lis.") ".substr($descrizione,0,30);
323 }
324 echo "</select></form></td></tr><tr><td style=\"vertical-align: top;\">&nbsp;</td>\n";
325 }else {
326 $id_lista=0;
327 }
328 echo "<td style=\"vertical-align: top;\">";
329 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
330 if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
331 $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";
332 $result = $dbi->prepare("$sql");
333 $result->execute();
334 }else{
335 $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";
336 $result = $dbi->prepare("$sql");
337 $result->execute();
338 }
339
340// 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
341 $isscr= $result->rowCount();
342 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
343 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
344 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
345 $resg = $dbi->prepare("$sql");
346 $resg->execute();
347 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
348 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>";
349 }
350 $valista=$validi2;
351####### controlli
352 $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
353 $resc = $dbi->prepare("$sql");
354 $resc->execute();
355 if($resc->rowCount()){
356 if(!$id_lista or $genere==3){ //controllo di congruenza
357 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
358 $res2 = $dbi->prepare("$sql");
359 $res2->execute();
360 list($tot) = $res2->fetch(PDO::FETCH_NUM);
361 if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
362 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>";
363 }
364 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
365 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>";
366 }
367 }
368 if($genere==5 or $genere==4){
369 if($id_lista){
370 $sql="SELECT max(t1.voti),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'";
371 $result = $dbi->prepare("$sql");
372 $result->execute();
373 list($votimaxcand,$votisezcand)=$result->fetch(PDO::FETCH_NUM);
374 if(($fascia>$limite or $disgiunto) or !$id_conf){
375 $sql="SELECT sum(t2.voti) from ".$prefix."_ele_voti_lista as t2 where t2.id_sez='$id_sez' and t2.id_lista='$id_lista'";
376 $result = $dbi->prepare("$sql");
377 $result->execute();
378 }else{
379 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
380 $result = $dbi->prepare("$sql");
381 $result->execute();
382 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
383 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
384 $result = $dbi->prepare("$sql");
385 $result->execute();
386 }
387 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
388 $errpres=0;
389 if($votisezcand>($votisezlis*$numprefs))
390 {
391 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 quelli ammessi ".$votisezlis*$numprefs."</b><br></td></tr></table>";
392 $segna2="style=\"background-color: #dd0000;\"";
393 $errpres=1;
394 }
395 if($votimaxcand>$votisezlis and !$errpres)
396 {
397 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 di un candidato $votimaxcand <br/>superano i voti di lista $votisezlis</b><br></td></tr></table>";
398 $segna2="style=\"background-color: #dd0000;\"";
399 }
400
401 }#else{
402 $sql="select solo_gruppo from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
403 $resgs = $dbi->prepare("$sql");
404 $resgs->execute();
405 list($sgs3)=$resgs->fetch(PDO::FETCH_NUM);
406 $sql="select sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' ";
407 $resgs = $dbi->prepare("$sql");
408 $resgs->execute();
409 list($vsg3)=$resgs->fetch(PDO::FETCH_NUM);
410 if($sgs3!=$vsg3 and $flagsg)
411 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 al solo gruppo: $sgs3 non corrispondono a quelli inseriti nella scheda dei gruppi $vsg3 </b><br></td></tr></table>";
412
413 }
414#die("TEST: if($sgs3!=$vsg3)");
415#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
416 $errgrulis=array();
417 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
418 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
419 $resref = $dbi->prepare("$sql");
420 $resref->execute();
421# die("qui: $sql");
422 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
423 $res4 = $dbi->prepare("$sql");
424 $res4->execute();
425 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
426 if ($sezscrl)
427 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
428 {
429 $sql="SELECT sum(voti),sum(solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
430 $res3 = $dbi->prepare("$sql");
431 $res3->execute();
432 $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')";
433 $res4 = $dbi->prepare("$sql");
434 $res4->execute();
435 list($vgruppo3,$vsl3)=$res3->fetch(PDO::FETCH_NUM);
436 $vgruppo=$vgruppo3-$vsl3;
437 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
438 if($vliste>$vgruppo)
439 {
440 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
441 $result = $dbi->prepare("$sql");
442 $result->execute();
443 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
444 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>";
445 $errgrulis[$id_gruppo]=1;
446 }
447 elseif($vliste<$vgruppo)
448 {
449 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
450 $result = $dbi->prepare("$sql");
451 $result->execute();
452 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
453 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>";
454 $errgrulis[$id_gruppo]=1;
455 }
456 }
457 }
458}
459
460
461 echo "\n<form name=\"sezioni\" data-ajax=\"false\" action=\"modules/Elezioni/salva_liste.php\">"
462 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
463 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
464 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
465 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
466 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
467 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
468 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
469 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
470 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
471 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
472 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
473 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
474 if ($genere<4){
475// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
476 }
477 echo "<b>"._NUM."</b></td>";
478 if($id_lista){
479 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
480 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b> (alla lista ".$preflis[$id_lista].")</td>";
481 }else{
482 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
483 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
484#funzione di inserimento del dettaglio di voti nulli sospesa, non ritenuta utile
485# if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
486# echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
487 if($disgiunto){
488 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
489 }
490 }
491 echo "</tr>\n";
492
493
494if($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";
495else $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";
496$result = $dbi->prepare("$sql");
497$result->execute();
498
499
500 $max = $result->rowCount();
501 $tot_pref=0;
502 $i=1;
503
504 if($id_lista) {
505 while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
506 // dati lista
507 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
508 $result1 = $dbi->prepare("$sql");
509 $result1->execute();
510 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
511 // dati gruppo
512 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
513 $result2 = $dbi->prepare("$sql");
514 $result2->execute();
515 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
516 echo "<tr bgcolor=\"$bgcolor2\">";
517 if ($genere<4){
518 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
519 }
520 echo "<td align=\"center\"><b> $num_cand </b></td>"
521 ."<td align=\"left\"><b>$cognome $nome</b></td>";
522 $cond_sele="and id_cand=$id_cand";
523 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
524 $res = $dbi->prepare("$sql");
525 $res->execute();
526 list($voti)= $res->fetch(PDO::FETCH_NUM); #if(!$voti) $voti2=''; else $voti2=$voti;
527 if(in_array($num_cand,$errcand[$id_lista2])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
528 echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\" onfocus=\"select();\">";
529 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
530 $i++;
531 $tot_pref+=$voti;
532 }
533 }else {
534 if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
535 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
536 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
537 where t1.id_cons='$id_cons'
538 and t1.id_lista=t2.id_lista
539 and t2.id_sez=$id_sez
540 $circot1
541 order by t1.num_lista";
542
543 try {
544 $result1 = $dbi->prepare("$sql");
545 $result1->execute();
546 }
547 catch(PDOException $e)
548 {
549 echo $sql . "<br>" . $e->getMessage();
550 }
551 $scruliste=$result1->rowCount();
552 if (!$scruliste){
553 $sql="select null,id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
554 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
555 order by num_lista";
556 $result1 = $dbi->prepare("$sql");
557 $result1->execute();
558 }
559 $tvnpl=0;
560 $tslpl=0;
561# $segna2='';
562 $sezscru=0;
563 while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
564 echo "<tr bgcolor=\"$bgcolor2\">";
565// if ($genere<4 or $votoc){
566// }
567 $sql="select max(t1.voti),sum(t1.voti), count(t1.voti) from ".$prefix."_ele_voti_candidati as t1, ".$prefix."_ele_candidati as t2 where t1.id_cand=t2.id_cand and t1.id_sez='$id_sez' and t2.id_lista='$id_lista3'";
568 $rese = $dbi->prepare("$sql");
569 $rese->execute();
570 list($maxvotic,$sumvotic,$numrec)=$rese->fetch(PDO::FETCH_NUM);#die("TEST: $numrec");
571 if($numrec>0 or ($votoc and $scruliste)) {$sezscru=1; $statuscol="#99CC33;";} else $statuscol='';
572 if($maxvotic>$voti or $sumvotic>$voti*$numprefs) $statuscol='#dd0000;'; #$segna="style=\"background-color: #dd0000;\"";
573 $sql="select * from ".$prefix."_ele_controlli where tipo='lista' and id_sez='$id_sez' and id='$id_lista3'";
574 $rese = $dbi->prepare("$sql");
575 $rese->execute();
576 if($rese->rowCount()) $statuscol='#dd0000;'; #$segna="style=\"background-color: #dd0000;\"";
577 list($sezcol)=$rese->fetch(PDO::FETCH_NUM);
578 $segna="style=\"background-color: $statuscol\"";
579 if ($statuscol) $errcolor=$segna; else $errcolor='';
580 if ($statuscol=='#dd0000;')
581 $bordcolor="border-color:red;";
582 else $bordcolor='';
583 if(isset($errgrulis[$rifgruppo])) {
584 $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
585 $bordcolor="border-color:red;";
586 }elseif(!$errcolor && $numrec) $errcolor="style=\"background-color: #99CC33;\"";
587 if($genere>=4 and !$votoc) $stilcur="style=\"cursor: pointer;\""; else $stilcur='';
588 echo "<td align=\"center\" $errcolor><b> $num_lista </b></td>"
589 ."<td align=\"left\" $stilcur onClick=\"vai_lista('id_rif$i');\"><b>$descr_lista</b></td>";
590## $cond_sele="and id_lista=$id_lista3";
591 echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" onfocus=\"select();\" style=\"text-align:right; $bordcolor;\"><input id=\"id_rif$i\" type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\">";
592#funzione non ritenuta utile
593# 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;}
594 if($disgiunto) {echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\" onfocus=\"select();\">"; $tslpl+=intval($slpl);}
595 echo "</td>";
596// echo "<td align=\"right\">$sgpl";
597 echo "</tr>\n";
598 $i++;
599 $tot_pref+=$voti;
600 }
601 }
602 if(!isset($segna2)) $segna2='';
603 if(!$id_lista) {
604 if ($tot_pref!=$validi2 and $sezscru) $segna2="style=\"background-color: #dd0000;\"";
605 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><font size=\"3\">"._TOT._VOTI_LISTA."</font></td><td align=\"center\" $segna2><font size=\"3\">$tot_pref</font></td>";
606# if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
607# echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
608 if($disgiunto)
609 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
610 echo "</tr>";
611 }
612 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\" $segna2>$tot_pref</td></tr>";
613 // toglie ai candidati la visual... del solo_gruppo
614 if(!$votog) {
615 if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
616 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;\" onfocus=\"select();\"></td></tr>";
617 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;\" onfocus=\"select();\">";
618 if(defined('_NULLISTA'))
619 echo "<input type=\"hidden\" name=\"votinulli\" value=\"$votinulli\"><input type=\"hidden\" name=\"contestati\" value=\"$contestati\"></td></tr>";
620 else
621 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;\" onfocus=\"select();\">"
622 ."</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;\" onfocus=\"select();\"></td></tr>";
623
624 }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
625 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
626 }
627/* visualizzazione tolta perché inappropriata 04/03/2022
628######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
629elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
630$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
631$resvg = $dbi->prepare("$sql");
632$resvg->execute();
633
634
635list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
636$sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
637$resvg = $dbi->prepare("$sql");
638$resvg->execute();
639
640
641 list($voti_sind) = $resvg->fetch(PDO::FETCH_NUM);
642
643echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
644} */
645###### fine modifica del 16-04-2009
646
647 }
648 echo "<tr>";
649 echo "<td></td><td></td>";
650 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
651 echo "</tr></table>";
652 if(chisei($id_cons_gen)>=64){
653 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
654 } # onclick=\"javascript:del_dati()\"
655 echo "</form></tr></table>";
656
657
658
659}
660#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
661 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
662 }
663
664
665function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
666 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
667////////////////////////////////////////////
668// da qua va la sezione per i voti finali
669///////////////////////////////////////////
670$bgcolor1="#7777ff";
671$bgcolor2=$_SESSION['bgcolor2'];
672
673
674
675 echo "<form name=\"spogliovoti\" data-ajax=\"false\" action=\"modules/Elezioni/salva_voti.php\">"
676 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
677 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
678 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
679 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
680 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
681 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
682
683 echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
684/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
685 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
686 else */
687 echo "<td width=\"15%\"><b>"._VALIDI."</b></td>";
688 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
689 ."<td><b>"._BIANCHI."</b></td>"
690 ."<td width=\"82\"><b>"._VOTINULLI."</b></td>"
691 ."<td><b>"._CONTESTATI."</b></td>"
692 ."<td><b>"._TOTNON."</b></td>"
693 ."<td><b>"._TOTALEVOTI."</b></td>"
694 ."<td bgcolor=\"#ffffff\"></td> </tr>";
695/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
696 $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' ";
697$res = $dbi->prepare("$sql");
698$res->execute();
699
700
701else */
702 $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' ";
703$result = $dbi->prepare("$sql");
704$result->execute();
705
706
707 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
708 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
709 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
710// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
711
712
713 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\">";
714/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
715 echo "</td><td>$nulli"
716 ."</td><td>$bianchi";
717 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
718 }else{ */
719 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right;\" onfocus=\"select();\">"
720 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right;\" onfocus=\"select();\">";
721// }
722 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" style=\"text-align:right;\" onfocus=\"select();\">"
723 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\" onfocus=\"select();\">"
724 ."</td><td>$tot_nulli"
725 ."</td><td>$tot_voti</td><td>"
726 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
727 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
728 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
729 ."</td></tr></table></form>"; //</td></tr>";
730
731
732// echo "</table>";
733/* echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
734 if (!$validi) {
735 echo "document.spogliovoti.validi.focus()\n";
736 echo "document.spogliovoti.validi.select()\n";
737 }
738 echo "//-->\n"
739 ."</script>\n"; */
740
741
742 }
743
744
745function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
746 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
747////////////////////////////////////////////
748// da qua va la sezione per le preferenze ai gruppi
749///////////////////////////////////////////
750// Controllo immmissioni
751
752$bgcolor1="#7777ff";
753$bgcolor2=$_SESSION['bgcolor2'];
754$sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
755$res = $dbi->prepare("$sql");
756$res->execute();
757
758
759 $max = $res->rowCount();
760 $max = $max-1;
761/* echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
762 if ($genere==0) {
763 echo "document.sezioni.si1.focus()\n";
764 echo "document.sezioni.si1.select()\n";
765 } else {
766 echo "document.sezioni.voti1.focus()\n"
767 ."document.sezioni.voti1.select()\n";
768 }
769 echo "//-->\n"
770 ."</script>\n"; */
771// tabella votanti
772 echo "<center>";
773 if ($genere!=0){
774 $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";
775$result = $dbi->prepare("$sql");
776$result->execute();
777
778
779 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
780 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
781 ."<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>"
782 ."<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>";
783 echo "</table>";
784 }
785 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
786 if ($genere==0){
787 $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' ";
788 $res = $dbi->prepare("$sql");
789 $res->execute();
790 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
791 if ($voti_parz!=$validi){
792 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
793 $res2 = $dbi->prepare("$sql");
794 $res2->execute();
795 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
796 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>";
797 }
798 $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' ";
799 $res2 = $dbi->prepare("$sql");
800 $res2->execute();
801 list($tot) = $res2->fetch(PDO::FETCH_NUM);
802 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
803 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
804 $res2 = $dbi->prepare("$sql");
805 $res2->execute();
806 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
807 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>";
808 }
809 }
810 }else{
811 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
812 $result = $dbi->prepare("$sql");
813 $result->execute();
814 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
815 $dettnulli=$flagsg;
816 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
817 $res = $dbi->prepare("$sql");
818 $res->execute();
819 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
820 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
821 $res = $dbi->prepare("$sql");
822 $res->execute();
823 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
824 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
825 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>";
826 }
827 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
828 $res2 = $dbi->prepare("$sql");
829 $res2->execute();
830 list($tot) = $res2->fetch(PDO::FETCH_NUM);
831 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
832 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>";
833 }
834 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
835 $resg = $dbi->prepare("$sql");
836 $resg->execute();
837 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
838 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
839 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
840 $resg = $dbi->prepare("$sql");
841 $resg->execute();
842 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
843 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
844 $resg = $dbi->prepare("$sql");
845 $resg->execute();
846 list($sg)=$resg->fetch(PDO::FETCH_NUM);
847 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>";
848 }
849#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
850 if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
851 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
852 $resref = $dbi->prepare("$sql");
853 $resref->execute();
854 $errgrulis=array();
855 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
856 $res4 = $dbi->prepare("$sql");
857 $res4->execute();
858 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
859 if ($sezscrl)
860 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
861 {
862 if($disgiunto || $flagsg){
863 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
864 $res3 = $dbi->prepare("$sql");
865 $res3->execute();
866 if($flagsg){
867 $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')";
868 $res4 = $dbi->prepare("$sql");
869 $res4->execute();
870 }else{
871 $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')";
872 $res4 = $dbi->prepare("$sql");
873 $res4->execute();
874 }
875 }else{
876 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
877 $res3 = $dbi->prepare("$sql");
878 $res3->execute();
879 $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')";
880 $res4 = $dbi->prepare("$sql");
881 $res4->execute();
882 }
883 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
884 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
885 if($vliste>$vgruppo and !$disgiunto )
886 {
887 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
888 $result = $dbi->prepare("$sql");
889 $result->execute();
890 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
891 echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate $vliste<br/> superano i voti assegnati al gruppo $dgruppo $vgruppo</b><br></td></tr>";
892 $errgrulis[$id_gruppo]=1;
893 }
894 elseif($vliste<$vgruppo and !$disgiunto )
895 {
896 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
897 $result = $dbi->prepare("$sql");
898 $result->execute();
899 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
900 echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr>";
901 $errgrulis[$id_gruppo]=1;
902 }
903 }
904 }
905 }
906 if(!isset($votinulli)) $votinulli=0;
907 echo "<tr><td></td></tr></table>";
908 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
909 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\">";
910 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\">";
911 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
912 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
913 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
914 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
915 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
916 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
917 ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
918 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
919 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
920 if ($genere==0){
921 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
922 ."<td colspan=\"6\"><b>"._GRUPPO."</b></td></tr>";
923 $campitesta= "<tr align=\"center\" bgcolor=\"$bgcolor1\"><td><b>Votanti "._SI."</b></td>"
924 ."<td><b>Votanti "._NO."</b></td>"
925 ."<td><b>"._VALIDI."</b></td>"
926 ."<td><b>"._BIANCHI."</b></td>"
927 ."<td><b>"._CONTESTATI."</b></td>"
928 ."<td><b>"._NULLI."</b></td></tr>";
929
930 $campiriep="<tr style=\"background-color: $bgcolor1; text-align:center\"><td colspan=\"2\"><b>"._TOTNON."</b></td>"
931 ."<td colspan=\"2\"><b>"._TOTALEVOTI."</b></td>"
932 ."<td colspan=\"2\"><b>"._VOTANTI."</b></td></tr>";
933 }else{
934 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
935 ."<td width=\"3%\"><b>"._NUM."</b></td>"
936 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
937 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
938 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
939 echo "</tr>";
940 }
941 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
942 $res = $dbi->prepare("$sql");
943 $res->execute();
944 $max = $res->rowCount();
945 //echo "Massimo:$max - id=$id_cons - circo: $circo";
946 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
947 $result = $dbi->prepare("$sql");
948 $result->execute();
949 $i=1;
950 $tot_pref=0;
951 $totsg=0;
952 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
953 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
954 ."//-->\n";
955 echo "function controlloref$i() {\n";
956 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";
957 echo "}\n";
958 echo "</script>\n";
959 if ($num_gruppo != ''){
960 if ($genere==0){
961 $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' ";
962 $res = $dbi->prepare("$sql");
963 $res->execute();
964 list($tot) = $res->fetch(PDO::FETCH_NUM);
965 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
966 $res = $dbi->prepare("$sql");
967 $res->execute();
968 $numpro=$res->rowCount();
969 $pro= $res->fetch(PDO::FETCH_BOTH);
970 echo "<tr><td colspan=\"6\">&nbsp;</td></tr>";
971 if ($numpro and ($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))){
972 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
973 }elseif($numpro and ($pro['validi']+$pro['nulli']+$pro['bianchi']+$pro['contestati']!=0))
974 echo "<tr style=\"background-color:#99CC33; text-align:center\">";
975 else
976 echo "<tr style=\"background-color:$bgcolor2; text-align:center\">";
977# $descr = explode('.',$descr_gruppo, 100);
978 echo "<td colspan=\"6\" align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo) </b>"
979 ."<b> $descr_gruppo </b></td></tr>";
980 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
981 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
982 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
983 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
984 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
985 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
986 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
987 $tot_voti=intval($pro['validi'])+$tot_nulli;
988 echo $campiriep; # style=\"text-align: center; border: 1px; border-color: black; border-collaps:collaps;\"
989 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td colspan=\"2\" >$tot_nulli</td>";
990 echo "<td colspan=\"2\">$tot_voti</td>";
991 echo "<td colspan=\"2\">$tot</td></tr>";
992 echo $campitesta;
993 echo "<tr><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i() onfocus=\"select();\"></td>";
994 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\" onchange=controlloref$i() onfocus=\"select();\"></td>";
995 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>";
996 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>";
997 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>";
998 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>";
999 }else{
1000 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>"
1001 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1002 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1003 $res = $dbi->prepare("$sql");
1004 $res->execute();
1005 $pro= $res->fetch(PDO::FETCH_BOTH);
1006 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
1007 $errcolor='';
1008 if(isset($errgrulis[$id_gruppo])) {$errcolor="style=\"background-color: rgb(255, 0, 0);\"";}
1009 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>";
1010 if($dettnulli) {echo "<td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\" style=\"text-align:right;\" onfocus=\"select();\"></td>"; $totsg+=intval($pro['solo_gruppo']);}
1011 $tot_pref += intval($pro['voti']);
1012 echo "</tr>";
1013 }
1014 $i++;
1015 }
1016 }
1017 if ($genere!=0) {
1018 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1019 $res = $dbi->prepare("$sql");
1020 $res->execute();
1021 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
1022 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
1023 $res = $dbi->prepare("$sql");
1024 $res->execute();
1025 if ($tot_pref!=$validi and ($tot_pref>0 and $validi>0)) $segna2="style=\"background-color: #dd0000;\""; else $segna2='';
1026 list($sololis)=$res->fetch(PDO::FETCH_NUM);
1027 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td $segna2>$tot_pref</td>";
1028 if($dettnulli) echo "<td>$totsg</td>";
1029 echo "</tr>";
1030 if($disgiunto)
1031 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;\" onfocus=\"select();\"></td></tr>";
1032 }
1033 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1034 echo "</tr></table></form></td></tr>";
1035 if(chisei($id_cons_gen)>=64){
1036 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1037 }
1038 echo "</td></tr></table></center>";
1039 }
1040 if ($genere!=0){
1041 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1042 }
1043}
1044
1045
1046
1047
1048?>
Note: See TracBrowser for help on using the repository browser.