1 | <?php
|
---|
2 |
|
---|
3 | /************************************************************************/
|
---|
4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
5 | /* by Roberto Gigli & Luciano Apolito */
|
---|
6 | /* http://www.eleonline.it */
|
---|
7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
8 | /************************************************************************/
|
---|
9 | /* Modulo Controllo dei voti */
|
---|
10 | /* Amministrazione */
|
---|
11 | /************************************************************************/
|
---|
12 |
|
---|
13 | if (!defined('ADMIN_FILE')) {
|
---|
14 | die ("You can't access this file directly...");
|
---|
15 | }
|
---|
16 |
|
---|
17 | $aid=$_SESSION['aid'];
|
---|
18 | $dbi=$_SESSION['dbi'];
|
---|
19 | $prefix=$_SESSION['prefix'];
|
---|
20 | $currentlang=$_SESSION['lang'];
|
---|
21 | $id_comune=$_SESSION['id_comune'];
|
---|
22 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
23 | $bgcolor1=$_SESSION['bgcolor1'];
|
---|
24 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
25 |
|
---|
26 | $perms=ChiSei($id_cons_gen);
|
---|
27 | if ($perms<16 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
28 | $res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
|
---|
29 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
30 | $res = mysql_query("SELECT genere,voto_g,voto_l FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
|
---|
31 | list($genere,$votog,$votol) = mysql_fetch_row($res);
|
---|
32 |
|
---|
33 | include("modules/Elezioni/funzionidata.php");
|
---|
34 | include("modules/Elezioni/ele.php");
|
---|
35 | if (! get_magic_quotes_gpc()) $magic='addslashes'; else $magic='';
|
---|
36 | if (isset($param['ops'])) get_magic_quotes_gpc() ? $ops=$param['ops']:$ops=addslashes($param['ops']); else $ops='';
|
---|
37 | if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
|
---|
38 | if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
|
---|
39 | if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
|
---|
40 | ele();
|
---|
41 | //**************************************************************************
|
---|
42 | // ELE
|
---|
43 | //**************************************************************************
|
---|
44 |
|
---|
45 | global $prefix, $dbi,$fascia,$limite;
|
---|
46 | $res = mysql_query("SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
|
---|
47 | list($totm,$totf) = mysql_fetch_row($res);
|
---|
48 | $totel=$totm+$totf;
|
---|
49 | if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina
|
---|
50 | if (!IsSet($num_ref)) {
|
---|
51 | $num_ref=1;
|
---|
52 | $resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
|
---|
53 | $num_refs= mysql_num_rows($resg); //quante pagine?
|
---|
54 | }
|
---|
55 | if((($genere!=4) and $pag==0 and !$votog) or $genere==1 or $genere==2){ //diverso da liste a piu' candidati
|
---|
56 | $ops=4; //gestione gruppi (anche liste uninominali)
|
---|
57 | }else{
|
---|
58 | $ops=3; //gestione liste
|
---|
59 | }
|
---|
60 | OpenTable();
|
---|
61 | $resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
|
---|
62 | list($idg,$numg) = mysql_fetch_row($resg);
|
---|
63 | $res = mysql_query("SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
|
---|
64 | $num_sez = mysql_num_rows($res); //quante sezioni?
|
---|
65 | for ($i=1;$i<=$num_sez;$i++){
|
---|
66 | $sezione[$i]=mysql_fetch_array($res, 3); //inizializza l'array delle sezioni
|
---|
67 | $ar[$i]=0;
|
---|
68 | }
|
---|
69 | $tab3="_ele_voti_lista";
|
---|
70 | // if ($genere==3) {$tab3="_ele_voti_candidati";} else {$tab3="_ele_voti_lista";} //i voti di lista per le uninominali sono memorizzati in ele_voti_candidati altrimenti in ele_voti_lista.
|
---|
71 | if ($genere==1 or $genere==2) $tab3="_ele_voti_gruppo";
|
---|
72 | if ($genere>0) { //se non e' un referendum
|
---|
73 | if (!($genere==4) and $pag==0){ //se non e' una lista uninominale ed e' la prima pagina
|
---|
74 | $tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0',t2.voti_nulli,t2.validi_lista,t2.voti_nulli_lista,t2.contestati_lista,t2.solo_gruppo,t2.solo_lista FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez order by t2.num_sez";
|
---|
75 |
|
---|
76 | }else{ // e' una lista uninominale o la seconda pagina
|
---|
77 | $tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli,t1.validi_lista,t1.voti_nulli_lista,t1.contestati_lista,t1.solo_gruppo,t1.solo_lista
|
---|
78 | FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
|
---|
79 | left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
|
---|
80 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez";
|
---|
81 | }
|
---|
82 | $riga1="<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZSCR." "._CONSULTAZIONE."</td></tr></table></td></tr>\n";
|
---|
83 | }else{ // e' un referendum
|
---|
84 | $tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo,'0','0','0','0','0','0'
|
---|
85 | FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
|
---|
86 | left join ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
|
---|
87 | where t1.id_cons='$id_cons' and t1.id_gruppo='$idg' order by t2.num_sez";
|
---|
88 | $riga1= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZSCR." "._CONSULTAZIONE." N. ".$numg."</td></tr></table></td></tr>\n";
|
---|
89 | }
|
---|
90 | $res = mysql_query("$tab ", $dbi);
|
---|
91 | $num_scr = mysql_num_rows($res);
|
---|
92 | $riga2= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZIONI." $num_scr "._SU." $num_sez</td></tr></table></td></tr>\n";//sezioni scrutinate
|
---|
93 | $riga2 .= "<tr><td>\n<table border=\"0\" width=\"100%\" align=\"center\">";
|
---|
94 | $riga3 = "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td>"
|
---|
95 | ."<td><b>"._VOTIU."</b></td>"."<td><b>"._VOTID."</b></td>"."<td><b>"._VOTIE."</b></td>"; //testata con nomi dei campi
|
---|
96 | if ($genere==0) { //se e' un referendum
|
---|
97 | $riga3 .= "<td><b>"._SI."</b></td><td><b>"._NO."</b></td>";
|
---|
98 | } elseif ((($genere==5) or ($genere==3)) and $pag==1){
|
---|
99 | $riga3 .= "<td><b>"._ASOLA_LISTA."</b></td>";
|
---|
100 | if (!$votog) $riga3 .= "<td><b>"._ASOLO_GRUPPO."</b></td>";
|
---|
101 | }
|
---|
102 | $riga3 .= "<td><b>"._VALIDI."</b></td><td><b>"._NULLI."</b></td><td><b>"._BIANCHI."</b></td><td><b>"._CONTESTATI."</b></td>";
|
---|
103 | // if (($genere==2 or $genere==3 or $genere==5) and !$votog)
|
---|
104 | // $riga3 .= "<td><b>"._PREFGRU."</b></td>";
|
---|
105 | // if ($genere>1 and !$votol)
|
---|
106 | // $riga3 .= "<td><b>"._PREFLIS."</b></td>";
|
---|
107 | $riga3 .= "<td><b>"._STATO."</b></td></tr>\n";
|
---|
108 | $res = mysql_query("$tab ", $dbi);//die($tab);
|
---|
109 | $num_scr = mysql_num_rows($res);
|
---|
110 | $righe= "";
|
---|
111 | $scrutinate=1;
|
---|
112 | // if ($genere>1 and $pag==1) $ops=3;
|
---|
113 | $tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;$tgrup_pref=0;$tot_voti_nulli=0;$tot_val_lista=0;$tot_vot_nul_lis=0;$tot_cont_lis=0;$tot_solog=0;$tot_solol=0;$errors=0;
|
---|
114 | while (list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$voti_nulli,$val_lista,$vot_nul_lis,$cont_lis,$solog,$solol) = mysql_fetch_row($res)){
|
---|
115 | // inserimento numeri di sez non scrutinate
|
---|
116 | while ($scrutinate < $num) {
|
---|
117 | $righe.= "<tr align=\"center\"><td><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=".$sezione[$scrutinate]['id_sez']."&id_circ=".$sezione[$scrutinate]['id_circ']."&id_sede=".$sezione[$scrutinate]['id_sede']."&do=spoglio&ops=$ops\"><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></a></td></tr>\n";
|
---|
118 | $scrutinate++;
|
---|
119 | }
|
---|
120 | $scrutinate++;
|
---|
121 | // fine inserimento
|
---|
122 | if (($genere==2 or $genere==3 or $genere==5) and !$votog) {
|
---|
123 | $respref = mysql_query("select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id'", $dbi);
|
---|
124 | list ($gruppref) = mysql_fetch_row($respref);
|
---|
125 | $tgrup_pref += $gruppref;
|
---|
126 | }
|
---|
127 | $tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
|
---|
128 | if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
|
---|
129 | $res2 = mysql_query($tab2, $dbi);
|
---|
130 | list($votid,$votiu,$voti) = mysql_fetch_row($res2);
|
---|
131 | // $voti=$votiu+$votid;
|
---|
132 |
|
---|
133 | $tot_u+=$votiu;
|
---|
134 | $tot_d+=$votid;
|
---|
135 | $tot_voti+=$voti;
|
---|
136 | $tot_si+=$si;
|
---|
137 | $tot_no+=$no;
|
---|
138 | $tot_validi+=$validi;
|
---|
139 | $tot_nulli+=$nulli;
|
---|
140 | $tot_bianchi+=$bianchi;
|
---|
141 | $tot_contestati+=$contestati;
|
---|
142 | $tot_voti_nulli+=$voti_nulli;
|
---|
143 | $tot_val_lista+=$val_lista;
|
---|
144 | $tot_vot_nul_lis+=$vot_nul_lis;
|
---|
145 | $tot_cont_lis+=$cont_lis;
|
---|
146 | $tot_solog+=$solog;
|
---|
147 | $tot_solol+=$solol;
|
---|
148 | $righe .= "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td>$num</td><td>".number_format($votiu,0,',','.')."</td><td>".number_format($votid,0,',','.')."</td><td>".number_format($voti,0,',','.')."</td>";
|
---|
149 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righe .= "<td>".number_format($si,0,',','.')."</td>";}
|
---|
150 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1 and !$votog)){$righe .= "<td>".number_format($no,0,',','.')."</td>";}
|
---|
151 | $righe .= "<td>".number_format($validi,0,',','.')."</td><td>$nulli</td><td>$bianchi</td><td>$contestati</td>";
|
---|
152 | $g_err=0;
|
---|
153 | if (($genere==2 or $genere==3 or $genere==5) and $pag==1 and !$votog) {
|
---|
154 | if ($gruppref!=$validi) {
|
---|
155 | $g_err=1;
|
---|
156 | $ops=4;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | $controllo1=$validi+$nulli+$bianchi+$contestati+$voti_nulli+$solol; #prova
|
---|
160 | $controllo2=$si+$no;
|
---|
161 | if($genere==5 and !$votog) #$validi+$nulli+$bianchi+$vcont+$vn
|
---|
162 | if($pag==0 and !$votog or $fascia<=$limite) {$controllo1=$validi+$nulli+$bianchi+$contestati+$voti_nulli+$solol;} else { $controllo1=$val_lista+$nulli+$bianchi+$contestati+$voti_nulli+$cont_lis+$vot_nul_lis+$solog;$controllo2=$si+$no-$solol+$cont_lis+$vot_nul_lis;}
|
---|
163 | if ($voti==$controllo1 and $validi==$controllo2 and !$g_err){
|
---|
164 | $righe .= "<td>"._OK."</td></tr>\n";
|
---|
165 | }else{
|
---|
166 | $righe .= "<td><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=$id&id_circ=$id_circ&id_sede=$id_sede&do=spoglio&ops=$ops\"><span style=\"color: rgb(255, 0, 0);\">"._ERRORE."</span></a></td></tr>\n";$errors=1;
|
---|
167 | if ($ops==4) $ops=3;
|
---|
168 | }
|
---|
169 | }
|
---|
170 | if ($num<$num_sez) {
|
---|
171 | for (;$scrutinate<=$num_sez;$scrutinate++) {
|
---|
172 | $righe .= "<tr align=\"center\"><td><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=".$sezione[$scrutinate]['id_sez']."&id_circ=".$sezione[$scrutinate]['id_circ']."&id_sede=".$sezione[$scrutinate]['id_sede']."&do=spoglio&ops=$ops\"><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>\n";
|
---|
173 | }
|
---|
174 | }
|
---|
175 | if($num_scr){
|
---|
176 | $righet = "<tr align=\"center\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br><i>(".number_format($tot_u*100/$totm,2)." %)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br><i>(".number_format($tot_d*100/$totf,2)." %)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br><i>(".number_format($tot_voti*100/$totel,2)." %)</i></td>";
|
---|
177 | // se e' un referendum o una consultazione con raggruppamenti
|
---|
178 | if($tot_validi){
|
---|
179 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br><i>(".number_format($tot_si*100/$tot_validi,2)." %)</i></td>";}
|
---|
180 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1 and !$votog)){$righet .= "<td><b>".number_format($tot_no,0,',','.')."</b><br><i>(".number_format($tot_no*100/$tot_validi,2)." %)</i></td>";}
|
---|
181 | $righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br><i>(".number_format($tot_validi*100/$tot_voti,2)." %)</i></td><td><b>"
|
---|
182 | .number_format($tot_nulli,0,',','.')."</b><br><i>(".number_format($tot_nulli*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br><i>(".number_format($tot_bianchi*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br><i>(".number_format($tot_contestati*100/$tot_voti,2)." %)</i></td>";
|
---|
183 | }else{
|
---|
184 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br><i>(0.00 %)</i></td>";}
|
---|
185 | if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1 and !$votog)){$righet .= "<td><b>".number_format($tot_no,0,',','.')."</b><br><i>(0.00 %)</i></td>";}
|
---|
186 | $righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br><i>(0.00 %)</i></td><td><b>"
|
---|
187 | .number_format($tot_nulli,0,',','.')."</b><br><i>(".number_format($tot_nulli*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br><i>(".number_format($tot_bianchi*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br><i>(".number_format($tot_contestati*100/$tot_voti,2)." %)</i></td>";
|
---|
188 | }
|
---|
189 | $g_err=0;
|
---|
190 | if (($genere==2 or $genere==3 or $genere==5) and $pag==1 and !$votog) {
|
---|
191 | if ($tgrup_pref!=$tot_validi) {
|
---|
192 | $g_err=1;
|
---|
193 | }
|
---|
194 | }
|
---|
195 | # if ($tot_voti==$tot_validi+$tot_nulli+$tot_bianchi+$tot_contestati and
|
---|
196 | # $tot_validi==$tot_si+$tot_no and !$g_err) {
|
---|
197 | if (! $errors) {
|
---|
198 | $righet .= "<td>"._OK."</td></tr>\n";
|
---|
199 | }else{
|
---|
200 | $righet .= "<td><span style=\"color: rgb(255, 0, 0);\">"._ERRORE."</span></td></tr>\n";
|
---|
201 | }
|
---|
202 | }else $righet='';
|
---|
203 | //$righe .= "</table></td></tr>\n";
|
---|
204 |
|
---|
205 | echo "$riga1";
|
---|
206 | echo $riga2;
|
---|
207 | echo $righet;
|
---|
208 | echo $riga3;
|
---|
209 | echo $righe;
|
---|
210 | CloseTable();
|
---|
211 |
|
---|
212 | echo"<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>\n";
|
---|
213 | if($genere==0){ //se e' referendum
|
---|
214 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
215 | $cur=$num_ref;
|
---|
216 | if ($cur>1) {
|
---|
217 | $num_ref--;
|
---|
218 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_voti&id_cons_gen=$id_cons_gen&num_ref=$num_ref&num_refs=$num_refs\">";
|
---|
219 | echo "<b>"._PREV_MATCH."</b></a></td>";
|
---|
220 | }
|
---|
221 | if ($cur<$num_refs) {
|
---|
222 | $cur++;
|
---|
223 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_voti&id_cons_gen=$id_cons_gen&num_ref=$cur&num_refs=$num_refs\">";
|
---|
224 | echo "<b>"._NEXT_MATCH."</b></a></td>";
|
---|
225 | }
|
---|
226 | }elseif(($genere==5 and $fascia>=$limite) or ($genere==3) or ($genere==2) or $genere==1){ //se vi sono raggruppamenti
|
---|
227 | $pag=($pag==0 ? 1:0);
|
---|
228 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_voti&id_cons_gen=$id_cons_gen&pag=$pag\"><b>";
|
---|
229 | if($pag) echo _CONTR_PREF;
|
---|
230 | else echo _CONTR_ESPR;
|
---|
231 | echo "</b></a></td>";
|
---|
232 |
|
---|
233 | }/* elseif ($genere==1){
|
---|
234 | $pag=($pag==0 ? 1:0);
|
---|
235 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_voti&id_cons_gen=$id_cons_gen&pag=$pag\"><b>";
|
---|
236 | if($pag) echo _CONTR_GRUP;
|
---|
237 | else echo _CONTR_ESPR;
|
---|
238 | echo "</b></a></td>";
|
---|
239 | }*/
|
---|
240 | echo "</tr></table><br>\n";
|
---|
241 | echo "</table>\n</td></tr></table>\n";
|
---|
242 |
|
---|
243 | include ("footer.php");
|
---|
244 |
|
---|
245 | ?>
|
---|