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

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

admin: perfezionamento della rev 216

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