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

Last change on this file since 221 was 221, checked in by roby, 10 years ago

admin: aggiunta tabella per i controlli di stato della congruenza dei voti inseriti - evita il ricalcolo per tutte le sezioni ad ogni inserimento (da completare ma funzionante)

client: rivista la funzione di proiezione dell'attribuzione seggi

File size: 82.1 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Roberto Gigli & Luciano Apolito */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8/* Modulo Inserimento dati */
9/* Amministrazione */
10/************************************************************************/
11
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15$aid=$_SESSION['aid'];
16$dbi=$_SESSION['dbi'];
17$prefix=$_SESSION['prefix'];
18$currentlang=$_SESSION['lang'];
19$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
20$vari= implode(',',$_GET);//param);
21$id_comune=$_SESSION['id_comune'];
22$id_cons_gen=intval($_GET['id_cons_gen']);
23$perms=ChiSei($id_cons_gen);
24if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
25if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
26//if (isset($param['id_cons'])) $id_cons=intval($param['id_cons']); else $id_cons='';
27if (isset($param['ops'])) $ops=intval($param['ops']); else $ops='';
28if (isset($param['min'])) $min=intval($param['min']); else $min=0;
29if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
30if (isset($param['ov'])) $ov=intval($param['ov']); else $ov='';
31if (isset($param['mv'])) $mv=intval($param['mv']); else $mv='';
32if (isset($param['gv'])) $gv=intval($param['gv']); else $gv='';
33if (isset($param['msv'])) $msv=intval($param['msv']); else $msv='';
34if (isset($param['av'])) $av=intval($param['av']); else $av='';
35if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else
36 if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='0';
37if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
38if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
39if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='0';
40if (isset($param['prev_sez'])) $prev_sez=intval($param['prev_sez']); else $prev_sez='0';
41if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='0';
42if (isset($param['update'])) $update=intval($param['update']); else $update='';
43include("modules/Elezioni/funzionidata.php");
44include("modules/Elezioni/ele.php");
45global $votolista, $limite;
46if(!isset($votolista)) $votolista=0;
47$res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
48list($tipo_cons) = mysql_fetch_row($res);
49if ($tipo_cons!=3 or $votolista==1) $limite=0; #die ("limite: $limite");}
50$res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
51list($num_circ)=mysql_fetch_row($res);
52if ($conscirc){ // or $num_circ==1
53 if (!$id_circ){
54 $res = mysql_query("SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1", $dbi);
55 if (!$res) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
56 list($id_circ)=mysql_fetch_row($res);
57 $_SESSION['id_circ']=$id_circ;
58 }
59 $result = mysql_query("select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'", $dbi);
60 $i=0;
61 while(list($tmp) = mysql_fetch_row($result)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
62 unset($idsedi);$i=0;$idsezi=array();unset($result);
63 $result = mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)", $dbi);
64 unset($tmp);
65 while(list($tmp) = mysql_fetch_row($result)) $idsezi[$i++]=$tmp;
66 $tmp=implode (",",$idsezi);
67 $sezi = "and id_sez in ($tmp)";
68 $circo = "and id_circ='$id_circ'";
69}else{
70 $sezi='';
71 $circo='';
72}
73
74function stato_rilevazione($id_sez,$solosede){
75global $id_cons, $prefix, $dbi, $id_cons_gen,$status,$genere,$votol, $votog, $idrefgruppo;
76
77if($idrefgruppo) $perref= "and id_gruppo='$idrefgruppo'";
78else $perref="";
79$ops=0;
80$status=0;
81 if($ops==0){
82#controllo congruenza affluenze
83 $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc", $dbi);
84 if($res)
85 while (list($ora,$giorno) = mysql_fetch_row($res)){
86 $query="SELECT sum(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";
87 $res2 = mysql_query("$query", $dbi);
88 list($voti)=mysql_fetch_row($res2);
89 if($voti) {
90 if(isset($ora)){
91 $query="SELECT count(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' $perref and orario='$ora' and data='$giorno'";
92 $res3 = mysql_query("$query", $dbi);
93 list($numscru)=mysql_fetch_row($res3);
94 $res3= mysql_query("SELECT count(num_sez) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
95 list($numtot) = mysql_fetch_row($res3);
96 $res3= mysql_query("SELECT maschi+autorizzati_m,femmine+autorizzati_f FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
97 list($iscrittim,$iscrittif) = mysql_fetch_row($res3);
98 $iscritti=$iscrittim+$iscrittif;
99
100 $query="SELECT voti_complessivi, voti_uomini, voti_donne FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";
101 $res3 = mysql_query("$query", $dbi);
102 list($voti, $uomini, $donne)=mysql_fetch_row($res3);
103# if($voti>0) {#echo $query;
104 if ((($uomini+$donne)==0 and ($voti)<=$iscritti) or ((($uomini+$donne)==$voti) and ($uomini<=$iscrittim) and ($donne<=$iscrittif))){
105 #if($numscru<$numtot and $numscru>0)
106 {$status=1;$ops=-1;break;}#
107# else
108# {$status=0;$ops=-1;break;}
109 }else {return 1;}
110# } else return 0;
111 }
112 } else {return -1;}
113 }
114 # return 0;
115 #controllo congruenza voti espressi
116 #per referendum
117 if($genere==0){
118 $res2= mysql_query("SELECT si,no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_sez='$id_sez' and id_gruppo='$idrefgruppo'", $dbi);
119 $refscru=mysql_num_rows($res2);
120 if($refscru){
121# echo "$voti - $ora - $giorno :<br>";
122 list($si,$no,$validi,$nulli,$bianchi,$contestati)=mysql_fetch_row($res2);
123 if(($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti)) {$status=1;return (-4);}
124 else return (4);
125 } else {$status=0; return (-4);}
126 }
127 #per le altre consultazione
128 $res2= mysql_query("SELECT sum(validi) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
129 if($res2){
130 list($validi) = mysql_fetch_row($res2);
131 if($validi) {
132 $status=0;
133 $query="SELECT validi,nulli,bianchi,contestati,voti_nulli,solo_gruppo,validi_lista,contestati_lista,voti_nulli_lista,solo_lista FROM ".$prefix."_ele_sezioni as t1 where t1.id_sez='$id_sez'";
134 $res4 = mysql_query("$query", $dbi);
135 list($validi, $nulli, $bianchi,$contestati,$votinulli,$sologruppo,$validilista,$contestatilista,$votinullilista,$sololista)=mysql_fetch_row($res4);
136 if($validi>0) {
137 if (($validi+$nulli+$bianchi+$contestati+$votinulli+$sololista)==$voti)
138 {$status=1;$ops=(-4+$votog);}
139 else return (4-$votog);
140 } #else return 0;
141 }
142 }
143 #controllo congruenza voti di gruppo
144 $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons'", $dbi);
145 if($res3 and !$votog){$status=0;$ops=-4;
146 list($votig) = mysql_fetch_row($res3);
147 if($votig and $genere!=2) {
148 $status=0;
149 $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
150 $res4 = mysql_query("$query", $dbi);
151 list($votigs)=mysql_fetch_row($res4);
152 if($votigs>0) {
153 if (($votigs)==$validi)
154 {$status=1;$ops=-3;}
155 else return 4;
156 } #else return 0;
157 }
158 }
159 $res4= mysql_query("SELECT t1.preferenze,t1.id_fascia,t2.limite FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_conf as t2 on t1.id_conf=t2.id_conf where t1.id_cons='$id_cons'", $dbi);
160 if($res4) list($testpref,$fascia,$limite)=mysql_fetch_row($res4); else {$testpref=0;$fascia=0;$limite=0;}
161
162 #controllo congruenza voti di lista
163 $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons'", $dbi);
164 if($res3 and ($genere>1 and !$votol)){$status=0;
165 list($votil) = mysql_fetch_row($res3);
166 if($votil) {
167 $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
168 $res4 = mysql_query("$query", $dbi);
169 list($votils)=mysql_fetch_row($res4);
170# if($votils>0) {
171 if(mysql_num_rows($res4)>0) {
172 $query="SELECT stato_aff, stato_val,stato_gru,stato_lis,stato_can FROM ".$prefix."_ele_controllosez where id_sez='$id_sez' and id_cons='$id_cons'";
173 $res3 = mysql_query("$query", $dbi);
174 $res4= mysql_query("SELECT count(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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
175 list($contains)=mysql_fetch_row($res4);
176 if($contains==0) $tutte=1; else $tutte=0;
177 if(mysql_num_rows($res3)){
178 list($aff,$val,$gru,$lis,$can)=mysql_fetch_row($res3);
179 }else{
180 $query="SELECT id_lista FROM ".$prefix."_ele_lista where id_cons='$id_cons'";
181 $res3 = mysql_query("$query", $dbi);
182 $testcand=0;
183
184 $res4= mysql_query("SELECT preferenze FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
185 if($res4) list($testpref)=mysql_fetch_row($res4); else $testpref=0;
186 while(list($testlista)=mysql_fetch_row($res3)){
187 $res4= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and id_lista='$testlista'", $dbi);
188 if($res4) list($testvotil)=mysql_fetch_row($res4); else $testvotil=0;
189 $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
190 if($res4) list($testvotic)=mysql_fetch_row($res4); else $testvotic=0;
191
192 if(($testvotil*$testpref)<$testvotic) { $testcand=1;break;}
193 $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
194 while(list($testvotic)=mysql_fetch_row($res4))
195 if($testvotil<$testvotic) { $testcand=1;break;}
196 }
197 }
198 if(!isset($can)){
199 $can=($testcand==0) ? 1:-1;
200 if($genere==4 or $votog) $contestatilista=0;
201 $val=(($votils+$sologruppo+$contestatilista+$votinullilista)==($validi+$sololista))?1:-1;
202 $lis=($validilista==$votils) ? 1:-1;
203 $res4=mysql_query("insert into ".$prefix."_ele_controllosez values('$id_sez','$id_cons','0','$val','0','$lis','$can')",$dbi);
204 }
205 # $res4= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$testlista' and id_cons='$id_cons' ", $dbi);
206 # $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
207 if($genere==4 or $votog) $contestatilista=0;
208# if (($votils+$sologruppo+$contestatilista+$votinullilista)==($validi+$sololista) and $validilista==$votils and $testcand==0)
209 if ($val==1 and $lis==1 and $can==1)
210 {$status=$tutte;$ops=-3;}
211 else {return 3;}
212 } #else return 0;
213 }elseif($genere==5 and $fascia<=$limite){
214/* $testcand=0;
215 $query="SELECT id_lista,id_gruppo FROM ".$prefix."_ele_lista where id_cons='$id_cons'";
216 $res3 = mysql_query("$query", $dbi);
217 $tutte=1;
218 while(list($testlista,$testgruppo)=mysql_fetch_row($res3)){
219 $res4= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$testgruppo'", $dbi);
220 if($res4) list($testvotit)=mysql_fetch_row($res4); else $testvotit=0;
221 $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
222 if($res4) list($testvotic)=mysql_fetch_row($res4); else $testvotic=0;
223 $res4= mysql_query("SELECT count(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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
224 list($contains)=mysql_fetch_row($res4);
225 if($contains==0) $tutte=0;
226
227
228 if(($testvotit*$testpref)<$testvotic) {$testcand=1;break;}
229 $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
230 while( list($testvotic)=mysql_fetch_row($res4))
231 if(($testvotit)<$testvotic) {$testcand=1;break;}
232 }*/
233 if($testcand==0)
234 {$status=$tutte;$ops=-3;}
235 else {return 3;}
236 }
237 }elseif($ops==-3){ $ops=-4;}
238
239
240return ($ops);
241 }
242
243}
244
245// Offset - visualizza il numero di elementi per pagina
246$offset=2;
247if (!isset($min)) $min=0;
248$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
249
250function numeri_sezione($nums) {
251// tabella visualizzazione sezioni per numero
252global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$id_cons,$id_lista,$ops, $perms,$id_sez;
253// $ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where aid='$aid'",$dbi);
254// list ($perms)=mysql_fetch_row($ressup);
255 $solosede='';
256 if ($perms<32) {
257 $res = mysql_query("SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons", $dbi);
258 if ($res) {
259 list($solouna)=mysql_fetch_row($res);
260 if ($solouna>0) $solosede="and id_sede='$solouna'";
261 }
262 }
263 $res = mysql_query("SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez", $dbi);
264 $max = mysql_num_rows($res);
265 //if ($max>=64){
266 $i=0;
267 echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
268
269
270 echo "<div id=\"navmenu\"> <ul>";
271 while(list($sez_num, $sez_id ,$sede_id) = mysql_fetch_row($res)) {
272 $ops='';
273 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
274 $i++;
275 $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ", $dbi);
276 list($circ_id) = mysql_fetch_row($result);
277 //colora la sezione
278 $sezstat=0; #die($ops);
279 global $status;
280 global $idrefgruppo; $idrefgruppo='';
281 if($genere==0){
282 $resref = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'", $dbi);
283 while(list($idrefgruppo)=mysql_fetch_row($resref)) {
284 $sezstat=stato_rilevazione($sez_id,$solosede);
285 if ($sezstat>0) break;
286 }
287 }else
288 $sezstat=stato_rilevazione($sez_id,$solosede);
289 $cursez="style=\" background: #bbbbbb;";
290 $bgsez="";
291# if ($sezstat==(-1)) $bgsez="#99CC33"; #verde
292
293# if ($status==1 and $sezstat<0) { $ops=abs($sezstat);$bgsez="#99CC33";} #verde
294 if ($status==1 and $sezstat<0) { $ops=abs($sezstat);$cursez="style=\" background: #99CC33;";} #verde
295 elseif ($sezstat<0) {$ops=abs($sezstat);}
296 elseif ($sezstat>0) {
297# $bgsez="#FF3300";#rosso;
298 $cursez="style=\" background: #FF3300;";#rosso;
299 if ($sezstat) $ops=$sezstat; else $ops=1;
300 }
301 else{$cursez="style=\" background: #8CC8C7;";}
302 if(!$ops) $ops=1;
303 $res2= mysql_query("SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
304 list($numero_sez) = mysql_fetch_row($res2);
305# if ($sez_num==$numero_sez) {$cursez= "style=\" border-color: YELLOW; border-width: 5px;\"";}
306 if ($sez_num==$numero_sez) {$cursez.= " border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px;\"";} else $cursez.="\"";
307# echo "\n<td align=\"center\" width=\"5%\" bgcolor=\"$bgsez\" $cursez><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$circ_id&amp;id_sede=$sede_id&amp;id_sez=$sez_id&amp;ops=$ops&amp;do=spoglio&amp;id_lista=$id_lista\">$sez_num</a></b></td>\n";
308 echo "\n<li $cursez><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$circ_id&amp;id_sede=$sede_id&amp;id_sez=$sez_id&amp;ops=$ops&amp;do=spoglio&amp;id_lista=$id_lista\">$sez_num</a></b></li>\n";
309# if (($i%$nums) ==0) echo "</ul></div></td></tr></table>\n"; #<tr bgcolor=\"$bgcolor1\">
310 }
311 //}
312echo "</ul></div></td></tr></table>\n";
313# echo"</td></tr></table>";
314 //}// fine tabella per numero sezioni
315 // inizio tabella centrale
316 # echo "\n</td><td valign=\"top\" align=\"left\">";
317}
318///////////////////////////////////////////////////////////////////////////////////
319
320
321function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
322 global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez;
323
324 echo "<table border=\"0\" width=\"770\" align=\"left\"><tr>";
325 echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
326 //echo "<h6>";
327# echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
328 numeri_sezione(22);
329# echo "<td></td></tr></table>\n";
330# echo "</td></tr></table>\n";
331 echo "\n</td></tr><tr><td>\n";
332
333
334 ///////////////////////
335 // Circoscrizione : scelta
336 ///////////////////////
337
338 $resoper=mysql_query("SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
339 ".$prefix."_ele_sede as t2
340 where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'", $dbi);
341 list($id_sede2,$id_circ2) = mysql_fetch_row($resoper);
342 if ($id_sede2 and !($id_sede==$id_sede2)) {
343 $id_sede=$id_sede2;
344 $id_circ=$id_circ2;
345 $do="spoglio";
346 $res= mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede=$id_sede order by num_sez limit 0,1", $dbi);
347 list($id_sez) = mysql_fetch_row($res);
348 }
349 if ($do == "circo") {
350 OpenTable();
351 echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
352 ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
353 ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
354 // Circoscrizione: lista
355 //**************************************
356 .""._CIRCO.": "
357 ."<select name=\"id_circ\">";
358 $res= mysql_query("SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ", $dbi);
359 while(list($id,$descr) = mysql_fetch_row($res)) {
360 if ($descr!="Tutte"){
361 if ($id == $id_circ) {
362 $sel = "selected";
363 } else {
364 $sel = "";
365 }
366 echo "<option value=\"$id\" $sel>$descr";
367 }
368 }
369 echo "</select>"
370 //***********************************
371 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
372 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
373 ."</form></td></tr>";
374 CloseTable();
375 }
376
377 ///////////////////////
378 // sede : scelta
379 ///////////////////////
380
381
382 if ($do == "sede") {
383 OpenTable();
384 echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
385 $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
386 list( $descr_circ) = mysql_fetch_row($res);
387 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=circo\">"._CIRCO."</a> $descr_circ ->";
388 echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
389 ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
390
391 // Indirizzo: lista
392 //**************************************
393 .""._INDIRIZZO.": "
394 ."<select name=\"id_sede\">";
395 $res= mysql_query("SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo", $dbi);
396// echo "$id_circ - $id_cons";
397 while(list($id,$indir) = mysql_fetch_row($res)) {
398 if ($id == $id_sede) {
399 $sel = "selected";
400 } else {
401 $sel = "";
402 }
403 echo "<option value=\"$id\" $sel>$indir";
404 }
405 echo "</select>"
406 //*************************************
407 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
408 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
409 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
410 ."</form></td></tr>\n";
411 CloseTable();
412 }
413
414 ///////////////////////
415 // sezione : scelta
416 ///////////////////////
417 if ($do == "spoglio") {
418/* echo "\n<form name=\"sezione\" action=\"admin.php\">";
419 OpenTable();
420 echo "<tr><td>";
421 $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
422 list($descr_circ) = mysql_fetch_row($res);
423 $res= mysql_query("SELECT indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' AND id_sede='$id_sede' order by indirizzo", $dbi);
424 list($indir) = mysql_fetch_row($res);
425 echo "<input type=\"hidden\" name=\"pag_sez\" value=\"admin.php?op=voti&amp;do=spoglio&amp;ops=$ops&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;id_lista=$id_lista&amp;id_sez=\">";
426 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=circo\">"._CIRCO."</a> $descr_circ ->
427 <a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$id_circ&amp;do=sede\">"._INDIRIZZO."</a> $indir ->
428 <input type=\"hidden\" name=\"op\" value=\"voti\">
429 <input type=\"hidden\" name=\"do\" value=\"spoglio\">"
430 // Sezioni:lista
431 //**************************************
432 ."<b>"._SEZIONE."</b>: "
433 ."<select name=\"id_sez\" onChange=\"top.location.href=this.form.pag_sez.value+this.form.id_sez.options[this.form.id_sez.selectedIndex].value;return false\">";
434 $res= mysql_query("SELECT id_sez,num_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede='$id_sede' order by num_sez", $dbi);
435 $rif_sez=0;
436 $next_sez=0;
437 unset($prev_sez);
438 while(list($id,$num) = mysql_fetch_row($res)) {
439 if (!($id_sez>0)) {$id_sez=$id;}
440 if ($id == $id_sez) {
441 $sel = "selected";
442 $prev_sez=$rif_sez;
443 } else {
444 $sel = "";
445 if (isset($prev_sez) and ($next_sez==0)) { $next_sez=$id;}
446 $rif_sez=$id;
447 }
448 echo "<option value=\"$id\" $sel>$num";
449 }
450 echo "</select>"
451 //*************************************
452 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">\n"
453 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">\n"
454 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">\n"
455 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">\n"
456 ."&nbsp;&nbsp;<input type=\"submit\" name=\"update\" value=\""._OK."\">\n";
457 if ($prev_sez) {
458 echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;id_sez=$prev_sez&amp;ops=$ops&amp;id_lista=$id_lista\">"._PREV."</a>&nbsp;&nbsp;&nbsp;&nbsp;\n";
459 }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._PREV."</span> ";}
460 if ($next_sez) {
461 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;id_sez=$next_sez&amp;ops=$ops&amp;id_lista=$id_lista\">"._NEXT."</a>\n";
462 }else {echo "&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(204, 204, 204);\">"._NEXT."</span>\n";}
463 echo "\n</td></tr>";
464 CloseTable();
465
466 echo "</form>\n";
467 echo "\n</td></tr><tr><td>\n";
468// echo "\n</td></tr></table>\n";
469*/
470
471 //************************************
472 // Menu spoglio
473 //************************************
474 $result = mysql_query("select id_cons,id_sez,id_sede,num_sez, maschi, femmine from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
475 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = mysql_fetch_row($result);
476
477 //$bgcolor1="#b0b0b0";
478# echo "<hr><table border=\"0\" width=\"60%\" align=\"center\"><tr>";
479 echo "<hr><table><tr><td width=\"200\"><font size =\"4\" color=\"black\" align=\"left\"><b>Sezione N. $num_sez</b></font size></td><td><table><tr>";
480 echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=1\">"._AFFLUENZE."</a></b></p></td>\n";
481 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
482 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=4\">"._GRUPPO."</a></b></p></td>\n";
483 }
484 if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
485 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3\">"._LISTA."</a></b></p></td>\n";
486 }
487 echo "</tr></table></td></tr></table><hr>\n";
488/*
489########################
490 echo "<hr><table class=\"table-menu\"><tr>";
491 echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=1\">"._AFFLUENZE."</a></b></td>\n";
492 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
493 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=4\">"._GRUPPO."</a></b></td>\n";
494 }
495 if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
496 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3\">"._PREFLISTA."</a></b></td>\n";
497 }
498 echo "</tr></table><hr>\n"; */
499// echo "\n</td></tr></table>\n";
500#############
501# posizionamento in mancanza di scelta
502#############
503if (!$ops){
504 if (!$id_sez) { echo"";#import( pagina di help );
505 } else{
506 $res= mysql_query("SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
507 list($data,$orario)=mysql_fetch_row($res);
508 $res= mysql_query("SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'", $dbi);
509 list($voti) = mysql_fetch_row($res);
510 if (!$voti) $ops=1;
511 else {
512# $res= mysql_query("SELECT validi from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
513# list($voti) = mysql_fetch_row($res);
514 if($genere<4){
515 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'", $dbi);
516 list($voti) = mysql_fetch_row($res);
517 if ($voti==0 or $genere<3) $ops=4;
518 }
519 if(!$ops) $ops=3;
520 }
521
522 }
523}
524############ fine posizionamento
525
526 ///////////////////////////////////////////
527 // opzioni per le funzioni di immissione
528
529 if ($ops == 1) {
530 votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
531 }else{
532############# Controllo flag per cancellazione consultazione
533 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
534 ."//-->\n";
535 echo "function del_dati() {\n";
536 echo "if (document.getElementById('pwd3').checked==false) {\n";
537 echo "document.getElementById('update').value=\""._OK."\" \n";
538 echo "document.getElementById('do').value=\"0\" \n";
539 echo "}else{\n";
540 echo "document.getElementById('update').value=\""._DELETE."\" \n";
541 echo "document.getElementById('do').value=\"1\" \n";
542 echo "} \n";
543 echo "} \n";
544 echo "</script>\n";
545 }
546 /*
547 if ($ops == 2) {
548 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
549 }
550 */
551 if ($ops == 3) {
552 preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
553 }
554 if ($ops == 4) {
555 preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
556
557 }
558
559 }
560 CloseTable();
561
562}
563////////////////////////////////////////////////////////////////////////////////
564// FUNZIONI DI IMMISSIONE
565// - preferenze (candidati consiglieri)
566// - preferenze_gruppi
567// - votanti
568////////////////////////////////////////////////////////////////////////////////
569
570//////////////////////////////////////////////////////////////////////
571// da qui va la sezione per le preferenze candidati consiglieri
572//////////////////////////////////////////////////////////////////////
573function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
574 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
575global $tipo_cons,$limite;
576$bgcolor1="#7777ff";
577$bgcolor2=$_SESSION['bgcolor2'];
578 //controlla se sono stati inseriti i votanti
579$result = mysql_query("SELECT preferenze, id_fascia, id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'",$dbi);
580list($numprefs,$fascia,$id_conf)=mysql_fetch_row($result);
581
582if(!$votog and ($genere==3 or $genere==5))
583 $result = mysql_query("select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
584else
585 $result = mysql_query("select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
586#e
587 list($validi,$nulli,$bianchi,$contestati,$votinulli) = mysql_fetch_row($result);
588# if ($validi+$nulli+$bianchi) die("entra($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)");
589 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
590 $res_lis = mysql_query("SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista",$dbi);
591 $num_liste = mysql_num_rows($res_lis);
592 $ele_lista='';
593 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
594 if(($genere==5 and $fascia<=$limite and $id_conf) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
595 $result = mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1",$dbi);
596 list($id_lista)=mysql_fetch_row($result);
597 }
598 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
599 echo "<form name=\"liste\" action=\"admin.php\">";
600 echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3&amp;id_lista=\">";
601 echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
602 if ($id_lista){
603 echo "<option value=\"0\">"._VOTI_LISTA;
604 $ele_lista=" and t1.id_lista='$id_lista' ";
605 }else{
606 echo "<option value=\"0\" selected>"._VOTI_LISTA;
607 $ele_lista=" group by t1.id_lista ";
608if(!isset($votolista)) $votolista=0;
609
610 }
611 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
612 $segna='';
613 $result = mysql_query("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",$dbi);
614 list($ctrvoticand)=mysql_fetch_row($result);
615 $result = mysql_query("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_rif",$dbi);
616 list($votisezcand)=mysql_fetch_row($result);
617 if(($fascia>$limite or !$id_conf) or $genere==4)
618 $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);
619 else{
620
621 $result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'", $dbi);
622 list($id_gruppo)=mysql_fetch_row($result);
623 $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
624 }
625 list($votisezlis)=mysql_fetch_row($result);
626 if($votisezcand>($votisezlis*$numprefs))
627 $segna="style=\"background-color: #dd0000;\"";
628 elseif($ctrvoticand)
629 $segna="style=\"background-color: #99CC33;\"";
630 $res4= mysql_query("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_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$id_rif'", $dbi);
631 while(list($testvotic)=mysql_fetch_row($res4))
632 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";}
633
634 $sel = ($id_rif == $id_lista) ? "selected" : "";
635 echo "<option $segna value=\"$id_rif\" $sel>";
636 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
637 echo $num_lis.") ".substr($descrizione,0,30);
638 }
639 echo "</select></form></td>\n";
640 }else {
641 $id_lista=0;
642 }
643 echo "<td style=\"vertical-align: top;\">";
644
645 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
646if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)
647 $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli 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",$dbi);
648else
649 $result = mysql_query("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 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",$dbi);
650 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2) = mysql_fetch_row($result);
651 $valista=$validi2;
652 if(!$id_lista or $genere==3){ //controllo di congruenza
653 $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
654 list($tot) = mysql_fetch_row($res2);
655 if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
656 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>";
657 }
658
659 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
660 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>";
661 }
662 }elseif($genere==5){
663 $result = mysql_query("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",$dbi);
664 list($votisezcand)=mysql_fetch_row($result);
665 if($fascia>$limite or !$id_conf)
666 $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'", $dbi);
667 else{
668
669 $result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
670 list($id_gruppo)=mysql_fetch_row($result);
671 $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
672 }
673 list($votisezlis)=mysql_fetch_row($result);
674 if($votisezcand>($votisezlis*$numprefs))
675 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>";
676
677 }
678
679
680
681 echo "\n<form name=\"sezioni\" action=\"admin.php\">"
682 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
683 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
684 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
685 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
686 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
687 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
688 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
689 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
690 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
691 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
692 if ($genere<4){
693// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
694 }
695 echo "<b>"._NUM."</b></td>";
696 if($id_lista){
697 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
698 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
699 }else{
700 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
701 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
702 }
703 echo "</tr>\n";
704
705
706
707
708
709 $result = mysql_query("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 ORDER BY t2.num_lista,t1.num_cand", $dbi);
710 $max = mysql_num_rows($result);
711 $tot_pref=0;
712 $i=1;
713
714 if($id_lista) {
715 while(list($id_cand,$id_cons2,$id_lista2, $cognome, $nome, $note, $simbolo, $num_cand) = mysql_fetch_row($result)){
716 // dati lista
717 $result1 = mysql_query("select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'", $dbi);
718 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1);
719 // dati gruppo
720 $result2 = mysql_query("select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
721 list($descr_gruppo,$simb_gruppo)=mysql_fetch_row($result2);
722
723 echo "<tr bgcolor=\"$bgcolor2\">";
724 if ($genere<4){
725 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
726 }
727 echo "<td align=\"center\"><b> $num_cand </b></td>"
728 ."<td align=\"left\"><b>$cognome $nome</b></td>";
729 $cond_sele="and id_cand=$id_cand";
730 $res = mysql_query("SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele", $dbi);
731 $pro= mysql_fetch_array($res, 3);
732 echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
733 echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
734 $i++;
735 $tot_pref+=$pro['voti'];
736 }
737 }else {
738 $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista
739 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
740 where t1.id_cons='$id_cons'
741 and t1.id_lista=t2.id_lista
742 and t2.id_sez=$id_sez
743 order by t1.num_lista", $dbi);
744 $num_lista=mysql_num_rows($result1);
745 if (!$num_lista){
746 $result1 = mysql_query("select '',t1.id_lista, descrizione,simbolo,num_lista
747 from ".$prefix."_ele_lista as t1 where t1.id_cons='$id_cons' $circo
748 order by t1.num_lista", $dbi);
749 }
750 while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1)){
751 echo "<tr bgcolor=\"$bgcolor2\">";
752// if ($genere<4 or $votoc){
753// }
754
755 echo "<td align=\"center\"><b> $num_lista </b></td>"
756 ."<td align=\"left\"><b> $descr_lista</b></td>";
757 $cond_sele="and id_lista=$id_lista3";
758 echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
759 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n";
760 $i++;
761 $tot_pref+=$pro['voti'];
762 }
763 }
764 if(!$id_lista) echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOT._VOTI_LISTA."</td><td align=\"center\">$tot_pref</td></tr>";
765 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
766 // toglie ai candidati la visual... del solo_gruppo
767 if(!$votog) {
768 if (($genere==3 OR $genere==5) and (!$id_lista) and ($fascia>$limite or !$id_conf)) { //gruppo e liste
769 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>";
770 echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input name=\"sg\" value=\"$sg\" size=\"5\" style=\"text-align:right\"></td></tr>";
771 echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._NULLI_LISTE."</b></td><td align=\"center\"><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
772 ."</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>";
773
774 }elseif (($genere==3 OR $genere==5) and !$votoc and ($fascia>$limite or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
775 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
776 }
777######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
778elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
779$resvg = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
780list($id_gruppo) = mysql_fetch_row($resvg);
781$resvg = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'", $dbi);
782 list($voti_sind) = mysql_fetch_row($resvg);
783
784echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
785}
786###### fine modifica del 16-04-2009
787
788 }
789 echo "<tr>";
790 echo "<td></td><td></td>";
791 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
792 echo "</tr></table></form></tr>";
793 if(chisei($id_cons_gen)>=64){
794 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."</td>";
795 }
796 echo "</table>";
797 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
798 ."document.sezioni.voti1.focus()\n"
799 ."document.sezioni.voti1.select()\n"
800 ."//-->\n";
801 echo "function vai_lista() {\n";
802 echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
803 echo "}\n";
804 echo "</script>\n";
805# }
806#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
807 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
808 }
809
810/////////////////////////////////////////////
811// registra le preferenze ai candidati
812/////////////////////////////////////////////
813
814function rec_voti() {
815 global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update;
816 $sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
817 $res = mysql_query($sqlcomu);
818 if($res)
819 list($fascia,$id_conf)=mysql_fetch_row($res);
820 else {$fascia=0; $id_conf=0;}
821 if ($fileout) while (!$fp = fopen($fileout,"a"));
822 $username=$aid;
823 $log_data= date("Y/m/d");
824 $log_ora=getdate(time());
825 $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
826 $arg2 = func_get_args();
827 $arg = split(",",$arg2[0]);
828 $id_cons_gen=intval($arg[1]);
829 $id_sez = intval($arg[2]);
830 $id_circ = intval($arg[3]);
831 $id_sede = intval($arg[4]);
832 $tab = $arg[5];
833 $id_lista = intval($arg[6]);
834 $do= intval($arg[7]);
835 if ($tab=="_ele_voti_candidati") {
836 $condizione="id_cand";
837 }else{
838 $condizione="id_lista";
839 }
840 if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ($fascia>$limite or !$id_conf)) $y = (count($arg)-4);
841 else $y=count($arg);#die ("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'");
842 mysql_query("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
843 if($do==1) {
844 mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
845 mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
846 if($genere!=4)
847 mysql_query("update ".$prefix."_ele_sezioni set validi_lista='0',contestati_lista='0',voti_nulli_lista='0',solo_gruppo='0' where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
848
849 }else{
850 for($i=8,$y--;$i< $y;$i++) {
851 $voti = intval($arg[$i++]);
852 $id_cand = intval($arg[$i]);
853 $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
854 $ar=mysql_fetch_array($result);
855 if ($ar){
856 if ($ar['voti']!=$voti) {
857 mysql_query("update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
858 if ($fileout) fwrite($fp,"update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand';\n");
859 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')", $dbi);
860 }
861 } else {
862 if ($voti)
863 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi);
864 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti')", $dbi);
865 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
866 }
867 }
868// foreach ($arg as $vval) echo $vval." - ";
869 // solo gruppo e preferenze alle liste
870
871 if(!$votog) {
872 if ((($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite or !$id_conf)) {
873 $valista=$arg[$i++];
874 $result = mysql_query("update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'",$dbi);
875 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
876 if ($condizione=="id_lista"){
877 $result = mysql_query("select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
878 $ar=mysql_fetch_array($result);
879 ++$i;
880 mysql_query("update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'", $dbi);
881 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
882# if ($ar['validi'] and !$ar['validi_lista']){
883 if ($ar['validi']){
884# $result = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez'", $dbi);
885# list($val)=mysql_fetch_row($result);
886# mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$val' where id_sez='$id_sez'", $dbi);
887 if($valista)
888 mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$valista' where id_sez='$id_sez'", $dbi);
889 else
890 mysql_query("update ".$prefix."_ele_sezioni set validi_lista=(`validi`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'", $dbi);
891 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi_lista=(`validi`+`contestati`+`voti_nulli`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez';\n");
892 }
893 }
894 }
895 }
896 }
897
898// $ops = $arg[$argc];
899 if ($fileout)fclose($fp);
900 Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=3&id_lista=$id_lista");
901}
902
903
904////////////////////////////////////////////
905// da qua va la sezione per i votanti
906///////////////////////////////////////////
907
908function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
909//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
910 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
911$bgcolor1=$_SESSION['bgcolor2'];
912OpenTable();
913$res = mysql_query("SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
914if($res) list($vismf)= mysql_fetch_row($res); else $vismf=0;
915$res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ", $dbi);
916$num = mysql_num_rows($res);
917$ressez = mysql_query("SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez", $dbi);
918list($maschi,$femmine)=mysql_fetch_row($ressez);
919$y=0;
920echo "<tr><td>&nbsp;</td></tr>";
921while (list($ora,$giorno)= mysql_fetch_row($res)){
922 $y++;
923 echo "\n<tr><td>";
924 echo "<form name=\"votanti$y\" action=\"admin.php\">";
925 echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
926 if ($genere==0){ //e' un referendum
927 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
928 }
929 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
930 ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
931 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
932 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
933 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
934 if ($genere==0){
935 $res2 = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
936 $max = mysql_num_rows($res2);
937 }else{ $max=1;}
938 echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
939 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
940 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
941 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
942 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
943 echo "</td>"; //la riga viene chiusa nel ciclo for
944 for ($i=1;$i<=$max;$i++){
945 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
946 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
947 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
948 if ($genere==0){
949 $query.=" and t2.num_gruppo=$i";
950 }
951 $result = mysql_query($query, $dbi);
952 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = mysql_fetch_row($result);
953 $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ", $dbi);
954 $resril = mysql_query("select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
955 list($numril)=mysql_fetch_row($resril);
956 if ($res2)
957 list($gruppo)= mysql_fetch_row($res2);
958 else
959 $gruppo=0;
960 if (!$gruppo>0) {
961 $gruppo=$i;
962 $res3 = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons", $dbi);
963 if ($res3)
964 list($id_gruppo)=mysql_fetch_row($res3);
965 }
966 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
967 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
968 $precede[$id_gruppo]=$voti_t;
969 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
970 echo "</tr><tr style=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
971 }else{
972 echo "</tr><tr class=\"tr-dx\">";
973 }
974 if ($genere==0){ // e' un referendum
975 echo "<td align=\"center\">$gruppo</td>";
976 }
977
978 list ($anno,$mese,$di)=explode('-',$giorno);
979 echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
980 if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\">";
981 else echo "<td align=\"center\">";
982 if ($y<$num and $vismf==0 and $voti_u==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
983 echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
984 if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\">";
985 else echo "<td align=\"center\">";
986 if ($y<$num and $vismf==0 and $voti_d==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
987 echo " name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
988 if ($voti_t > ($maschi+$femmine)) echo "<td align=\"center\" bgcolor=\"red\"><input type=\"text\" name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
989 else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
990 echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
991 ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
992 ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
993 ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
994 echo "</td>";
995 }
996 if (chisei($id_cons_gen)>=64 and $y==$numril) echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"></td>";
997 else echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"></td>";
998 echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td>";
999 echo "</tr>";
1000
1001
1002
1003# echo "</table></form></td></tr>";
1004 echo "</table></form>";
1005 $compl= mysql_query("select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez", $dbi);
1006 list ($complessivi)= mysql_fetch_row($compl);
1007 if (!$complessivi)
1008 {
1009 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1010 if ($y==$num) {
1011 echo "document.votanti$y.voti_u1.focus()\n";
1012 echo "document.votanti$y.voti_u1.select()\n";
1013 }else{
1014 echo "document.votanti$y.voti_t1.focus()\n";
1015 echo "document.votanti$y.voti_t1.select()\n";
1016 }
1017 echo "//-->\n"
1018 ."</script>\n";
1019 break;
1020 }
1021 echo "</td></tr>";
1022 }
1023CloseTable();
1024}
1025
1026
1027///////////////////////////
1028// registra i votanti
1029///////////////////////////
1030
1031function rec_add_votanti() {
1032global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
1033//ordine dei parametri: 0)op 1)voti_u 2) voti_d 3)voti_t 4)id_cons 5)id_sez 6)id_circ 7)id_sede
1034// 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
1035if ($fileout) while (!$fp = fopen($fileout,"a"));
1036
1037$username="$aid";
1038$arg2 = func_get_args();
1039$arg = split(",",$arg2[0]);
1040$id_cons_gen=intval($arg[1]);
1041$id_sez=intval($arg[2]);
1042$id_circ=intval($arg[3]);
1043$id_sede=intval($arg[4]);
1044$op=$arg[count($arg)-2];
1045for($i=5;$i< count($arg)-2;) {
1046 $voti_u = intval($arg[$i++]);
1047 $voti_d = intval($arg[$i++]);
1048 $voti_t = intval($arg[$i++]);
1049 if($voti_t==0) $voti_t=$voti_d+$voti_u;
1050 $id_parz = intval($arg[$i++]);
1051 $giorno = $arg[$i++];
1052 $ora = $arg[$i++];
1053 $id_gruppo = intval($arg[$i++]);
1054 $data=date("Y/m/d");
1055 $tempo=date("H:i:s");
1056 mysql_query("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1057 $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
1058 if ($genere==0){
1059 $query.=" and id_gruppo=$id_gruppo";
1060 }
1061 $res=mysql_query("$query",$dbi);
1062 $righe=mysql_num_rows($res);
1063 if (!$righe){
1064 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')", $dbi);
1065 mysql_query("insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo')", $dbi);
1066 if ($fileout) fwrite($fp,"insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo');\n");
1067 } elseif($op=="true"){
1068 $result = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'", $dbi);
1069 if ($fileout) fwrite($fp,"delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz';\n");
1070 } else {
1071 $res=mysql_query("select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz",$dbi);
1072 $ar=mysql_fetch_array($res);
1073
1074 if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){
1075 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','ora:$ar[3] data:$ar[4] voti uomini:$ar[5] donne:$ar[6] totali:$ar[7] gruppo:$ar[8]','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')", $dbi);
1076 $result = mysql_query("update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz'", $dbi);
1077 if ($fileout) fwrite($fp,"update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz';\n");
1078 }
1079 }
1080 }
1081if ($fileout)fclose($fp);
1082Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&ops=1&do=spoglio");
1083}
1084
1085
1086
1087function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1088 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
1089////////////////////////////////////////////
1090// da qua va la sezione per i voti finali
1091///////////////////////////////////////////
1092$bgcolor1="#7777ff";
1093$bgcolor2=$_SESSION['bgcolor2'];
1094
1095
1096
1097 echo "<form name=\"spogliovoti\" action=\"admin.php\">"
1098 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
1099 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1100 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1101 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1102 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1103
1104 echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
1105/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1106 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
1107 else */
1108 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
1109 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
1110 ."<td><b>"._BIANCHI."</b></td>"
1111 ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
1112 ."<td><b>"._CONTESTATI."</b></td>"
1113 ."<td><b>"._TOTNON."</b></td>"
1114 ."<td><b>"._TOTALEVOTI."</b></td>"
1115 ."<td bgcolor=\"#ffffff\"></td> </tr>";
1116/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1117 $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' ", $dbi);
1118else */
1119 $result = mysql_query("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' ", $dbi);
1120 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = mysql_fetch_row($result);
1121 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
1122 $tot_voti=$validi+$tot_nulli+$sg+$conts+$nullis+$sololista;
1123// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
1124
1125
1126 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
1127/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
1128 echo "</td><td>$nulli"
1129 ."</td><td>$bianchi";
1130 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
1131 }else{ */
1132 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
1133 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
1134// }
1135 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
1136 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
1137 ."</td><td>$tot_nulli"
1138 ."</td><td>$tot_voti</td><td>"
1139// ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
1140 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
1141 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
1142 ."</td></tr></table></form>"; //</td></tr>";
1143
1144
1145// echo "</table>";
1146 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1147 if (!$validi) {
1148 echo "document.spogliovoti.validi.focus()\n";
1149 echo "document.spogliovoti.validi.select()\n";
1150 }
1151 echo "//-->\n"
1152 ."</script>\n";
1153
1154
1155 }
1156
1157
1158
1159
1160
1161
1162///////////////////////////
1163// registra voti finali
1164///////////////////////////
1165
1166function rec_finale() {
1167global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
1168
1169if ($fileout) while (!$fp = fopen($fileout,"a"));
1170$arg2 = func_get_args();
1171$arg = split(",",$arg2[0]);
1172$id_cons_gen=intval($arg[1]);
1173$id_sez = intval($arg[2]);
1174$id_circ = intval($arg[3]);
1175$id_sede = intval($arg[4]);
1176$validi = intval($arg[5]);
1177$nulli = intval($arg[6]);
1178$bianchi = intval($arg[7]);
1179$votinulli = intval($arg[8]);
1180$contestati = intval($arg[9]);
1181//$sololista = intval($arg[10]);
1182$ops = $arg[10];
1183$username="$aid";
1184$log_data= date("Y/m/d");
1185$log_ora=getdate(time());
1186$orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
1187mysql_query("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1188
1189$result= mysql_query("select voti_complessivi from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' order by id_parz desc", $dbi);
1190list($voti_t) = mysql_fetch_row($result);
1191 $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
1192$sololista=$voti_t-$tot_voti;
1193 $result= mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
1194 $ar=mysql_fetch_array($result);
1195 if ($ar['solo_lista'] or !isdisgiunto()) $rigasl=''; else $rigasl=", solo_lista='$sololista'";
1196#die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
1197 if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
1198 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] contestati_lista:$ar[15] voti_nulli_lista:$ar[16]','validi_lista=$validi, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')", $dbi);
1199
1200/* $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
1201 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez';\n"); */
1202 $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
1203 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez';\n");
1204 }else{
1205 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')", $dbi);
1206 $valista="";
1207 if ($ar['validi_lista']){
1208 $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista']+$ar['solo_lista'];
1209 $valista=",validi_lista='$tvalista'";
1210 }
1211
1212 $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $rigasl $valista where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
1213 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $rigasl $valista where id_cons='$id_cons' and id_sez='$id_sez';\n");
1214 }
1215// }
1216// Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
1217 if ($fileout) fclose($fp);
1218 Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
1219
1220/*}else{
1221
1222echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
1223echo "<hr><a href=\"admin.php?op=voti&amp;id_cons=$id_cons&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;do=spoglio&amp;ops=$ops\">Torna e correggi i dati immessi</a></center>";
1224}*/
1225}
1226
1227
1228function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1229 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo;
1230////////////////////////////////////////////
1231// da qua va la sezione per le preferenze ai gruppi
1232///////////////////////////////////////////
1233// Controllo immmissioni
1234$bgcolor1="#7777ff";
1235$bgcolor2=$_SESSION['bgcolor2'];
1236 $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
1237 $max = mysql_num_rows($res);
1238 $max = $max-1;
1239 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1240 if ($genere==0) {
1241 echo "document.sezioni.si1.focus()\n";
1242 echo "document.sezioni.si1.select()\n";
1243 } else {
1244 echo "document.sezioni.voti1.focus()\n"
1245 ."document.sezioni.voti1.select()\n";
1246 }
1247 echo "//-->\n"
1248 ."</script>\n";
1249// tabella votanti
1250 if ($genere!=0){
1251 $result = mysql_query("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", $dbi);
1252 list( $voti_u, $voti_d, $voti_t) = mysql_fetch_row($result);
1253 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
1254 ."<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>"
1255 ."<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>";
1256 echo "</table>";
1257 }
1258 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\"><tr>";
1259 if ($genere==0){
1260 $res = mysql_query("SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
1261 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = mysql_fetch_row($res)){
1262 if ($voti_parz!=$validi){
1263 $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ", $dbi);
1264 list($num_gruppo) = mysql_fetch_row($res2);
1265 echo "<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>";
1266 }
1267 $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
1268 list($tot) = mysql_fetch_row($res2);
1269 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
1270 $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
1271 list($num_gruppo) = mysql_fetch_row($res2);
1272 echo "<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>";
1273 }
1274 }
1275 }else{
1276 $res = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1277 list($voti_parz) = mysql_fetch_row($res);
1278 $res = mysql_query("SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1279 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = mysql_fetch_row($res);
1280 if ($voti_parz!=$validi and $voti_parz>0){
1281 echo "<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."</b><br></td>";
1282 }
1283 $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1284 list($tot) = mysql_fetch_row($res2);
1285 if ($validi+$nulli+$bianchi+$contestati+$votinulli+$solo_lista!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
1286 echo "<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>";
1287 }
1288 }
1289 if(!isset($votinulli)) $votinulli=0;
1290 echo "<td></td></tr></table>";
1291 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1292 echo "<table class=\"table-menu\" style=\"width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"admin.php\">";
1293 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
1294 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1295 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1296 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1297 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1298 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1299 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1300 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1301 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1302 if ($genere==0){
1303 echo "<td><b>"._SI."</b></td>"
1304 ."<td><b>"._NO."</b></td>"
1305 ."<td><b>"._VALIDI."</b></td>"
1306 ."<td><b>"._BIANCHI."</b></td>"
1307 ."<td><b>"._CONTESTATI."</b></td>"
1308 ."<td><b>"._NULLI."</b></td>"
1309 ."<td><b>"._TOTNON."</b></td>";
1310 }else{
1311 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1312 }
1313 echo "</tr>";
1314 $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
1315 $max = mysql_num_rows($res);
1316 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1317 $result = mysql_query("select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ", $dbi);
1318 $i=1;
1319 $tot_pref=0;
1320
1321 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = mysql_fetch_row($result)){
1322
1323 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1324
1325
1326 if ($num_gruppo != ''){
1327 if ($genere==0){
1328 $res = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
1329 list($tot) = mysql_fetch_row($res);
1330 $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
1331 $pro= mysql_fetch_array($res, 3);
1332
1333 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)){
1334 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
1335 }else{
1336 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
1337 }
1338 $descr = explode('.',$descr_gruppo, 100);
1339 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1340 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
1341 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
1342 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
1343 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
1344 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
1345 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
1346 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
1347 $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
1348 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\"></td>";
1349 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\"></td>";
1350 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
1351 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
1352 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
1353 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
1354 echo "</td><td align=\"right\">$tot_nulli</td>";
1355 }else{
1356 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
1357 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
1358 $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
1359 $pro= mysql_fetch_array($res, 3);
1360 echo "</td><td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
1361 $tot_pref += $pro['voti'];
1362 }
1363
1364 $i++;
1365 }
1366
1367 }
1368 if ($genere!=0) {
1369 $res = mysql_query("SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ", $dbi);
1370 list($sololis)=mysql_fetch_row($res);
1371 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td></tr>";
1372 if(isdisgiunto())
1373 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>";
1374 }
1375
1376 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
1377
1378 echo "</tr></table></form></td></tr>";
1379 if(chisei($id_cons_gen)>=64){
1380 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
1381 }
1382
1383 echo "</td></tr></table>";
1384 }
1385 if ($genere!=0){
1386 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1387 }
1388}
1389
1390
1391
1392
1393
1394
1395///////////////////////////
1396// registra le preferenze ai gruppi
1397///////////////////////////
1398
1399function rec_voti_gruppi() {
1400global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout;
1401if ($fileout) while (!$fp = fopen($fileout,"a"));
1402$username="$aid";
1403$log_data= date("Y/m/d");
1404$log_ora=getdate(time());
1405$arg2 = func_get_args();
1406$arg = split(",",$arg2[0]);
1407$id_cons_gen=intval($arg[1]);
1408$id_sez = intval($arg[2]);
1409$id_circ = intval($arg[3]);
1410$id_sede = intval($arg[4]);
1411$do = intval($arg[5]);
1412$y=count($arg)-1;
1413 mysql_query("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1414 if($do==1) {
1415 mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1416 mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1417 mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1418 mysql_query("update ".$prefix."_ele_sezioni set validi_lista='',contestati_lista='',voti_nulli_lista='',solo_gruppo='',solo_lista='' where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
1419
1420 }else{
1421
1422if ($genere==0) {
1423 $tab="_ele_voti_ref";
1424} else {
1425 $tab="_ele_voti_gruppo";
1426 $y--;
1427 if(isdisgiunto())
1428 $res=mysql_query("update ".$prefix."_ele_sezioni set solo_lista='".$arg[$y--]."' where id_sez='$id_sez'", $dbi);
1429
1430}
1431
1432for($i=6;$i< $y;) {
1433 $id_gruppo = intval($arg[$i++]);
1434 $testval=0;
1435 switch ($genere){
1436 case (0):
1437 if($arg[$i].$arg[$i+1]=='' ) {
1438 $i+=6;
1439 $testval=1;
1440 }else{
1441 $si=intval($arg[$i++]);
1442 $no=intval($arg[$i++]);
1443 $val=intval($arg[$i++]);
1444 if ($val==0){$val=$si+$no;}
1445 $bia=intval($arg[$i++]);
1446 $con=intval($arg[$i++]);
1447 $nul=intval($arg[$i++]);
1448 $voti = "'$si','$no','$val','$nul','$bia','$con'";
1449 $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
1450 }
1451 break;
1452 default:
1453 $voti = intval($arg[$i++]);
1454 if (!$voti) {$voti="0";}
1455 $riga="voti=$voti";
1456 break;
1457 }
1458 if($testval) continue;
1459 $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
1460 $ar=mysql_fetch_array($result);
1461 $res = mysql_query("select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
1462 list($num_gruppo)=mysql_fetch_array($res);
1463 $oldval='';
1464 if ($ar){
1465 switch ($genere){
1466 case (0):
1467 if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
1468 or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
1469 $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
1470 }
1471 break;
1472 default:
1473 if ($ar['voti']!=$voti) {
1474 $oldval="voti:".$ar['voti'];
1475 $voti.=",null";
1476 }
1477 if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
1478 break;
1479 }
1480 if ($oldval) {
1481 mysql_query("update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
1482 if ($fileout) fwrite($fp,"update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo';\n");
1483 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','$oldval','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
1484 }
1485 } else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)");
1486 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
1487 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)", $dbi);
1488 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti);\n");
1489 //
1490 }
1491
1492}
1493}
1494//$ops = $arg[$argc];
1495if ($fileout) fclose($fp);
1496Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=4");
1497
1498}
1499
1500
1501 if (!preg_match("/rec/",$op)) {
1502 ele(); //menu
1503/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
1504 numeri_sezione(8);
1505 echo "<td></td></tr></table>\n";*/
1506 echo"</td></tr></table>";
1507 }
1508
1509 switch ($op){
1510 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
1511# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1512 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
1513 break;
1514 default :
1515 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
1516 }
1517echo"</td></tr></table>";
1518 include ("footer.php");
1519?>
1520
Note: See TracBrowser for help on using the repository browser.