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

Last change on this file since 22 was 2, checked in by root, 15 years ago

importo il progetto

File size: 8.9 KB
RevLine 
[2]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 $resril = mysql_query("SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
88 $num_ril= mysql_num_rows($resril); //numero delle rilevazioni previste
89 echo "\n<table border=\"0\" width=\"100%\" align=\"center\">";
90 echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
91 $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);
92 while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
93 $perc_u='';$perc_d='';$perc_c='';
94 if($votiu or $votid)
95 {
96 $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";
97 $perc_u=number_format($votiu*100/$tot_u,2);
98 $perc_d=number_format($votid*100/$tot_d,2);
99 $perc_c=number_format($somma*100/$tot_compl,2);
100 }
101 else
102 $tot[$data.$ora]=$somma;
103 }
104 $ud=0;$ora_rif="";
105 while (list($data1,$ora1) = mysql_fetch_row($resril))
106 {
107 $ud++;
108 list($hour, $minute, $second) = explode(":", $ora1);
109 $ora_ril=$hour.":".$minute;
110 echo "<td";
111 if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
112 echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
113 $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);
114 list($num_scr) = mysql_fetch_row($resaff); //numero delle sezioni inserite
115 echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
116 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";
117
118 echo "</td>";
119// $ar['riga1'][$data1.$ora1]="<hr>";
120 if (isset($tot[$data1.$ora1])){
121 if ($ora_rif=="$data1.$ora1")
122 {
123 $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";
124 $ar[0][$data1.$ora1]=$tot[$data1.$ora1];
125 }
126 else
127 {
128 $ar['perc'][$data1.$ora1]="<i>".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i>";
129 $ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
130 }
131// $ar['riga2'][$data1.$ora1]="<hr>";
132 if (intval(ereg("[1-9]",$tot[$data1.$ora1]))>0) {
133 for ($i=1;$i<=$num_sez;$i++)
134 {
135 $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>";
136 }
137 }
138 }
139 }
140 $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);
141 $ud=0;
142 while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
143 if ($ora_rif=="$data.$ora")
144 $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";
145 else
146 $ar[$numsez][$data.$ora]=$complessivi;
147 if ($uomini+$donne>0) {
148 if ($uomini+$donne!=$complessivi) {
149 $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>";
150 } else {
151 $ar[$numsez]['controllo']= "OK";
152 }
153 }
154 }
155 echo "<td><b>"._STATO."</b></td></tr>\n";
156
157 foreach ($ar as $i => $arr) {
158 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\">";
159 foreach ($arr as $valore)
160 {
161
162 echo "<td >$valore</td>";
163 }
164 echo "</tr>\n";
165 }
166
167
168
169
170 if($genere==0){ //se e' referendum
171 #'Pagina precedente' e 'Pagina Successiva'
172 echo "\n<table width=\"100%\"><tr align=middle>";
173 $cur=$num_ref;
174 if ($cur>1) {
175 $num_ref--;
176 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\">";
177 echo "<b>"._PREV_MATCH."</b></a></td>";
178 }
179 if ($cur<$num_refs) {
180 $cur++;
181 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\">";
182 echo "<b>"._NEXT_MATCH."</b></a></td>";
183 }
184 echo "</tr></table>\n";
185 }
186
187 echo "</table>\n<br>\n";
188
189 echo "</table>\n";
190 include ("footer.php");
191
192?>
Note: See TracBrowser for help on using the repository browser.