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

Last change on this file since 422 was 344, checked in by roby, 4 years ago

Segue modifiche per la compatibilità php7.x

File size: 9.7 KB
RevLine 
[331]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'];
18global $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
27 $sql="SELECT t1.descrizione,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'";
28 $sth = $dbi->prepare("$sql");
29 $sth->execute();
30 $row = $sth->fetch(PDO::FETCH_BOTH);
31$descr_consultazione=$row[0];
32$tipo_cons=$row[1];
33$id_cons=$row[2];
34 $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
35 $sth = $dbi->prepare("$sql");
36 $sth->execute();
37 $row = $sth->fetch(PDO::FETCH_BOTH);
38 $genere = $row[0];
[344]39if (isset($param['ops'])) $ops=addslashes($param['ops']); else $ops='';
[331]40if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
41if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
42if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
43
44include("modules/Elezioni/funzionidata.php");
45include("modules/Elezioni/ele.php");
46// echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
47// ."//-->\n";
48// echo "function com_pref(testo) {\n";
49// echo "window2=open(testo,\"test di apertura\")\n";
50// echo "}\n";
51// echo "</script>\n";
52
53ele();
54//**************************************************************************
55// ELE
56//**************************************************************************
57
58 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $genere, $id_gruppo;
59
60 $cond='';
61 if ($genere==0) {
62 if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina
63 if (!IsSet($num_ref)) {
64 $num_ref=1;
65 $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
66 $sth = $dbi->prepare("$sql");
67 $sth->execute();
68 $num_refs= $sth->rowCount(); //quante pagine?
69 }
70 $sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
71 $sth = $dbi->prepare("$sql");
72 $sth->execute();
73 $row = $sth->fetch(PDO::FETCH_BOTH);
74 $idg=$row[0];
75 $numg=$row[1];
76 $id_gruppo=$idg;
77 $cond= "and id_gruppo=$id_gruppo";
78 echo "\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._CONSULTAZIONE." N. ".$numg."</td></tr></table>\n<hr>";
79 }
80 $i=1;
81 $sql="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";
82 $sth = $dbi->prepare("$sql");
83 $sth->execute();
84 while ($linka[$i++] = $sth->fetch(PDO::FETCH_BOTH));
85 $num_sez = $sth->rowCount(); //numero totale delle sezioni
86 $tot_compl=0;$tot_u=0;$tot_d=0;
87// $ar['riga1'][0]="<hr>";
88 $ar[0][0]="<b>"._TOTS."</b>";
89 $ar['perc'][0]=_PERC;
90// $ar['riga2'][0]="<hr>";
91 for ($i=1;$i<=$num_sez;$i++)
92 {
93 $ar[$i]['numsez']=$i;
94 $ar[$i]['elettori']=number_format($linka[$i]['elettori'],0,',','.');
95 $tot_compl+=$linka[$i]['elettori'];
96 $tot_u+=$linka[$i]['maschi'];
97 $tot_d+=$linka[$i]['femmine'];
98
99 }
100 $ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
101// $ar['riga1'][1]="<hr>";
102 $ar['perc'][1]=" ";
103// $ar['riga2'][1]="<hr>";
104 $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
105 $sth = $dbi->prepare("$sql");
106 $sth->execute();
107 $row = $sth->fetch(PDO::FETCH_BOTH);
108 $ultora=$row[0];
109 $ultdata=$row[1];
110
111 $sql = "SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
112 $resril = $dbi->prepare("$sql");
113 $resril->execute();
114 $num_ril = $resril->rowCount(); //numero delle rilevazioni previste
115 echo "\n<table border=\"0\" width=\"100%\" align=\"center\">";
116 echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
117 $sql="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";
118 $sth = $dbi->prepare("$sql");
119 $sth->execute();
120 while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
121 $data=$row[0];
122 $ora=$row[1];
123 $somma=$row[2];
124 $votiu=$row[3];
125 $votid=$row[4];
126 $perc_u='';$perc_d='';$perc_c='';
127# if($votiu or $votid)
128 if(($data==$ultdata) and ($ora==$ultora))
129 {
130 $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";
131 if($tot_u) $perc_u=number_format($votiu*100/$tot_u,2);
132 if($tot_d) $perc_d=number_format($votid*100/$tot_d,2);
133 $perc_c=number_format($somma*100/$tot_compl,2);
134 }
135 else
136 $tot[$data.$ora]=$somma;
137 }
138 $ud=0;$ora_rif="";
139 while ($row2 = $resril->fetch(PDO::FETCH_BOTH))
140 {
141 $data1=$row2[0];
142 $ora1=$row2[1];
143 $ud++;
144 list($hour, $minute, $second) = explode(":", $ora1);
145 $ora_ril=$hour.":".$minute;
146 echo "<td";
147 if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
148 echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
149 $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond";
150 $resaff = $dbi->prepare("$sql");
151 $resaff->execute();
152 list($num_scr)=$resaff->fetch(PDO::FETCH_NUM); //numero delle sezioni inserite
153 echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
154 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";
155
156 echo "</td>";
157// $ar['riga1'][$data1.$ora1]="<hr>";
158 if (isset($tot[$data1.$ora1])){
159 if ($ora_rif=="$data1.$ora1")
160 {
161 $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";
162 $ar[0][$data1.$ora1]=$tot[$data1.$ora1];
163 }
164 else
165 {
166 $ar['perc'][$data1.$ora1]="<i>".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i>";
167 $ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
168 }
169// $ar['riga2'][$data1.$ora1]="<hr>";
170 if (intval(preg_match("/[1-9]/",$tot[$data1.$ora1]))>0) {
171 for ($i=1;$i<=$num_sez;$i++)
172 {
173 $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>";
174 }
175 }
176 }
177 }
178 $sql="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";
179 $sth = $dbi->prepare("$sql");
180 $sth->execute();
181 $ud=0;
182 while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
183 $data=$row[0];
184 $ora=$row[1];
185 $numsez=$row[2];
186 $uomini=$row[3];
187 $donne=$row[4];
188 $complessivi=$row[5];
189 if ($ora_rif=="$data.$ora")
190 $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";
191 else
192 $ar[$numsez][$data.$ora]=$complessivi;
193 if ($uomini+$donne>0) {
194 if ($uomini+$donne!=$complessivi) {
195 $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>";
196 } else {
197 $ar[$numsez]['controllo']= "OK";
198 }
199 }
200 }
201 echo "<td><b>"._STATO."</b></td></tr>\n";
202
203 foreach ($ar as $i => $arr) {
204 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\">";
205 foreach ($arr as $valore)
206 {
207
208 echo "<td >$valore</td>";
209 }
210 echo "</tr>\n";
211 }
212
213
214
215
216 if($genere==0){ //se e' referendum
217 #'Pagina precedente' e 'Pagina Successiva'
218 echo "\n<table width=\"100%\"><tr align=middle>";
219 $cur=$num_ref;
220 if ($cur>1) {
221 $num_ref--;
222 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\">";
223 echo "<b>"._PREV_MATCH."</b></a></td>";
224 }
225 if ($cur<$num_refs) {
226 $cur++;
227 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\">";
228 echo "<b>"._NEXT_MATCH."</b></a></td>";
229 }
230 echo "</tr></table>\n";
231 }
232
233 echo "</table>\n<br>\n";
234
235 echo "</table>\n";
236 include ("footer.php");
237
238?>
Note: See TracBrowser for help on using the repository browser.