[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>
|
---|
| 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=\"\" /></a></div>";
|
---|
| 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>
|
---|
| 142 | <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 * 2)."\" /><img src=\"modules/Elezioni/images/barre/rightbar2.gif\" height=\"$r_size2[1]\" width=\"$r_size2[0]\" alt=\"\" /><span class=\"red\"> $perc</span> % ($voti_t)<br /></td></tr>\n";
|
---|
| 143 |
|
---|
| 144 | $tot_gen=$tot;
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | echo "<tr><td> "._AVENTI.": </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 * 2)."\" /><img src=\"modules/Elezioni/images/barre/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"\" /> 100 % ($tot_gen)</td></tr></table>";
|
---|
| 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=\"
|
---|
| 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=\"\" /></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=\"\" /></a>";
|
---|
| 177 | if($flash==1)
|
---|
| 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=\"\" /></a>";
|
---|
| 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)
|
---|
[265] | 222 | $sql="select t1.* from ".$prefix."_ele_voti_".$tab." as t1 left join ".$prefix."_ele_$tab 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='';
|
---|
| 405 | if ($genere!=0){$tab="ele_voti_gruppo";}else{$tab="ele_voti_ref";}
|
---|
[41] | 406 | if ($genere==4 or $visgralista){$tab="ele_voti_lista";}
|
---|
[2] | 407 | if ($votog){$tab="ele_voti_lista";}
|
---|
[265] | 408 | $sql="select * from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
| 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 |
|
---|
[2] | 431 | if ($numero>0){
|
---|
| 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)
|
---|
[265] | 444 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
[2] | 445 | if ($votog)
|
---|
[265] | 446 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
| 447 | $restotv = $dbi->prepare("$sql");
|
---|
| 448 | $restotv->execute();
|
---|
| 449 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
| 450 |
|
---|
[2] | 451 |
|
---|
| 452 | $i=0;
|
---|
| 453 | // lista o gruppo
|
---|
[41] | 454 | if ($genere!=4 and !$visgralista){
|
---|
[2] | 455 |
|
---|
| 456 | if ($votog){
|
---|
| 457 |
|
---|
[265] | 458 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 459 | from ".$prefix."_ele_gruppo as t1,
|
---|
| 460 | ".$prefix."_ele_voti_lista as t2,
|
---|
| 461 | ".$prefix."_ele_lista as t3
|
---|
| 462 | where t1.id_cons='$id_cons'
|
---|
| 463 | and t2.id_lista=t3.id_lista
|
---|
| 464 | and t1.id_gruppo=t3.id_gruppo
|
---|
| 465 | group by t1.id_gruppo
|
---|
[265] | 466 | order by somma desc";
|
---|
| 467 | $cosa='id_gruppo';
|
---|
[2] | 468 |
|
---|
| 469 | }else{
|
---|
| 470 |
|
---|
| 471 |
|
---|
[265] | 472 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 473 | from ".$prefix."_ele_gruppo as t1
|
---|
| 474 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 475 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
| 476 | group by t2.id_gruppo
|
---|
[265] | 477 | order by somma desc";
|
---|
| 478 | $cosa='id_gruppo';
|
---|
| 479 | }
|
---|
| 480 | $res = $dbi->prepare("$sql");
|
---|
| 481 | $res->execute();
|
---|
[2] | 482 |
|
---|
| 483 |
|
---|
| 484 | }else{
|
---|
[265] | 485 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 486 | from ".$prefix."_ele_lista as t1
|
---|
| 487 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
[229] | 488 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
[2] | 489 | group by t2.id_lista
|
---|
[265] | 490 | order by somma desc";
|
---|
| 491 | $res = $dbi->prepare("$sql");
|
---|
| 492 | $res->execute();
|
---|
| 493 | $cosa='id_lista';
|
---|
[2] | 494 | }
|
---|
| 495 |
|
---|
| 496 | echo "<table>
|
---|
| 497 | <tr>
|
---|
| 498 | <td><br />
|
---|
| 499 | <table cellspacing=\"0\" cellpadding=\"2\" rules=\"cols\">";
|
---|
| 500 | // inizio tabella dati
|
---|
| 501 | // variabili stampa flash
|
---|
| 502 | $e=0;
|
---|
| 503 | $gruppos[$e]="";
|
---|
| 504 | $pre[$e]="";
|
---|
| 505 | $e=1;
|
---|
| 506 | // fine
|
---|
[265] | 507 | $gruppinum=$res->rowCount();
|
---|
[2] | 508 | $altrivoti=0;
|
---|
[68] | 509 | ####calcolo percentuale
|
---|
| 510 | $arvoti=array();
|
---|
| 511 | $arperc=array();
|
---|
[265] | 512 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[68] | 513 | $arvoti[$id]=$voti;
|
---|
| 514 | }
|
---|
| 515 | $arperc=arrayperc($arvoti,$tot);
|
---|
[265] | 516 | $res = $dbi->prepare("$sql");
|
---|
| 517 | $res->execute();
|
---|
| 518 |
|
---|
[68] | 519 | ####
|
---|
[69] | 520 | $altriperc=0;
|
---|
[265] | 521 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 522 |
|
---|
| 523 |
|
---|
| 524 | // verica chi ha preso meno del 3%
|
---|
| 525 | $menotre=(number_format($voti*100/$tot,2));
|
---|
| 526 |
|
---|
| 527 | if($menotre>3){
|
---|
| 528 |
|
---|
| 529 |
|
---|
| 530 |
|
---|
| 531 |
|
---|
| 532 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
| 533 | //$descrizione=taglio(4,$descrizione);
|
---|
| 534 |
|
---|
[21] | 535 | $gruppo[$i]=(substr($descrizione,0,21));
|
---|
| 536 | $gruppos[$e]=(substr($descrizione,0,21)); //flash
|
---|
[2] | 537 |
|
---|
| 538 |
|
---|
| 539 |
|
---|
| 540 | if (strlen($descrizione)>21) $gruppo[$i].="...";
|
---|
| 541 | if (strlen($descrizione)>21) $gruppos[$e].="...";
|
---|
[69] | 542 | $pro[$i]=number_format($arperc[$id],2);
|
---|
| 543 | $pre[$e]=number_format($arperc[$id],2); //flash
|
---|
[2] | 544 |
|
---|
| 545 |
|
---|
| 546 | }else{
|
---|
| 547 | //somma i voti sotto il 3%
|
---|
| 548 | $altrivoti = $altrivoti + $voti;
|
---|
[69] | 549 | $altriperc += $arperc[$id];
|
---|
[2] | 550 | }
|
---|
| 551 |
|
---|
| 552 |
|
---|
| 553 |
|
---|
| 554 |
|
---|
| 555 |
|
---|
| 556 |
|
---|
| 557 | $votiv=number_format($voti,0,',','.');
|
---|
| 558 | // formattazione numeri perc
|
---|
[68] | 559 | $prov=number_format($arperc[$id],2);
|
---|
[2] | 560 |
|
---|
| 561 | // sviluppo tabella dati
|
---|
| 562 | $bgcolor1= ($bgcolor1=="#cacaca") ? "#ffffff":"#cacaca";
|
---|
| 563 | echo "<tr valign=\"top\">
|
---|
| 564 | <td valign=\"top\"><b><img src=\"modules.php?name=Elezioni&file=foto&$cosa=$id\" class=\"stemmapic\" alt=\"\" /></b></td>
|
---|
| 565 | <td><b>$descrizione</b></td>
|
---|
| 566 | <td>"._VOTI."</td><td align=\"right\">$votiv</td><td align=\"right\"> <i>($prov%)</i></td>
|
---|
| 567 | </tr>";
|
---|
| 568 |
|
---|
| 569 | $e++; // flash
|
---|
| 570 | $i++;
|
---|
| 571 | }
|
---|
| 572 | // aggiunge altri minori al 3%
|
---|
| 573 | // esiste
|
---|
| 574 | // corretto 15 aprile 2006
|
---|
| 575 | if ($altrivoti>0){
|
---|
| 576 |
|
---|
| 577 | $gruppo[]=_ALTRI;
|
---|
| 578 | $gruppos[]=_ALTRI;
|
---|
[69] | 579 | $pro[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
| 580 | $pre[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
[2] | 581 | }
|
---|
| 582 |
|
---|
| 583 |
|
---|
| 584 | if ($i<=10) $i=10;
|
---|
| 585 | $titolo=""._PERCE." "._VOTIE."";
|
---|
| 586 | $dati1=serialize($pro);
|
---|
| 587 | //$dati1=urlencode($dati1);
|
---|
| 588 | //$gruppo=utf8_encode($gruppo);
|
---|
| 589 | $dati2=serialize($gruppo);
|
---|
| 590 | $dati2=urlencode($dati2);
|
---|
| 591 |
|
---|
| 592 | $titolo=urlencode($titolo);
|
---|
| 593 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 594 | $descr_cons=urlencode($descr_cons);
|
---|
[105] | 595 | if ($genere==4){$w=800;$l=250;}else{$w=750;$l=220;}
|
---|
[2] | 596 |
|
---|
| 597 |
|
---|
[65] | 598 | echo "</table></td>";
|
---|
| 599 | global $tema;
|
---|
| 600 | if($tema!="tour") echo "</tr><tr>";
|
---|
| 601 | echo "<td valign=\"top\"><br />";
|
---|
[2] | 602 | # grafico statico
|
---|
| 603 | 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\" />";
|
---|
| 604 |
|
---|
| 605 | echo "</td></tr></table><table><tr><td>";
|
---|
| 606 | # grafico flash
|
---|
[267] | 607 | # if($flash=='1') flash_torta($gruppos,$pre,40,145);
|
---|
| 608 | $uno='';
|
---|
| 609 | foreach($gruppos as $k=>$v) $uno.="- $v";
|
---|
| 610 | $due='due:';
|
---|
| 611 | foreach($pre as $k=>$v) $due.="- $v";
|
---|
| 612 | include("flash_torta($uno,$due,20,70)");
|
---|
[2] | 613 | echo "</td></tr></table>";
|
---|
| 614 |
|
---|
| 615 |
|
---|
| 616 | }else{
|
---|
| 617 | // tot voti
|
---|
[132] | 618 | if($tema=='tour'){
|
---|
[265] | 619 | $sql="SELECT count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 620 | $res1 = $dbi->prepare("$sql");
|
---|
| 621 | $res1->execute();
|
---|
| 622 |
|
---|
| 623 | list($max_ruotag) =$res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 624 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
| 625 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
[265] | 626 | $sql="select sum(t1.validi),t1.id_gruppo from ".$prefix."_$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] | 627 | }else
|
---|
[265] | 628 | $sql="select sum(validi),id_gruppo from ".$prefix."_$tab where id_cons=$id_cons group by id_gruppo";
|
---|
| 629 | $res = $dbi->prepare("$sql");
|
---|
| 630 | $res->execute();
|
---|
| 631 |
|
---|
| 632 | while (list($tot,$id_gruppo) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 633 |
|
---|
| 634 | $s=0;
|
---|
[265] | 635 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
[2] | 636 | from ".$prefix."_ele_gruppo as t1
|
---|
| 637 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 638 | where t1.id_cons='$id_cons' and t1.id_gruppo='$id_gruppo'
|
---|
| 639 | group by t1.id_gruppo
|
---|
[265] | 640 | ";
|
---|
| 641 | $res1 = $dbi->prepare("$sql");
|
---|
| 642 | $res1->execute();
|
---|
| 643 |
|
---|
[2] | 644 |
|
---|
| 645 |
|
---|
[265] | 646 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 647 | if($tot){
|
---|
| 648 | $percsi=number_format($si*100/$tot,3);
|
---|
| 649 | $percno=number_format($no*100/$tot,3);
|
---|
| 650 | $percsi=number_format($percsi,2);
|
---|
| 651 | $percno=number_format($percno,2);
|
---|
| 652 | }else{ $percsi="0.00"; $percno="0.00";}
|
---|
| 653 | $gruppo=array("si","no");
|
---|
| 654 | $gruppos=array("","si","no");// flash
|
---|
| 655 | $pro=array($percsi,$percno);
|
---|
| 656 | $pre=array("",$percsi,$percno);//flash
|
---|
| 657 | // echo "<br/><b><center>$descrizione</center><br/><br/>";
|
---|
| 658 | // sviluppo tabella dati
|
---|
| 659 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
| 660 | echo "<tr><td bgcolor=\"$bgcolor1\">$num_gruppo - $descrizione</b></td></tr><tr></table>
|
---|
| 661 | <table><tr>
|
---|
[132] | 662 | <td ><b>"._SI.":</b> </td><td>$si</td>
|
---|
| 663 | <td ><b>%</b> </td><td>$percsi</td>
|
---|
| 664 | <td ><b>"._NO.":</b> </td><td>$no</td>
|
---|
| 665 | <td ><b>%</b> </td><td>$percno</td><tr>
|
---|
[2] | 666 | </table></td><td><center><br />";
|
---|
| 667 |
|
---|
| 668 | $i=8; // parametro lunghezza tavola
|
---|
| 669 | $l=30; // larghezza label
|
---|
| 670 | $titolo="Numero ".$num_gruppo."";
|
---|
| 671 | $dati1=serialize($pro);
|
---|
| 672 | //$dati1=urlencode($dati1); //IE
|
---|
| 673 | $dati2=serialize($gruppo);
|
---|
| 674 | $dati2=urlencode($dati2);
|
---|
| 675 | $titolo=urlencode($titolo);
|
---|
| 676 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 677 | $descr=urlencode($descr_cons);
|
---|
| 678 | 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>";
|
---|
| 679 |
|
---|
| 680 |
|
---|
| 681 | if($flash=='1')flash_torta($gruppos,$pre,20,70);
|
---|
| 682 |
|
---|
| 683 |
|
---|
[267] | 684 |
|
---|
[2] | 685 |
|
---|
| 686 |
|
---|
| 687 | echo "</td></tr></table>"; // fine tabella dati
|
---|
| 688 | $s++;
|
---|
| 689 | }
|
---|
| 690 |
|
---|
| 691 |
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 |
|
---|
| 695 |
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | }
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 | }
|
---|
| 702 |
|
---|
| 703 |
|
---|
| 704 |
|
---|
| 705 |
|
---|
| 706 | /***********************************
|
---|
| 707 | /* Grafica Candidato
|
---|
| 708 | /**********************************/
|
---|
| 709 |
|
---|
| 710 | function graf_candidato(){
|
---|
[253] | 711 | 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;
|
---|
[2] | 712 |
|
---|
[105] | 713 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
| 714 |
|
---|
[2] | 715 | $tab="ele_voti_candidati";
|
---|
| 716 |
|
---|
[265] | 717 | $sql="select * from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_sez ";
|
---|
| 718 | $res = $dbi->prepare("$sql");
|
---|
| 719 | $res->execute();
|
---|
| 720 |
|
---|
| 721 | $numero=$res->rowCount();
|
---|
| 722 | $sql = "select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 723 | $res = $dbi->prepare("$sql");
|
---|
| 724 | $res->execute();
|
---|
| 725 |
|
---|
| 726 | $sezioni=$res->rowCount();
|
---|
[2] | 727 | if ($numero!=0){
|
---|
| 728 | echo "<table border=\"0\" align=\"center\"><tr><td>";
|
---|
| 729 | echo "<h5>"._PREFERENZE." "._CONSI." $descr_cons </h5>";
|
---|
| 730 | echo "<h5>"._SEZSCRU." $numero "._SU." $sezioni </h5>
|
---|
| 731 | <h5>I 30 piu' votati</h5>";
|
---|
| 732 | echo "</td></tr></table>";
|
---|
| 733 | // tot voti
|
---|
[265] | 734 | $sql="select sum(voti) from ".$prefix."_ele_voti_candidati where id_cons=$id_cons ";
|
---|
| 735 | $res = $dbi->prepare("$sql");
|
---|
| 736 | $res->execute();
|
---|
| 737 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 738 |
|
---|
| 739 | // gruppi o liste per simbolo
|
---|
| 740 |
|
---|
| 741 | if ($genere==4){
|
---|
| 742 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 743 | }else{
|
---|
| 744 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 745 | }
|
---|
| 746 | $i=0;
|
---|
[265] | 747 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t2.voti) as somma
|
---|
[2] | 748 | from ".$prefix."_ele_candidati as t1
|
---|
| 749 | left join ".$prefix."_ele_voti_candidati as t2 on (t1.id_cand=t2.id_cand)
|
---|
| 750 | left join ".$prefix.$scelta."
|
---|
| 751 | where t1.id_cons='$id_cons'
|
---|
| 752 | group by t2.id_cand
|
---|
| 753 |
|
---|
| 754 | order by somma desc
|
---|
| 755 |
|
---|
[265] | 756 | ";
|
---|
| 757 | $res = $dbi->prepare("$sql");
|
---|
| 758 | $res->execute();
|
---|
| 759 |
|
---|
| 760 | $n_candi=$res->rowCount();
|
---|
[2] | 761 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
[265] | 762 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 763 | $candidato[$i]=$cognome;
|
---|
[253] | 764 | if ($tot) $pro[$i]=number_format($voti*100/$tot,2); else $pro[$i]=0;
|
---|
[2] | 765 | // sviluppo tabella dati
|
---|
| 766 | $e=$i+1;
|
---|
| 767 |
|
---|
| 768 | 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>
|
---|
| 769 | <td bgcolor=\"$bgcolor1\"><b>$nome $cognome</b></td>
|
---|
| 770 | <td bgcolor=\"$bgcolor1\">"._VOTI."</td><td>$voti</td>
|
---|
| 771 | <td bgcolor=\"$bgcolor1\">%</td><td>$pro[$i]</td></tr>";
|
---|
| 772 |
|
---|
| 773 | if ($e=='30' || $e==$n_candi){
|
---|
| 774 |
|
---|
| 775 |
|
---|
| 776 |
|
---|
| 777 | echo "</table></td></tr></table>"; // fine tabella dati
|
---|
| 778 |
|
---|
| 779 | include("footer.php");
|
---|
| 780 | exit;
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 |
|
---|
| 784 |
|
---|
| 785 | $i++;
|
---|
| 786 |
|
---|
| 787 |
|
---|
| 788 |
|
---|
| 789 |
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | }
|
---|
| 793 |
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | function flash_torta($gruppos,$pre,$y,$x){
|
---|
| 797 | //if (!defined('FLASH')) die();
|
---|
[132] | 798 | include_once ("class/charts.php");
|
---|
[2] | 799 | // inizio grafico torta flash
|
---|
| 800 |
|
---|
| 801 |
|
---|
| 802 |
|
---|
| 803 | $chart[ 'chart_data' ] = array ($gruppos, $pre);
|
---|
[268] | 804 | // $chart[ 'chart_data' ] = array ( array ("","Ciao", "Bella"), array ( "",40, 60));
|
---|
[2] | 805 | $chart[ 'chart_grid_h' ] = array ( 'thickness'=>0 );
|
---|
| 806 | $chart[ 'chart_pref' ] = array ( 'rotation_x'=>60 );
|
---|
| 807 | $chart[ 'chart_rect' ] = array ( 'x'=>$x, 'y'=>$y, 'width'=>350, 'height'=>200, 'positive_alpha'=>0 );
|
---|
| 808 | $chart[ 'chart_transition' ] = array ( 'type'=>"spin", 'delay'=>.5, 'duration'=>.75, 'order'=>"category" );
|
---|
| 809 | $chart[ 'chart_type' ] = "3d pie";
|
---|
| 810 | $chart[ 'chart_value' ] = array ( 'color'=>"000000", 'alpha'=>150, 'font'=>"arial", 'bold'=>true, 'size'=>10, 'position'=>"inside", 'prefix'=>"", 'suffix'=>"", 'decimals'=>2, 'separator'=>"", 'as_percentage'=>true );
|
---|
| 811 |
|
---|
| 812 | $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" )) ;
|
---|
| 813 |
|
---|
| 814 | $chart[ 'legend_label' ] = array ( 'layout'=>"horizontal", 'bullet'=>"circle", 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000000", 'alpha'=>85 );
|
---|
| 815 | $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 );
|
---|
| 816 | $chart[ 'legend_transition' ] = array ( 'type'=>"dissolve", 'delay'=>0, 'duration'=>4 );
|
---|
| 817 |
|
---|
| 818 | $chart[ 'series_color' ] = array ( "00ff88", "ffaa00","44aaff", "aa00ff" );
|
---|
| 819 | $chart[ 'series_explode' ] = array ( 25, 75, 0, 0 );
|
---|
| 820 | $fileout="";
|
---|
| 821 | /////////////////////////////// MODIFICHE PER TOGLIERE FILETEMP
|
---|
| 822 | // $fileout=SendChartData ( $chart );
|
---|
| 823 | $xml=SendChartData ( $chart );
|
---|
| 824 | $max=isset($_SESSION['max']) ? $_SESSION['max']:0;
|
---|
| 825 | $max++;
|
---|
| 826 | $cur="xml$max";
|
---|
| 827 | $_SESSION[$cur]=$xml;
|
---|
| 828 | $_SESSION['max']=$max;
|
---|
| 829 | $fileout="modules.php?file=graf&pos=$cur";
|
---|
| 830 | ///////////////////////////////
|
---|
| 831 | echo InsertChart ( "class/charts.swf", "class/charts_library","$fileout" );
|
---|
| 832 |
|
---|
| 833 | // Fine Grafico torta flash
|
---|
| 834 | echo "<noembed>Elemento non supportato!<br/>Grafico a torta</noembed>";
|
---|
| 835 |
|
---|
| 836 |
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 |
|
---|
| 840 |
|
---|
| 841 |
|
---|
| 842 |
|
---|
| 843 |
|
---|
| 844 |
|
---|
| 845 | ?>
|
---|
| 846 |
|
---|
| 847 |
|
---|