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