source: trunk/admin/modules/Elezioni/controllo_votanti.php@ 253

Last change on this file since 253 was 64, checked in by roby, 15 years ago

icorretto calcolo percentuali in visualizzazione riepilogo voti (da completare con arrotondamento percentuali) + vari aggiustamenti

File size: 9.2 KB
Line 
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 votanti */
10/* Amministrazione */
11/************************************************************************/
12
13if (!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$bgcolor0=$_SESSION['bgcolor1'];
24$perms=ChiSei($id_cons_gen);
25if ($perms<16 or !$id_cons_gen) die("$perms ".$_SESSION['id_comune'].$_SESSION['aid'].";Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
26$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);
27list($tipo_cons,$id_cons) = mysql_fetch_row($res);
28$res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
29 list($genere) = mysql_fetch_row($res);
30if (isset($param['ops'])) get_magic_quotes_gpc() ? $ops=$param['ops']:$ops=addslashes($param['ops']); else $ops='';
31if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
32if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
33if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
34
35include("modules/Elezioni/funzionidata.php");
36include("modules/Elezioni/ele.php");
37// echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
38// ."//-->\n";
39// echo "function com_pref(testo) {\n";
40// echo "window2=open(testo,\"test di apertura\")\n";
41// echo "}\n";
42// echo "</script>\n";
43
44ele();
45//**************************************************************************
46// ELE
47//**************************************************************************
48
49 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $genere, $id_gruppo;
50
51 $cond='';
52 if ($genere==0) {
53 if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina
54 if (!IsSet($num_ref)) {
55 $num_ref=1;
56 $resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
57 $num_refs= mysql_num_rows($resg); //quante pagine?
58 }
59 $resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
60 list($idg,$numg) = mysql_fetch_row($resg);
61 $id_gruppo=$idg;
62 $cond= "and id_gruppo=$id_gruppo";
63 echo "\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._CONSULTAZIONE." N. ".$numg."</td></tr></table>\n<hr>";
64 }
65 $i=1;
66 $res = mysql_query("SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori 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);
67 while ($linka[$i++] = mysql_fetch_array($res));
68 $num_sez = mysql_num_rows($res); //numero totale delle sezioni
69 $tot_compl=0;$tot_u=0;$tot_d=0;
70// $ar['riga1'][0]="<hr>";
71 $ar[0][0]="<b>"._TOTS."</b>";
72 $ar['perc'][0]=_PERC;
73// $ar['riga2'][0]="<hr>";
74 for ($i=1;$i<=$num_sez;$i++)
75 {
76 $ar[$i]['numsez']=$i;
77 $ar[$i]['elettori']=number_format($linka[$i]['elettori'],0,',','.');
78 $tot_compl+=$linka[$i]['elettori'];
79 $tot_u+=$linka[$i]['maschi'];
80 $tot_d+=$linka[$i]['femmine'];
81
82 }
83 $ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
84// $ar['riga1'][1]="<hr>";
85 $ar['perc'][1]=" ";
86// $ar['riga2'][1]="<hr>";
87 $resuo = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
88 list($ultora,$ultdata)=mysql_fetch_row($resuo);
89
90 $resril = mysql_query("SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
91 $num_ril= mysql_num_rows($resril); //numero delle rilevazioni previste
92 echo "\n<table border=\"0\" width=\"100%\" align=\"center\">";
93 echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
94 $ressomma = mysql_query("SELECT data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario", $dbi);
95 while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
96 $perc_u='';$perc_d='';$perc_c='';
97# if($votiu or $votid)
98 if(($data==$ultdata) and ($ora==$ultora))
99 {
100 $tot[$data.$ora]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\"><b>".number_format($votiu,0,',','.')."</b></td><td width=\"30%\"><b>".number_format($votid,0,',','.')."</b></td><td><b>".number_format($somma,0,',','.')."</b></td></tr></table>\n";
101 if($tot_u) $perc_u=number_format($votiu*100/$tot_u,2);
102 if($tot_d) $perc_d=number_format($votid*100/$tot_d,2);
103 $perc_c=number_format($somma*100/$tot_compl,2);
104 }
105 else
106 $tot[$data.$ora]=$somma;
107 }
108 $ud=0;$ora_rif="";
109 while (list($data1,$ora1) = mysql_fetch_row($resril))
110 {
111 $ud++;
112 list($hour, $minute, $second) = explode(":", $ora1);
113 $ora_ril=$hour.":".$minute;
114 echo "<td";
115 if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
116 echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
117 $resaff = mysql_query("SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond", $dbi);
118 list($num_scr) = mysql_fetch_row($resaff); //numero delle sezioni inserite
119 echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
120 if ($ud==$num_ril) echo "<br>\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">"._UOMINI."</td><td width=\"30%\">"._DONNE."</td><td>"._COMPLESSIVI."</td></tr></table>\n";
121
122 echo "</td>";
123// $ar['riga1'][$data1.$ora1]="<hr>";
124 if (isset($tot[$data1.$ora1])){
125 if ($ora_rif=="$data1.$ora1")
126 {
127 $ar['perc'][$data1.$ora1]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\"><i>$perc_u%</i></td><td width=\"30%\"><i>$perc_d%</i></td><td><i>$perc_c%</i></td></tr></table>\n";
128 $ar[0][$data1.$ora1]=$tot[$data1.$ora1];
129 }
130 else
131 {
132 $ar['perc'][$data1.$ora1]="<i>".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i>";
133 $ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
134 }
135// $ar['riga2'][$data1.$ora1]="<hr>";
136 if (intval(preg_match("/[1-9]/",$tot[$data1.$ora1]))>0) {
137 for ($i=1;$i<=$num_sez;$i++)
138 {
139 $ar[$i][$data1.$ora1]="<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=".$linka[$i]['id_sez']."&amp;id_circ=".$linka[$i]['id_circ']."&amp;id_sede=".$linka[$i]['id_sede']."&amp;do=spoglio&amp;ops=1\"><span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
140 }
141 }
142 }
143 }
144 $resvoti = mysql_query("SELECT data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez", $dbi);
145 $ud=0;
146 while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
147 if ($ora_rif=="$data.$ora")
148 $ar[$numsez][$data.$ora]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">$uomini</td><td width=\"30%\">$donne</td><td>$complessivi</td></tr></table>\n";
149 else
150 $ar[$numsez][$data.$ora]=$complessivi;
151 if ($uomini+$donne>0) {
152 if ($uomini+$donne!=$complessivi) {
153 $ar[$numsez]['controllo']= "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=".$linka[$numsez]['id_sez']."&amp;id_circ=".$linka[$numsez]['id_circ']."&amp;id_sede=".$linka[$numsez]['id_sede']."&amp;do=spoglio&amp;ops=1\"><span style=\"color: rgb(255, 0, 0);\">ERRORE</span></a>";
154 } else {
155 $ar[$numsez]['controllo']= "OK";
156 }
157 }
158 }
159 echo "<td><b>"._STATO."</b></td></tr>\n";
160
161 foreach ($ar as $i => $arr) {
162 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\">";
163 foreach ($arr as $valore)
164 {
165
166 echo "<td >$valore</td>";
167 }
168 echo "</tr>\n";
169 }
170
171
172
173
174 if($genere==0){ //se e' referendum
175 #'Pagina precedente' e 'Pagina Successiva'
176 echo "\n<table width=\"100%\"><tr align=middle>";
177 $cur=$num_ref;
178 if ($cur>1) {
179 $num_ref--;
180 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_votanti&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">";
181 echo "<b>"._PREV_MATCH."</b></a></td>";
182 }
183 if ($cur<$num_refs) {
184 $cur++;
185 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=controllo_votanti&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$cur&amp;num_refs=$num_refs\">";
186 echo "<b>"._NEXT_MATCH."</b></a></td>";
187 }
188 echo "</tr></table>\n";
189 }
190
191 echo "</table>\n<br>\n";
192
193 echo "</table>\n";
194 include ("footer.php");
195
196?>
Note: See TracBrowser for help on using the repository browser.