[358] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | /************************************************************************/
|
---|
| 4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 5 | /* by Luciano Apolito & Roberto Gigli */
|
---|
| 6 | /* http://www.eleonline.it */
|
---|
| 7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 8 | /************************************************************************/
|
---|
| 9 |
|
---|
| 10 | if (!defined('ADMIN_FILE')) {
|
---|
| 11 | die ("You can't access this file directly...");
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | $sql="SELECT t1.descrizione, t1.tipo_cons,t2.genere, t2.voto_g, t2.voto_l, t2.voto_c, t2.circo FROM ".$prefix."_ele_consultazione as t1,".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' ";
|
---|
| 16 | $res = $dbi->prepare("$sql");
|
---|
| 17 | $res->execute();
|
---|
| 18 | list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 19 | $sql="SELECT 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'";
|
---|
| 20 | $res = $dbi->prepare("$sql");
|
---|
| 21 | $res->execute();
|
---|
| 22 | list($id_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 23 |
|
---|
| 24 | /*********************************/
|
---|
| 25 | /* Grafica votanti */
|
---|
| 26 | /**********************************/
|
---|
| 27 |
|
---|
| 28 | function votanti_mobile(){
|
---|
| 29 | global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$tema;
|
---|
| 30 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
| 31 | $_GET : $_POST;
|
---|
| 32 | if ($siteistat==$id_comune) $logo="$siteistat"; else $logo=''; // logo per il comune
|
---|
| 33 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
| 34 |
|
---|
| 35 | if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 36 | else $tab="gruppo";
|
---|
| 37 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 38 | else $circos='';
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | $sql="select t1.* from ".$prefix."_ele_voti_".$tab." as t1 left join ".$prefix."_ele_$tab as t2 on t1.id_$tab=t2.id_$tab where t1.id_cons='$id_cons' $circos group by t1.id_sez ";
|
---|
| 42 | $res = $dbi->prepare("$sql");
|
---|
| 43 | $res->execute();
|
---|
| 44 | if($res)
|
---|
| 45 | $numero=$res->rowCount();
|
---|
| 46 | else
|
---|
| 47 | $numero=1;
|
---|
| 48 | $sql="select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos";
|
---|
| 49 | $res = $dbi->prepare("$sql");
|
---|
| 50 | $res->execute();
|
---|
| 51 | $sezioni=$res->rowCount();
|
---|
| 52 | if ($numero!=0){
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | $sql="SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos";
|
---|
| 58 | $res1 = $dbi->prepare("$sql");
|
---|
| 59 | $res1->execute();
|
---|
| 60 | list($tot_aventi) = $res1->fetch(PDO::FETCH_NUM);
|
---|
| 61 |
|
---|
| 62 | if ($genere!=0) {
|
---|
| 63 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 64 | echo "<center><h2>";
|
---|
| 65 | echo "<b>Grafica "._DETTAGLIO." "._VOTIE."</b>";
|
---|
| 66 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 67 | echo "</h2></center></li>";
|
---|
| 68 |
|
---|
| 69 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
| 70 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), '0'
|
---|
| 71 | from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos having tot>0";
|
---|
| 72 | $res1 = $dbi->prepare("$sql");
|
---|
| 73 | $res1->execute();
|
---|
| 74 | }else{
|
---|
| 75 |
|
---|
| 76 | if($tema=='tour'){
|
---|
| 77 | $sql="SELECT count(0)
|
---|
| 78 | from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 79 | $res1 = $dbi->prepare("$sql");
|
---|
| 80 | $res1->execute();
|
---|
| 81 |
|
---|
| 82 | list($max_ruotag) = $res1->fetch(PDO::FETCH_NUM);
|
---|
| 83 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
| 84 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
| 85 | if ($ruotag>=$max_ruotag) {$ruotag=1;}
|
---|
| 86 | else {$ruotag++;}
|
---|
| 87 | $_SESSION['ruotag']=$ruotag;
|
---|
| 88 | $sql="SELECT count(0) from ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag'";
|
---|
| 89 | $res1 = $dbi->prepare("$sql");
|
---|
| 90 | $res1->execute();
|
---|
| 91 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
| 92 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 93 | echo "<center><h2>";
|
---|
| 94 | echo "<b>Grafica "._DETTAGLIO." "._VOTIE."</b> ";
|
---|
| 95 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 96 | echo "</h2></center></li>";
|
---|
| 97 |
|
---|
| 98 | $sql="SELECT sum( t1.validi + t1.nulli + t1.bianchi + t1.contestati ) AS tot, sum( t1.validi ) , sum( t1.nulli ) , sum( t1.bianchi ) , sum( t1.contestati ) , t1.id_gruppo
|
---|
| 99 | FROM ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo
|
---|
| 100 | WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag' GROUP BY t1.id_gruppo HAVING tot >0";
|
---|
| 101 | $res1 = $dbi->prepare("$sql");
|
---|
| 102 | $res1->execute();
|
---|
| 103 | } else
|
---|
| 104 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
| 105 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
|
---|
| 106 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>0";
|
---|
| 107 | $res1 = $dbi->prepare("$sql");
|
---|
| 108 | $res1->execute();
|
---|
| 109 | }
|
---|
| 110 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
| 111 | $arperc=array();
|
---|
| 112 | $arval=array($validi,$nulli,$bianchi,$contestati);
|
---|
| 113 | $arperc=arrayperc($arval,$tot_votanti);
|
---|
| 114 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
| 115 | $perc_validi=number_format($arperc[0],2);
|
---|
| 116 | $perc_nulli=number_format($arperc[1],2);
|
---|
| 117 | $perc_bianchi=number_format($arperc[2],2);
|
---|
| 118 | $perc_conte=number_format($arperc[3],2);
|
---|
| 119 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
| 120 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
| 121 | $perc_non=100-$perc_votanti;
|
---|
| 122 |
|
---|
| 123 | if ($genere==0) {
|
---|
| 124 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
| 125 | $res = $dbi->prepare("$sql");
|
---|
| 126 | $res->execute();
|
---|
| 127 | list($num_gruppo,$descr_gruppo) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | $a1=_VALIDI;$b1=_NULLI;$c1=_BIANCHI;$d1=_CONTESTATI;$titolo=""._PERCE." "._VOTIE."";
|
---|
| 133 | $e1=_VOTANTI;$f1=""._NON." "._VOTANTI."";$titolo2=""._PERCE." "._AFFLUENZE."";
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | echo "<div style=\"text-align:center\">
|
---|
| 140 | <h1>"._PERCE." "._VOTANTI."</h1>";
|
---|
| 141 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo</h2>";
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 | echo "<br /><img alt=\"Grafico\" width=\"300\" src=\"modules/Elezioni/grafici/votanti_graf.php?titolo=$titolo2&e=$perc_votanti&f=$perc_non&e1=$e1&f1=$f1&logo=$logo\" /><br /><br /></div>";
|
---|
| 146 |
|
---|
| 147 | echo "<div style=\"text-align:center\">";
|
---|
| 148 | echo "<h1>"._PERCE." "._VOTIE."</h1>";
|
---|
| 149 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo<h2> ";
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | echo "<br /><img alt=\"Grafico\" width=\"300\" src=\"modules/Elezioni/grafici/voti_graf.php?cop=&titolo=$titolo&a=$perc_validi&b=$perc_nulli&c=$perc_bianchi&d=$perc_conte&a1=$a1&b1=$b1&c1=$c1&d1=$d1&logo=$logo\" /><br /><br /></div>";
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | /***********************************
|
---|
| 166 | /* Grafica Gruppo
|
---|
| 167 | /**********************************/
|
---|
| 168 |
|
---|
| 169 | function graf_gruppo_mob(){
|
---|
| 170 | global $dbi,$admin, $bgcolor1, $bgcolor5, $prefix, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$visgralista,$graficogruppo,$rss;
|
---|
| 171 | # parte grafica
|
---|
| 172 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
| 173 | $_GET : $_POST;
|
---|
| 174 | if (isset($param['grafica'])) $grafica=intval($param['grafica']); else $grafica='';
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | if ($siteistat==$id_comune) $logo=$siteistat; else $logo=''; // logo per il comune
|
---|
| 178 |
|
---|
| 179 | if (!$id_circ and $circo){
|
---|
| 180 | $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons order by num_circ limit 0,1";
|
---|
| 181 | $res_sez = $dbi->prepare("$sql");
|
---|
| 182 | $res_sez->execute();
|
---|
| 183 | list($id_circ)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
| 184 | }
|
---|
| 185 | $circond='';$circondt1='';
|
---|
| 186 | if ($genere!=0){$tab="ele_voti_gruppo";}else{$tab="ele_voti_ref";}
|
---|
| 187 | if ($genere==4 or $visgralista){$tab="ele_voti_lista";}
|
---|
| 188 | if ($votog){$tab="ele_voti_lista";}
|
---|
| 189 | $sql="select * from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
| 190 | $res = $dbi->prepare("$sql");
|
---|
| 191 | $res->execute();
|
---|
| 192 | if ($circo){
|
---|
| 193 | $sql="select t1.* from ".$prefix."_ele_voti_gruppo as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' and t2.id_circ=$id_circ group by t1.id_sez ";
|
---|
| 194 | $res = $dbi->prepare("$sql");
|
---|
| 195 | $res->execute();
|
---|
| 196 |
|
---|
| 197 | $sql="select sum(t1.voti) from ".$prefix."_ele_voti_gruppo as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' and t2.id_circ=$id_circ";
|
---|
| 198 | $circond="and id_circ=$id_circ";$circondt1="and t1.id_circ=$id_circ";
|
---|
| 199 | $restotv = $dbi->prepare("$sql");
|
---|
| 200 | $restotv->execute();
|
---|
| 201 | }
|
---|
| 202 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
| 203 | $sql="select t2.* from ".$prefix."_ele_sezioni as t2, ".$prefix."_ele_sede as t1 where t2.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circondt1";
|
---|
| 204 | $res = $dbi->prepare("$sql");
|
---|
| 205 | $res->execute();
|
---|
| 206 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | if ($numero>0){
|
---|
| 210 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 211 | echo "<center><b>"._PREFERENZE." "._GRUPPO."</b>";
|
---|
| 212 | //echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
| 213 | echo "</center></li>";
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | if ($genere!=0){
|
---|
| 217 | // tot voti
|
---|
| 218 | if (!$circo)
|
---|
| 219 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
| 220 | if ($votog)
|
---|
| 221 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
| 222 | $restotv = $dbi->prepare("$sql");
|
---|
| 223 | $restotv->execute();
|
---|
| 224 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
| 225 |
|
---|
| 226 | $i=0;
|
---|
| 227 | // lista o gruppo
|
---|
| 228 | if ($genere!=4 and !$visgralista){
|
---|
| 229 |
|
---|
| 230 | if ($votog){
|
---|
| 231 |
|
---|
| 232 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
| 233 | from ".$prefix."_ele_gruppo as t1,
|
---|
| 234 | ".$prefix."_ele_voti_lista as t2,
|
---|
| 235 | ".$prefix."_ele_lista as t3
|
---|
| 236 | where t1.id_cons='$id_cons'
|
---|
| 237 | and t2.id_lista=t3.id_lista
|
---|
| 238 | and t1.id_gruppo=t3.id_gruppo
|
---|
| 239 | group by t1.id_gruppo
|
---|
| 240 | order by somma desc";
|
---|
| 241 | $cosa='id_gruppo';
|
---|
| 242 |
|
---|
| 243 | }else{
|
---|
| 244 |
|
---|
| 245 |
|
---|
| 246 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
| 247 | from ".$prefix."_ele_gruppo as t1
|
---|
| 248 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 249 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
| 250 | group by t2.id_gruppo
|
---|
| 251 | order by somma desc";
|
---|
| 252 | $cosa='id_gruppo';
|
---|
| 253 | }
|
---|
| 254 | $res = $dbi->prepare("$sql");
|
---|
| 255 | $res->execute();
|
---|
| 256 |
|
---|
| 257 |
|
---|
| 258 | }else{
|
---|
| 259 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
| 260 | from ".$prefix."_ele_lista as t1
|
---|
| 261 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
| 262 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons
|
---|
| 263 | group by t2.id_lista
|
---|
| 264 | order by somma desc";
|
---|
| 265 | $res = $dbi->prepare("$sql");
|
---|
| 266 | $res->execute();
|
---|
| 267 | $cosa='id_lista';
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 |
|
---|
| 271 | // inizio tabella dati
|
---|
| 272 | // variabili stampa flash
|
---|
| 273 | $e=0;
|
---|
| 274 | $gruppos[$e]="";
|
---|
| 275 | $pre[$e]="";
|
---|
| 276 | $e=1;
|
---|
| 277 | // fine
|
---|
| 278 | $gruppinum=$res->rowCount();
|
---|
| 279 | $altrivoti=0;
|
---|
| 280 | ####calcolo percentuale
|
---|
| 281 | $arvoti=array();
|
---|
| 282 | $arperc=array();
|
---|
| 283 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 284 | $arvoti[$id]=$voti;
|
---|
| 285 | }
|
---|
| 286 | $arperc=arrayperc($arvoti,$tot);
|
---|
| 287 | //$db->sql_data_seek($res,0);
|
---|
| 288 | $res = $dbi->prepare("$sql");
|
---|
| 289 | $res->execute();
|
---|
| 290 | # mysql_data_seek($res,0);
|
---|
| 291 | ####
|
---|
| 292 | $altriperc=0;
|
---|
| 293 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | // verica chi ha preso meno del 3%
|
---|
| 297 | $menotre=(number_format($voti*100/$tot,2));
|
---|
| 298 |
|
---|
| 299 | if($menotre>3){
|
---|
| 300 |
|
---|
| 301 |
|
---|
| 302 |
|
---|
| 303 |
|
---|
| 304 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
| 305 | //$descrizione=taglio(4,$descrizione);
|
---|
| 306 |
|
---|
| 307 | $gruppo[$i]=(substr($descrizione,0,21));
|
---|
| 308 | $gruppos[$e]=(substr($descrizione,0,21)); //flash
|
---|
| 309 |
|
---|
| 310 |
|
---|
| 311 |
|
---|
| 312 | if (strlen($descrizione)>21) $gruppo[$i].="...";
|
---|
| 313 | if (strlen($descrizione)>21) $gruppos[$e].="...";
|
---|
| 314 | $pro[$i]=number_format($arperc[$id],2);
|
---|
| 315 | $pre[$e]=number_format($arperc[$id],2); //flash
|
---|
| 316 |
|
---|
| 317 |
|
---|
| 318 | }else{
|
---|
| 319 | //somma i voti sotto il 3%
|
---|
| 320 | $altrivoti = $altrivoti + $voti;
|
---|
| 321 | $altriperc += $arperc[$id];
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 |
|
---|
| 325 |
|
---|
| 326 |
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | $votiv=number_format($voti,0,',','.');
|
---|
| 330 | // formattazione numeri perc
|
---|
| 331 | $prov=number_format($arperc[$id],2);
|
---|
| 332 |
|
---|
| 333 | // sviluppo tabella dati
|
---|
| 334 | $bgcolor1= ($bgcolor1=="#cacaca") ? "#ffffff":"#cacaca";
|
---|
| 335 |
|
---|
| 336 | if($grafica!="1"){
|
---|
| 337 | echo "<table style=\" text-align:left;border:1px solid Black;width:100%;\"><tr>\n<td width=\"55\"><a href=\"#dati\">
|
---|
| 338 | <img src=\"modules.php?name=Elezioni&file=foto&$cosa=$id\" width=\"50\" align=\"left\" alt=\"\" /></a></td>\n
|
---|
| 339 | <td><span style=\"font-size:10px;\">$descrizione</span><br/>
|
---|
| 340 |
|
---|
| 341 | "._VOTI." <span style=\"font-size:20px;\"><b>$votiv</b> <i>($prov%)</i></span></td>\n
|
---|
| 342 | </tr></table>\n";
|
---|
| 343 | }
|
---|
| 344 | $i++;
|
---|
| 345 | }
|
---|
| 346 | // aggiunge altri minori al 3%
|
---|
| 347 | // esiste
|
---|
| 348 | // corretto 15 aprile 2006
|
---|
| 349 | if ($altrivoti>0){
|
---|
| 350 |
|
---|
| 351 | $gruppo[]=_ALTRI;
|
---|
| 352 | $gruppos[]=_ALTRI;
|
---|
| 353 | $pro[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
| 354 | $pre[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 |
|
---|
| 358 | if ($i<=10) $i=10;
|
---|
| 359 | $titolo=""._PERCE." "._VOTIE."";
|
---|
| 360 | $dati1=serialize($pro);
|
---|
| 361 | //$dati1=urlencode($dati1);
|
---|
| 362 | //$gruppo=utf8_encode($gruppo);
|
---|
| 363 | $dati2=serialize($gruppo);
|
---|
| 364 | $dati2=urlencode($dati2);
|
---|
| 365 |
|
---|
| 366 | $titolo=urlencode($titolo);
|
---|
| 367 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 368 | $descr_cons=urlencode($descr_cons);
|
---|
| 369 | if ($genere==4){$w=700;$l=300;}else{$w=500;$l=180;}
|
---|
| 370 |
|
---|
| 371 |
|
---|
| 372 | if($grafica=="1")
|
---|
| 373 | echo "<br/><center><img width=\"300\" src='modules/Elezioni/grafici/barre.php?dati1=$dati1&dati2=$dati2&i=$i&cop=$copy&titolo=$titolo&descr=$descr_cons&l=$l&w=$w&logo=$logo' alt=\"Grafico\" /><br/></center>";
|
---|
| 374 |
|
---|
| 375 |
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | }else{
|
---|
| 380 | // tot voti
|
---|
| 381 | $sql="
|
---|
| 382 | select sum(validi),id_gruppo from ".$prefix."_$tab where id_cons=$id_cons group by id_gruppo";
|
---|
| 383 | $res = $dbi->prepare("$sql");
|
---|
| 384 | $res->execute();
|
---|
| 385 | while (list($tot,$id_gruppo) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 386 |
|
---|
| 387 | $s=0;
|
---|
| 388 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
| 389 | from ".$prefix."_ele_gruppo as t1
|
---|
| 390 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 391 | where t1.id_cons='$id_cons' and t1.id_gruppo='$id_gruppo'
|
---|
| 392 | group by t1.id_gruppo
|
---|
| 393 | ";
|
---|
| 394 | $res1 = $dbi->prepare("$sql");
|
---|
| 395 | $res1->execute();
|
---|
| 396 |
|
---|
| 397 |
|
---|
| 398 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
| 399 | if($tot){
|
---|
| 400 | $percsi=number_format($si*100/$tot,3);
|
---|
| 401 | $percno=number_format($no*100/$tot,3);
|
---|
| 402 | $percsi=number_format($percsi,2);
|
---|
| 403 | $percno=number_format($percno,2);
|
---|
| 404 | }else{
|
---|
| 405 | $percsi="0.00"; $percno="0.00";
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | $gruppo=array("si","no");
|
---|
| 409 | $gruppos=array("","si","no");// flash
|
---|
| 410 | $pro=array($percsi,$percno);
|
---|
| 411 | $pre=array("",$percsi,$percno);//flash
|
---|
| 412 | // echo "<br/><b><center>$descrizione</center><br/><br/>";
|
---|
| 413 | // sviluppo tabella dati
|
---|
| 414 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%;\">"; // inizio tabella dati
|
---|
| 415 | echo "<tr><td >$num_gruppo - $descrizione</b></td></tr></table>
|
---|
| 416 | <table style=\"text-align:left;border : 1px solid Black;width:100%;\" bgcolor=\"#ffffff\" width=\"100%\">
|
---|
| 417 | <tr>
|
---|
| 418 |
|
---|
| 419 | <td width=\"33%\">"._SI."</td>
|
---|
| 420 | <td width=\"33%\"><b>$si voti</b></td>
|
---|
| 421 | <td width=\"33%\"><b><span style=\"color:#ff0000\">$percsi %</span></b></td><table>
|
---|
| 422 | <table style=\"text-align:left;border : 1px solid Black;width:100%;\">
|
---|
| 423 | <tr>
|
---|
| 424 | <td width=\"33%\">"._NO."</td>
|
---|
| 425 | <td width=\"33%\"><b>$no voti</b></td>
|
---|
| 426 | <td width=\"33%\"><b><span style=\"color:#ff0000\">$percno %</span></b></td><tr>
|
---|
| 427 | </table></li>";
|
---|
| 428 |
|
---|
| 429 | $i=8; // parametro lunghezza tavola
|
---|
| 430 | $l=30; // larghezza label
|
---|
| 431 | $titolo="Numero ".$num_gruppo."";
|
---|
| 432 | $dati1=serialize($pro);
|
---|
| 433 | //$dati1=urlencode($dati1); //IE
|
---|
| 434 | $dati2=serialize($gruppo);
|
---|
| 435 | $dati2=urlencode($dati2);
|
---|
| 436 | $titolo=urlencode($titolo);
|
---|
| 437 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 438 | $descr=urlencode($descr_cons);
|
---|
| 439 |
|
---|
| 440 |
|
---|
| 441 |
|
---|
| 442 |
|
---|
| 443 |
|
---|
| 444 |
|
---|
| 445 |
|
---|
| 446 |
|
---|
| 447 | $s++;
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 |
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 |
|
---|
| 454 |
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 |
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | /***********************************
|
---|
| 463 | /* Grafica liste
|
---|
| 464 | /**********************************/
|
---|
| 465 |
|
---|
| 466 | function graf_liste_mob(){
|
---|
| 467 |
|
---|
| 468 | global $id_cons,$id_cons_gen,$prefix,$dbi,$min,$offset,$op,$tipo_cons,$prev,$next,$votog,$votol,$circo,$genere,$id_comune,$colortheme;
|
---|
| 469 |
|
---|
| 470 | $offset=10000;
|
---|
| 471 | if (!isset($min)) $min=0;
|
---|
| 472 |
|
---|
| 473 | // numero sezioni scrutinate sul gruppo
|
---|
| 474 | if ($circo) $circos = "and id_circ=$id_circ" ; else $circos='';
|
---|
| 475 | if ($genere==0) $tab="ref"; else $tab="gruppo";
|
---|
| 476 | $sql="select * from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons' $circos group by id_sez ";
|
---|
| 477 | $res = $dbi->prepare("$sql");
|
---|
| 478 | $res->execute();
|
---|
| 479 | $numero=$res->rowCount();
|
---|
| 480 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos ";
|
---|
| 481 | $res = $dbi->prepare("$sql");
|
---|
| 482 | $res->execute();
|
---|
| 483 | $sezioni=$res->rowCount();
|
---|
| 484 | //$res = mysql_query("select chiusa from ".$prefix."_ele_cons_comuni where id_cons='$id_cons' $circos ",$dbi);
|
---|
| 485 | //$chiusa=mysql_num_rows($res);
|
---|
| 486 | //if ($numero!=0 and $chiusa==0)
|
---|
| 487 |
|
---|
| 488 | if ($numero>0){
|
---|
| 489 |
|
---|
| 490 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 491 | echo "<center><b>Voti per Lista</b>";
|
---|
| 492 | echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
| 493 | echo "</center></li>";
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 |
|
---|
| 497 | // tot liste
|
---|
| 498 | $sql="SELECT * FROM ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
| 499 | $res = $dbi->prepare("$sql");
|
---|
| 500 | $res->execute();
|
---|
| 501 | $max = $res->rowCount();
|
---|
| 502 |
|
---|
| 503 | // tot voti liste
|
---|
| 504 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'";
|
---|
| 505 | $res_lista_tutti = $dbi->prepare("$sql");
|
---|
| 506 | $res_lista_tutti->execute();
|
---|
| 507 | list($voti_lista_tutti) = $res_lista_tutti->fetch(PDO::FETCH_NUM);
|
---|
| 508 |
|
---|
| 509 | $sql="select id_cons ,id_lista ,id_gruppo, num_lista, descrizione from ".$prefix."_ele_lista where id_cons='$id_cons' ORDER BY num_lista LIMIT $min,$offset";
|
---|
| 510 | $result = $dbi->prepare("$sql");
|
---|
| 511 | $result->execute();
|
---|
| 512 | while(list($id_cons2,$id_lista,$id_gruppo, $num_lista, $descr_lista) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
| 513 | if ($num_lista!=0) {
|
---|
| 514 | // voti lista
|
---|
| 515 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_lista='$id_lista'";
|
---|
| 516 | $res_lista = $dbi->prepare("$sql");
|
---|
| 517 | $res_lista->execute();
|
---|
| 518 | list($voti_lista) = $res_lista->fetch(PDO::FETCH_NUM);
|
---|
| 519 | if ($voti_lista_tutti!=0)
|
---|
| 520 | $perc_lista=number_format(($voti_lista*100)/$voti_lista_tutti,2);
|
---|
| 521 | else $perc_lista='';
|
---|
| 522 | // gruppo
|
---|
| 523 | $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
| 524 | $res_gruppo = $dbi->prepare("$sql");
|
---|
| 525 | $res_gruppo->execute();
|
---|
| 526 | list($descr_gruppo) = $res_gruppo->fetch(PDO::FETCH_NUM);
|
---|
| 527 |
|
---|
| 528 |
|
---|
| 529 | /*echo "<table><tr class=\"bggray\">"
|
---|
| 530 | ."<td class=\"td-5\"><b>"._NUM."</b></td>"
|
---|
| 531 | ."<td ><b>"._DESCR."</b></td>"
|
---|
| 532 | ."<td class=\"td-5\"><b>"._SIMBOLO."</b></td>"
|
---|
| 533 | ."<td class=\"td-5\"><b>"._GRUPPO."</b></td></tr>";
|
---|
| 534 | */
|
---|
| 535 |
|
---|
| 536 |
|
---|
| 537 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%\"><tr><td width=\"15\">$num_lista
|
---|
| 538 | </td>
|
---|
| 539 | <td width=\"60\">
|
---|
| 540 | <img width=\"50\" src=\"modules.php?name=Elezioni&file=foto&id_lista=$id_lista\" alt=\"$descr_lista\" /></td>
|
---|
| 541 |
|
---|
| 542 |
|
---|
| 543 | <td width=\"320\"><span style=\"font-size:12px;\">$descr_lista</span><br />Voti:
|
---|
| 544 | <b>$voti_lista </b><span style=\"color:#ff0000;font-size:12px;\"> ($perc_lista %)</span>";
|
---|
| 545 | echo "</td>
|
---|
| 546 |
|
---|
| 547 | <td width=\"180\">
|
---|
| 548 | <img class=\"stemma\" width=\"50\" src=\"modules.php?name=Elezioni&file=foto&id_gruppo=$id_gruppo\" alt=\"$descr_gruppo\" />
|
---|
| 549 | <br /><span style=\"font-size:10px;\">$descr_gruppo</span></td>
|
---|
| 550 | </tr></table></li>";
|
---|
| 551 | }
|
---|
| 552 | }
|
---|
| 553 | }
|
---|
| 554 |
|
---|
| 555 |
|
---|
| 556 |
|
---|
| 557 |
|
---|
| 558 |
|
---|
| 559 | /***********************************
|
---|
| 560 | /* Grafica Candidato
|
---|
| 561 | /**********************************/
|
---|
| 562 |
|
---|
| 563 | function graf_candidato_mob(){
|
---|
| 564 | global $dbi,$bgcolor1, $bgcolor5,$bgcolor5, $prefix, $offset, $min,$descr_cons, $id_cons,$tipo_cons,$copy,$id_comune,$id_istat,$genere,$votog,$votol,$votoc,$circo,$siteistat;
|
---|
| 565 | if ($siteistat==$id_comune) $logo='1'; else $logo=''; // logo per il comune
|
---|
| 566 | $bgcolor1="";
|
---|
| 567 |
|
---|
| 568 | $tab="ele_voti_candidati";
|
---|
| 569 |
|
---|
| 570 | $sql="select id_sez from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_sez ";
|
---|
| 571 | $res = $dbi->prepare("$sql");
|
---|
| 572 | $res->execute();
|
---|
| 573 | $numero=$res->rowCount();
|
---|
| 574 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 575 | $res = $dbi->prepare("$sql");
|
---|
| 576 | $res->execute();
|
---|
| 577 | $sezioni=$res->rowCount();
|
---|
| 578 |
|
---|
| 579 |
|
---|
| 580 | if ($numero>0){
|
---|
| 581 |
|
---|
| 582 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 583 | echo "<center><b>Elenco candidati in ordine di voti</b>";
|
---|
| 584 | echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
| 585 | echo "</center></li>";
|
---|
| 586 |
|
---|
| 587 |
|
---|
| 588 | // tot voti
|
---|
| 589 | $sql="
|
---|
| 590 | select sum(voti) from ".$prefix."_ele_voti_candidati where id_cons=$id_cons ";
|
---|
| 591 | $res = $dbi->prepare("$sql");
|
---|
| 592 | $res->execute();
|
---|
| 593 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 594 |
|
---|
| 595 | // gruppi o liste per simbolo
|
---|
| 596 |
|
---|
| 597 | if ($genere==4){
|
---|
| 598 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 599 | }else{
|
---|
| 600 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 601 | }
|
---|
| 602 | $i=0;
|
---|
| 603 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t2.voti) as somma
|
---|
| 604 | from ".$prefix."_ele_candidati as t1
|
---|
| 605 | left join ".$prefix."_ele_voti_candidati as t2 on (t1.id_cand=t2.id_cand)
|
---|
| 606 | left join ".$prefix.$scelta."
|
---|
| 607 | where t1.id_cons='$id_cons'
|
---|
| 608 | group by t2.id_cand
|
---|
| 609 |
|
---|
| 610 | order by somma desc
|
---|
| 611 |
|
---|
| 612 | ";
|
---|
| 613 | $res = $dbi->prepare("$sql");
|
---|
| 614 | $res->execute();
|
---|
| 615 | $n_candi=$res->rowCount();
|
---|
| 616 |
|
---|
| 617 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 618 | $candidato[$i]=$cognome;
|
---|
| 619 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
| 620 | // sviluppo tabella dati
|
---|
| 621 | $e=$i+1;
|
---|
| 622 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%;\">"; // inizio tabella dati
|
---|
| 623 | echo "<tr><td>".$e."°</td><td><b><img alt=\"$nome $cognome\" src=\"modules.php?name=Elezioni&file=foto&id_lista=$id_lista\" align=\"middle\" width=\"30\"></b></td>
|
---|
| 624 | <td width=\"70%\" bgcolor=\"$bgcolor1\"><b>$nome $cognome</b><br/>
|
---|
| 625 | "._VOTI.": <b>$voti </b>
|
---|
| 626 | ( <span style=\"color:#ff0000;\">$pro[$i]%</span> )</td></tr>";
|
---|
| 627 | echo "</table></li>"; // fine tabella dati
|
---|
| 628 | /* tolto il conteggio
|
---|
| 629 | if ($e=='5000' || $e==$n_candi){
|
---|
| 630 |
|
---|
| 631 |
|
---|
| 632 |
|
---|
| 633 |
|
---|
| 634 |
|
---|
| 635 | //include("footer.php");
|
---|
| 636 | exit;
|
---|
| 637 | }
|
---|
| 638 |
|
---|
| 639 | */
|
---|
| 640 |
|
---|
| 641 | $i++;
|
---|
| 642 |
|
---|
| 643 |
|
---|
| 644 |
|
---|
| 645 |
|
---|
| 646 | }
|
---|
| 647 |
|
---|
| 648 | }
|
---|
| 649 |
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | ######################################################
|
---|
| 654 | function numerodisezioni() {
|
---|
| 655 | /*Funzione numero sezioni scrutinate
|
---|
| 656 | /*****************************************************
|
---|
| 657 | Ritorna i dati in un array con quest'ordine:
|
---|
| 658 | numero di sezioni totali , numero di sezioni scrutinate
|
---|
| 659 | *******************************************************/
|
---|
| 660 |
|
---|
| 661 |
|
---|
| 662 |
|
---|
| 663 | global $dbi,$db, $prefix, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
| 664 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 665 | else $circos='';
|
---|
| 666 |
|
---|
| 667 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 668 | if($genere=='4' || $votog) $tab="lista";
|
---|
| 669 | else $tab="gruppo";
|
---|
| 670 | if ($genere==0) $tab="ref";
|
---|
| 671 |
|
---|
| 672 |
|
---|
| 673 | $sql="select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos";
|
---|
| 674 | $res2 = $dbi->prepare("$sql");
|
---|
| 675 | $res2->execute();
|
---|
| 676 | $result_sezioni[1]=$res2->rowCount();
|
---|
| 677 |
|
---|
| 678 |
|
---|
| 679 |
|
---|
| 680 | // numero sezioni
|
---|
| 681 | $sql="select t3.* from ".$prefix."_ele_voti_".$tab." as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' $circos group by t3.id_sez ";
|
---|
| 682 | $sez_num = $dbi->prepare("$sql");
|
---|
| 683 | $sez_num->execute();
|
---|
| 684 | $result_sezioni[0]=$sez_num->rowCount();
|
---|
| 685 |
|
---|
| 686 | // $sez_scrut = $db->sql_query("select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos");
|
---|
| 687 | //$result_sezioni[1]=$db->sql_numrows($sez_scrut);
|
---|
| 688 |
|
---|
| 689 |
|
---|
| 690 | $sql="select chiusa from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
| 691 | $res = $dbi->prepare("$sql");
|
---|
| 692 | $res->execute();
|
---|
| 693 | //$chiusa=$db->sql_numrows($res);
|
---|
| 694 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 695 | //echo "-----------> $chiusa - $id_comune";
|
---|
| 696 |
|
---|
| 697 | if($chiusa!=0)$result_sezioni[0]=0;
|
---|
| 698 | return $result_sezioni;
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 |
|
---|
| 702 |
|
---|
| 703 |
|
---|
| 704 | }
|
---|
| 705 | ####################################################
|
---|
| 706 | # Come
|
---|
| 707 | ####################################################
|
---|
| 708 |
|
---|
| 709 | function come_mob($info) {
|
---|
| 710 | global $prefix, $dbi, $offset, $min,$id_cons,$tipo_cons,$descr_cons,$id_comune;
|
---|
| 711 |
|
---|
| 712 | $tab='';
|
---|
| 713 | if ($info=="come"){ $tab="_ele_come";$vista="Come si vota";}
|
---|
| 714 | elseif ($info=="numeri"){ $tab="_ele_numeri";$vista="Numeri Utili";}
|
---|
| 715 | elseif ($info=="servizi"){ $tab="_ele_servizi";$vista="Servizi Elettorali";}
|
---|
| 716 | elseif ($info=="link"){ $tab="_ele_link";$vista="Link Utili";}
|
---|
| 717 | else{ $tab="_ele_come";$vista="Come si vota";}
|
---|
| 718 |
|
---|
| 719 |
|
---|
| 720 | global $user, $admin, $cookie, $textcolor2;
|
---|
| 721 | $sql="select mid, title, preamble, content,editimage from ".$prefix."$tab where id_cons='$id_cons' order by mid ";
|
---|
| 722 | $result = $dbi->prepare("$sql");
|
---|
| 723 | $result->execute();
|
---|
| 724 |
|
---|
| 725 | echo "<li data-role=\"list-divider\" >";
|
---|
| 726 | echo "<center><b>$vista</b>";
|
---|
| 727 | echo "</center></li>";
|
---|
| 728 |
|
---|
| 729 |
|
---|
| 730 |
|
---|
| 731 | if ($result->rowCount() == 0) {
|
---|
| 732 | return;
|
---|
| 733 | } else {
|
---|
| 734 | while (list($mid, $title, $preamble,$content, $editimage) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
| 735 | if ($title != "" && $content != "") {
|
---|
| 736 |
|
---|
| 737 | if ($info=="link"){
|
---|
| 738 |
|
---|
| 739 | echo "<li>
|
---|
| 740 | <b><a href=\"$preamble\">$title</a></b>
|
---|
| 741 | $content
|
---|
| 742 | </li>";
|
---|
| 743 |
|
---|
| 744 | }else{
|
---|
| 745 | echo "<li><div><b>$title</b><br /></div>";
|
---|
| 746 |
|
---|
| 747 |
|
---|
| 748 | echo "<div class=\"message\">$preamble<br /><br /></div>";
|
---|
| 749 |
|
---|
| 750 | echo "<div class=\"message\">$content</div></li>";
|
---|
| 751 | }
|
---|
| 752 |
|
---|
| 753 |
|
---|
| 754 |
|
---|
| 755 | }
|
---|
| 756 | }
|
---|
| 757 | }
|
---|
| 758 |
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 |
|
---|
| 762 |
|
---|
| 763 | /****************
|
---|
| 764 | Funzione dati Generali
|
---|
| 765 | visuallizza la stringa dei dati generali
|
---|
| 766 | ****************/
|
---|
| 767 |
|
---|
| 768 |
|
---|
| 769 | function dati_mob($print) {
|
---|
| 770 | global $db,$prefix, $dbi, $votog, $votol, $votoc, $circo, $id_cons,$tipo_cons,$descr_cons,$id_cons_gen,$id_comune,$genere,$id_circ;
|
---|
| 771 | $print=intval($print);
|
---|
| 772 |
|
---|
| 773 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
| 774 | $res = $dbi->prepare("$sql");
|
---|
| 775 | $res->execute();
|
---|
| 776 | $sql="select * from ".$prefix."_ele_sede where id_cons='$id_cons' ";
|
---|
| 777 | $ressede = $dbi->prepare("$sql");
|
---|
| 778 | $ressede->execute();
|
---|
| 779 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' ";
|
---|
| 780 | $res3 = $dbi->prepare("$sql");
|
---|
| 781 | $res3->execute();
|
---|
| 782 | $circo = $res->rowCount();
|
---|
| 783 | $sedi = $ressede->rowCount();
|
---|
| 784 | $sez = $res3->rowCount();
|
---|
| 785 |
|
---|
| 786 | //Variabili linguaggio
|
---|
| 787 | $DATIG=_DATIG;$AVENTI=_AVENTI;$MASCHI=_MASCHI;$FEMMINE=_FEMMINE;$SEZIONI=_SEZIONI; $GRUPPI=_GRUPPI;$CANDIDATI=_CANDIDATI;$LISTE=_LISTE;
|
---|
| 788 | if ($circo>1)$SEDE=_CIRCS; else $SEDE=_SEDI;
|
---|
| 789 |
|
---|
| 790 | $candi=0;
|
---|
| 791 |
|
---|
| 792 | // se non referendum
|
---|
| 793 | if ($genere!=0 and !$votoc){
|
---|
| 794 | $sql="select id_cons from ".$prefix."_ele_candidati where id_cons='$id_cons' ";
|
---|
| 795 | $res1 = $dbi->prepare("$sql");
|
---|
| 796 | $res1->execute();
|
---|
| 797 | $candi = $res1->rowCount();
|
---|
| 798 | }
|
---|
| 799 |
|
---|
| 800 | // se non europee (non liste e candidati)
|
---|
| 801 | if ($genere!=4){
|
---|
| 802 | $sql="select id_cons from ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
|
---|
| 803 | }else{
|
---|
| 804 | $sql="select id_cons from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
| 805 | }
|
---|
| 806 | $res2 = $dbi->prepare("$sql");
|
---|
| 807 | $res2->execute();
|
---|
| 808 |
|
---|
| 809 | $gruppo = $res2->rowCount();
|
---|
| 810 |
|
---|
| 811 | // camera e senato con raggruppamenti
|
---|
| 812 | //if($votog){
|
---|
| 813 | $sql="select * from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
| 814 | $res3 = $dbi->prepare("$sql");
|
---|
| 815 | $res3->execute();
|
---|
| 816 | $liste = $res3->rowCount();
|
---|
| 817 | //}
|
---|
| 818 |
|
---|
| 819 | if($circo==1) $circo=$sedi;
|
---|
| 820 | $sql="select sum(maschi),sum(femmine), sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
|
---|
| 821 | $res4 = $dbi->prepare("$sql");
|
---|
| 822 | $res4->execute();
|
---|
| 823 | if($res4) list($maschi,$femmine,$tot) = $res4->fetch(PDO::FETCH_NUM);
|
---|
| 824 |
|
---|
| 825 |
|
---|
| 826 |
|
---|
| 827 | $ris = array($tot,$maschi,$femmine,$circo,$sez,$gruppo,$candi,$liste);
|
---|
| 828 | return $ris;
|
---|
| 829 |
|
---|
| 830 |
|
---|
| 831 | }
|
---|
| 832 |
|
---|
| 833 | ####################################
|
---|
| 834 | ## funzione che richiama i dati generali
|
---|
| 835 | ## function dati_mob e li stampa
|
---|
| 836 |
|
---|
| 837 | function dati_mob_fun(){
|
---|
| 838 | $dati=dati_mob(0);
|
---|
| 839 | global $genere;
|
---|
| 840 | if($genere==0)$gruppo="Quesiti";else$gruppo="Gruppi";
|
---|
| 841 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 842 | echo "<b> <center>Dati Generali della consultazione </center></b></li>";
|
---|
| 843 | echo "<br/><div style=\"margin:0 auto;width:300px;\"><ul>";
|
---|
| 844 | echo "<li>Aventi Diritto: $dati[0]</li>";
|
---|
| 845 | echo "<li> Maschi: $dati[1]</li>";
|
---|
| 846 | echo "<li>Femmine: $dati[2]</li>";
|
---|
| 847 | if($dati[3]!=0) echo "<li>Num. Circoscrizioni: $dati[3]</li>";
|
---|
| 848 | echo "<li>Num: Sezioni: $dati[4]</li>";
|
---|
| 849 | if($dati[5]!=0)echo "<li>Num: $gruppo: $dati[5]</li>";
|
---|
| 850 | if($dati[6]!=0)echo "<li>Num. Candidati: $dati[6]</li>";
|
---|
| 851 | if($dati[7]!=0)echo "<li>Num. Liste: $dati[7]</li>";
|
---|
| 852 | echo "</ul></div>";
|
---|
| 853 | }
|
---|
| 854 |
|
---|
| 855 |
|
---|
| 856 |
|
---|
| 857 |
|
---|
| 858 | function circo_mob() {
|
---|
| 859 |
|
---|
| 860 | /******************************************************/
|
---|
| 861 | /*Funzione di visualizzazione sede */
|
---|
| 862 | /*****************************************************/
|
---|
| 863 | global $admin, $prefix, $dbi, $offset, $min,$id_cons,$file,$id_cons_gen,$id_comune ,$prev,$next;
|
---|
| 864 | $sql="SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
| 865 | $res = $dbi->prepare("$sql");
|
---|
| 866 | $res->execute();
|
---|
| 867 | $max = $res->rowCount();
|
---|
| 868 |
|
---|
| 869 | //OpenTable();
|
---|
| 870 |
|
---|
| 871 | dati();
|
---|
| 872 |
|
---|
| 873 |
|
---|
| 874 | $offset=10;
|
---|
| 875 | if (!isset($min)) $min=0;
|
---|
| 876 | $go="circo";
|
---|
| 877 |
|
---|
| 878 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ
|
---|
| 879 | LIMIT $min,$offset";
|
---|
| 880 | $result = $dbi->prepare("$sql");
|
---|
| 881 | $result->execute();
|
---|
| 882 | $numcirc=$result->rowCount();
|
---|
| 883 | if ($numcirc>1){
|
---|
| 884 | echo "<div><b>"._CIRCS."</b></div><br /><br />
|
---|
| 885 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
| 886 | ."<td ><b>"._NUM."</b></td>"
|
---|
| 887 | ."<td ><b>"._CIRCO."</b></td>"
|
---|
| 888 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
| 889 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
| 890 | }else{
|
---|
| 891 | echo "<div><b></b></div><br /><br />
|
---|
| 892 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
| 893 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
| 894 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
| 895 | }
|
---|
| 896 |
|
---|
| 897 | while(list($id_cons2,$id_circ,$num_circ,$descr_circ) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
| 898 | #if($numcirc==1) {$descr_circ=''; $num_circ='';}
|
---|
| 899 | if (!($num_circ===0)) {
|
---|
| 900 |
|
---|
| 901 | echo "<tr class=\"bggray3\">";
|
---|
| 902 | if ($numcirc>1) {
|
---|
| 903 | echo "<td><b>$num_circ</b>"
|
---|
| 904 | ."</td><td><b>";
|
---|
| 905 | echo "<a href=\"modules.php?name=Elezioni&op=sezione&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&descr_circ=$descr_circ\">$descr_circ</a></b></td>";
|
---|
| 906 | }
|
---|
| 907 |
|
---|
| 908 | // dati sede
|
---|
| 909 | $sql="select id_sede,indirizzo,telefono1,telefono2, mappa, filemappa from ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ'";
|
---|
| 910 | $result1 = $dbi->prepare("$sql");
|
---|
| 911 | $result1->execute();
|
---|
| 912 | $righe=$result1->rowCount();$i=0;
|
---|
| 913 | while(list($id_sede,$indir,$tel1,$tel2,$mappa,$filemappa)=$result1->fetch(PDO::FETCH_NUM)){
|
---|
| 914 |
|
---|
| 915 | $i++;
|
---|
| 916 | echo "<td><b><a href=\"modules.php?name=Elezioni&file=iphone&op=sezione&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_sede=$id_sede&indirizzo=$indir\">$indir</a></b>"
|
---|
| 917 | ."</td><td><b>$tel1 </b></td><td><b> $tel2</b></td></tr>";
|
---|
| 918 |
|
---|
| 919 | if ($i<$righe) echo"<tr class=\"bggray3\">";
|
---|
| 920 | if ($numcirc>1) echo "<td></td><td></td>";
|
---|
| 921 |
|
---|
| 922 | }
|
---|
| 923 | }
|
---|
| 924 | }
|
---|
| 925 | echo "</table>";
|
---|
| 926 |
|
---|
| 927 | //page($id_cons_gen,$go,$max,$min,$prev,$next,$offset,$file);
|
---|
| 928 |
|
---|
| 929 | //CloseTable();
|
---|
| 930 | }
|
---|
| 931 |
|
---|
| 932 | /******************************************************/
|
---|
| 933 | /*Funzione di visualizzazione globale sezioni */
|
---|
| 934 | /*****************************************************/
|
---|
| 935 |
|
---|
| 936 | function sezione_mob() {
|
---|
| 937 | global $admin, $prefix, $dbi, $offset, $min,$votog,$circo, $id_cons_gen,$id_circ,$descr_circ,$id_cons,$file,$prev,$next,$id_comune,$googlemaps;
|
---|
| 938 |
|
---|
| 939 | if(!isset($_GET['id_circ'])) unset($id_circ);
|
---|
| 940 | //dati();
|
---|
| 941 | $totali_t=0;$maschi_t=0;$femmine_t=0;
|
---|
| 942 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 943 | //mappa
|
---|
| 944 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
|
---|
| 945 | if (isset($param['indirizzo'])) $indirizzo=$param['indirizzo']; else $indirizzo='';
|
---|
| 946 | if ($id_sede!='0' && $googlemaps!='1'){
|
---|
| 947 |
|
---|
| 948 | echo "$indirizzo<br /><div><img src=\"modules.php?name=Elezioni&file=foto&id_sede=".$id_sede."\" alt=\"mappa\" /></div>";
|
---|
| 949 | }elseif($id_sede!='0' && $googlemaps=='1'){
|
---|
| 950 | echo "$indirizzo";
|
---|
| 951 | $mappa=googlemaps(); echo $mappa;
|
---|
| 952 | }
|
---|
| 953 |
|
---|
| 954 |
|
---|
| 955 | //CloseTable();
|
---|
| 956 | }
|
---|
| 957 |
|
---|
| 958 |
|
---|
| 959 | function genere(){
|
---|
| 960 | global $prefix,$db,$id_cons_gen;
|
---|
| 961 | $sql="SELECT descrizione,genere FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
|
---|
| 962 | $res = $dbi->prepare("$sql");
|
---|
| 963 | $res->execute();
|
---|
| 964 | list($descr_cons,$genere) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 965 | //$descr_cons =stripslashes($descr_com);
|
---|
| 966 |
|
---|
| 967 |
|
---|
| 968 |
|
---|
| 969 | echo $genere;
|
---|
| 970 | }
|
---|
| 971 |
|
---|
| 972 |
|
---|
| 973 | ########################################################
|
---|
| 974 | # Affluenze
|
---|
| 975 | function affluenze_mob() {
|
---|
| 976 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset,$genere,$votog,$votol,$votoc,$circo, $min,$id_cons,$tipo_cons,$id_cons_gen,$csv,$id_comune,$id_circ, $tema;
|
---|
| 977 | // icone
|
---|
| 978 | if ($circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 979 | else $circos="";
|
---|
| 980 | if (!$csv)
|
---|
| 981 |
|
---|
| 982 |
|
---|
| 983 | // numero sezioni scrutinate
|
---|
| 984 | //if ($circo)$circos="and id_circ='$id_circ'";
|
---|
| 985 | if (!isset($data1)) $data1='';
|
---|
| 986 | if (!isset($ora_ril)) $ora_ril='';
|
---|
| 987 | $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo";
|
---|
| 988 | $res1 = $dbi->prepare("$sql");
|
---|
| 989 | $res1->execute();
|
---|
| 990 | # mysql_query("select * from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' $circos group by id_sez ",$dbi);
|
---|
| 991 | $numero=$res1->rowCount();
|
---|
| 992 | $sql="SELECT t1.* FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos order by num_sez";
|
---|
| 993 | $res2 = $dbi->prepare("$sql");
|
---|
| 994 | $res2->execute();
|
---|
| 995 | #mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos",$dbi);
|
---|
| 996 | $sezioni=$res2->rowCount();
|
---|
| 997 |
|
---|
| 998 |
|
---|
| 999 |
|
---|
| 1000 |
|
---|
| 1001 |
|
---|
| 1002 | // barre
|
---|
| 1003 | $l_size = getimagesize("modules/Elezioni/images/barre/leftbar.gif");
|
---|
| 1004 | $m_size = getimagesize("modules/Elezioni/images/barre/mainbar.gif");
|
---|
| 1005 | $r_size = getimagesize("modules/Elezioni/images/barre/rightbar.gif");
|
---|
| 1006 | $l_size2 = getimagesize("modules/Elezioni/images/barre/leftbar2.gif");
|
---|
| 1007 | $m_size2 = getimagesize("modules/Elezioni/images/barre/mainbar2.gif");
|
---|
| 1008 | $r_size2 = getimagesize("modules/Elezioni/images/barre/rightbar2.gif");
|
---|
| 1009 | // totali
|
---|
| 1010 |
|
---|
| 1011 | if($tema=='tour') $andcond="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 0,1";
|
---|
| 1012 | else $andcond="select orario,data from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
|
---|
| 1013 |
|
---|
| 1014 | $sql="$andcond";
|
---|
| 1015 | $res = $dbi->prepare("$sql");
|
---|
| 1016 | $res->execute();
|
---|
| 1017 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
| 1018 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 1019 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 1020 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 1021 |
|
---|
| 1022 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1023 | echo "<center>"._VOTANTI." "._ALLE." "._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</center></li>";
|
---|
| 1024 |
|
---|
| 1025 | $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and data='$data' and orario='$orario' $circos group by t3.id_gruppo";
|
---|
| 1026 | $res1 = $dbi->prepare("$sql");
|
---|
| 1027 | $res1->execute();
|
---|
| 1028 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
| 1029 |
|
---|
| 1030 |
|
---|
| 1031 | $sql="select sum(t3.voti_complessivi), t4.num_gruppo , t4.id_gruppo from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede left join ".$prefix."_ele_gruppo as t4 on (t3.id_gruppo=t4.id_gruppo) where t3.id_cons='$id_cons' and t3.orario='$orario' and t3.data='$data' $circos group by t4.num_gruppo, t4.id_gruppo order by t4.num_gruppo ";
|
---|
| 1032 | $res1 = $dbi->prepare("$sql");
|
---|
| 1033 | $res1->execute();
|
---|
| 1034 |
|
---|
| 1035 |
|
---|
| 1036 |
|
---|
| 1037 |
|
---|
| 1038 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
| 1039 | /* $query="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where orario='$orario' and data='$data' and id_cons='$id_cons'";
|
---|
| 1040 |
|
---|
| 1041 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
| 1042 |
|
---|
| 1043 | $res_aff = $dbi->prepare("$query");
|
---|
| 1044 | $res_aff->execute();
|
---|
| 1045 | $voti_numero=$res_aff->rowCount();*/
|
---|
| 1046 | $query="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos";
|
---|
| 1047 |
|
---|
| 1048 |
|
---|
| 1049 | $res1234 = $dbi->prepare("$query");
|
---|
| 1050 | $res1234->execute();
|
---|
| 1051 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 1052 |
|
---|
| 1053 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 1054 |
|
---|
| 1055 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%\"><tr>";
|
---|
| 1056 | if ($genere==0){echo "<td>Refer. N.</td>";}
|
---|
| 1057 | echo "<td><b>"._VOTANTI."</b></td><td><b>Percent.</b></td>";
|
---|
| 1058 | echo "<td><b>"._SEZIONI."</b></td>";
|
---|
| 1059 | echo "</tr>";
|
---|
| 1060 | echo "<tr>";
|
---|
| 1061 | if ($genere==0){echo "<td><h2>$num_gruppo</h2></td>";}
|
---|
| 1062 | echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td>
|
---|
| 1063 | </tr></table>";
|
---|
| 1064 |
|
---|
| 1065 |
|
---|
| 1066 | // barre
|
---|
| 1067 |
|
---|
| 1068 | echo "<table style=\"width:100%\"><tr><td><table><tr><td> "._VOTANTI." : </td><td>
|
---|
| 1069 | <img src=\"modules/Elezioni/images/barre/leftbar2.gif\" height=\"$l_size2[1]\" width=\"$l_size2[0]\" alt=\"\" /><img src=\"modules/Elezioni/images/barre/mainbar2.gif\" alt=\"\" height=\"$m_size2[1]\" width=\"". ($perc * 1)."\" /><img src=\"modules/Elezioni/images/barre/rightbar2.gif\" height=\"$r_size2[1]\" width=\"$r_size2[0]\" alt=\"\" /> $perc% <br /></td></tr>\n";
|
---|
| 1070 |
|
---|
| 1071 | $tot_gen=$tot;
|
---|
| 1072 |
|
---|
| 1073 |
|
---|
| 1074 | echo "<tr><td> </td><td><img src=\"modules/Elezioni/images/barre/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"\" /><img src=\"modules/Elezioni/images/barre/mainbar.gif\" alt=\"\" height=\"$m_size[1]\" width=\"".(100 * 1)."\" /><img src=\"modules/Elezioni/images/barre/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"\" /> 100% </td></tr></table>";
|
---|
| 1075 | echo "</td></tr></table></li><br/>";
|
---|
| 1076 |
|
---|
| 1077 | }
|
---|
| 1078 |
|
---|
| 1079 | }
|
---|
| 1080 |
|
---|
| 1081 |
|
---|
| 1082 | }
|
---|
| 1083 |
|
---|
| 1084 | ## risultati semplici
|
---|
| 1085 | function graf_risultati(){
|
---|
| 1086 | global $descr_cons,$circo,$genere;
|
---|
| 1087 |
|
---|
| 1088 | if($genere!='0' && !$circo){ // referendum e circoscrizionali
|
---|
| 1089 | list ($gruppo,$pro)=grupporss();
|
---|
| 1090 | if ($gruppo!=''){
|
---|
| 1091 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1092 | echo "<center><h2>";
|
---|
| 1093 | echo "<b>Risultati</b> ";
|
---|
| 1094 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 1095 | echo "</h2></center></li>";
|
---|
| 1096 | }
|
---|
| 1097 |
|
---|
| 1098 | //$content .="<div style=\"text-align:left;\"><strong>$descr_cons</strong></div><br/>";
|
---|
| 1099 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
| 1100 | for($x=0;$x<count($gruppo);$x++){
|
---|
| 1101 | $nume=$x+1;
|
---|
| 1102 | echo "<tr bgcolor=\"#ffffff\"><td>$nume - ".$gruppo[$x]." </td><td align=\"right\"><b><span style=\"color:#ff0000;\">".$pro[$x] ."%</span></b></td></tr>\n";
|
---|
| 1103 | }
|
---|
| 1104 | echo "</table></center>";
|
---|
| 1105 |
|
---|
| 1106 | }
|
---|
| 1107 |
|
---|
| 1108 | }
|
---|
| 1109 |
|
---|
| 1110 | ###############################
|
---|
| 1111 | # grafico affluenza unica
|
---|
| 1112 |
|
---|
| 1113 | function affluenza_unica(){
|
---|
| 1114 | global $dbi,$circo,$prefix,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
|
---|
| 1115 |
|
---|
| 1116 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1117 | else $circos='';
|
---|
| 1118 | $circos='';
|
---|
| 1119 | // numero sezioni scrutinate
|
---|
| 1120 |
|
---|
| 1121 | $sql="select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons'";
|
---|
| 1122 | $res2 = $dbi->prepare("$sql");
|
---|
| 1123 | $res2->execute();
|
---|
| 1124 | $sezioni=$res2->rowCount();
|
---|
| 1125 |
|
---|
| 1126 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
| 1127 | $res = $dbi->prepare("$sql");
|
---|
| 1128 | $res->execute();
|
---|
| 1129 | if($res){
|
---|
| 1130 |
|
---|
| 1131 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
| 1132 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 1133 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 1134 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 1135 |
|
---|
| 1136 |
|
---|
| 1137 | $sql="select t3.* from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' and t3.data='$data' and t3.orario='$orario' group by t3.id_sez ";
|
---|
| 1138 | $res1 = $dbi->prepare("$sql");
|
---|
| 1139 | $res1->execute();
|
---|
| 1140 | $numero=$res1->rowCount();
|
---|
| 1141 |
|
---|
| 1142 | echo "<div style=\"text-align:center;\">Ultime Affluenze<br/>";
|
---|
| 1143 | echo "<b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
| 1144 |
|
---|
| 1145 |
|
---|
| 1146 |
|
---|
| 1147 |
|
---|
| 1148 | $sql="select sum(t3.voti_complessivi), t4.num_gruppo , t4.id_gruppo from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede left join ".$prefix."_ele_gruppo as t4 on (t3.id_gruppo=t4.id_gruppo) where t3.id_cons='$id_cons' and t3.orario='$orario' and t3.data='$data' $circos group by t4.num_gruppo, t4.id_gruppo order by t4.num_gruppo ";
|
---|
| 1149 | $res1 = $dbi->prepare("$sql");
|
---|
| 1150 | $res1->execute();
|
---|
| 1151 |
|
---|
| 1152 |
|
---|
| 1153 |
|
---|
| 1154 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
| 1155 |
|
---|
| 1156 | $query="select sum(t3.voti_complessivi) from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' and t3.data='$data' and t3.orario='$orario' $circos";
|
---|
| 1157 | if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 1158 |
|
---|
| 1159 | $res_aff = $dbi->prepare("$query");
|
---|
| 1160 | $res_aff->execute();
|
---|
| 1161 | $voti_numero=$res_aff->rowCount();
|
---|
| 1162 |
|
---|
| 1163 | # $query="select sum(t1.maschi+t1.femmine) from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' and t3.data='$data' and t3.orario='$orario' ";
|
---|
| 1164 |
|
---|
| 1165 | $query="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede ";
|
---|
| 1166 |
|
---|
| 1167 | //if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 1168 | $tot='';
|
---|
| 1169 | $res1234 = $dbi->prepare("$query");
|
---|
| 1170 | $res1234->execute();
|
---|
| 1171 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 1172 | if (isset($tot)){$perc=number_format($voti_t*100/$tot,2);}
|
---|
| 1173 | else{$tot=0;$perc="0.00";}
|
---|
| 1174 | if($voti_t<=$tot){
|
---|
| 1175 |
|
---|
| 1176 | $resto=100-$perc;
|
---|
| 1177 | if ($genere==0){echo "<div style=\"text-align:center\"><b>Referendum n. $num_gruppo</b></div>";}
|
---|
| 1178 |
|
---|
| 1179 | echo "<div style=\"margin:0 auto;width:300px;\"><img src=\"http://chart.apis.google.com/chart?
|
---|
| 1180 | chs=300x200
|
---|
| 1181 | &chd=t:$perc
|
---|
| 1182 | &cht=gom
|
---|
| 1183 | &chl=$perc%
|
---|
| 1184 | &chco=ff0000,ffff00 \"
|
---|
| 1185 | alt=\"Sample chart\" />
|
---|
| 1186 |
|
---|
| 1187 | </div>";
|
---|
| 1188 |
|
---|
| 1189 | }
|
---|
| 1190 |
|
---|
| 1191 | }
|
---|
| 1192 |
|
---|
| 1193 | }
|
---|
| 1194 | }
|
---|
| 1195 |
|
---|
| 1196 | }
|
---|
| 1197 |
|
---|
| 1198 |
|
---|
| 1199 | ###############################
|
---|
| 1200 | # votanti in tabella
|
---|
| 1201 |
|
---|
| 1202 | function votanti_tabella(){
|
---|
| 1203 |
|
---|
| 1204 | global $op, $prefix, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$dbi;
|
---|
| 1205 |
|
---|
| 1206 |
|
---|
| 1207 |
|
---|
| 1208 |
|
---|
| 1209 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1210 | else $circos='';
|
---|
| 1211 | $circos='';
|
---|
| 1212 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 1213 | if($genere=='4' || $votog) $tab="lista";
|
---|
| 1214 | else $tab="gruppo";
|
---|
| 1215 | if ($genere==0) $tab="ref";
|
---|
| 1216 |
|
---|
| 1217 | $sql="select t3.* from ".$prefix."_ele_voti_".$tab." as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' $circos group by t3.id_sez ";
|
---|
| 1218 | $res = $dbi->prepare("$sql");
|
---|
| 1219 | $res->execute();
|
---|
| 1220 | $numero=$res->rowCount();
|
---|
| 1221 | $sql="select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos";
|
---|
| 1222 | $res = $dbi->prepare("$sql");
|
---|
| 1223 | $res->execute();
|
---|
| 1224 | $sezioni=$res->rowCount();
|
---|
| 1225 |
|
---|
| 1226 | if ($numero!=0){
|
---|
| 1227 |
|
---|
| 1228 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1229 | echo "<center><b>"._DETTAGLIO." "._VOTIE."</b></center></li>";
|
---|
| 1230 | echo "<div style=\"text-align:center;\"><i> "._SEZSCRU." $numero "._SU." $sezioni </i></div>";
|
---|
| 1231 |
|
---|
| 1232 |
|
---|
| 1233 |
|
---|
| 1234 |
|
---|
| 1235 | if ($genere!=0) {
|
---|
| 1236 |
|
---|
| 1237 | $sql="select sum(t1.maschi+t1.femmine) from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and validi>0 $circos";
|
---|
| 1238 | $res = $dbi->prepare("$sql");
|
---|
| 1239 | $res->execute();
|
---|
| 1240 | list($tot_aventi) = $res->rowCount();
|
---|
| 1241 |
|
---|
| 1242 | $sql="select sum(t1.validi+t1.nulli+t1.bianchi+t1.contestati) as tot,
|
---|
| 1243 | sum(t1.validi),sum(t1.nulli),sum(t1.bianchi),sum(t1.contestati), '0', '0', '0'
|
---|
| 1244 | from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and validi>0 $circos";
|
---|
| 1245 | $res = $dbi->prepare("$sql");
|
---|
| 1246 | $res->execute();
|
---|
| 1247 |
|
---|
| 1248 | }else{
|
---|
| 1249 | $sql="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 1250 | $res = $dbi->prepare("$sql");
|
---|
| 1251 | $res->execute();
|
---|
| 1252 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 1253 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
| 1254 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo, sum(si), sum(no)
|
---|
| 1255 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>'0'";
|
---|
| 1256 | $res = $dbi->prepare("$sql");
|
---|
| 1257 | $res->execute();
|
---|
| 1258 | }
|
---|
| 1259 |
|
---|
| 1260 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id,$si,$no) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 1261 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
| 1262 | $arvoti=array($validi,$nulli,$bianchi,$contestati);
|
---|
| 1263 | $arperc=arrayperc($arvoti,$tot_votanti);
|
---|
| 1264 | if($tot_votanti){
|
---|
| 1265 | if($genere==0 and $validi) {$perc_si=number_format($si*100/$validi,2);$perc_no=number_format(100 - $si*100/$validi,2);}
|
---|
| 1266 | else {$perc_si="0.00"; $perc_no="0.00";}
|
---|
| 1267 | $perc_validi=number_format($arperc[0],2);#number_format($validi*100/$tot_votanti,2);
|
---|
| 1268 | $perc_nulli=number_format($arperc[1],2);
|
---|
| 1269 | $perc_bianchi=number_format($arperc[2],2);
|
---|
| 1270 | $perc_conte=number_format($arperc[3],2);
|
---|
| 1271 | }else {$perc_validi="0.00";$perc_nulli="0.00";$perc_bianchi="0.00";$perc_conte="0.00";}
|
---|
| 1272 | if($tot_aventi)
|
---|
| 1273 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
| 1274 | else $perc_votanti="0.00";
|
---|
| 1275 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
| 1276 | $perc_non=100-$perc_votanti;
|
---|
| 1277 |
|
---|
| 1278 | if ($genere==0) {
|
---|
| 1279 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
| 1280 | $resg = $dbi->prepare("$sql");
|
---|
| 1281 | $resg->execute();
|
---|
| 1282 | list($num_gruppo,$descr_gruppo) = $resg->fetch(PDO::FETCH_NUM);
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
| 1285 |
|
---|
| 1286 |
|
---|
| 1287 |
|
---|
| 1288 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
| 1289 | if ($genere==0) {echo "<br/>Referendum n. <b>[$num_gruppo]</b><br/>";}
|
---|
| 1290 | echo "
|
---|
| 1291 | <tr bgcolor=\"#ffffff\"><td ><b>"._AVENTI."</b></td><td align=\"right\">$tot_aventi</td><td align=\"right\"><span class=\"red\">100.00%</span></td></tr>
|
---|
| 1292 |
|
---|
| 1293 | <tr bgcolor=\"#ffffff\"><td><b>"._VOTANTI."</b></td><td align=\"right\">$tot_votanti</td><td align=\"right\"><span class=\"red\">$perc_votanti%</span></td></tr>";
|
---|
| 1294 | if ($genere==0){
|
---|
| 1295 | echo "<tr bgcolor=\"#ffffff\"><td>"._SI."</td><td align=\"right\">$si</td><td align=\"right\"><span class=\"red\">$perc_si%</span></td></tr>
|
---|
| 1296 |
|
---|
| 1297 | <tr bgcolor=\"#ffffff\"><td>"._NO."</td><td align=\"right\">$no</td><td align=\"right\"><span class=\"red\">$perc_no%</span></td></tr>";
|
---|
| 1298 | }
|
---|
| 1299 | echo "<tr bgcolor=\"#ffffff\"><td>"._VALIDI."</td><td align=\"right\">$validi</td><td align=\"right\"><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
| 1300 |
|
---|
| 1301 | <tr bgcolor=\"#ffffff\"><td>"._NULLI."</td><td align=\"right\">$nulli</td><td align=\"right\"><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
| 1302 |
|
---|
| 1303 | <tr bgcolor=\"#ffffff\"><td>"._BIANCHI."</td><td align=\"right\">$bianchi</td><td align=\"right\"><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
| 1304 |
|
---|
| 1305 | <tr bgcolor=\"#ffffff\"><td>"._CONTESTATI."</td><td align=\"right\">$contestati</td><td align=\"right\"><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
| 1306 |
|
---|
| 1307 | </table></li>";
|
---|
| 1308 |
|
---|
| 1309 | }
|
---|
| 1310 | }
|
---|
| 1311 | }
|
---|
| 1312 |
|
---|
| 1313 |
|
---|
| 1314 |
|
---|
| 1315 | ######## fine
|
---|
| 1316 |
|
---|
| 1317 |
|
---|
| 1318 |
|
---|
| 1319 |
|
---|
| 1320 |
|
---|
| 1321 |
|
---|
| 1322 | ####################################
|
---|
| 1323 | # grafico sezioni
|
---|
| 1324 |
|
---|
| 1325 | function graf_sezioni(){
|
---|
| 1326 | global $prefix, $dbi,$id_cons_gen;
|
---|
| 1327 | $sql = "select chiusa from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'";
|
---|
| 1328 | $res = $dbi->prepare("$sql");
|
---|
| 1329 | $res->execute();
|
---|
| 1330 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 1331 |
|
---|
| 1332 | //if($chiusa!='1') numeri_sezione(); # se la consultazione non Ú chiusa
|
---|
| 1333 |
|
---|
| 1334 |
|
---|
| 1335 |
|
---|
| 1336 | //numeri_sezione(); //lancia la funzione
|
---|
| 1337 |
|
---|
| 1338 | function numeri_sezione() {
|
---|
| 1339 | global $prefix, $dbi, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
| 1340 |
|
---|
| 1341 |
|
---|
| 1342 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1343 | else $circos='';
|
---|
| 1344 |
|
---|
| 1345 | if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 1346 | else $tab="gruppo";
|
---|
| 1347 |
|
---|
| 1348 |
|
---|
| 1349 |
|
---|
| 1350 | # numero sezioni
|
---|
| 1351 | $sql="select t1.id_sez,t1.num_sez from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos order by t1.num_sez";
|
---|
| 1352 | $res = $dbi->prepare("$sql");
|
---|
| 1353 | $res->execute();
|
---|
| 1354 | $max = $res->rowCount();
|
---|
| 1355 | if(!isset($html)) $html='';
|
---|
| 1356 | $html = "\n<table style=\"margin:0px auto;border:0px; width:90%\"><tr>";
|
---|
| 1357 |
|
---|
| 1358 | $i=0;$id_circ_old=0;$e=0;
|
---|
| 1359 | while(list($sez_id, $sez_num) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
| 1360 | $i++;
|
---|
| 1361 |
|
---|
| 1362 | $sql="select * from ".$prefix."_ele_voti_".$tab." where id_sez='$sez_id'";
|
---|
| 1363 | $res2 = $dbi->prepare("$sql");
|
---|
| 1364 | $res2->execute();
|
---|
| 1365 | $numero=$res2->rowCount();
|
---|
| 1366 | if ($numero!=0){$e++;$bgsez="#FFFF00";}else{$bgsez="";}
|
---|
| 1367 |
|
---|
| 1368 |
|
---|
| 1369 | if ($genere==0) $pos="gruppo_sezione";elseif($genere=='4' || $votog) $pos="lista_sezione";
|
---|
| 1370 | else $pos="gruppo_sezione";
|
---|
| 1371 |
|
---|
| 1372 | //$html .="<td style=\"margin:0px auto; text-align:center; width:5%;\" bgcolor=\"$bgsez\"><a href=\"modules.php?id_cons_gen=$id_cons_gen&name=Elezioni&id_comune=$id_comune&perc=true&file=index&op=$pos&minsez=$sez_num&offsetsez=$sez_num\"><b>$sez_num</b></a></td>";
|
---|
| 1373 | $html .="<td style=\"margin:0px auto; text-align:center; width:5%;\" bgcolor=\"$bgsez\"><b>$sez_num</b></td>";
|
---|
| 1374 |
|
---|
| 1375 | if (($i%8) ==0) $html .="</tr>\n<tr>";
|
---|
| 1376 | }
|
---|
| 1377 |
|
---|
| 1378 | $html .="</tr></table>\n";
|
---|
| 1379 | // stampa
|
---|
| 1380 | if($e!='0'){
|
---|
| 1381 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1382 | echo "<center>";
|
---|
| 1383 | echo "<b>"._SEZSCRU."</b> ";
|
---|
| 1384 | echo "</center></li><br/></center>";
|
---|
| 1385 | echo "<center><img alt=\"Grafico\" src=\"modules/Elezioni/grafici/ledex2.php?sez=$e&max=$max\" /></center>";
|
---|
| 1386 |
|
---|
| 1387 | echo $html; }
|
---|
| 1388 | }
|
---|
| 1389 | numeri_sezione(); //lancia la funzione
|
---|
| 1390 | }
|
---|
| 1391 |
|
---|
| 1392 | ?>
|
---|
| 1393 |
|
---|
| 1394 |
|
---|