[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
|
---|
[284] | 607 | if($flash=='1') flash_torta($gruppos,$pre,40,145);
|
---|
[267] | 608 | $uno='';
|
---|
| 609 | foreach($gruppos as $k=>$v) $uno.="- $v";
|
---|
| 610 | $due='due:';
|
---|
| 611 | foreach($pre as $k=>$v) $due.="- $v";
|
---|
[2] | 612 | echo "</td></tr></table>";
|
---|
| 613 |
|
---|
| 614 |
|
---|
| 615 | }else{
|
---|
| 616 | // tot voti
|
---|
[132] | 617 | if($tema=='tour'){
|
---|
[265] | 618 | $sql="SELECT count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
| 619 | $res1 = $dbi->prepare("$sql");
|
---|
| 620 | $res1->execute();
|
---|
| 621 |
|
---|
| 622 | list($max_ruotag) =$res1->fetch(PDO::FETCH_NUM);
|
---|
[132] | 623 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
| 624 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
[265] | 625 | $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] | 626 | }else
|
---|
[265] | 627 | $sql="select sum(validi),id_gruppo from ".$prefix."_$tab where id_cons=$id_cons group by id_gruppo";
|
---|
| 628 | $res = $dbi->prepare("$sql");
|
---|
| 629 | $res->execute();
|
---|
| 630 |
|
---|
| 631 | while (list($tot,$id_gruppo) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 632 |
|
---|
| 633 | $s=0;
|
---|
[265] | 634 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
[2] | 635 | from ".$prefix."_ele_gruppo as t1
|
---|
| 636 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 637 | where t1.id_cons='$id_cons' and t1.id_gruppo='$id_gruppo'
|
---|
| 638 | group by t1.id_gruppo
|
---|
[265] | 639 | ";
|
---|
| 640 | $res1 = $dbi->prepare("$sql");
|
---|
| 641 | $res1->execute();
|
---|
| 642 |
|
---|
[2] | 643 |
|
---|
| 644 |
|
---|
[265] | 645 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 646 | if($tot){
|
---|
| 647 | $percsi=number_format($si*100/$tot,3);
|
---|
| 648 | $percno=number_format($no*100/$tot,3);
|
---|
| 649 | $percsi=number_format($percsi,2);
|
---|
| 650 | $percno=number_format($percno,2);
|
---|
| 651 | }else{ $percsi="0.00"; $percno="0.00";}
|
---|
| 652 | $gruppo=array("si","no");
|
---|
| 653 | $gruppos=array("","si","no");// flash
|
---|
| 654 | $pro=array($percsi,$percno);
|
---|
| 655 | $pre=array("",$percsi,$percno);//flash
|
---|
| 656 | // echo "<br/><b><center>$descrizione</center><br/><br/>";
|
---|
| 657 | // sviluppo tabella dati
|
---|
| 658 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
| 659 | echo "<tr><td bgcolor=\"$bgcolor1\">$num_gruppo - $descrizione</b></td></tr><tr></table>
|
---|
| 660 | <table><tr>
|
---|
[132] | 661 | <td ><b>"._SI.":</b> </td><td>$si</td>
|
---|
| 662 | <td ><b>%</b> </td><td>$percsi</td>
|
---|
| 663 | <td ><b>"._NO.":</b> </td><td>$no</td>
|
---|
| 664 | <td ><b>%</b> </td><td>$percno</td><tr>
|
---|
[2] | 665 | </table></td><td><center><br />";
|
---|
| 666 |
|
---|
| 667 | $i=8; // parametro lunghezza tavola
|
---|
| 668 | $l=30; // larghezza label
|
---|
| 669 | $titolo="Numero ".$num_gruppo."";
|
---|
| 670 | $dati1=serialize($pro);
|
---|
| 671 | //$dati1=urlencode($dati1); //IE
|
---|
| 672 | $dati2=serialize($gruppo);
|
---|
| 673 | $dati2=urlencode($dati2);
|
---|
| 674 | $titolo=urlencode($titolo);
|
---|
| 675 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
| 676 | $descr=urlencode($descr_cons);
|
---|
| 677 | 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>";
|
---|
| 678 |
|
---|
| 679 |
|
---|
| 680 | if($flash=='1')flash_torta($gruppos,$pre,20,70);
|
---|
| 681 |
|
---|
| 682 |
|
---|
[267] | 683 |
|
---|
[2] | 684 |
|
---|
| 685 |
|
---|
| 686 | echo "</td></tr></table>"; // fine tabella dati
|
---|
| 687 | $s++;
|
---|
| 688 | }
|
---|
| 689 |
|
---|
| 690 |
|
---|
| 691 | }
|
---|
| 692 |
|
---|
| 693 |
|
---|
| 694 |
|
---|
| 695 | }
|
---|
| 696 |
|
---|
| 697 | }
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 |
|
---|
| 703 |
|
---|
| 704 |
|
---|
| 705 | /***********************************
|
---|
| 706 | /* Grafica Candidato
|
---|
| 707 | /**********************************/
|
---|
| 708 |
|
---|
| 709 | function graf_candidato(){
|
---|
[253] | 710 | 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] | 711 |
|
---|
[105] | 712 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
| 713 |
|
---|
[2] | 714 | $tab="ele_voti_candidati";
|
---|
| 715 |
|
---|
[265] | 716 | $sql="select * from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_sez ";
|
---|
| 717 | $res = $dbi->prepare("$sql");
|
---|
| 718 | $res->execute();
|
---|
| 719 |
|
---|
| 720 | $numero=$res->rowCount();
|
---|
| 721 | $sql = "select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 722 | $res = $dbi->prepare("$sql");
|
---|
| 723 | $res->execute();
|
---|
| 724 |
|
---|
| 725 | $sezioni=$res->rowCount();
|
---|
[2] | 726 | if ($numero!=0){
|
---|
| 727 | echo "<table border=\"0\" align=\"center\"><tr><td>";
|
---|
| 728 | echo "<h5>"._PREFERENZE." "._CONSI." $descr_cons </h5>";
|
---|
| 729 | echo "<h5>"._SEZSCRU." $numero "._SU." $sezioni </h5>
|
---|
| 730 | <h5>I 30 piu' votati</h5>";
|
---|
| 731 | echo "</td></tr></table>";
|
---|
| 732 | // tot voti
|
---|
[265] | 733 | $sql="select sum(voti) from ".$prefix."_ele_voti_candidati where id_cons=$id_cons ";
|
---|
| 734 | $res = $dbi->prepare("$sql");
|
---|
| 735 | $res->execute();
|
---|
| 736 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 737 |
|
---|
| 738 | // gruppi o liste per simbolo
|
---|
| 739 |
|
---|
| 740 | if ($genere==4){
|
---|
| 741 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 742 | }else{
|
---|
| 743 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
| 744 | }
|
---|
| 745 | $i=0;
|
---|
[265] | 746 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t2.voti) as somma
|
---|
[2] | 747 | from ".$prefix."_ele_candidati as t1
|
---|
| 748 | left join ".$prefix."_ele_voti_candidati as t2 on (t1.id_cand=t2.id_cand)
|
---|
| 749 | left join ".$prefix.$scelta."
|
---|
| 750 | where t1.id_cons='$id_cons'
|
---|
| 751 | group by t2.id_cand
|
---|
| 752 |
|
---|
| 753 | order by somma desc
|
---|
| 754 |
|
---|
[265] | 755 | ";
|
---|
| 756 | $res = $dbi->prepare("$sql");
|
---|
| 757 | $res->execute();
|
---|
| 758 |
|
---|
| 759 | $n_candi=$res->rowCount();
|
---|
[2] | 760 | echo "<table><tr><td><table>"; // inizio tabella dati
|
---|
[265] | 761 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 762 | $candidato[$i]=$cognome;
|
---|
[253] | 763 | if ($tot) $pro[$i]=number_format($voti*100/$tot,2); else $pro[$i]=0;
|
---|
[2] | 764 | // sviluppo tabella dati
|
---|
| 765 | $e=$i+1;
|
---|
| 766 |
|
---|
| 767 | 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>
|
---|
| 768 | <td bgcolor=\"$bgcolor1\"><b>$nome $cognome</b></td>
|
---|
| 769 | <td bgcolor=\"$bgcolor1\">"._VOTI."</td><td>$voti</td>
|
---|
| 770 | <td bgcolor=\"$bgcolor1\">%</td><td>$pro[$i]</td></tr>";
|
---|
| 771 |
|
---|
| 772 | if ($e=='30' || $e==$n_candi){
|
---|
| 773 |
|
---|
| 774 |
|
---|
| 775 |
|
---|
| 776 | echo "</table></td></tr></table>"; // fine tabella dati
|
---|
| 777 |
|
---|
| 778 | include("footer.php");
|
---|
| 779 | exit;
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 |
|
---|
| 783 |
|
---|
| 784 | $i++;
|
---|
| 785 |
|
---|
| 786 |
|
---|
| 787 |
|
---|
| 788 |
|
---|
| 789 | }
|
---|
| 790 |
|
---|
| 791 | }
|
---|
| 792 |
|
---|
| 793 | }
|
---|
| 794 |
|
---|
| 795 | function flash_torta($gruppos,$pre,$y,$x){
|
---|
| 796 | //if (!defined('FLASH')) die();
|
---|
[132] | 797 | include_once ("class/charts.php");
|
---|
[2] | 798 | // inizio grafico torta flash
|
---|
| 799 |
|
---|
| 800 |
|
---|
| 801 |
|
---|
| 802 | $chart[ 'chart_data' ] = array ($gruppos, $pre);
|
---|
[268] | 803 | // $chart[ 'chart_data' ] = array ( array ("","Ciao", "Bella"), array ( "",40, 60));
|
---|
[2] | 804 | $chart[ 'chart_grid_h' ] = array ( 'thickness'=>0 );
|
---|
| 805 | $chart[ 'chart_pref' ] = array ( 'rotation_x'=>60 );
|
---|
| 806 | $chart[ 'chart_rect' ] = array ( 'x'=>$x, 'y'=>$y, 'width'=>350, 'height'=>200, 'positive_alpha'=>0 );
|
---|
| 807 | $chart[ 'chart_transition' ] = array ( 'type'=>"spin", 'delay'=>.5, 'duration'=>.75, 'order'=>"category" );
|
---|
| 808 | $chart[ 'chart_type' ] = "3d pie";
|
---|
| 809 | $chart[ 'chart_value' ] = array ( 'color'=>"000000", 'alpha'=>150, 'font'=>"arial", 'bold'=>true, 'size'=>10, 'position'=>"inside", 'prefix'=>"", 'suffix'=>"", 'decimals'=>2, 'separator'=>"", 'as_percentage'=>true );
|
---|
| 810 |
|
---|
| 811 | $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" )) ;
|
---|
| 812 |
|
---|
| 813 | $chart[ 'legend_label' ] = array ( 'layout'=>"horizontal", 'bullet'=>"circle", 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000000", 'alpha'=>85 );
|
---|
| 814 | $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 );
|
---|
| 815 | $chart[ 'legend_transition' ] = array ( 'type'=>"dissolve", 'delay'=>0, 'duration'=>4 );
|
---|
| 816 |
|
---|
| 817 | $chart[ 'series_color' ] = array ( "00ff88", "ffaa00","44aaff", "aa00ff" );
|
---|
| 818 | $chart[ 'series_explode' ] = array ( 25, 75, 0, 0 );
|
---|
| 819 | $fileout="";
|
---|
| 820 | /////////////////////////////// MODIFICHE PER TOGLIERE FILETEMP
|
---|
| 821 | // $fileout=SendChartData ( $chart );
|
---|
| 822 | $xml=SendChartData ( $chart );
|
---|
| 823 | $max=isset($_SESSION['max']) ? $_SESSION['max']:0;
|
---|
| 824 | $max++;
|
---|
| 825 | $cur="xml$max";
|
---|
| 826 | $_SESSION[$cur]=$xml;
|
---|
| 827 | $_SESSION['max']=$max;
|
---|
| 828 | $fileout="modules.php?file=graf&pos=$cur";
|
---|
| 829 | ///////////////////////////////
|
---|
| 830 | echo InsertChart ( "class/charts.swf", "class/charts_library","$fileout" );
|
---|
| 831 |
|
---|
| 832 | // Fine Grafico torta flash
|
---|
| 833 | echo "<noembed>Elemento non supportato!<br/>Grafico a torta</noembed>";
|
---|
| 834 |
|
---|
| 835 |
|
---|
| 836 | }
|
---|
| 837 |
|
---|
| 838 |
|
---|
| 839 |
|
---|
| 840 |
|
---|
| 841 |
|
---|
| 842 |
|
---|
| 843 |
|
---|
| 844 | ?>
|
---|
| 845 |
|
---|
| 846 |
|
---|