[231] | 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('MODULE_FILE')) {
|
---|
| 11 | die ("You can't access this file directly...");
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 |
|
---|
[265] | 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);
|
---|
[231] | 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
|
---|
[376] | 34 | $tab="gruppo"; $tabr="gruppo";
|
---|
| 35 | if ($genere==0) $tabr="ref";elseif($genere=='4' || $votog) {$tab="lista"; $tabr="lista";}
|
---|
| 36 | # else $tab="gruppo";
|
---|
[231] | 37 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 38 | else $circos='';
|
---|
| 39 |
|
---|
| 40 |
|
---|
[376] | 41 | $sql="select t1.id_sez from ".$prefix."_ele_voti_".$tabr." 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 ";
|
---|
[364] | 42 | $res = $dbi->prepare("$sql");
|
---|
| 43 | $res->execute();
|
---|
[231] | 44 | if($res)
|
---|
[265] | 45 | $numero=$res->rowCount();
|
---|
[231] | 46 | else
|
---|
| 47 | $numero=1;
|
---|
[265] | 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";
|
---|
[364] | 49 | $res = $dbi->prepare("$sql");
|
---|
| 50 | $res->execute();
|
---|
[265] | 51 | $sezioni=$res->rowCount();
|
---|
[231] | 52 | if ($numero!=0){
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
[265] | 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);
|
---|
[231] | 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 |
|
---|
[265] | 69 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
[231] | 70 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), '0'
|
---|
[265] | 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();
|
---|
[231] | 74 | }else{
|
---|
| 75 |
|
---|
| 76 | if($tema=='tour'){
|
---|
[265] | 77 | $sql="SELECT count(0)
|
---|
| 78 | from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 79 | $res1 = $dbi->prepare("$sql");
|
---|
| 80 | $res1->execute();
|
---|
[231] | 81 |
|
---|
[265] | 82 | list($max_ruotag) = $res1->fetch(PDO::FETCH_NUM);
|
---|
[231] | 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;
|
---|
[265] | 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);
|
---|
[231] | 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 |
|
---|
[265] | 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
|
---|
[231] | 99 | FROM ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo
|
---|
[265] | 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();
|
---|
[231] | 103 | } else
|
---|
[265] | 104 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
[231] | 105 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
|
---|
[265] | 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();
|
---|
[231] | 109 | }
|
---|
[265] | 110 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 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) {
|
---|
[265] | 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);
|
---|
[231] | 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(){
|
---|
[283] | 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;
|
---|
[231] | 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){
|
---|
[265] | 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);
|
---|
[231] | 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";}
|
---|
[364] | 189 | $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
| 190 | $res = $dbi->prepare("$sql");
|
---|
| 191 | $res->execute();
|
---|
[231] | 192 | if ($circo){
|
---|
[265] | 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";
|
---|
[231] | 198 | $circond="and id_circ=$id_circ";$circondt1="and t1.id_circ=$id_circ";
|
---|
[265] | 199 | $restotv = $dbi->prepare("$sql");
|
---|
| 200 | $restotv->execute();
|
---|
[231] | 201 | }
|
---|
[265] | 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;
|
---|
[231] | 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)
|
---|
[265] | 219 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
[231] | 220 | if ($votog)
|
---|
[265] | 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);
|
---|
[231] | 225 |
|
---|
| 226 | $i=0;
|
---|
| 227 | // lista o gruppo
|
---|
| 228 | if ($genere!=4 and !$visgralista){
|
---|
| 229 |
|
---|
| 230 | if ($votog){
|
---|
| 231 |
|
---|
[265] | 232 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[231] | 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
|
---|
[265] | 240 | order by somma desc";
|
---|
| 241 | $cosa='id_gruppo';
|
---|
[231] | 242 |
|
---|
| 243 | }else{
|
---|
| 244 |
|
---|
| 245 |
|
---|
[265] | 246 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[231] | 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
|
---|
[364] | 250 | group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
|
---|
[265] | 251 | order by somma desc";
|
---|
| 252 | $cosa='id_gruppo';
|
---|
[231] | 253 | }
|
---|
[265] | 254 | $res = $dbi->prepare("$sql");
|
---|
| 255 | $res->execute();
|
---|
[231] | 256 |
|
---|
| 257 |
|
---|
| 258 | }else{
|
---|
[265] | 259 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
[231] | 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
|
---|
[419] | 263 | group by t1.id_lista, t1.num_lista, t1.descrizione
|
---|
[265] | 264 | order by somma desc";
|
---|
| 265 | $res = $dbi->prepare("$sql");
|
---|
| 266 | $res->execute();
|
---|
| 267 | $cosa='id_lista';
|
---|
[231] | 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
|
---|
[265] | 278 | $gruppinum=$res->rowCount();
|
---|
[231] | 279 | $altrivoti=0;
|
---|
| 280 | ####calcolo percentuale
|
---|
| 281 | $arvoti=array();
|
---|
| 282 | $arperc=array();
|
---|
[265] | 283 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 284 | $arvoti[$id]=$voti;
|
---|
| 285 | }
|
---|
| 286 | $arperc=arrayperc($arvoti,$tot);
|
---|
| 287 | //$db->sql_data_seek($res,0);
|
---|
[265] | 288 | $res = $dbi->prepare("$sql");
|
---|
| 289 | $res->execute();
|
---|
| 290 | # mysql_data_seek($res,0);
|
---|
[231] | 291 | ####
|
---|
| 292 | $altriperc=0;
|
---|
[265] | 293 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 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
|
---|
[265] | 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)){
|
---|
[231] | 386 |
|
---|
| 387 | $s=0;
|
---|
[265] | 388 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
[231] | 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
|
---|
[265] | 393 | ";
|
---|
| 394 | $res1 = $dbi->prepare("$sql");
|
---|
| 395 | $res1->execute();
|
---|
[231] | 396 |
|
---|
| 397 |
|
---|
[265] | 398 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 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";
|
---|
[364] | 476 | $sql="select id_sez from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons' $circos group by id_sez ";
|
---|
| 477 | $res = $dbi->prepare("$sql");
|
---|
| 478 | $res->execute();
|
---|
[265] | 479 | $numero=$res->rowCount();
|
---|
| 480 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos ";
|
---|
[364] | 481 | $res = $dbi->prepare("$sql");
|
---|
| 482 | $res->execute();
|
---|
[265] | 483 | $sezioni=$res->rowCount();
|
---|
[231] | 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
|
---|
[265] | 498 | $sql="SELECT * FROM ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
| 499 | $res = $dbi->prepare("$sql");
|
---|
| 500 | $res->execute();
|
---|
| 501 | $max = $res->rowCount();
|
---|
[231] | 502 |
|
---|
| 503 | // tot voti liste
|
---|
[265] | 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);
|
---|
[231] | 508 |
|
---|
[265] | 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)) {
|
---|
[231] | 513 | if ($num_lista!=0) {
|
---|
| 514 | // voti lista
|
---|
[265] | 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);
|
---|
[231] | 519 | if ($voti_lista_tutti!=0)
|
---|
| 520 | $perc_lista=number_format(($voti_lista*100)/$voti_lista_tutti,2);
|
---|
| 521 | else $perc_lista='';
|
---|
| 522 | // gruppo
|
---|
[265] | 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);
|
---|
[231] | 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(){
|
---|
[335] | 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;
|
---|
[231] | 565 | if ($siteistat==$id_comune) $logo='1'; else $logo=''; // logo per il comune
|
---|
| 566 | $bgcolor1="";
|
---|
| 567 |
|
---|
| 568 | $tab="ele_voti_candidati";
|
---|
| 569 |
|
---|
[335] | 570 | $sql="select id_sez from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_sez ";
|
---|
[265] | 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();
|
---|
[231] | 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
|
---|
[265] | 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);
|
---|
[231] | 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;
|
---|
[265] | 603 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t2.voti) as somma
|
---|
[231] | 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'
|
---|
[364] | 608 | group by t1.id_lista, t1.id_cand, t1.nome, t1.cognome
|
---|
| 609 | order by somma desc";
|
---|
[265] | 610 | $res = $dbi->prepare("$sql");
|
---|
| 611 | $res->execute();
|
---|
| 612 | $n_candi=$res->rowCount();
|
---|
[231] | 613 |
|
---|
[265] | 614 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 615 | $candidato[$i]=$cognome;
|
---|
| 616 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
| 617 | // sviluppo tabella dati
|
---|
| 618 | $e=$i+1;
|
---|
| 619 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%;\">"; // inizio tabella dati
|
---|
| 620 | 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>
|
---|
| 621 | <td width=\"70%\" bgcolor=\"$bgcolor1\"><b>$nome $cognome</b><br/>
|
---|
| 622 | "._VOTI.": <b>$voti </b>
|
---|
| 623 | ( <span style=\"color:#ff0000;\">$pro[$i]%</span> )</td></tr>";
|
---|
| 624 | echo "</table></li>"; // fine tabella dati
|
---|
| 625 | /* tolto il conteggio
|
---|
| 626 | if ($e=='5000' || $e==$n_candi){
|
---|
| 627 |
|
---|
| 628 |
|
---|
| 629 |
|
---|
| 630 |
|
---|
| 631 |
|
---|
| 632 | //include("footer.php");
|
---|
| 633 | exit;
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | */
|
---|
| 637 |
|
---|
| 638 | $i++;
|
---|
| 639 |
|
---|
| 640 |
|
---|
| 641 |
|
---|
| 642 |
|
---|
| 643 | }
|
---|
| 644 |
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 | }
|
---|
| 648 |
|
---|
| 649 |
|
---|
| 650 | ######################################################
|
---|
| 651 | function numerodisezioni() {
|
---|
| 652 | /*Funzione numero sezioni scrutinate
|
---|
| 653 | /*****************************************************
|
---|
| 654 | Ritorna i dati in un array con quest'ordine:
|
---|
| 655 | numero di sezioni totali , numero di sezioni scrutinate
|
---|
| 656 | *******************************************************/
|
---|
| 657 |
|
---|
| 658 |
|
---|
| 659 |
|
---|
| 660 | global $dbi,$db, $prefix, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
| 661 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 662 | else $circos='';
|
---|
| 663 |
|
---|
| 664 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 665 | if($genere=='4' || $votog) $tab="lista";
|
---|
| 666 | else $tab="gruppo";
|
---|
| 667 | if ($genere==0) $tab="ref";
|
---|
| 668 |
|
---|
| 669 |
|
---|
[265] | 670 | $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";
|
---|
| 671 | $res2 = $dbi->prepare("$sql");
|
---|
| 672 | $res2->execute();
|
---|
| 673 | $result_sezioni[1]=$res2->rowCount();
|
---|
[231] | 674 |
|
---|
| 675 |
|
---|
| 676 |
|
---|
| 677 | // numero sezioni
|
---|
[364] | 678 | $sql="select t3.id_sez 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 ";
|
---|
[265] | 679 | $sez_num = $dbi->prepare("$sql");
|
---|
| 680 | $sez_num->execute();
|
---|
| 681 | $result_sezioni[0]=$sez_num->rowCount();
|
---|
[231] | 682 |
|
---|
| 683 | // $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");
|
---|
| 684 | //$result_sezioni[1]=$db->sql_numrows($sez_scrut);
|
---|
| 685 |
|
---|
| 686 |
|
---|
[265] | 687 | $sql="select chiusa from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
| 688 | $res = $dbi->prepare("$sql");
|
---|
| 689 | $res->execute();
|
---|
[231] | 690 | //$chiusa=$db->sql_numrows($res);
|
---|
[265] | 691 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
[231] | 692 | //echo "-----------> $chiusa - $id_comune";
|
---|
| 693 |
|
---|
| 694 | if($chiusa!=0)$result_sezioni[0]=0;
|
---|
| 695 | return $result_sezioni;
|
---|
| 696 |
|
---|
| 697 |
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 | }
|
---|
| 702 | ####################################################
|
---|
| 703 | # Come
|
---|
| 704 | ####################################################
|
---|
| 705 |
|
---|
| 706 | function come_mob($info) {
|
---|
| 707 | global $prefix, $dbi, $offset, $min,$id_cons,$tipo_cons,$descr_cons,$id_comune;
|
---|
| 708 |
|
---|
| 709 | $tab='';
|
---|
| 710 | if ($info=="come"){ $tab="_ele_come";$vista="Come si vota";}
|
---|
| 711 | elseif ($info=="numeri"){ $tab="_ele_numeri";$vista="Numeri Utili";}
|
---|
| 712 | elseif ($info=="servizi"){ $tab="_ele_servizi";$vista="Servizi Elettorali";}
|
---|
| 713 | elseif ($info=="link"){ $tab="_ele_link";$vista="Link Utili";}
|
---|
| 714 | else{ $tab="_ele_come";$vista="Come si vota";}
|
---|
| 715 |
|
---|
| 716 |
|
---|
[283] | 717 | global $user, $admin, $cookie, $textcolor2;
|
---|
[265] | 718 | $sql="select mid, title, preamble, content,editimage from ".$prefix."$tab where id_cons='$id_cons' order by mid ";
|
---|
| 719 | $result = $dbi->prepare("$sql");
|
---|
| 720 | $result->execute();
|
---|
[231] | 721 |
|
---|
| 722 | echo "<li data-role=\"list-divider\" >";
|
---|
| 723 | echo "<center><b>$vista</b>";
|
---|
| 724 | echo "</center></li>";
|
---|
| 725 |
|
---|
| 726 |
|
---|
| 727 |
|
---|
[265] | 728 | if ($result->rowCount() == 0) {
|
---|
[231] | 729 | return;
|
---|
| 730 | } else {
|
---|
[265] | 731 | while (list($mid, $title, $preamble,$content, $editimage) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
[231] | 732 | if ($title != "" && $content != "") {
|
---|
| 733 |
|
---|
| 734 | if ($info=="link"){
|
---|
| 735 |
|
---|
| 736 | echo "<li>
|
---|
| 737 | <b><a href=\"$preamble\">$title</a></b>
|
---|
| 738 | $content
|
---|
| 739 | </li>";
|
---|
| 740 |
|
---|
| 741 | }else{
|
---|
| 742 | echo "<li><div><b>$title</b><br /></div>";
|
---|
| 743 |
|
---|
| 744 |
|
---|
| 745 | echo "<div class=\"message\">$preamble<br /><br /></div>";
|
---|
| 746 |
|
---|
| 747 | echo "<div class=\"message\">$content</div></li>";
|
---|
| 748 | }
|
---|
| 749 |
|
---|
| 750 |
|
---|
| 751 |
|
---|
| 752 | }
|
---|
| 753 | }
|
---|
| 754 | }
|
---|
| 755 |
|
---|
| 756 | }
|
---|
| 757 |
|
---|
| 758 |
|
---|
| 759 |
|
---|
| 760 | /****************
|
---|
| 761 | Funzione dati Generali
|
---|
| 762 | visuallizza la stringa dei dati generali
|
---|
| 763 | ****************/
|
---|
| 764 |
|
---|
| 765 |
|
---|
| 766 | function dati_mob($print) {
|
---|
| 767 | global $db,$prefix, $dbi, $votog, $votol, $votoc, $circo, $id_cons,$tipo_cons,$descr_cons,$id_cons_gen,$id_comune,$genere,$id_circ;
|
---|
| 768 | $print=intval($print);
|
---|
| 769 |
|
---|
[265] | 770 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
| 771 | $res = $dbi->prepare("$sql");
|
---|
| 772 | $res->execute();
|
---|
| 773 | $sql="select * from ".$prefix."_ele_sede where id_cons='$id_cons' ";
|
---|
| 774 | $ressede = $dbi->prepare("$sql");
|
---|
| 775 | $ressede->execute();
|
---|
| 776 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' ";
|
---|
| 777 | $res3 = $dbi->prepare("$sql");
|
---|
| 778 | $res3->execute();
|
---|
| 779 | $circo = $res->rowCount();
|
---|
| 780 | $sedi = $ressede->rowCount();
|
---|
| 781 | $sez = $res3->rowCount();
|
---|
[231] | 782 |
|
---|
| 783 | //Variabili linguaggio
|
---|
| 784 | $DATIG=_DATIG;$AVENTI=_AVENTI;$MASCHI=_MASCHI;$FEMMINE=_FEMMINE;$SEZIONI=_SEZIONI; $GRUPPI=_GRUPPI;$CANDIDATI=_CANDIDATI;$LISTE=_LISTE;
|
---|
| 785 | if ($circo>1)$SEDE=_CIRCS; else $SEDE=_SEDI;
|
---|
| 786 |
|
---|
| 787 | $candi=0;
|
---|
| 788 |
|
---|
| 789 | // se non referendum
|
---|
| 790 | if ($genere!=0 and !$votoc){
|
---|
[265] | 791 | $sql="select id_cons from ".$prefix."_ele_candidati where id_cons='$id_cons' ";
|
---|
| 792 | $res1 = $dbi->prepare("$sql");
|
---|
| 793 | $res1->execute();
|
---|
| 794 | $candi = $res1->rowCount();
|
---|
[231] | 795 | }
|
---|
| 796 |
|
---|
| 797 | // se non europee (non liste e candidati)
|
---|
| 798 | if ($genere!=4){
|
---|
[265] | 799 | $sql="select id_cons from ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
|
---|
[231] | 800 | }else{
|
---|
[265] | 801 | $sql="select id_cons from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
[231] | 802 | }
|
---|
[265] | 803 | $res2 = $dbi->prepare("$sql");
|
---|
| 804 | $res2->execute();
|
---|
[231] | 805 |
|
---|
[265] | 806 | $gruppo = $res2->rowCount();
|
---|
[231] | 807 |
|
---|
| 808 | // camera e senato con raggruppamenti
|
---|
| 809 | //if($votog){
|
---|
[265] | 810 | $sql="select * from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
| 811 | $res3 = $dbi->prepare("$sql");
|
---|
| 812 | $res3->execute();
|
---|
| 813 | $liste = $res3->rowCount();
|
---|
[231] | 814 | //}
|
---|
| 815 |
|
---|
| 816 | if($circo==1) $circo=$sedi;
|
---|
[265] | 817 | $sql="select sum(maschi),sum(femmine), sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
|
---|
| 818 | $res4 = $dbi->prepare("$sql");
|
---|
| 819 | $res4->execute();
|
---|
| 820 | if($res4) list($maschi,$femmine,$tot) = $res4->fetch(PDO::FETCH_NUM);
|
---|
[231] | 821 |
|
---|
| 822 |
|
---|
| 823 |
|
---|
| 824 | $ris = array($tot,$maschi,$femmine,$circo,$sez,$gruppo,$candi,$liste);
|
---|
| 825 | return $ris;
|
---|
| 826 |
|
---|
| 827 |
|
---|
| 828 | }
|
---|
| 829 |
|
---|
| 830 | ####################################
|
---|
| 831 | ## funzione che richiama i dati generali
|
---|
| 832 | ## function dati_mob e li stampa
|
---|
| 833 |
|
---|
| 834 | function dati_mob_fun(){
|
---|
| 835 | $dati=dati_mob(0);
|
---|
| 836 | global $genere;
|
---|
| 837 | if($genere==0)$gruppo="Quesiti";else$gruppo="Gruppi";
|
---|
| 838 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 839 | echo "<b> <center>Dati Generali della consultazione </center></b></li>";
|
---|
| 840 | echo "<br/><div style=\"margin:0 auto;width:300px;\"><ul>";
|
---|
| 841 | echo "<li>Aventi Diritto: $dati[0]</li>";
|
---|
| 842 | echo "<li> Maschi: $dati[1]</li>";
|
---|
| 843 | echo "<li>Femmine: $dati[2]</li>";
|
---|
| 844 | if($dati[3]!=0) echo "<li>Num. Circoscrizioni: $dati[3]</li>";
|
---|
| 845 | echo "<li>Num: Sezioni: $dati[4]</li>";
|
---|
| 846 | if($dati[5]!=0)echo "<li>Num: $gruppo: $dati[5]</li>";
|
---|
| 847 | if($dati[6]!=0)echo "<li>Num. Candidati: $dati[6]</li>";
|
---|
| 848 | if($dati[7]!=0)echo "<li>Num. Liste: $dati[7]</li>";
|
---|
| 849 | echo "</ul></div>";
|
---|
| 850 | }
|
---|
| 851 |
|
---|
| 852 |
|
---|
| 853 |
|
---|
| 854 |
|
---|
| 855 | function circo_mob() {
|
---|
| 856 |
|
---|
| 857 | /******************************************************/
|
---|
| 858 | /*Funzione di visualizzazione sede */
|
---|
| 859 | /*****************************************************/
|
---|
| 860 | global $admin, $prefix, $dbi, $offset, $min,$id_cons,$file,$id_cons_gen,$id_comune ,$prev,$next;
|
---|
[265] | 861 | $sql="SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
| 862 | $res = $dbi->prepare("$sql");
|
---|
| 863 | $res->execute();
|
---|
| 864 | $max = $res->rowCount();
|
---|
[231] | 865 |
|
---|
| 866 | //OpenTable();
|
---|
| 867 |
|
---|
| 868 | dati();
|
---|
| 869 |
|
---|
| 870 |
|
---|
| 871 | $offset=10;
|
---|
| 872 | if (!isset($min)) $min=0;
|
---|
| 873 | $go="circo";
|
---|
| 874 |
|
---|
[265] | 875 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ
|
---|
| 876 | LIMIT $min,$offset";
|
---|
| 877 | $result = $dbi->prepare("$sql");
|
---|
| 878 | $result->execute();
|
---|
| 879 | $numcirc=$result->rowCount();
|
---|
[231] | 880 | if ($numcirc>1){
|
---|
| 881 | echo "<div><b>"._CIRCS."</b></div><br /><br />
|
---|
| 882 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
| 883 | ."<td ><b>"._NUM."</b></td>"
|
---|
| 884 | ."<td ><b>"._CIRCO."</b></td>"
|
---|
| 885 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
| 886 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
| 887 | }else{
|
---|
| 888 | echo "<div><b></b></div><br /><br />
|
---|
| 889 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
| 890 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
| 891 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
| 892 | }
|
---|
| 893 |
|
---|
[265] | 894 | while(list($id_cons2,$id_circ,$num_circ,$descr_circ) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
[231] | 895 | #if($numcirc==1) {$descr_circ=''; $num_circ='';}
|
---|
| 896 | if (!($num_circ===0)) {
|
---|
| 897 |
|
---|
| 898 | echo "<tr class=\"bggray3\">";
|
---|
| 899 | if ($numcirc>1) {
|
---|
| 900 | echo "<td><b>$num_circ</b>"
|
---|
| 901 | ."</td><td><b>";
|
---|
| 902 | 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>";
|
---|
| 903 | }
|
---|
| 904 |
|
---|
| 905 | // dati sede
|
---|
[265] | 906 | $sql="select id_sede,indirizzo,telefono1,telefono2, mappa, filemappa from ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ'";
|
---|
| 907 | $result1 = $dbi->prepare("$sql");
|
---|
| 908 | $result1->execute();
|
---|
| 909 | $righe=$result1->rowCount();$i=0;
|
---|
| 910 | while(list($id_sede,$indir,$tel1,$tel2,$mappa,$filemappa)=$result1->fetch(PDO::FETCH_NUM)){
|
---|
[231] | 911 |
|
---|
| 912 | $i++;
|
---|
| 913 | 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>"
|
---|
| 914 | ."</td><td><b>$tel1 </b></td><td><b> $tel2</b></td></tr>";
|
---|
| 915 |
|
---|
| 916 | if ($i<$righe) echo"<tr class=\"bggray3\">";
|
---|
| 917 | if ($numcirc>1) echo "<td></td><td></td>";
|
---|
| 918 |
|
---|
| 919 | }
|
---|
| 920 | }
|
---|
| 921 | }
|
---|
| 922 | echo "</table>";
|
---|
| 923 |
|
---|
| 924 | //page($id_cons_gen,$go,$max,$min,$prev,$next,$offset,$file);
|
---|
| 925 |
|
---|
| 926 | //CloseTable();
|
---|
| 927 | }
|
---|
| 928 |
|
---|
| 929 | /******************************************************/
|
---|
| 930 | /*Funzione di visualizzazione globale sezioni */
|
---|
| 931 | /*****************************************************/
|
---|
| 932 |
|
---|
| 933 | function sezione_mob() {
|
---|
| 934 | global $admin, $prefix, $dbi, $offset, $min,$votog,$circo, $id_cons_gen,$id_circ,$descr_circ,$id_cons,$file,$prev,$next,$id_comune,$googlemaps;
|
---|
| 935 |
|
---|
| 936 | if(!isset($_GET['id_circ'])) unset($id_circ);
|
---|
| 937 | //dati();
|
---|
| 938 | $totali_t=0;$maschi_t=0;$femmine_t=0;
|
---|
| 939 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 940 | //mappa
|
---|
| 941 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
|
---|
| 942 | if (isset($param['indirizzo'])) $indirizzo=$param['indirizzo']; else $indirizzo='';
|
---|
| 943 | if ($id_sede!='0' && $googlemaps!='1'){
|
---|
| 944 |
|
---|
| 945 | echo "$indirizzo<br /><div><img src=\"modules.php?name=Elezioni&file=foto&id_sede=".$id_sede."\" alt=\"mappa\" /></div>";
|
---|
| 946 | }elseif($id_sede!='0' && $googlemaps=='1'){
|
---|
| 947 | echo "$indirizzo";
|
---|
| 948 | $mappa=googlemaps(); echo $mappa;
|
---|
| 949 | }
|
---|
| 950 |
|
---|
| 951 |
|
---|
| 952 | //CloseTable();
|
---|
| 953 | }
|
---|
| 954 |
|
---|
| 955 |
|
---|
| 956 | function genere(){
|
---|
| 957 | global $prefix,$db,$id_cons_gen;
|
---|
[265] | 958 | $sql="SELECT descrizione,genere FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
|
---|
| 959 | $res = $dbi->prepare("$sql");
|
---|
| 960 | $res->execute();
|
---|
| 961 | list($descr_cons,$genere) = $res->fetch(PDO::FETCH_NUM);
|
---|
[231] | 962 | //$descr_cons =stripslashes($descr_com);
|
---|
| 963 |
|
---|
| 964 |
|
---|
| 965 |
|
---|
| 966 | echo $genere;
|
---|
| 967 | }
|
---|
| 968 |
|
---|
| 969 |
|
---|
| 970 | ########################################################
|
---|
| 971 | # Affluenze
|
---|
| 972 | function affluenze_mob() {
|
---|
| 973 | 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;
|
---|
| 974 | // icone
|
---|
| 975 | if ($circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 976 | else $circos="";
|
---|
[418] | 977 | $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";
|
---|
[265] | 978 | $res2 = $dbi->prepare("$sql");
|
---|
| 979 | $res2->execute();
|
---|
[418] | 980 | $sezioni=$res2->rowCount();
|
---|
| 981 |
|
---|
[231] | 982 | // barre
|
---|
| 983 | $l_size = getimagesize("modules/Elezioni/images/barre/leftbar.gif");
|
---|
| 984 | $m_size = getimagesize("modules/Elezioni/images/barre/mainbar.gif");
|
---|
| 985 | $r_size = getimagesize("modules/Elezioni/images/barre/rightbar.gif");
|
---|
| 986 | $l_size2 = getimagesize("modules/Elezioni/images/barre/leftbar2.gif");
|
---|
| 987 | $m_size2 = getimagesize("modules/Elezioni/images/barre/mainbar2.gif");
|
---|
| 988 | $r_size2 = getimagesize("modules/Elezioni/images/barre/rightbar2.gif");
|
---|
| 989 | // totali
|
---|
| 990 |
|
---|
[265] | 991 | 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";
|
---|
| 992 | else $andcond="select orario,data from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
|
---|
| 993 |
|
---|
| 994 | $sql="$andcond";
|
---|
| 995 | $res = $dbi->prepare("$sql");
|
---|
| 996 | $res->execute();
|
---|
| 997 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[231] | 998 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 999 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 1000 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 1001 |
|
---|
| 1002 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1003 | echo "<center>"._VOTANTI." "._ALLE." "._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</center></li>";
|
---|
| 1004 |
|
---|
[265] | 1005 | $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";
|
---|
| 1006 | $res1 = $dbi->prepare("$sql");
|
---|
| 1007 | $res1->execute();
|
---|
| 1008 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
[231] | 1009 |
|
---|
| 1010 |
|
---|
[265] | 1011 | $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 ";
|
---|
| 1012 | $res1 = $dbi->prepare("$sql");
|
---|
| 1013 | $res1->execute();
|
---|
[231] | 1014 |
|
---|
| 1015 |
|
---|
| 1016 |
|
---|
| 1017 |
|
---|
[265] | 1018 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
[283] | 1019 | /* $query="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where orario='$orario' and data='$data' and id_cons='$id_cons'";
|
---|
[231] | 1020 |
|
---|
| 1021 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
[265] | 1022 |
|
---|
| 1023 | $res_aff = $dbi->prepare("$query");
|
---|
| 1024 | $res_aff->execute();
|
---|
[283] | 1025 | $voti_numero=$res_aff->rowCount();*/
|
---|
[231] | 1026 | $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";
|
---|
| 1027 |
|
---|
| 1028 |
|
---|
[265] | 1029 | $res1234 = $dbi->prepare("$query");
|
---|
| 1030 | $res1234->execute();
|
---|
[283] | 1031 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
[265] | 1032 |
|
---|
[231] | 1033 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 1034 |
|
---|
| 1035 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%\"><tr>";
|
---|
| 1036 | if ($genere==0){echo "<td>Refer. N.</td>";}
|
---|
| 1037 | echo "<td><b>"._VOTANTI."</b></td><td><b>Percent.</b></td>";
|
---|
| 1038 | echo "<td><b>"._SEZIONI."</b></td>";
|
---|
| 1039 | echo "</tr>";
|
---|
| 1040 | echo "<tr>";
|
---|
| 1041 | if ($genere==0){echo "<td><h2>$num_gruppo</h2></td>";}
|
---|
| 1042 | echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td>
|
---|
| 1043 | </tr></table>";
|
---|
| 1044 |
|
---|
| 1045 |
|
---|
| 1046 | // barre
|
---|
| 1047 |
|
---|
| 1048 | echo "<table style=\"width:100%\"><tr><td><table><tr><td> "._VOTANTI." : </td><td>
|
---|
| 1049 | <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";
|
---|
| 1050 |
|
---|
| 1051 | $tot_gen=$tot;
|
---|
| 1052 |
|
---|
| 1053 |
|
---|
| 1054 | 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>";
|
---|
| 1055 | echo "</td></tr></table></li><br/>";
|
---|
| 1056 |
|
---|
| 1057 | }
|
---|
| 1058 |
|
---|
| 1059 | }
|
---|
| 1060 |
|
---|
| 1061 |
|
---|
| 1062 | }
|
---|
| 1063 |
|
---|
| 1064 | ## risultati semplici
|
---|
| 1065 | function graf_risultati(){
|
---|
| 1066 | global $descr_cons,$circo,$genere;
|
---|
| 1067 |
|
---|
| 1068 | if($genere!='0' && !$circo){ // referendum e circoscrizionali
|
---|
| 1069 | list ($gruppo,$pro)=grupporss();
|
---|
| 1070 | if ($gruppo!=''){
|
---|
| 1071 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1072 | echo "<center><h2>";
|
---|
| 1073 | echo "<b>Risultati</b> ";
|
---|
| 1074 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 1075 | echo "</h2></center></li>";
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|
| 1078 | //$content .="<div style=\"text-align:left;\"><strong>$descr_cons</strong></div><br/>";
|
---|
| 1079 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
| 1080 | for($x=0;$x<count($gruppo);$x++){
|
---|
| 1081 | $nume=$x+1;
|
---|
| 1082 | echo "<tr bgcolor=\"#ffffff\"><td>$nume - ".$gruppo[$x]." </td><td align=\"right\"><b><span style=\"color:#ff0000;\">".$pro[$x] ."%</span></b></td></tr>\n";
|
---|
| 1083 | }
|
---|
| 1084 | echo "</table></center>";
|
---|
| 1085 |
|
---|
| 1086 | }
|
---|
| 1087 |
|
---|
| 1088 | }
|
---|
| 1089 |
|
---|
| 1090 | ###############################
|
---|
| 1091 | # grafico affluenza unica
|
---|
| 1092 |
|
---|
| 1093 | function affluenza_unica(){
|
---|
[265] | 1094 | global $dbi,$circo,$prefix,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
|
---|
[231] | 1095 |
|
---|
[419] | 1096 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1097 | else $circos='';
|
---|
| 1098 | $circos='';
|
---|
| 1099 | // numero sezioni scrutinate
|
---|
[265] | 1100 | $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'";
|
---|
| 1101 | $res2 = $dbi->prepare("$sql");
|
---|
| 1102 | $res2->execute();
|
---|
| 1103 | $sezioni=$res2->rowCount();
|
---|
| 1104 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
| 1105 | $res = $dbi->prepare("$sql");
|
---|
| 1106 | $res->execute();
|
---|
[231] | 1107 | if($res){
|
---|
[419] | 1108 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
| 1109 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 1110 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 1111 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 1112 | $sql="select t3.id_sez 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 ";
|
---|
| 1113 | $res1 = $dbi->prepare("$sql");
|
---|
| 1114 | $res1->execute();
|
---|
| 1115 | $numero=$res1->rowCount();
|
---|
| 1116 | echo "<div style=\"text-align:center;\"><br/>Ultime Affluenze<br/>";
|
---|
| 1117 | echo "<b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
| 1118 | $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 ";
|
---|
| 1119 | $res1 = $dbi->prepare("$sql");
|
---|
| 1120 | $res1->execute();
|
---|
| 1121 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
| 1122 | $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";
|
---|
| 1123 | if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 1124 | $res_aff = $dbi->prepare("$query");
|
---|
| 1125 | $res_aff->execute();
|
---|
| 1126 | $voti_numero=$res_aff->rowCount();
|
---|
| 1127 | # $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' ";
|
---|
| 1128 | $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 ";
|
---|
| 1129 | //if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 1130 | $tot='';
|
---|
| 1131 | $res1234 = $dbi->prepare("$query");
|
---|
| 1132 | $res1234->execute();
|
---|
| 1133 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 1134 | if (isset($tot)){$perc=number_format($voti_t*100/$tot,2);}
|
---|
| 1135 | else{$tot=0;$perc="0.00";}
|
---|
| 1136 | if($voti_t<=$tot){
|
---|
| 1137 | $resto=100-$perc;
|
---|
| 1138 | if ($genere==0){echo "<div style=\"text-align:center\"><b>Referendum n. $num_gruppo</b></div>";}
|
---|
| 1139 | echo '<center>
|
---|
| 1140 | <div id="piechart" style="width:100%; min-height:200px;"></div><br/>
|
---|
| 1141 | </center>
|
---|
| 1142 | <script>google.charts.load("current", {"packages":["corechart"]});
|
---|
| 1143 | google.charts.setOnLoadCallback(drawChart);
|
---|
| 1144 |
|
---|
| 1145 | function drawChart() {
|
---|
| 1146 | var data = google.visualization.arrayToDataTable([
|
---|
| 1147 | ["Task", "Affluenze"],
|
---|
| 1148 | ["", '.$resto.'],
|
---|
| 1149 | ["'.$perc.'%", '.$perc.']
|
---|
| 1150 | ]);
|
---|
| 1151 | var options = {
|
---|
| 1152 | title: "",
|
---|
| 1153 | is3D:true,
|
---|
| 1154 | legend: "none",
|
---|
| 1155 | pieSliceText: "label",
|
---|
| 1156 | pieSliceTextStyle: {
|
---|
| 1157 | color: "#000",
|
---|
| 1158 | bold:true,
|
---|
| 1159 | fontSize:12
|
---|
| 1160 | },
|
---|
| 1161 | slices: {
|
---|
| 1162 | 0: { color: "#ff0000", textStyle:{color:"#fff"}},
|
---|
| 1163 | 1: { color: "#ffff00" }
|
---|
| 1164 | }
|
---|
| 1165 | };
|
---|
| 1166 | var chart = new google.visualization.PieChart(document.getElementById("piechart"));
|
---|
[231] | 1167 |
|
---|
[419] | 1168 | chart.draw(data, options);
|
---|
| 1169 | }
|
---|
| 1170 | </script>';
|
---|
| 1171 | }
|
---|
| 1172 | }
|
---|
| 1173 | }
|
---|
| 1174 | }
|
---|
[231] | 1175 | }
|
---|
| 1176 |
|
---|
| 1177 |
|
---|
| 1178 | ###############################
|
---|
| 1179 | # votanti in tabella
|
---|
| 1180 |
|
---|
| 1181 | function votanti_tabella(){
|
---|
| 1182 |
|
---|
[283] | 1183 | 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;
|
---|
[231] | 1184 |
|
---|
[419] | 1185 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1186 | else $circos='';
|
---|
| 1187 | $circos='';
|
---|
| 1188 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 1189 | if($genere=='4' || $votog) $tab="lista";
|
---|
| 1190 | else $tab="gruppo";
|
---|
| 1191 | if ($genere==0) $tab="ref";
|
---|
[364] | 1192 | $sql="select t3.id_sez 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 ";
|
---|
[265] | 1193 | $res = $dbi->prepare("$sql");
|
---|
| 1194 | $res->execute();
|
---|
| 1195 | $numero=$res->rowCount();
|
---|
| 1196 | $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";
|
---|
| 1197 | $res = $dbi->prepare("$sql");
|
---|
| 1198 | $res->execute();
|
---|
[419] | 1199 | $sezioni=$res->rowCount();
|
---|
[231] | 1200 | if ($numero!=0){
|
---|
[419] | 1201 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1202 | echo "<center><b>"._DETTAGLIO." "._VOTIE."</b></center></li>";
|
---|
| 1203 | echo "<div style=\"text-align:center;\"><i> "._SEZSCRU." $numero "._SU." $sezioni </i></div>";
|
---|
| 1204 | if ($genere!=0) {
|
---|
| 1205 | $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";
|
---|
| 1206 | $res = $dbi->prepare("$sql");
|
---|
| 1207 | $res->execute();
|
---|
| 1208 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 1209 | $sql="select sum(t1.validi+t1.nulli+t1.bianchi+t1.contestati) as tot,
|
---|
| 1210 | sum(t1.validi),sum(t1.nulli),sum(t1.bianchi),sum(t1.contestati), '0', '0', '0'
|
---|
| 1211 | 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";
|
---|
| 1212 | $res = $dbi->prepare("$sql");
|
---|
| 1213 | $res->execute();
|
---|
| 1214 | }else{
|
---|
| 1215 | $sql="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 1216 | $res = $dbi->prepare("$sql");
|
---|
| 1217 | $res->execute();
|
---|
| 1218 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 1219 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
| 1220 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo, sum(si), sum(no)
|
---|
| 1221 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>'0'";
|
---|
| 1222 | $res = $dbi->prepare("$sql");
|
---|
| 1223 | $res->execute();
|
---|
[231] | 1224 | }
|
---|
[419] | 1225 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id,$si,$no) = $res->fetch(PDO::FETCH_NUM)){
|
---|
| 1226 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
| 1227 | $arvoti=array($validi,$nulli,$bianchi,$contestati);
|
---|
| 1228 | $arperc=arrayperc($arvoti,$tot_votanti);
|
---|
| 1229 | if($tot_votanti){
|
---|
| 1230 | if($genere==0 and $validi) {$perc_si=number_format($si*100/$validi,2);$perc_no=number_format(100 - $si*100/$validi,2);}
|
---|
| 1231 | else {$perc_si="0.00"; $perc_no="0.00";}
|
---|
| 1232 | $perc_validi=number_format($arperc[0],2);#number_format($validi*100/$tot_votanti,2);
|
---|
| 1233 | $perc_nulli=number_format($arperc[1],2);
|
---|
| 1234 | $perc_bianchi=number_format($arperc[2],2);
|
---|
| 1235 | $perc_conte=number_format($arperc[3],2);
|
---|
| 1236 | }else{$perc_validi="0.00";$perc_nulli="0.00";$perc_bianchi="0.00";$perc_conte="0.00";}
|
---|
| 1237 | if($tot_aventi) $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
| 1238 | else $perc_votanti="0.00";
|
---|
| 1239 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
| 1240 | $perc_non=100-$perc_votanti;
|
---|
| 1241 | if ($genere==0) {
|
---|
| 1242 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
| 1243 | $resg = $dbi->prepare("$sql");
|
---|
| 1244 | $resg->execute();
|
---|
| 1245 | list($num_gruppo,$descr_gruppo) = $resg->fetch(PDO::FETCH_NUM);
|
---|
| 1246 | }
|
---|
| 1247 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
| 1248 | if ($genere==0) {echo "<br/>Referendum n. <b>[$num_gruppo]</b><br/>";}
|
---|
| 1249 | echo "
|
---|
| 1250 | <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>
|
---|
[231] | 1251 |
|
---|
[419] | 1252 | <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>";
|
---|
| 1253 | if ($genere==0){
|
---|
| 1254 | echo "<tr bgcolor=\"#ffffff\"><td>"._SI."</td><td align=\"right\">$si</td><td align=\"right\"><span class=\"red\">$perc_si%</span></td></tr>
|
---|
| 1255 | <tr bgcolor=\"#ffffff\"><td>"._NO."</td><td align=\"right\">$no</td><td align=\"right\"><span class=\"red\">$perc_no%</span></td></tr>";
|
---|
| 1256 | }
|
---|
| 1257 | echo "<tr bgcolor=\"#ffffff\"><td>"._VALIDI."</td><td align=\"right\">$validi</td><td align=\"right\"><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
| 1258 | <tr bgcolor=\"#ffffff\"><td>"._NULLI."</td><td align=\"right\">$nulli</td><td align=\"right\"><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
| 1259 | <tr bgcolor=\"#ffffff\"><td>"._BIANCHI."</td><td align=\"right\">$bianchi</td><td align=\"right\"><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
| 1260 | <tr bgcolor=\"#ffffff\"><td>"._CONTESTATI."</td><td align=\"right\">$contestati</td><td align=\"right\"><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
| 1261 | </table></li>";
|
---|
[231] | 1262 | }
|
---|
[419] | 1263 | }
|
---|
[231] | 1264 | }
|
---|
| 1265 | ######## fine
|
---|
| 1266 |
|
---|
| 1267 | ####################################
|
---|
| 1268 | # grafico sezioni
|
---|
| 1269 |
|
---|
| 1270 | function graf_sezioni(){
|
---|
| 1271 | global $prefix, $dbi,$id_cons_gen;
|
---|
[265] | 1272 | $sql = "select chiusa from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'";
|
---|
| 1273 | $res = $dbi->prepare("$sql");
|
---|
| 1274 | $res->execute();
|
---|
| 1275 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
[231] | 1276 |
|
---|
| 1277 | //if($chiusa!='1') numeri_sezione(); # se la consultazione non Ú chiusa
|
---|
| 1278 |
|
---|
| 1279 |
|
---|
| 1280 |
|
---|
| 1281 | //numeri_sezione(); //lancia la funzione
|
---|
| 1282 |
|
---|
| 1283 | function numeri_sezione() {
|
---|
| 1284 | global $prefix, $dbi, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
| 1285 |
|
---|
| 1286 |
|
---|
| 1287 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 1288 | else $circos='';
|
---|
| 1289 |
|
---|
| 1290 | if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 1291 | else $tab="gruppo";
|
---|
| 1292 |
|
---|
| 1293 |
|
---|
| 1294 |
|
---|
| 1295 | # numero sezioni
|
---|
[265] | 1296 | $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";
|
---|
[419] | 1297 | $res = $dbi->prepare("$sql");
|
---|
| 1298 | $res->execute();
|
---|
[265] | 1299 | $max = $res->rowCount();
|
---|
[231] | 1300 | if(!isset($html)) $html='';
|
---|
| 1301 | $html = "\n<table style=\"margin:0px auto;border:0px; width:90%\"><tr>";
|
---|
| 1302 |
|
---|
| 1303 | $i=0;$id_circ_old=0;$e=0;
|
---|
[265] | 1304 | while(list($sez_id, $sez_num) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[231] | 1305 | $i++;
|
---|
| 1306 |
|
---|
[265] | 1307 | $sql="select * from ".$prefix."_ele_voti_".$tab." where id_sez='$sez_id'";
|
---|
| 1308 | $res2 = $dbi->prepare("$sql");
|
---|
| 1309 | $res2->execute();
|
---|
| 1310 | $numero=$res2->rowCount();
|
---|
[231] | 1311 | if ($numero!=0){$e++;$bgsez="#FFFF00";}else{$bgsez="";}
|
---|
| 1312 |
|
---|
| 1313 |
|
---|
| 1314 | if ($genere==0) $pos="gruppo_sezione";elseif($genere=='4' || $votog) $pos="lista_sezione";
|
---|
| 1315 | else $pos="gruppo_sezione";
|
---|
| 1316 |
|
---|
| 1317 | //$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>";
|
---|
| 1318 | $html .="<td style=\"margin:0px auto; text-align:center; width:5%;\" bgcolor=\"$bgsez\"><b>$sez_num</b></td>";
|
---|
| 1319 |
|
---|
| 1320 | if (($i%8) ==0) $html .="</tr>\n<tr>";
|
---|
| 1321 | }
|
---|
| 1322 |
|
---|
| 1323 | $html .="</tr></table>\n";
|
---|
| 1324 | // stampa
|
---|
| 1325 | if($e!='0'){
|
---|
| 1326 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
| 1327 | echo "<center>";
|
---|
| 1328 | echo "<b>"._SEZSCRU."</b> ";
|
---|
| 1329 | echo "</center></li><br/></center>";
|
---|
| 1330 | echo "<center><img alt=\"Grafico\" src=\"modules/Elezioni/grafici/ledex2.php?sez=$e&max=$max\" /></center>";
|
---|
| 1331 |
|
---|
| 1332 | echo $html; }
|
---|
| 1333 | }
|
---|
| 1334 | numeri_sezione(); //lancia la funzione
|
---|
| 1335 | }
|
---|
| 1336 |
|
---|
| 1337 | ?>
|
---|
| 1338 |
|
---|
| 1339 |
|
---|