[2] | 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 | /************************************************************************/
|
---|
[267] | 9 |
|
---|
[2] | 10 | if (!defined('MODULE_FILE')) {
|
---|
[267] | 11 | die ("You can't access this file directly...");
|
---|
[2] | 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();
|
---|
[2] | 18 |
|
---|
[265] | 19 | list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 20 | $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'" ;
|
---|
| 21 | $res = $dbi->prepare("$sql");
|
---|
| 22 | $res->execute();
|
---|
[2] | 23 |
|
---|
[265] | 24 | list($id_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 25 |
|
---|
| 26 |
|
---|
[2] | 27 | /***********************************
|
---|
| 28 | /* Grafica affluenze
|
---|
| 29 | /**********************************/
|
---|
| 30 |
|
---|
| 31 | function affluenze_graf(){
|
---|
[132] | 32 | 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;
|
---|
[2] | 33 | // icone
|
---|
| 34 | if ($circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 35 | else $circos="";
|
---|
| 36 | if (!$csv)
|
---|
| 37 | echo "<div>
|
---|
| 38 | <a href=\"
|
---|
| 39 | modules.php?name=Elezioni&op=come&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&info=affluenze_sez\">"._DETTAGLIO." "._AFFLUENZE."<img class=\"image\" src=\"modules/Elezioni/images/dettagli.png\" alt=\" "._AFFLUENZE."\" /></a>
|
---|
[350] | 40 | <a href=\" modules.php?name=Elezioni&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&op=affluenze_graf&csv=1\">"._VER_STAMPA." <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"stampa\" /></a></div>";
|
---|
[2] | 41 |
|
---|
[368] | 42 | $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";
|
---|
| 43 | $res2 = $dbi->prepare("$sql");
|
---|
| 44 | $res2->execute();
|
---|
| 45 | $sezioni=$res2->rowCount();
|
---|
[2] | 46 |
|
---|
| 47 | // barre
|
---|
[371] | 48 | $l_size = getimagesize("modules/Elezioni/images/barre/leftbar.jpg");
|
---|
| 49 | $m_size = getimagesize("modules/Elezioni/images/barre/mainbar.jpg");
|
---|
| 50 | $r_size = getimagesize("modules/Elezioni/images/barre/rightbar.jpg");
|
---|
| 51 | $l_size2 = getimagesize("modules/Elezioni/images/barre/leftbar2.jpg");
|
---|
| 52 | $m_size2 = getimagesize("modules/Elezioni/images/barre/mainbar2.jpg");
|
---|
| 53 | $r_size2 = getimagesize("modules/Elezioni/images/barre/rightbar2.jpg");
|
---|
[265] | 54 | // totali
|
---|
[133] | 55 |
|
---|
[368] | 56 | if($tema=='tour')
|
---|
| 57 | $andcond="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 0,1";
|
---|
| 58 | else
|
---|
| 59 | $andcond="select orario,data from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
|
---|
[265] | 60 | $sql="$andcond";
|
---|
| 61 | $res = $dbi->prepare("$sql");
|
---|
| 62 | $res->execute();
|
---|
[368] | 63 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
| 64 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 65 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 66 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 67 | echo "<br /><div><h5>"._VOTANTI." "._ALLE." "._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</h5></div>";
|
---|
[265] | 68 | $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";
|
---|
| 69 | $res1 = $dbi->prepare("$sql");
|
---|
[368] | 70 | $res1->execute();
|
---|
[265] | 71 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
| 72 | $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 ";
|
---|
| 73 | $res1 = $dbi->prepare("$sql");
|
---|
| 74 | $res1->execute();
|
---|
[2] | 75 |
|
---|
[368] | 76 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
| 77 | $query="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where orario='$orario' and data='$data' and id_cons='$id_cons'";
|
---|
| 78 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
| 79 | $sql=$query;
|
---|
| 80 | $res_aff = $dbi->prepare("$sql");
|
---|
| 81 | $res_aff->execute();
|
---|
[265] | 82 | $voti_numero=$res_aff->rowCount();
|
---|
[368] | 83 | $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";
|
---|
| 84 | $sql=$query;
|
---|
| 85 | $res1234 = $dbi->prepare("$sql");
|
---|
| 86 | $res1234->execute();
|
---|
| 87 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 88 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 89 | echo "<table class=\"td-80\"><tr class=\"bggray\">";
|
---|
[133] | 90 | if ($genere==0){echo "<td>Referendum N.</td>";}
|
---|
[368] | 91 | echo "<td><b>"._VOTANTI."</b></td><td><b>"._PERCE."</b></td>";
|
---|
| 92 | echo "<td><b>"._SEZIONI."</b></td>";
|
---|
[2] | 93 | echo "</tr>";
|
---|
[368] | 94 | echo "<tr class=\"bggray2\">";
|
---|
| 95 | if ($genere==0){echo "<td><h2>$num_gruppo</h2></td>";}
|
---|
| 96 | echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td></tr></table>";
|
---|
| 97 | // barre
|
---|
[371] | 98 | echo "<table><tr><td><table><tr><td> "._VOTANTI." : </td><td><img src=\"modules/Elezioni/images/barre/leftbar2.jpg\" height=\"$l_size2[1]\" width=\"$l_size2[0]\" alt=\"votanti\" /><img src=\"modules/Elezioni/images/barre/mainbar2.jpg\" alt=\"votanti\" height=\"$m_size2[1]\" width=\"". ($perc * 2)."\" /><img src=\"modules/Elezioni/images/barre/rightbar2.jpg\" height=\"$r_size2[1]\" width=\"$r_size2[0]\" alt=\"votanti\" /><span class=\"red\"> $perc</span> % ($voti_t)<br /></td></tr>\n";
|
---|
[368] | 99 | $tot_gen=$tot;
|
---|
[371] | 100 | echo "<tr><td> "._AVENTI.": </td><td><img src=\"modules/Elezioni/images/barre/leftbar.jpg\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"elettori\" /><img src=\"modules/Elezioni/images/barre/mainbar.jpg\" alt=\"elettori\" height=\"$m_size[1]\" width=\"".(100 * 2)."\" /><img src=\"modules/Elezioni/images/barre/rightbar.jpg\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"elettori\" /> 100 % ($tot_gen)</td></tr></table>";
|
---|
[368] | 101 | echo "</td></tr></table>";
|
---|
[421] | 102 | }
|
---|
[368] | 103 | }
|
---|
[421] | 104 | $gruppi=array('Hanno votato','Non hanno votato');
|
---|
| 105 | $resto=100-$perc;
|
---|
| 106 | $valori=array($perc,$resto);
|
---|
| 107 | echo "<center>";
|
---|
| 108 | torta($gruppi,$valori);
|
---|
| 109 | echo "</center>";
|
---|
[2] | 110 | }
|
---|
| 111 |
|
---|
| 112 | /*********************************/
|
---|
| 113 | /* Grafica votanti */
|
---|
| 114 | /**********************************/
|
---|
| 115 |
|
---|
| 116 | function graf_votanti(){
|
---|
[421] | 117 | 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,$tour,$tema,$copy;
|
---|
[2] | 118 |
|
---|
| 119 |
|
---|
| 120 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
| 121 | $_GET : $_POST;
|
---|
| 122 | if (isset($param['anim'])) $anim=intval($param['anim']); else $anim='';
|
---|
[268] | 123 |
|
---|
[2] | 124 | if ($siteistat==$id_comune) $logo="$siteistat"; else $logo=''; // logo per il comune
|
---|
[105] | 125 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
[2] | 126 | // menu
|
---|
| 127 | if (!$csv && $anim!=1){ $anim=1;$versione=_VER_HTML;
|
---|
| 128 | }else{ $anim='';$versione=_VER_FLASH;}
|
---|
[127] | 129 | if($csv!=1){
|
---|
[2] | 130 | echo " <div>
|
---|
| 131 | <a href=\"
|
---|
[350] | 132 | modules.php?name=Elezioni&op=come&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&info=votanti\">"._DETTAGLIO." "._VOTANTI."<img class=\"image\" src=\"modules/Elezioni/images/dettagli.png\" alt=\"votanti\" /></a>
|
---|
| 133 | <a href=\" modules.php?name=Elezioni&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&op=graf_votanti&csv=1&flash=\">"._VER_STAMPA." <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"stampa\" /></a>";
|
---|
[421] | 134 | # if($flash==1)
|
---|
| 135 | # echo "<a href=\" modules.php?name=Elezioni&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&op=graf_votanti&csv=&anim=$anim\">$versione <img class=\"image\" src=\"modules/Elezioni/images/grafici.gif\" alt=\"flash\" /></a>";
|
---|
[2] | 136 | echo "</div>";
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | /* Scelta circoscrizioni da implementare
|
---|
| 141 | if ($circo){ // elenco per scelta circoscrizione
|
---|
| 142 | echo "<form id=\"test\" action=\"modules.php\"> <input type=\"hidden\" name=\"pagina\" value=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=\">";
|
---|
| 143 | $res_sez = mysql_query("SELECT id_circ,descrizione,num_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons",$dbi);
|
---|
| 144 | echo "<table><tr><td>Scegli la Circoscrizione: <select name=\"id_circ\" onChange=\"top.location.href=this.form.pagina.value+this.form.id_circ.options[this.form.id_circ.selectedIndex].value;return false\">";
|
---|
| 145 | while(list($id_rif,$descrizione,$num_cir)=mysql_fetch_row($res_sez)) {
|
---|
| 146 | if (!$id_circ) $id_circ=$id_rif;
|
---|
| 147 | $sel = ($id_rif == $id_circ) ? "selected" : "";
|
---|
| 148 | echo "<option value=\"$id_rif\" $sel>";
|
---|
| 149 | for ($j=strlen($num_cir);$j<2;$j++) { echo " ";}
|
---|
| 150 | echo $num_cir.") ".$descrizione;
|
---|
| 151 | }
|
---|
| 152 | echo "</select></td></tr></table></form>";
|
---|
| 153 |
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 | */
|
---|
| 158 |
|
---|
| 159 | if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
| 160 | else $tab="gruppo";
|
---|
| 161 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 162 | else $circos='';
|
---|
| 163 |
|
---|
| 164 | // Verificare per la circoscrizione aprile 2008 Nicola?
|
---|
| 165 | //if ($genere==0) {$tab="ref";}else{$tab="gruppo";}
|
---|
| 166 | //if ($votog or $genere==4) {$tab="lista";}else{$tab="gruppo";}
|
---|
| 167 |
|
---|
| 168 | /*
|
---|
| 169 | if($circo){
|
---|
| 170 | if(!$id_circ){
|
---|
| 171 | $res = mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
|
---|
| 172 | list($id_circ)=mysql_fetch_row($res);
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | $res = mysql_query("select t1.id_sez,sum(t1.voti) from ".$prefix."_ele_voti_$tab as t1, ".$prefix."_ele_$tab as t2 where t1.id_$tab=t2.id_$tab and t1.id_cons='$id_cons' and t2.id_circ='$id_circ' group by t1.id_sez", $dbi);
|
---|
| 176 | }else
|
---|
| 177 | */
|
---|
[177] | 178 | if($genere==0)
|
---|
[417] | 179 | $sql="select t1.id_sez from ".$prefix."_ele_voti_".$tab." as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons' $circos group by t1.id_sez ";
|
---|
[177] | 180 | else
|
---|
[265] | 181 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and validi+nulli+bianchi+contestati>0";
|
---|
| 182 | $res = $dbi->prepare("$sql");
|
---|
| 183 | $res->execute();
|
---|
[177] | 184 |
|
---|
[265] | 185 |
|
---|
[30] | 186 | if($res)
|
---|
[265] | 187 | $numero=$res->rowCount();
|
---|
[30] | 188 | else
|
---|
[127] | 189 | $numero=1;
|
---|
[265] | 190 | $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";
|
---|
| 191 | $res = $dbi->prepare("$sql");
|
---|
| 192 | $res->execute();
|
---|
| 193 |
|
---|
| 194 | $sezioni=$res->rowCount();
|
---|
[2] | 195 | if ($numero!=0){
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 |
|
---|
[265] | 200 | $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";
|
---|
| 201 | $res1 = $dbi->prepare("$sql");
|
---|
| 202 | $res1->execute();
|
---|
| 203 |
|
---|
| 204 | list($tot_aventi) = $res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 205 |
|
---|
[2] | 206 | if ($genere!=0) {
|
---|
[132] | 207 | echo "<center><h2>";
|
---|
| 208 | echo "<b>"._DETTAGLIO." "._VOTIE."</b> - ";
|
---|
| 209 | echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 210 | echo "</h2></center>";
|
---|
[2] | 211 |
|
---|
[265] | 212 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
[2] | 213 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), '0'
|
---|
[265] | 214 | 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";
|
---|
| 215 | $res1 = $dbi->prepare("$sql");
|
---|
| 216 | $res1->execute();
|
---|
| 217 |
|
---|
[2] | 218 | }else{
|
---|
[132] | 219 |
|
---|
| 220 | if($tema=='tour'){
|
---|
[265] | 221 | $sql="SELECT count(0)
|
---|
| 222 | from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 223 | $res1 = $dbi->prepare("$sql");
|
---|
| 224 | $res1->execute();
|
---|
[132] | 225 |
|
---|
[265] | 226 |
|
---|
| 227 | list($max_ruotag) =$res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 228 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
| 229 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
| 230 | if ($ruotag>=$max_ruotag) {$ruotag=1;}
|
---|
| 231 | else {$ruotag++;}
|
---|
| 232 | $_SESSION['ruotag']=$ruotag;
|
---|
[265] | 233 | $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'";
|
---|
| 234 | $res1 = $dbi->prepare("$sql");
|
---|
| 235 | $res1->execute();
|
---|
| 236 |
|
---|
| 237 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 238 | echo "<center><h2>";
|
---|
| 239 | echo "<b>"._DETTAGLIO." "._VOTIE."</b> - ";
|
---|
| 240 | echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
| 241 | echo "</h2></center>";
|
---|
| 242 |
|
---|
[265] | 243 | $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
|
---|
[132] | 244 | FROM ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo
|
---|
[265] | 245 | WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag' GROUP BY t1.id_gruppo HAVING tot >0";
|
---|
| 246 | $res1 = $dbi->prepare("$sql");
|
---|
| 247 | $res1->execute();
|
---|
| 248 |
|
---|
[132] | 249 | } else
|
---|
[265] | 250 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
[2] | 251 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
|
---|
[265] | 252 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>0";
|
---|
| 253 | $res1 = $dbi->prepare("$sql");
|
---|
| 254 | $res1->execute();
|
---|
| 255 |
|
---|
[2] | 256 | }
|
---|
[265] | 257 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[68] | 258 | $arperc=array();
|
---|
| 259 | $arval=array($validi,$nulli,$bianchi,$contestati);
|
---|
| 260 | $arperc=arrayperc($arval,$tot_votanti);
|
---|
[2] | 261 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
[68] | 262 | $perc_validi=number_format($arperc[0],2);
|
---|
| 263 | $perc_nulli=number_format($arperc[1],2);
|
---|
| 264 | $perc_bianchi=number_format($arperc[2],2);
|
---|
| 265 | $perc_conte=number_format($arperc[3],2);
|
---|
[2] | 266 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
| 267 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
| 268 | $perc_non=100-$perc_votanti;
|
---|
| 269 |
|
---|
| 270 | if ($genere==0) {
|
---|
[265] | 271 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
| 272 | $res = $dbi->prepare("$sql");
|
---|
| 273 | $res->execute();
|
---|
| 274 |
|
---|
| 275 | list($num_gruppo,$descr_gruppo) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 276 | }
|
---|
| 277 |
|
---|
| 278 |
|
---|
| 279 |
|
---|
| 280 | $a1=_VALIDI;$b1=_NULLI;$c1=_BIANCHI;$d1=_CONTESTATI;$titolo=""._PERCE." "._VOTIE."";
|
---|
| 281 | $e1=_VOTANTI;$f1=""._NON." "._VOTANTI."";$titolo2=""._PERCE." "._AFFLUENZE."";
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 |
|
---|
| 285 |
|
---|
[132] | 286 | echo "<table width=\"100%\" class=\"modulo\"><tr>";
|
---|
| 287 | if ($genere==0) echo "<td colspan=\"2\" valign=\"top\" >";
|
---|
| 288 | else echo "<td valign=\"top\" >";
|
---|
[127] | 289 |
|
---|
[132] | 290 | echo "<table cellspacing=\"5\" style=\"text-align:center;\">";
|
---|
| 291 | if ($genere==0) {echo "<tr><td colspan=\"4\"><h4>"._GRUPPO." $num_gruppo <br/> $descr_gruppo</h4></td></tr>";}
|
---|
[2] | 292 | echo "
|
---|
[132] | 293 | <tr class=\"bggray3\"><td style=\"text-align: right;\"><b>"._AVENTI."</b></td><td>$tot_aventi</td><td><span class=\"red\">100%</span></td></td></td></tr>
|
---|
[2] | 294 |
|
---|
[132] | 295 | <tr class=\"bggray3\"><td style=\"text-align: right;\"><b>"._VOTANTI."</b></td><td>$tot_votanti</td><td><span class=\"red\">$perc_votanti%</span></td></tr>
|
---|
[2] | 296 |
|
---|
[132] | 297 | <tr class=\"bggray3\"><td style=\"text-align: right;\">"._VALIDI."</td><td>$validi</td><td><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
[2] | 298 |
|
---|
[132] | 299 | <tr class=\"bggray3\"><td style=\"text-align: right;\">"._NULLI."</td><td>$nulli</td><td><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
[2] | 300 |
|
---|
[132] | 301 | <tr class=\"bggray3\"><td style=\"text-align: right;\">"._BIANCHI."</td><td>$bianchi</td><td><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
[2] | 302 |
|
---|
[132] | 303 | <tr class=\"bggray3\"><td style=\"text-align: right;\">"._CONTESTATI."</td><td>$contestati</td><td><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
[2] | 304 |
|
---|
| 305 | </table>";
|
---|
| 306 | echo "</td></tr><tr><td style=\"text-align:center;\">
|
---|
| 307 | <h1>"._PERCE." "._VOTANTI."</h1>";
|
---|
| 308 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo</h2>";
|
---|
| 309 |
|
---|
| 310 |
|
---|
| 311 | //if ((!$csv && $flash!=1 && $anim!=1) or ($tour==1 && $flash!=1 && $anim!=1)){ # rotazione x tour marzo 2009 a.l.
|
---|
[417] | 312 | # if ((!$csv && $flash!=1 || $anim!=1) and ($tour!=1)) { # rotazione x tour marzo 2009 a.l.
|
---|
[2] | 313 | echo "<br /><img alt=\"Grafico\" src=\"modules/Elezioni/grafici/votanti_graf.php?cop=$copy&titolo=$titolo2&e=$perc_votanti&f=$perc_non&e1=$e1&f1=$f1&logo=$logo\" /><br /><br />";
|
---|
[417] | 314 | /* }else{
|
---|
[2] | 315 | // Flash affluenze
|
---|
| 316 | $gruppos1=array("",_VOTANTI,_NONVOTANTI);
|
---|
| 317 | $pre1=array("",$perc_votanti,$perc_non);
|
---|
| 318 | flash_torta($gruppos1,$pre1,50,50);
|
---|
| 319 | }
|
---|
[417] | 320 | */
|
---|
[127] | 321 | if($csv) echo "</td><td>";else echo "</td></tr><tr><td style=\"text-align:center;\">"; # rotazione x tour marzo 2009 a.l.
|
---|
[2] | 322 | echo "<h1>"._PERCE." "._VOTIE."</h1>";
|
---|
[127] | 323 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo<h2> ";
|
---|
[105] | 324 |
|
---|
[126] | 325 | //$logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
[2] | 326 |
|
---|
[417] | 327 | # if ((!$csv && $flash!=1 || $anim!=1) and ($tour!=1)){ # rotazione x tour marzo 2009 a.l.
|
---|
[2] | 328 | echo "<br /><img alt=\"Grafico\" src=\"modules/Elezioni/grafici/voti_graf.php?cop=$copy&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 />";
|
---|
[417] | 329 | /* }else{
|
---|
[2] | 330 |
|
---|
| 331 | $gruppos2=array("","Validi","Nulli", "Bianchi", "Contestati");
|
---|
| 332 | $pre2=array("",$perc_validi,$perc_nulli,$perc_bianchi,$perc_conte);
|
---|
| 333 | flash_torta($gruppos2,$pre2,50,50);
|
---|
| 334 | }
|
---|
[417] | 335 | */
|
---|
[2] | 336 |
|
---|
| 337 |
|
---|
| 338 | echo "</td></tr></table>";
|
---|
| 339 |
|
---|
| 340 |
|
---|
| 341 | }
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | /***********************************
|
---|
| 347 | /* Grafica Gruppo
|
---|
| 348 | /**********************************/
|
---|
| 349 |
|
---|
[206] | 350 | function graf_gruppo($visgralista){
|
---|
[421] | 351 | global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$tema,$copy;
|
---|
[364] | 352 | if ($siteistat==$id_comune) $logo=$siteistat; else $logo=''; // logo per il comune
|
---|
| 353 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
[2] | 354 | if (!$id_circ and $circo){
|
---|
[265] | 355 | $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons order by num_circ limit 0,1";
|
---|
[364] | 356 | $res_sez = $dbi->prepare("$sql");
|
---|
| 357 | $res_sez->execute();
|
---|
[265] | 358 |
|
---|
| 359 | list($id_circ)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
[2] | 360 | }
|
---|
| 361 | $circond='';$circondt1='';
|
---|
[338] | 362 | if ($genere!=0){$tab="gruppo";}else{$tab="ref";}
|
---|
| 363 | if ($genere==4 or $visgralista){$tab="lista";}
|
---|
| 364 | if ($votog){$tab="lista";}
|
---|
[364] | 365 | $sql="select id_sez from ".$prefix."_ele_voti_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
[265] | 366 | $res = $dbi->prepare("$sql");
|
---|
| 367 | $res->execute();
|
---|
| 368 |
|
---|
[2] | 369 | if ($circo){
|
---|
[399] | 370 | $sql="select t1.id_sez 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 ";
|
---|
[364] | 371 | $res = $dbi->prepare("$sql");
|
---|
| 372 | $res->execute();
|
---|
[265] | 373 |
|
---|
| 374 | $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";
|
---|
[364] | 375 | $restotv = $dbi->prepare("$sql");
|
---|
| 376 | $restotv->execute();
|
---|
[265] | 377 |
|
---|
[2] | 378 | $circond="and id_circ=$id_circ";$circondt1="and t1.id_circ=$id_circ";
|
---|
| 379 | }
|
---|
[265] | 380 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
| 381 | $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";
|
---|
| 382 | $res = $dbi->prepare("$sql");
|
---|
| 383 | $res->execute();
|
---|
[2] | 384 |
|
---|
[265] | 385 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
| 386 |
|
---|
| 387 |
|
---|
[287] | 388 | if ($numero>0 ){
|
---|
[2] | 389 | echo "<center><h2>";
|
---|
[149] | 390 | if ($genere!=4 and !$visgralista){
|
---|
| 391 | echo "<b>"._PREFERENZE." "._GRUPPO." $descr_cons </b>";
|
---|
| 392 | }else{
|
---|
| 393 | echo "<b>"._PREFERENZE." "._LISTA." $descr_cons </b>";
|
---|
| 394 | }
|
---|
[150] | 395 | echo "<i>- "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
[2] | 396 | echo "</h2></center>";
|
---|
| 397 |
|
---|
| 398 | if ($genere!=0){
|
---|
| 399 | // tot voti
|
---|
| 400 | if (!$circo)
|
---|
[338] | 401 | $sql="select sum(voti) from ".$prefix."_ele_voti_$tab where id_cons=$id_cons ";
|
---|
| 402 | else
|
---|
| 403 | $sql="select sum(t1.voti) from ".$prefix."_ele_voti_$tab as t1 left join ".$prefix."_ele_$tab as t2 on t1.id_$tab=t2.id_$tab where t2.id_circ=$id_circ ";
|
---|
[2] | 404 | if ($votog)
|
---|
[265] | 405 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
| 406 | $restotv = $dbi->prepare("$sql");
|
---|
| 407 | $restotv->execute();
|
---|
| 408 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
| 409 |
|
---|
[2] | 410 |
|
---|
| 411 | $i=0;
|
---|
| 412 | // lista o gruppo
|
---|
[41] | 413 | if ($genere!=4 and !$visgralista){
|
---|
[2] | 414 |
|
---|
| 415 | if ($votog){
|
---|
| 416 |
|
---|
[265] | 417 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 418 | from ".$prefix."_ele_gruppo as t1,
|
---|
| 419 | ".$prefix."_ele_voti_lista as t2,
|
---|
| 420 | ".$prefix."_ele_lista as t3
|
---|
| 421 | where t1.id_cons='$id_cons'
|
---|
| 422 | and t2.id_lista=t3.id_lista
|
---|
| 423 | and t1.id_gruppo=t3.id_gruppo
|
---|
| 424 | group by t1.id_gruppo
|
---|
[265] | 425 | order by somma desc";
|
---|
| 426 | $cosa='id_gruppo';
|
---|
[2] | 427 |
|
---|
| 428 | }else{
|
---|
| 429 |
|
---|
| 430 |
|
---|
[265] | 431 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 432 | from ".$prefix."_ele_gruppo as t1
|
---|
[338] | 433 | left join ".$prefix."_ele_voti_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
[2] | 434 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
[364] | 435 | group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
|
---|
[265] | 436 | order by somma desc";
|
---|
| 437 | $cosa='id_gruppo';
|
---|
| 438 | }
|
---|
| 439 | $res = $dbi->prepare("$sql");
|
---|
| 440 | $res->execute();
|
---|
[2] | 441 |
|
---|
| 442 |
|
---|
| 443 | }else{
|
---|
[265] | 444 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 445 | from ".$prefix."_ele_lista as t1
|
---|
[338] | 446 | left join ".$prefix."_ele_voti_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
[229] | 447 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
[371] | 448 | group by t1.id_lista,t1.num_lista,t1.descrizione
|
---|
[265] | 449 | order by somma desc";
|
---|
| 450 | $res = $dbi->prepare("$sql");
|
---|
| 451 | $res->execute();
|
---|
| 452 | $cosa='id_lista';
|
---|
[2] | 453 | }
|
---|
| 454 |
|
---|
| 455 | echo "<table>
|
---|
| 456 | <tr>
|
---|
| 457 | <td><br />
|
---|
[352] | 458 | <table style=\"border-collapse: collapse;\" rules=\"cols\">";
|
---|
[2] | 459 | // inizio tabella dati
|
---|
| 460 | // variabili stampa flash
|
---|
| 461 | $e=0;
|
---|
[421] | 462 | # $gruppos[$e]="";
|
---|
| 463 | # $pre[$e]="";
|
---|
| 464 | # $e=1;
|
---|
[2] | 465 | // fine
|
---|
[265] | 466 | $gruppinum=$res->rowCount();
|
---|
[2] | 467 | $altrivoti=0;
|
---|
[68] | 468 | ####calcolo percentuale
|
---|
| 469 | $arvoti=array();
|
---|
| 470 | $arperc=array();
|
---|
[265] | 471 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[68] | 472 | $arvoti[$id]=$voti;
|
---|
| 473 | }
|
---|
| 474 | $arperc=arrayperc($arvoti,$tot);
|
---|
[265] | 475 | $res = $dbi->prepare("$sql");
|
---|
| 476 | $res->execute();
|
---|
| 477 |
|
---|
[68] | 478 | ####
|
---|
[69] | 479 | $altriperc=0;
|
---|
[265] | 480 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 481 |
|
---|
| 482 |
|
---|
| 483 | // verica chi ha preso meno del 3%
|
---|
| 484 | $menotre=(number_format($voti*100/$tot,2));
|
---|
| 485 |
|
---|
| 486 | if($menotre>3){
|
---|
| 487 |
|
---|
| 488 |
|
---|
| 489 |
|
---|
| 490 |
|
---|
| 491 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
| 492 | //$descrizione=taglio(4,$descrizione);
|
---|
[421] | 493 | if (strlen($descrizione)<18){
|
---|
| 494 | $gruppo[$i]=(substr($descrizione,0,18));
|
---|
| 495 | $gruppos[$e]=(substr($descrizione,0,18)); //flash
|
---|
| 496 | }else{
|
---|
| 497 | $gruppo[$i]=(substr($descrizione,0,15));
|
---|
| 498 | $gruppos[$e]=(substr($descrizione,0,15)); //flash
|
---|
| 499 | }
|
---|
[2] | 500 |
|
---|
| 501 |
|
---|
[421] | 502 | if (strlen($descrizione)>16) $gruppo[$i].=".";
|
---|
| 503 | if (strlen($descrizione)>16) $gruppos[$e].=".";
|
---|
[69] | 504 | $pro[$i]=number_format($arperc[$id],2);
|
---|
| 505 | $pre[$e]=number_format($arperc[$id],2); //flash
|
---|
[2] | 506 |
|
---|
| 507 |
|
---|
| 508 | }else{
|
---|
| 509 | //somma i voti sotto il 3%
|
---|
| 510 | $altrivoti = $altrivoti + $voti;
|
---|
[69] | 511 | $altriperc += $arperc[$id];
|
---|
[2] | 512 | }
|
---|
| 513 |
|
---|
| 514 |
|
---|
| 515 |
|
---|
| 516 |
|
---|
| 517 |
|
---|
| 518 |
|
---|
| 519 | $votiv=number_format($voti,0,',','.');
|
---|
| 520 | // formattazione numeri perc
|
---|
[68] | 521 | $prov=number_format($arperc[$id],2);
|
---|
[2] | 522 |
|
---|
| 523 | // sviluppo tabella dati
|
---|
| 524 | $bgcolor1= ($bgcolor1=="#cacaca") ? "#ffffff":"#cacaca";
|
---|
| 525 | echo "<tr valign=\"top\">
|
---|
[352] | 526 | <td style=\"vertical-align=:top;\"><b><img src=\"modules.php?name=Elezioni&file=foto&$cosa=$id\" class=\"stemmapic\" alt=\"descrizione\" /></b></td>
|
---|
[2] | 527 | <td><b>$descrizione</b></td>
|
---|
| 528 | <td>"._VOTI."</td><td align=\"right\">$votiv</td><td align=\"right\"> <i>($prov%)</i></td>
|
---|
| 529 | </tr>";
|
---|
| 530 |
|
---|
| 531 | $e++; // flash
|
---|
| 532 | $i++;
|
---|
| 533 | }
|
---|
| 534 | // aggiunge altri minori al 3%
|
---|
| 535 | // esiste
|
---|
| 536 | // corretto 15 aprile 2006
|
---|
| 537 | if ($altrivoti>0){
|
---|
| 538 |
|
---|
| 539 | $gruppo[]=_ALTRI;
|
---|
| 540 | $gruppos[]=_ALTRI;
|
---|
[69] | 541 | $pro[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
| 542 | $pre[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
[2] | 543 | }
|
---|
| 544 |
|
---|
| 545 |
|
---|
| 546 | if ($i<=10) $i=10;
|
---|
| 547 | $titolo=""._PERCE." "._VOTIE."";
|
---|
| 548 | $dati1=serialize($pro);
|
---|
| 549 | //$dati1=urlencode($dati1);
|
---|
| 550 | //$gruppo=utf8_encode($gruppo);
|
---|
| 551 | $dati2=serialize($gruppo);
|
---|
| 552 | $dati2=urlencode($dati2);
|
---|
| 553 |
|
---|
| 554 | $titolo=urlencode($titolo);
|
---|
| 555 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 556 | $descr_cons=urlencode($descr_cons);
|
---|
[105] | 557 | if ($genere==4){$w=800;$l=250;}else{$w=750;$l=220;}
|
---|
[2] | 558 |
|
---|
| 559 |
|
---|
[65] | 560 | echo "</table></td>";
|
---|
| 561 | global $tema;
|
---|
| 562 | if($tema!="tour") echo "</tr><tr>";
|
---|
[403] | 563 | echo "<td style=\"vertical-align=:top; text-align:center;\"><br />";
|
---|
[2] | 564 | # grafico statico
|
---|
| 565 | echo "<img 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\" />";
|
---|
| 566 |
|
---|
| 567 | echo "</td></tr></table><table><tr><td>";
|
---|
| 568 | # grafico flash
|
---|
[421] | 569 | torta($gruppos,$pre);
|
---|
[267] | 570 | $uno='';
|
---|
| 571 | foreach($gruppos as $k=>$v) $uno.="- $v";
|
---|
| 572 | $due='due:';
|
---|
| 573 | foreach($pre as $k=>$v) $due.="- $v";
|
---|
[2] | 574 | echo "</td></tr></table>";
|
---|
| 575 |
|
---|
| 576 |
|
---|
| 577 | }else{
|
---|
| 578 | // tot voti
|
---|
[132] | 579 | if($tema=='tour'){
|
---|
[265] | 580 | $sql="SELECT count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 581 | $res1 = $dbi->prepare("$sql");
|
---|
| 582 | $res1->execute();
|
---|
| 583 |
|
---|
| 584 | list($max_ruotag) =$res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 585 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
| 586 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
[338] | 587 | $sql="select sum(t1.validi),t1.id_gruppo from ".$prefix."_ele_voti_$tab as t1 left join soraldo_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons' and t2.num_gruppo='$ruotag' group by t1.id_gruppo";
|
---|
[132] | 588 | }else
|
---|
[338] | 589 | $sql="select sum(validi),id_gruppo from ".$prefix."_ele_voti_$tab where id_cons=$id_cons group by id_gruppo";
|
---|
[265] | 590 | $res = $dbi->prepare("$sql");
|
---|
| 591 | $res->execute();
|
---|
| 592 |
|
---|
| 593 | while (list($tot,$id_gruppo) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 594 |
|
---|
| 595 | $s=0;
|
---|
[265] | 596 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
[2] | 597 | from ".$prefix."_ele_gruppo as t1
|
---|
[338] | 598 | left join ".$prefix."_ele_voti_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
[2] | 599 | where t1.id_cons='$id_cons' and t1.id_gruppo='$id_gruppo'
|
---|
| 600 | group by t1.id_gruppo
|
---|
[265] | 601 | ";
|
---|
| 602 | $res1 = $dbi->prepare("$sql");
|
---|
| 603 | $res1->execute();
|
---|
| 604 |
|
---|
[2] | 605 |
|
---|
| 606 |
|
---|
[265] | 607 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 608 | if($tot){
|
---|
| 609 | $percsi=number_format($si*100/$tot,3);
|
---|
| 610 | $percno=number_format($no*100/$tot,3);
|
---|
| 611 | $percsi=number_format($percsi,2);
|
---|
| 612 | $percno=number_format($percno,2);
|
---|
| 613 | }else{ $percsi="0.00"; $percno="0.00";}
|
---|
| 614 | $gruppo=array("si","no");
|
---|
| 615 | $gruppos=array("","si","no");// flash
|
---|
| 616 | $pro=array($percsi,$percno);
|
---|
| 617 | $pre=array("",$percsi,$percno);//flash
|
---|
| 618 | // echo "<br/><b><center>$descrizione</center><br/><br/>";
|
---|
| 619 | // sviluppo tabella dati
|
---|
| 620 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
[350] | 621 | echo "<tr><td style=\"background-color:$bgcolor1;\">$num_gruppo - $descrizione</b></td></tr><tr></table>
|
---|
[2] | 622 | <table><tr>
|
---|
[132] | 623 | <td ><b>"._SI.":</b> </td><td>$si</td>
|
---|
| 624 | <td ><b>%</b> </td><td>$percsi</td>
|
---|
| 625 | <td ><b>"._NO.":</b> </td><td>$no</td>
|
---|
| 626 | <td ><b>%</b> </td><td>$percno</td><tr>
|
---|
[2] | 627 | </table></td><td><center><br />";
|
---|
| 628 |
|
---|
| 629 | $i=8; // parametro lunghezza tavola
|
---|
| 630 | $l=30; // larghezza label
|
---|
| 631 | $titolo="Numero ".$num_gruppo."";
|
---|
| 632 | $dati1=serialize($pro);
|
---|
| 633 | //$dati1=urlencode($dati1); //IE
|
---|
| 634 | $dati2=serialize($gruppo);
|
---|
| 635 | $dati2=urlencode($dati2);
|
---|
| 636 | $titolo=urlencode($titolo);
|
---|
| 637 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 638 | $descr=urlencode($descr_cons);
|
---|
| 639 | echo "<center><img src='modules/Elezioni/grafici/barre.php?dati1=$dati1&dati2=$dati2&i=$i&cop=$copy&titolo=$titolo&descr=$descr&l=$l&w=$w&logo=$logo' alt=\"Grafico\" /></center>";
|
---|
| 640 |
|
---|
| 641 |
|
---|
[421] | 642 | torta($gruppos,$pre);
|
---|
[2] | 643 |
|
---|
| 644 |
|
---|
[267] | 645 |
|
---|
[2] | 646 |
|
---|
| 647 |
|
---|
| 648 | echo "</td></tr></table>"; // fine tabella dati
|
---|
| 649 | $s++;
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | }
|
---|
| 654 |
|
---|
| 655 |
|
---|
| 656 |
|
---|
| 657 | }
|
---|
| 658 |
|
---|
| 659 | }
|
---|
| 660 |
|
---|
| 661 |
|
---|
| 662 | }
|
---|
| 663 |
|
---|
| 664 |
|
---|
| 665 |
|
---|
| 666 |
|
---|
| 667 | /***********************************
|
---|
| 668 | /* Grafica Candidato
|
---|
| 669 | /**********************************/
|
---|
| 670 |
|
---|
| 671 | function graf_candidato(){
|
---|
[343] | 672 | global $descr_com, $bgcolor1, $bgcolor5,$bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons, $id_cons,$tipo_cons,$copy,$id_comune,$id_istat,$genere,$votog,$votol,$votoc,$circo,$siteistat,$id_circ;
|
---|
[2] | 673 |
|
---|
[105] | 674 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
[343] | 675 | if($circo) $circos=" and t2.id_circ='$id_circ'"; else $circos='';
|
---|
[2] | 676 | $tab="ele_voti_candidati";
|
---|
| 677 |
|
---|
[343] | 678 | $sql="select id_sez from ".$prefix."_ele_voti_candidati where id_sez in (select t1.id_sez from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons=$id_cons $circos) group by id_sez";
|
---|
| 679 | $res = $dbi->prepare("$sql");
|
---|
| 680 | $res->execute();
|
---|
[265] | 681 |
|
---|
| 682 | $numero=$res->rowCount();
|
---|
[343] | 683 | $sql="select t1.id_sez from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons=$id_cons $circos";
|
---|
[265] | 684 | $res = $dbi->prepare("$sql");
|
---|
| 685 | $res->execute();
|
---|
| 686 |
|
---|
| 687 | $sezioni=$res->rowCount();
|
---|
[2] | 688 | if ($numero!=0){
|
---|
| 689 | echo "<table border=\"0\" align=\"center\"><tr><td>";
|
---|
| 690 | echo "<h5>"._PREFERENZE." "._CONSI." $descr_cons </h5>";
|
---|
| 691 | echo "<h5>"._SEZSCRU." $numero "._SU." $sezioni </h5>
|
---|
| 692 | <h5>I 30 piu' votati</h5>";
|
---|
| 693 | echo "</td></tr></table>";
|
---|
| 694 | // tot voti
|
---|
[343] | 695 | $sql="select sum(voti) from ".$prefix."_ele_voti_candidati where id_sez in (select t1.id_sez from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons=$id_cons $circos)";
|
---|
[265] | 696 | $res = $dbi->prepare("$sql");
|
---|
| 697 | $res->execute();
|
---|
| 698 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 699 |
|
---|
| 700 | // gruppi o liste per simbolo
|
---|
| 701 |
|
---|
| 702 | if ($genere==4){
|
---|
[343] | 703 | $scelta="_ele_lista as t2 on (t1.id_lista=t2.id_lista)";
|
---|
[2] | 704 | }else{
|
---|
[343] | 705 | $scelta="_ele_lista as t2 on (t1.id_lista=t2.id_lista)";
|
---|
[2] | 706 | }
|
---|
| 707 | $i=0;
|
---|
[343] | 708 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t3.voti) as somma
|
---|
[2] | 709 | from ".$prefix."_ele_candidati as t1
|
---|
[343] | 710 | left join ".$prefix."_ele_voti_candidati as t3 on (t1.id_cand=t3.id_cand)
|
---|
[2] | 711 | left join ".$prefix.$scelta."
|
---|
[343] | 712 | where t1.id_cons='$id_cons' $circos
|
---|
[364] | 713 | group by t1.id_lista, t1.id_cand, t1.nome, t1.cognome
|
---|
| 714 | order by somma desc";
|
---|
| 715 | $res = $dbi->prepare("$sql");
|
---|
| 716 | $res->execute();
|
---|
[265] | 717 |
|
---|
| 718 | $n_candi=$res->rowCount();
|
---|
[2] | 719 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
[265] | 720 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 721 | $candidato[$i]=$cognome;
|
---|
[253] | 722 | if ($tot) $pro[$i]=number_format($voti*100/$tot,2); else $pro[$i]=0;
|
---|
[2] | 723 | // sviluppo tabella dati
|
---|
| 724 | $e=$i+1;
|
---|
| 725 |
|
---|
| 726 | 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>
|
---|
| 727 | <td bgcolor=\"$bgcolor1\"><b>$nome $cognome</b></td>
|
---|
| 728 | <td bgcolor=\"$bgcolor1\">"._VOTI."</td><td>$voti</td>
|
---|
| 729 | <td bgcolor=\"$bgcolor1\">%</td><td>$pro[$i]</td></tr>";
|
---|
| 730 |
|
---|
| 731 | if ($e=='30' || $e==$n_candi){
|
---|
| 732 |
|
---|
| 733 |
|
---|
| 734 |
|
---|
| 735 | echo "</table></td></tr></table>"; // fine tabella dati
|
---|
| 736 |
|
---|
| 737 | include("footer.php");
|
---|
| 738 | exit;
|
---|
| 739 | }
|
---|
| 740 |
|
---|
| 741 |
|
---|
| 742 |
|
---|
| 743 | $i++;
|
---|
| 744 |
|
---|
| 745 |
|
---|
| 746 |
|
---|
| 747 |
|
---|
| 748 | }
|
---|
| 749 |
|
---|
| 750 | }
|
---|
| 751 |
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[287] | 754 |
|
---|
[421] | 755 | function torta($gruppos,$pre){
|
---|
| 756 | echo '<div id="piechart" style="width:1000px; height:500px;text-align:center;"></div>';
|
---|
[287] | 757 |
|
---|
[421] | 758 | echo '<script>google.charts.load("current", {"packages":["corechart"]});
|
---|
| 759 | google.charts.setOnLoadCallback(drawChart);
|
---|
[2] | 760 |
|
---|
[421] | 761 | function drawChart() {
|
---|
| 762 | var data = google.visualization.arrayToDataTable([
|
---|
| 763 | ["Task", "Affluenze"]';
|
---|
| 764 | $x=0;
|
---|
| 765 | foreach($gruppos as $key=>$val)
|
---|
| 766 | echo ',["'.$val.' '.$pre[$x].'%", '.$pre[$x++].']';
|
---|
| 767 |
|
---|
| 768 | echo ']);
|
---|
| 769 | var options = {
|
---|
| 770 | title: "",
|
---|
| 771 | is3D:true,
|
---|
| 772 | pieSliceText: "label",
|
---|
| 773 | pieSliceTextStyle: {
|
---|
| 774 | color: "#000",
|
---|
| 775 | bold:true,
|
---|
| 776 | fontSize:9
|
---|
| 777 | },
|
---|
| 778 | slices: {
|
---|
| 779 | 0: { color: "#ff0000", textStyle:{color:"#fff"}},
|
---|
| 780 | 1: { color: "#ffff00" }
|
---|
| 781 | }
|
---|
| 782 | };
|
---|
| 783 | var chart = new google.visualization.PieChart(document.getElementById("piechart"));
|
---|
[2] | 784 |
|
---|
[421] | 785 | chart.draw(data, options);
|
---|
| 786 | }</script>';
|
---|
[2] | 787 |
|
---|
| 788 |
|
---|
| 789 | }
|
---|
| 790 |
|
---|
| 791 |
|
---|
| 792 |
|
---|
| 793 |
|
---|
| 794 |
|
---|
| 795 | ?>
|
---|
| 796 |
|
---|
| 797 |
|
---|