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

Last change on this file since 217 was 217, checked in by roby, 11 years ago

admin: perfezionamento della rev 216

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