[254] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Luciano Apolito & Roberto Gigli */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 |
|
---|
| 9 | if (!defined('MODULE_FILE')) {
|
---|
| 10 | die ("You can't access this file directly...");
|
---|
| 11 | }
|
---|
| 12 | if ($xls=='1' or $pdf=='1') {
|
---|
| 13 | include_once("modules/Elezioni/language/lang-$lang.php");
|
---|
| 14 | include_once("modules/Elezioni/funzioni.php");
|
---|
| 15 | }
|
---|
| 16 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
| 17 | $_GET : $_POST;
|
---|
| 18 |
|
---|
| 19 | if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
|
---|
| 20 | //if (isset($param['op'])) $op=$param['op']; else $op='';
|
---|
| 21 | if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
|
---|
| 22 | if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
|
---|
| 23 | if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
|
---|
| 24 | if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
|
---|
| 25 | if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
|
---|
| 26 | if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
|
---|
| 27 | if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
|
---|
| 28 | if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
|
---|
| 29 | if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
|
---|
| 30 | if (isset($param['info'])) $info=addslashes($param['info']); else $info='';
|
---|
| 31 | if (isset($param['files'])) $files=addslashes($param['files']); else $files='';
|
---|
| 32 | if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
|
---|
| 33 | if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
|
---|
| 34 | if (isset($param['lettera'])) $lettera=addslashes($param['lettera']); else $lettera='';
|
---|
| 35 | if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
|
---|
| 36 | #if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
|
---|
| 37 | if (isset($param['pdf'])) $pdf=intval($param['pdf']); else $pdf='';
|
---|
| 38 | if (isset($param['orienta'])) $orienta=addslashes($param['orienta']); else $orienta='';
|
---|
| 39 | if (isset($param['datipdf'])) $datipdf=addslashes($param['datipdf']); else $datipdf='';
|
---|
| 40 | if (isset($param['formato'])) $formato=addslashes($param['formato']); else $formato='';
|
---|
| 41 | # anti-xss nov. 2009
|
---|
| 42 | $id_comune=htmlentities($id_comune);
|
---|
| 43 | $id_comune=intval($id_comune);
|
---|
| 44 | $perc=htmlentities($perc);
|
---|
| 45 | $perc_lista=floatval($perc_lista);
|
---|
| 46 | #$datipdf= htmlentities($datipdf);
|
---|
| 47 | $op= htmlentities($op);
|
---|
| 48 | $info= htmlentities($info);
|
---|
| 49 | $files=htmlentities($files);
|
---|
| 50 | $lettera=htmlentities($lettera);
|
---|
| 51 | $orienta=htmlentities($orienta);
|
---|
| 52 | $formato=htmlentities($formato);
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 |
|
---|
[348] | 56 | $test=phpversion();
|
---|
| 57 | if($test>=5.6)
|
---|
| 58 | include("crea_paginaphp7.php");
|
---|
| 59 | else
|
---|
| 60 | include("crea_paginaphp5.php");
|
---|
[254] | 61 |
|
---|
[318] | 62 | $sql="SELECT descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'" ;
|
---|
| 63 | $res = $dbi->prepare("$sql");
|
---|
| 64 | $res->execute();
|
---|
[254] | 65 |
|
---|
[265] | 66 | list($descr_comune) = $res->fetch(PDO::FETCH_NUM);
|
---|
[254] | 67 |
|
---|
[318] | 68 | $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' ";
|
---|
| 69 | $res = $dbi->prepare("$sql");
|
---|
| 70 | $res->execute();
|
---|
[254] | 71 |
|
---|
[265] | 72 | list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM);
|
---|
[318] | 73 | $sql="SELECT t2.id_cons,t2.solo_gruppo,t2.disgiunto 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'" ;
|
---|
| 74 | $res = $dbi->prepare("$sql");
|
---|
| 75 | $res->execute();
|
---|
[254] | 76 |
|
---|
[265] | 77 | list($id_cons,$dettnulli,$disgiunto) = $res->fetch(PDO::FETCH_NUM);
|
---|
[254] | 78 |
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 |
|
---|
[265] | 82 |
|
---|
| 83 |
|
---|
| 84 |
|
---|
[254] | 85 | ////////////////////////////////////////////////////////////
|
---|
| 86 | // Visualizza i dati per liste, gruppi e referendum, per sezione o circoscrizione
|
---|
| 87 | ////////////////////////////////////////////////////////////
|
---|
| 88 |
|
---|
| 89 | function gruppo_circo(){
|
---|
| 90 | global $prefix, $dbi, $descr_cons, $id_cons, $id_cons_gen,$tipo_cons,$votog,$votol,$votoc,$circo, $genere,$id_gruppo,$id_lista,$bgcolor1,$bgcolor2,$id_comune,$descr_comune,$id_circ;
|
---|
| 91 | global $id_comune,$id_cons_gen,$op,$minsez,$id_lista,$id_circ,$csv,$min,$orienta,$formato,$dettnulli,$disgiunto,
|
---|
| 92 | $orvert,$offset,$offsetsez,$perc,$info,$files,$nomefile;
|
---|
| 93 | $nomefile="";
|
---|
| 94 | #Denominazione pagine
|
---|
| 95 | if($op=="gruppo_circo") $pagina=_GRUPPO." "._PER." "._CIRCO;
|
---|
| 96 | if($op=="gruppo_sezione") $pagina=_GRUPPO." "._PER." "._SEZIONI;
|
---|
| 97 | if($op=="lista_circo") $pagina=_LISTA." "._PER." "._CIRCO;
|
---|
| 98 | if($op=="lista_sezione") $pagina=_LISTA." "._PER." "._SEZIONI;
|
---|
| 99 | if($op=="candidato_circo") $pagina=_CONSI." "._PER." "._CIRCO;
|
---|
| 100 | if($op=="candidato_sezione") $pagina=_CONSI." "._PER." "._SEZIONI;
|
---|
| 101 | if($op=="consiglieri") $pagina=_CALCONS;
|
---|
| 102 | if (strstr( $op,'circo')) { //$op=='gruppo_circo' or $op=='lista_circo') {
|
---|
| 103 | $tab1="circ";
|
---|
| 104 | $tab2="t5.num_circ,t5.descrizione";
|
---|
| 105 | $tab3="t5.num_circ";
|
---|
| 106 | $tipo1=_DA." "._CIRCO;
|
---|
| 107 | $tipo2=_CIRCOS;
|
---|
| 108 | $tipo3=_CIRCO;
|
---|
| 109 | }else{
|
---|
| 110 | $tab1="sez";
|
---|
| 111 | $tab2="t3.num_sez,''";
|
---|
| 112 | $tab3="t3.num_sez";
|
---|
| 113 | $tipo1=_DA." "._SEZIONE;
|
---|
| 114 | $tipo2=_SEZIONI;
|
---|
| 115 | $tipo3=_SEZIONE;
|
---|
| 116 | }
|
---|
| 117 | if (strstr( $op,"gruppo")){
|
---|
| 118 | $tab="gruppo";
|
---|
| 119 | }elseif (strstr( $op,'lista')) {
|
---|
| 120 | $tab="lista";
|
---|
| 121 | }else{
|
---|
| 122 | $tab="candidati";
|
---|
| 123 | }
|
---|
| 124 | if ($orvert) {
|
---|
| 125 | $righe='';
|
---|
| 126 | $colonne='checked';
|
---|
| 127 | }else{
|
---|
| 128 | $righe='checked';
|
---|
| 129 | $colonne='';
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | if ($orienta) {
|
---|
| 133 | $land='';
|
---|
| 134 | $port='checked';
|
---|
| 135 | }else{
|
---|
| 136 | $land='checked';
|
---|
| 137 | $port='';
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | if ($formato) {
|
---|
| 141 | $A3='';
|
---|
| 142 | $A4='checked';
|
---|
| 143 | }else{
|
---|
| 144 | $A3='checked';
|
---|
| 145 | $A4='';
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | if ($genere>0) { //se non e' un referendum
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | $voticompl=0;
|
---|
| 154 | if (!($offset)) $offset=25;
|
---|
| 155 | if (!($min)) $min=1;
|
---|
| 156 | if (!($offsetsez)) $offsetsez=22;
|
---|
| 157 | if (!($minsez)) $minsez=1;
|
---|
| 158 | if ($min>$offset) {
|
---|
| 159 | $appo=$min;
|
---|
| 160 | $min=$offset;
|
---|
| 161 | $offset=$appo;
|
---|
| 162 | }
|
---|
| 163 | if ($minsez>$offsetsez) {
|
---|
| 164 | $appo=$minsez;
|
---|
| 165 | $minsez=$offsetsez;
|
---|
| 166 | $offsetsez=$appo;
|
---|
| 167 | }
|
---|
| 168 | if (!$csv){
|
---|
[265] | 169 | echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
|
---|
| 170 | echo "<div><input type=\"hidden\" name=\"pag\" value=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&id_lista=\"></input>";
|
---|
| 171 | echo "<input type=\"hidden\" name=\"pagina\" value=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=\"></input>";
|
---|
[254] | 172 | }
|
---|
| 173 | $condcirc='';
|
---|
| 174 | if ($circo){ //gestione circoscrizionali
|
---|
| 175 | if(!$id_circ){
|
---|
[318] | 176 | $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ=1";
|
---|
| 177 | $res_cir = $dbi->prepare("$sql");
|
---|
| 178 | $res_cir->execute();
|
---|
[265] | 179 | //se non si e' scelta una circoscr. prende la prima
|
---|
| 180 | list($id_circ)=$res_cir->fetch(PDO::FETCH_NUM);
|
---|
[254] | 181 | }
|
---|
[318] | 182 | $sql="SELECT num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ";
|
---|
| 183 | $res_cir = $dbi->prepare("$sql");
|
---|
| 184 | $res_cir->execute();
|
---|
[265] | 185 | //estrae il numero della circoscrizione
|
---|
| 186 | list($num_circ)=$res_cir->fetch(PDO::FETCH_NUM);
|
---|
[254] | 187 | $condcirc="and id_circ=$id_circ"; //variabile aggiunta nelle select per le circ.
|
---|
[338] | 188 | $sql="SELECT count(t1.num_sez),min(t1.num_sez),max(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ";
|
---|
[318] | 189 | $res_sez = $dbi->prepare("$sql");
|
---|
| 190 | $res_sez->execute();
|
---|
[265] | 191 | //numero di sezioni nella circoscrizione
|
---|
[318] | 192 | $sql="SELECT min(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ";
|
---|
| 193 | $res_min = $dbi->prepare("$sql");
|
---|
| 194 | $res_min->execute();
|
---|
[265] | 195 | //setta minsez sulla prima sezione della circoscrizione
|
---|
| 196 | list($minsez)=$res_min->fetch(PDO::FETCH_NUM);
|
---|
| 197 | }
|
---|
| 198 | elseif (strstr( $op,'circo')){
|
---|
[318] | 199 | $sql="SELECT count(num_circ),min(num_circ),max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons";
|
---|
| 200 | $res_sez = $dbi->prepare("$sql");
|
---|
| 201 | $res_sez->execute();
|
---|
[265] | 202 | }
|
---|
| 203 | else{
|
---|
[318] | 204 | $sql="SELECT count(num_sez),min(num_sez),max(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
|
---|
| 205 | $res_sez = $dbi->prepare("$sql");
|
---|
| 206 | $res_sez->execute();
|
---|
[265] | 207 | }
|
---|
[318] | 208 | if($res_sez->rowCount()) list($tot_sez,$numsezmin,$numsezmax)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
[337] | 209 | else {$tot_sez=0;$numsezmin=0;$numsezmax=0;}
|
---|
[318] | 210 | $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
|
---|
| 211 | $res_sez = $dbi->prepare("$sql");
|
---|
| 212 | $res_sez->execute();
|
---|
[337] | 213 |
|
---|
[265] | 214 | list($tuttelesez)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
| 215 |
|
---|
[254] | 216 | $num_sez=$tot_sez;//mysql_data_seek($res_sez,0);
|
---|
| 217 | if ($circo) $offsetsez=$numsezmax; //$num_sez+$minsez-1;//setta offsetsez sull'ultima sezione della circoscrizione
|
---|
| 218 |
|
---|
[265] | 219 | $visvot='';
|
---|
[254] | 220 |
|
---|
[265] | 221 | if (!$csv) echo "<div><h5>$pagina</h5></div>";
|
---|
| 222 | if (!$csv) echo "<div style=\" text-align:left; margin-left:20px;\">";
|
---|
| 223 |
|
---|
| 224 | if(strstr( $op,'candidato')){
|
---|
[254] | 225 | // $numliste=mysql_num_rows($res_lis);
|
---|
[265] | 226 | $visvot="cand";
|
---|
| 227 | if (!$csv){
|
---|
[318] | 228 | $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $condcirc order by num_lista";
|
---|
| 229 | $res_lis = $dbi->prepare("$sql");
|
---|
| 230 | $res_lis->execute();
|
---|
[254] | 231 |
|
---|
[265] | 232 | //elenco delle liste per la scelta
|
---|
| 233 | echo "<p>"._SCEGLI_LISTA.":
|
---|
| 234 | <select name=\"id_lista\" class=\"modulo\" onChange=\"top.location.href=this.form.pag.value+this.form.id_lista.options[this.form.id_lista.selectedIndex].value;return false\">";
|
---|
| 235 | while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
|
---|
| 236 | if (!$id_lista) $id_lista=$id_rif;
|
---|
| 237 | $sel = ($id_rif == $id_lista) ? "selected=\"selected\"" : "";
|
---|
| 238 | echo "<option value=\"$id_rif\" $sel>";
|
---|
| 239 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
| 240 | echo $num_lis.") ".$descrizione."</option>";
|
---|
[254] | 241 | }
|
---|
[265] | 242 | echo "</select></p>";
|
---|
| 243 | }
|
---|
[318] | 244 | $sql="SELECT count(t1.id_sez) from ".$prefix."_ele_voti_$tab as t1, ".$prefix."_ele_$tab as t2 where t2.id_lista=$id_lista and t1.id_cand=t2.id_cand group by t1.id_cand";
|
---|
| 245 | $res_scr = $dbi->prepare("$sql");
|
---|
| 246 | $res_scr->execute();
|
---|
[254] | 247 |
|
---|
[318] | 248 | $sqlc="SELECT id_cand, concat(cognome,' ', nome), num_cand from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista order by num_cand";
|
---|
| 249 | $res_cand = $dbi->prepare("$sqlc");
|
---|
| 250 | $res_cand->execute();
|
---|
[254] | 251 |
|
---|
[265] | 252 | if ($circo) $condcirc="and t5.id_circ=$id_circ";
|
---|
| 253 |
|
---|
[318] | 254 | $sqlvoti="select $tab2, t1.num_cand, concat(t1.cognome,' ', t1.nome) as nome, sum(t2.voti),'','','','',''
|
---|
[265] | 255 | from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2, "
|
---|
| 256 | .$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5
|
---|
| 257 | where t1.id_lista=$id_lista
|
---|
| 258 | and t1.id_cons=$id_cons
|
---|
| 259 | and t1.id_cand=t2.id_cand
|
---|
| 260 | and t2.id_sez=t3.id_sez
|
---|
| 261 | and t3.id_sede=t4.id_sede
|
---|
| 262 | and t4.id_circ=t5.id_circ $condcirc
|
---|
[320] | 263 | group by t1.num_cand,$tab2, t1.cognome,t1.nome
|
---|
[318] | 264 | order by $tab3,t1.num_cand";
|
---|
| 265 | $res_voti = $dbi->prepare("$sqlvoti");
|
---|
| 266 | $res_voti->execute();
|
---|
[254] | 267 | }else{
|
---|
| 268 | if (!$csv)
|
---|
| 269 | echo "<input type=\"hidden\" name=\"id_lista\" value=\"\"></input>";
|
---|
| 270 |
|
---|
[265] | 271 | // camera e senato nel 2006 aggiunte le somme della coalizione
|
---|
| 272 | // divise per circo e sez. in quanto nella tabella del gruppo
|
---|
| 273 | // all'atto dell'immsione non viene fatta la somma
|
---|
| 274 | // quindi leggere prima i voti di lista e poi agganciali al gruppo
|
---|
| 275 | // la var $tab diviene lista, $tab15 diviene gruppo in caso di somma
|
---|
| 276 | // dei voti di lista...oltre naturalmnte alle condizioni messe in variabile
|
---|
| 277 | // 4 aprile 2006 by luc
|
---|
| 278 | if ($votog && $tab=="gruppo"){ // camera e senato 2006
|
---|
| 279 | $t="t9";
|
---|
| 280 | $tab="lista";
|
---|
| 281 | $tab15="gruppo";
|
---|
| 282 | $add_1= ",".$prefix."_ele_gruppo as t9";
|
---|
| 283 | $and_1="and t1.id_gruppo=t9.id_gruppo";
|
---|
| 284 | }else{
|
---|
| 285 | $t="t1";
|
---|
| 286 | $tab15=$tab;
|
---|
| 287 | $add_1='';
|
---|
| 288 | $and_1='';
|
---|
| 289 | }
|
---|
| 290 | // fine della modifica
|
---|
| 291 |
|
---|
[318] | 292 | $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15";
|
---|
| 293 | $res_scr = $dbi->prepare("$sql");
|
---|
| 294 | $res_scr->execute();
|
---|
[265] | 295 | //numero sezioni scrutinate
|
---|
[318] | 296 | $sqlc="SELECT id_$tab15, descrizione, num_$tab15 from ".$prefix."_ele_$tab15 where id_cons='$id_cons' $condcirc order by num_$tab15";
|
---|
| 297 | $res_cand = $dbi->prepare("$sqlc");
|
---|
| 298 | $res_cand->execute();
|
---|
[254] | 299 |
|
---|
[265] | 300 | if ($circo) $condcirc="and t5.id_circ=$id_circ";
|
---|
[352] | 301 | if ($tab=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA'))
|
---|
[265] | 302 | $votigl=" sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli)";
|
---|
| 303 | else
|
---|
[352] | 304 | if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli_lista+t3.voti_nulli)";
|
---|
[265] | 305 | else $votigl=" sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli)";
|
---|
| 306 | $sqlvoti="select $tab2, $t.num_$tab15, $t.descrizione, sum(t2.voti), $votigl
|
---|
| 307 | from
|
---|
| 308 | ".$prefix."_ele_$tab as t1,
|
---|
| 309 | ".$prefix."_ele_voti_$tab as t2,
|
---|
| 310 | ".$prefix."_ele_sezioni as t3,
|
---|
| 311 | ".$prefix."_ele_sede as t4,
|
---|
| 312 | ".$prefix."_ele_circoscrizione as t5
|
---|
| 313 | $add_1
|
---|
| 314 |
|
---|
| 315 | where t1.id_cons=$id_cons
|
---|
| 316 | and t1.id_$tab=t2.id_$tab
|
---|
| 317 | $and_1
|
---|
| 318 |
|
---|
| 319 | and t2.id_sez=t3.id_sez
|
---|
| 320 | and t3.id_sede=t4.id_sede
|
---|
| 321 | and t4.id_circ=t5.id_circ $condcirc
|
---|
| 322 |
|
---|
| 323 |
|
---|
[318] | 324 | group by $t.num_$tab15,$tab3,$tab2, $t.descrizione
|
---|
| 325 | order by $tab3,$t.num_$tab15";
|
---|
| 326 | $res_voti = $dbi->prepare("$sqlvoti");
|
---|
[353] | 327 | $res_voti->execute();
|
---|
[265] | 328 | }
|
---|
| 329 | if ($res_scr) list($tot_scr)=$res_scr->fetch(PDO::FETCH_NUM);else $tot_scr=0;
|
---|
| 330 | if ($res_cand) $num_cand=$res_cand->rowCount(); else $num_cand=0;
|
---|
| 331 | if(!$circo){
|
---|
| 332 | if (!(0 < $minsez and $minsez<=$numsezmax)) $minsez=1;
|
---|
| 333 | if (!(0<$offsetsez and $offsetsez<=$numsezmax)) $offsetsez=$numsezmax;
|
---|
| 334 | }
|
---|
| 335 | if (!(0 < $min and $min<=$num_cand)) $min=1;
|
---|
| 336 | if (!(0<$offset and $offset<=$num_cand)) $offset=$num_cand;
|
---|
| 337 | if (!$csv) {
|
---|
| 338 | if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;}
|
---|
| 339 | echo "<p>$scelta "._DA.": <select name=\"min\" class=\"modulo\">";
|
---|
| 340 | while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) {
|
---|
| 341 | if (!$min) $min=$num_lis;
|
---|
| 342 | $sel = ($num_lis == $min) ? "selected=\"selected\"" : "";
|
---|
| 343 | echo "<option value=\"$num_lis\" $sel>";
|
---|
| 344 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
| 345 | echo $num_lis.") ".$descrizione."</option>";
|
---|
| 346 | }
|
---|
| 347 | echo "</select>";
|
---|
| 348 | echo " "._A.": <select name=\"offset\" class=\"modulo\">";
|
---|
| 349 | $res_cand = $dbi->prepare("$sqlc");
|
---|
| 350 | $res_cand->execute();
|
---|
[254] | 351 |
|
---|
[265] | 352 | while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) {
|
---|
| 353 | if (!$offset) $offset=$num_lis;
|
---|
| 354 | $sel = ($num_lis == $offset) ? "selected=\"selected\"" : "";
|
---|
| 355 | echo "<option value=\"$num_lis\" $sel>";
|
---|
| 356 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
| 357 | echo $num_lis.") ".$descrizione."</option>";
|
---|
[254] | 358 |
|
---|
| 359 | }
|
---|
[265] | 360 | echo "</select></p>";
|
---|
| 361 | //echo "<div style=\"text-align:left; margin-left:20px;\">";
|
---|
| 362 | if(!$circo){
|
---|
[254] | 363 | echo "<p>"._SCEGLI." $tipo1 n. <input name=\"minsez\" value=\"$minsez\" size=\"4\" ></input>";
|
---|
| 364 | echo _A." n. <input name=\"offsetsez\" value=\"$offsetsez\" size=\"4\" ></input> (max. $numsezmax)";
|
---|
[265] | 365 | }
|
---|
| 366 | # pagine
|
---|
[254] | 367 | ############
|
---|
[337] | 368 | if(!$offsetsez) $offsetsez=0;
|
---|
[265] | 369 | if (strstr( $op,'circo'))
|
---|
[318] | 370 | $sql="SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ>=$minsez and num_circ<=$offsetsez";
|
---|
[265] | 371 |
|
---|
[318] | 372 |
|
---|
[265] | 373 | else
|
---|
[318] | 374 | $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons and num_sez>=$minsez and num_sez<=$offsetsez";
|
---|
[265] | 375 | $resnsez = $dbi->prepare("$sql");
|
---|
| 376 | $resnsez->execute();
|
---|
| 377 | list($diff)=$resnsez->fetch(PDO::FETCH_NUM);
|
---|
| 378 | ########
|
---|
[254] | 379 | # $diff=($offsetsez-$minsez);
|
---|
[338] | 380 | if ($minsez>1 and !$circo){
|
---|
[265] | 381 | $minsez_p= ($minsez-$diff)>1 ? $minsez-$diff:1;
|
---|
| 382 | $offsetsez_p=$offsetsez-$diff;
|
---|
| 383 | echo "<div style=\"float: right; width:200px;margin-left:10px;margin-right:400px;font-size:12px \"><a href=\"modules.php?name=Elezioni&file=index&id_cons_gen=$id_cons_gen&id_comune=$id_comune&op=$op&min=$min&offset=$offset&minsez=$minsez_p&offsetsez=$offsetsez_p&perc=$perc&id_lista=$id_lista\"> <- $tipo2 Precedenti</a></div>";
|
---|
| 384 | }else{echo "";}
|
---|
| 385 | if ($offsetsez<$numsezmax){
|
---|
| 386 | $minsez_s=$minsez+$diff;
|
---|
| 387 | $offsetsez_s= ($offsetsez+$diff)>$num_sez ? $num_sez: $offsetsez+$diff;
|
---|
| 388 | echo "<div style=\"float: left; width:200px; margin-left:10px;\"><a href=\"modules.php?name=Elezioni&file=index&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&orvert=$orvert&min=$min&offset=$offset&minsez=$minsez_s&offsetsez=$offsetsez_s&perc=$perc&id_lista=$id_lista\"> $tipo2 Successive -></a></div>";
|
---|
| 389 | }else{echo "";}
|
---|
| 390 | if(!$circo)
|
---|
[254] | 391 | echo "<div style=\"margin-left:10px;\"><br/>"._MOSTRA." $tipo2 "._PERCOL."<input type=\"radio\" name=\"orvert\" $righe value=\"0\"></input>"._PERRIGHE." <input
|
---|
| 392 | type=\"radio\" name=\"orvert\" $colonne value=\"1\"></input>";
|
---|
[265] | 393 | echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input></div>";
|
---|
| 394 | echo "<p>";
|
---|
| 395 | if (!strstr( $op,'candidato')) {
|
---|
| 396 | echo ""._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
|
---|
| 397 | if($perc=='true') echo " checked=\"true\"";
|
---|
| 398 | echo "></input><br/>";
|
---|
| 399 | }
|
---|
| 400 | echo "";
|
---|
[254] | 401 | if($circo)
|
---|
| 402 | echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
|
---|
| 403 | echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
|
---|
| 404 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
|
---|
| 405 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
|
---|
| 406 |
|
---|
| 407 | echo "<input type=\"hidden\" name=\"pag2\" value=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&orvert=$orvert&min=$min&offset=$offset&minsez=$minsez&offsetsez=$offsetsez&perc=$perc&id_lista=\"></input>";
|
---|
| 408 |
|
---|
| 409 | echo " <input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></input></p></div></form>";
|
---|
| 410 |
|
---|
| 411 |
|
---|
| 412 | #### recupera dati stampa supporti diversi dati
|
---|
| 413 | //echo "</tr><tr><td><b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons <br/>";
|
---|
| 414 | //echo "tot:$tot_scr";
|
---|
| 415 | //if ($tipo_cons!=4 && $tot_scr) echo " - Sezioni scrutinate: $tot_scr su $tuttelez";
|
---|
| 416 |
|
---|
| 417 | # liste e gruppi da.... a
|
---|
| 418 | if (!strstr( $op,'candidato')) {
|
---|
[318] | 419 | $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$min'";
|
---|
| 420 | $res_cand2 = $dbi->prepare("$sql");
|
---|
| 421 | $res_cand2->execute();
|
---|
[265] | 422 |
|
---|
| 423 | list($descrizione)= $res_cand2->fetch(PDO::FETCH_NUM);
|
---|
[254] | 424 | $list1 ="da $descrizione ";
|
---|
| 425 |
|
---|
| 426 |
|
---|
| 427 |
|
---|
[318] | 428 | $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$offset'";
|
---|
| 429 | $res_cand3 = $dbi->prepare("$sql");
|
---|
| 430 | $res_cand3->execute();
|
---|
[265] | 431 |
|
---|
| 432 | list($descrizione)= $res_cand3->fetch(PDO::FETCH_NUM);
|
---|
[254] | 433 | $list1 .=" a $descrizione <br/>";
|
---|
| 434 |
|
---|
| 435 | }else{$list1='';}
|
---|
| 436 |
|
---|
| 437 | # nome della lista
|
---|
| 438 | if (!isset($list2)) $list2='';
|
---|
| 439 | if (strstr( $op,'candidato')) {
|
---|
[318] | 440 | $sql="SELECT num_lista, descrizione from ".$prefix."_ele_lista where id_lista=$id_lista";
|
---|
| 441 | $res_lis2 = $dbi->prepare("$sql");
|
---|
| 442 | $res_lis2->execute();
|
---|
[265] | 443 |
|
---|
| 444 | list($num_lista2,$descr_lista2)= $res_lis2->fetch(PDO::FETCH_NUM);
|
---|
[254] | 445 | $nomefile=" Lista n. $num_lista2 - $descr_lista2 ";
|
---|
| 446 | $list2 .=" Lista n. $num_lista2 - $descr_lista2 <br/>";
|
---|
| 447 |
|
---|
[318] | 448 | $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$min";
|
---|
| 449 | $res_cand4 = $dbi->prepare("$sql");
|
---|
| 450 | $res_cand4->execute();
|
---|
[265] | 451 |
|
---|
| 452 | list($descrizione)= $res_cand4->fetch(PDO::FETCH_NUM);
|
---|
[254] | 453 | $list3 ="da $descrizione ";
|
---|
[318] | 454 | $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$offset";
|
---|
| 455 | $res_cand5 = $dbi->prepare("$sql");
|
---|
| 456 | $res_cand5->execute();
|
---|
[265] | 457 |
|
---|
| 458 | list($descrizione)= $res_cand5->fetch(PDO::FETCH_NUM);
|
---|
[254] | 459 | $list3 .="a $descrizione <br/>";
|
---|
| 460 |
|
---|
| 461 | }else{ $list2 .='';$list3='';}
|
---|
| 462 | if(!isset($tab15)) $tab15='';
|
---|
| 463 | $nomefile.="$descr_cons $tab15";
|
---|
| 464 | $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile));
|
---|
[265] | 465 | $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 ";
|
---|
| 466 | # verificare la stampa sulle circoscrizioni
|
---|
[347] | 467 | echo "<div style=\"text-align:right;width:65%;margin-left:10px;margin-right:0px;font-size:12px; \">";
|
---|
| 468 | echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 280px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
|
---|
[265] | 469 | if($circo){ echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&orvert=$orvert&min=$min&offset=$offset&minsez=$minsez&offsetsez=$offsetsez&perc=$perc&id_lista=$id_lista&id_circ=$id_circ&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
|
---|
[254] | 470 | }else{
|
---|
[265] | 471 | echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&orvert=$orvert&min=$min&offset=$offset&minsez=$minsez&offsetsez=$offsetsez&perc=$perc&id_lista=$id_lista&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
|
---|
| 472 | echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&orvert=$orvert&min=$min&offset=$offset&minsez=$minsez&offsetsez=$offsetsez&perc=$perc&id_lista=$id_lista&xls=1&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
|
---|
| 473 | echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
|
---|
[347] | 474 | echo " </td>";
|
---|
[265] | 475 | # stampa pdf
|
---|
[347] | 476 | echo "<td>";
|
---|
[265] | 477 | echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
|
---|
| 478 | echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
|
---|
| 479 | echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
|
---|
| 480 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
|
---|
| 481 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
|
---|
| 482 | echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
|
---|
| 483 | echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
|
---|
| 484 | echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
|
---|
[254] | 485 | echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
|
---|
[265] | 486 | echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
|
---|
| 487 | echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
|
---|
| 488 | echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
|
---|
| 489 | echo "<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\"></input>";
|
---|
| 490 | echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
|
---|
| 491 | echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
|
---|
| 492 | # echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>";
|
---|
| 493 | echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
|
---|
| 494 | echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
|
---|
| 495 | echo " L <input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P <input
|
---|
| 496 | type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
|
---|
| 497 | echo " A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
|
---|
| 498 | type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
|
---|
[347] | 499 | echo " </form></td></tr></table> ";
|
---|
[254] | 500 | }
|
---|
| 501 | echo "</div></br />";
|
---|
[265] | 502 | }
|
---|
[254] | 503 | if (!$csv){
|
---|
| 504 | echo "<h5> Sezioni scrutinate";
|
---|
| 505 | if ($tipo_cons!=4) echo ": $tot_scr su $tuttelesez ";
|
---|
| 506 | echo "</h5> ";
|
---|
| 507 | }
|
---|
| 508 | $y=1;
|
---|
| 509 | $ar[0][0]=$tipo3;
|
---|
| 510 | $ra[0][0]=$tipo3;
|
---|
| 511 | $num_sez++;
|
---|
| 512 | $voticompl=0;
|
---|
| 513 | $ominsez=$minsez-1;
|
---|
| 514 | $valar=array();$percar=array();
|
---|
| 515 | ////////////////////////////////////////////////////////////////////
|
---|
| 516 | // sandro: carica i numeri di sezione dal DB - giugno 2009
|
---|
| 517 | // caso: sezioni in collegi diversi non consecutive
|
---|
| 518 | if (strstr( $op,'circo'))
|
---|
[318] | 519 | $sql="select num_circ,id_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ";
|
---|
[254] | 520 | else{
|
---|
| 521 | if($circo) { $secirco=" and t2.id_circ=$id_circ";} else $secirco="and t1.num_sez >= $minsez and t1.num_sez <= $offsetsez";
|
---|
| 522 | $numsezioni = $offsetsez-$ominsez;
|
---|
[318] | 523 | $sql="SELECT t1.num_sez,t1.id_sez from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede $secirco order by t1.num_sez";
|
---|
[254] | 524 | }
|
---|
[265] | 525 | $res_numsez = $dbi->prepare("$sql");
|
---|
[344] | 526 | $res_numsez->execute();
|
---|
[318] | 527 | $sevaltot=0;
|
---|
| 528 | $senultot=0;
|
---|
| 529 | $sebiatot=0;
|
---|
| 530 | $secontot=0;
|
---|
| 531 | $sevnutot=0;
|
---|
[337] | 532 | while($res=$res_numsez->fetch(PDO::FETCH_NUM)) {
|
---|
[265] | 533 | $z=$res[0];
|
---|
[254] | 534 | ##############inserimento percentuale di scrutinio nella sezione
|
---|
[265] | 535 | $scruvalidi=0;
|
---|
| 536 | $scrunulli=0;
|
---|
| 537 | $grpercscru=0;
|
---|
| 538 | $altri=0;
|
---|
| 539 | $votiscru=0;
|
---|
| 540 | if($op=="gruppo_sezione"){
|
---|
| 541 | $sqlr="select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
|
---|
| 542 | $sqlv="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'";
|
---|
| 543 | $resperc = $dbi->prepare("$sqlr");
|
---|
| 544 | $resperc->execute();
|
---|
| 545 | $votiperc = $dbi->prepare("$sqlv");
|
---|
| 546 | $votiperc->execute();
|
---|
| 547 | }
|
---|
| 548 | elseif($op=="lista_sezione"){
|
---|
[318] | 549 | $sqlr="select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
|
---|
| 550 | $sqlv="select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'";
|
---|
[265] | 551 | $resperc = $dbi->prepare("$sqlr");
|
---|
| 552 | $resperc->execute();
|
---|
| 553 | $votiperc = $dbi->prepare("$sqlv");
|
---|
| 554 | $votiperc->execute();
|
---|
| 555 | }
|
---|
| 556 | if (isset($resperc) and $resperc)
|
---|
| 557 | list($scruvalidi,$scrunulli)=$resperc->fetch(PDO::FETCH_NUM);
|
---|
| 558 | if (isset($votiperc) and $votiperc)
|
---|
| 559 | list($votiscru)=$votiperc->fetch(PDO::FETCH_NUM);
|
---|
[318] | 560 | $sql="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_sez='".$res[1]."' group by data,orario order by data desc, orario desc limit 0,1 ";
|
---|
| 561 | $resperc = $dbi->prepare("$sql");
|
---|
| 562 | $resperc->execute();
|
---|
[254] | 563 |
|
---|
[265] | 564 | if ($resperc)
|
---|
| 565 | list($totschede)=$resperc->fetch(PDO::FETCH_NUM);
|
---|
| 566 | if (isset($scruvalidi) and $scruvalidi>0 )
|
---|
| 567 | $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0;
|
---|
| 568 |
|
---|
[254] | 569 | ################### <span class=\"red\"><i>".$temp3[$key]." %</i></span>
|
---|
[265] | 570 | $ar[$z][0]=$res[0]; if($grpercscru) {$ar[$z][0].="<br /><span class=\"red\"><i>$grpercscru%</i></span>";if(!strstr($ar[0][0],'scrutinio')) $ar[0][0].="<br /><span class=\"red\"><i>% scrutinio</i></span>"; }
|
---|
| 571 | $pos[$z]=$res[0];
|
---|
| 572 | #$valar[$z]=array();
|
---|
| 573 | }
|
---|
[254] | 574 | if (!isset($pos)) $pos[0]=0;
|
---|
| 575 | $minpos=min($pos);
|
---|
| 576 | $maxpos=max($pos);
|
---|
| 577 | ////////////////////////////////////////////////////////////////////
|
---|
[352] | 578 | if ($tab=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA'))
|
---|
[347] | 579 | $sqlvoti2="select $tab3, sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli) from ".$prefix."_ele_circoscrizione as t5, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4 where t5.id_cons=$id_cons and t5.id_circ=t4.id_circ and t3.id_sede=t4.id_sede group by $tab3";
|
---|
| 580 | else
|
---|
[353] | 581 | if (strstr( $op,'circo')) $sqlvoti2="select t1.num_circ, sum(t3.validi_lista),sum(t3.voti_nulli_lista),sum(t3.contestati_lista),sum(t3.solo_gruppo),sum(t3.voti_nulli_lista+t3.voti_nulli) from ".$prefix."_ele_circoscrizione as t1, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4 where t1.id_cons=$id_cons and t1.id_circ=t4.id_circ and t3.id_sede=t4.id_sede group by t1.num_circ";
|
---|
| 582 | # togli circo vai con modo tab3, genere=2 e =4 prende stringa madre (poi va sistemato il tipo camera 2001 che registra i voti di lista sui gruppi
|
---|
| 583 | # camera 2008 e 2001 --> tipo cons=6 non funziona
|
---|
[350] | 584 |
|
---|
[353] | 585 | else $sqlvoti2="select t3.num_sez, (t3.validi_lista),(t3.voti_nulli_lista),(t3.contestati_lista),(t3.solo_gruppo),(t3.voti_nulli_lista+t3.voti_nulli) from ".$prefix."_ele_sezioni as t3 where t3.id_cons=$id_cons ";
|
---|
[347] | 586 | $res_voti = $dbi->prepare("$sqlvoti2");
|
---|
| 587 | $res_voti->execute();
|
---|
[353] | 588 | # echo "TEST: ---- $sqlvoti2";
|
---|
[347] | 589 | ///////////////////////////
|
---|
[265] | 590 | if ($res_voti->rowCount())
|
---|
[347] | 591 | while (list($num_circ,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
|
---|
[318] | 592 | # if($genere==4) $sevalidi=$voti;
|
---|
[265] | 593 | $z=array_search($num_circ, $pos);
|
---|
[254] | 594 | if (!isset($votitot[($z)])) {
|
---|
[265] | 595 | $votitot[($z)]=0;
|
---|
| 596 | if($sevalidi) $sevaltot+=$sevalidi;
|
---|
| 597 | if($senulli) $senultot+=$senulli;
|
---|
| 598 | if($sebianchi) $sebiatot+=$sebianchi;
|
---|
| 599 | if($secontestati) $secontot+=$secontestati;
|
---|
| 600 | if($sevonulli) $sevnutot+=$sevonulli;
|
---|
[254] | 601 | }
|
---|
[347] | 602 | # $votitot[($z)]+=$voti;
|
---|
| 603 | # if(!isset($valsez[$z])) $valsez[$z]=0;
|
---|
[318] | 604 | $valsez[$z]=$sevalidi;
|
---|
[347] | 605 | $nulsez[$z]=$senulli;
|
---|
| 606 | $biasez[$z]=$sebianchi;
|
---|
| 607 | $consez[$z]=$secontestati;
|
---|
| 608 | $vonsez[$z]=$sevonulli;
|
---|
| 609 | # $voticompl+=$voti;
|
---|
[254] | 610 | }
|
---|
[265] | 611 | if ($voticompl) {
|
---|
| 612 | $res_voti = $dbi->prepare("$sqlvoti");
|
---|
| 613 | $res_voti->execute();
|
---|
| 614 | }
|
---|
[353] | 615 | $piuvot=0;
|
---|
| 616 |
|
---|
| 617 | if ($visvot!='cand') if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')) $piuvot=5; else $piuvot=4;
|
---|
[265] | 618 | for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" ";
|
---|
| 619 | if (strstr( $op,'circo'))
|
---|
[318] | 620 | $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ";
|
---|
[265] | 621 | else
|
---|
[318] | 622 | $sql="select num_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez>='$minsez' and num_sez<='$offsetsez' order by num_sez";
|
---|
[265] | 623 | $lis_sez = $dbi->prepare("$sql");
|
---|
| 624 | $lis_sez->execute();
|
---|
| 625 | $nsezsel=$lis_sez->rowCount();
|
---|
| 626 | while(list($z)=$lis_sez->fetch(PDO::FETCH_NUM))
|
---|
| 627 | {
|
---|
| 628 | for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" ";} //inizializza le celle interne
|
---|
[254] | 629 |
|
---|
| 630 | ###################################################################
|
---|
| 631 | # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" ";
|
---|
| 632 | # for ($z=1;$z<=($offsetsez-$ominsez);$z++)
|
---|
| 633 | # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" "; //inizializza le celle interne
|
---|
[265] | 634 | $onetime="";
|
---|
| 635 | if ($res_voti)
|
---|
| 636 | {
|
---|
| 637 | while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
|
---|
[254] | 638 | $z=array_search($num_circ, $pos);
|
---|
[265] | 639 | $valar[($z)][$num_cand]=$voti;
|
---|
[254] | 640 | }
|
---|
[318] | 641 |
|
---|
[254] | 642 | foreach ($valar as $key=>$val){
|
---|
| 643 | if(isset($votitot[($key)]))
|
---|
| 644 | $percar[$key]=arrayperc($val,$votitot[($key)]);
|
---|
[318] | 645 |
|
---|
| 646 | }
|
---|
| 647 | # if($res_voti->rowCount()) {
|
---|
| 648 | $res_voti = $dbi->prepare("$sqlvoti");
|
---|
| 649 | $res_voti->execute();
|
---|
| 650 | #}
|
---|
| 651 |
|
---|
[265] | 652 | while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
|
---|
| 653 | if($num_cand<$min or $num_cand>$offset) continue;
|
---|
[318] | 654 | if($genere==4) $sevalidi=$voti;
|
---|
| 655 |
|
---|
[265] | 656 | if (!isset($temp[$num_cand])) $temp[$num_cand]=0;
|
---|
| 657 | $temp[$num_cand]+=$voti;
|
---|
| 658 | $z=array_search($num_circ, $pos);
|
---|
| 659 | if (!$z) continue;
|
---|
| 660 | if ($num_cand>=$min and $num_cand<=$offset){
|
---|
| 661 | if($num_circ>=$minpos and $num_circ <=$maxpos){
|
---|
| 662 | $ar[0][$num_cand]=$num_cand.") ".$nome;
|
---|
| 663 | if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;}
|
---|
| 664 | $percento=$voti;
|
---|
| 665 | if ($perc=='true' and $votitot[($z)])
|
---|
| 666 | {
|
---|
| 667 | $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>";
|
---|
| 668 | }
|
---|
[318] | 669 |
|
---|
[265] | 670 | $ar[($z)][$num_cand]=$percento;
|
---|
| 671 | }
|
---|
[254] | 672 | }
|
---|
[265] | 673 | if (!strstr( $op,'candidato')){
|
---|
| 674 | if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0;
|
---|
| 675 | $tempar[$num_cand]+=$voti;
|
---|
| 676 | }
|
---|
| 677 | if ($visvot!='cand'){
|
---|
| 678 | $posvoti=($offset);
|
---|
[353] | 679 | if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')){
|
---|
| 680 | $ar[0][$posvoti+1]='<b>Voti Validi</b>';
|
---|
| 681 | $ar[0][$posvoti+2]='<b>Schede Nulle</b>';
|
---|
| 682 | $ar[0][$posvoti+3]='<b>Schede Bianche</b>';
|
---|
| 683 | $ar[0][$posvoti+4]='<b>Voti Contestati</b>';
|
---|
| 684 | $ar[0][$posvoti+5]='<b>Voti Nulli</b>';
|
---|
| 685 | }else{
|
---|
| 686 | $ar[0][$posvoti+1]='<b>Voti Validi</b>';
|
---|
| 687 | $ar[0][$posvoti+2]='<b>Voti Nulli</b>';
|
---|
| 688 | $ar[0][$posvoti+3]='<b>Voti Contestati</b>';
|
---|
| 689 | $ar[0][$posvoti+4]='<b>Solo Gruppo</b>';
|
---|
| 690 | }
|
---|
[265] | 691 | if (($maxpos)>=$num_circ and $minpos<=$num_circ){
|
---|
| 692 | //$posvoti++;
|
---|
[318] | 693 | $ar[($z)][$posvoti+1]="<b>$valsez[$z]</b>";
|
---|
[347] | 694 | $ar[($z)][$posvoti+2]="<b>$nulsez[$z]</b>";
|
---|
| 695 | $ar[($z)][$posvoti+3]="<b>$biasez[$z]</b>";
|
---|
| 696 | $ar[($z)][$posvoti+4]="<b>$consez[$z]</b>";
|
---|
[353] | 697 | if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')) $ar[($z)][$posvoti+5]="<b>$vonsez[$z]</b>";
|
---|
[265] | 698 | }
|
---|
| 699 | }
|
---|
[254] | 700 | }
|
---|
| 701 | }
|
---|
| 702 |
|
---|
[265] | 703 | if (($offsetsez+1)>=$num_sez){
|
---|
| 704 | $ar[(1+$numsezmax)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>";
|
---|
| 705 | if(isset($temp)) {
|
---|
| 706 | if (!isset($tab15) or !$tab15) $tab15="candidati";
|
---|
[353] | 707 | if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')){
|
---|
[344] | 708 | if($votog) $tab15="lista";
|
---|
| 709 | $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
|
---|
[265] | 710 | }elseif($votog){
|
---|
[318] | 711 | $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
|
---|
[265] | 712 | }else{
|
---|
[353] | 713 | # if($dettnulli)
|
---|
| 714 | $votigl=" sum(validi_lista),sum(voti_nulli_lista),sum(contestati_lista),sum(solo_gruppo),0";
|
---|
| 715 | # else $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista+voti_nulli)";
|
---|
[265] | 716 | }
|
---|
[254] | 717 | if($circo)
|
---|
[318] | 718 | $sql="SELECT $votigl from ".$prefix."_ele_sezioni AS t1 LEFT JOIN soraldo_ele_sede AS t2 ON t1.id_sede = t2.id_sede WHERE t1.id_cons='$id_cons' and t2.id_circ=$id_circ";
|
---|
[254] | 719 | else
|
---|
[318] | 720 | $sql="SELECT $votigl from ".$prefix."_ele_sezioni as t1 where t1.id_cons='$id_cons' and t1.id_sez=(select t2.id_sez from ".$prefix."_ele_voti_$tab15 as t2 where t2.id_sez=t1.id_sez group by t2.id_sez)";
|
---|
[265] | 721 | $resv = $dbi->prepare("$sql");
|
---|
[353] | 722 | $resv->execute(); #echo "TEST2: --- $sql";
|
---|
[265] | 723 | list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= $resv->fetch(PDO::FETCH_NUM);
|
---|
[254] | 724 | $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot;
|
---|
[318] | 725 | $sql="SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'";
|
---|
| 726 | $resvt = $dbi->prepare("$sql");
|
---|
[265] | 727 | $resvt->execute();
|
---|
| 728 | if($resvt) list($votlt)=$resvt->fetch(PDO::FETCH_NUM); else $votlt=0;
|
---|
[254] | 729 | if($perc) $temp3=arrayperc($temp,$sevaltot);
|
---|
[344] | 730 |
|
---|
| 731 | foreach($temp as $key=>$voti) {
|
---|
[254] | 732 | if ($perc=='true' and $voticompl)
|
---|
| 733 | {
|
---|
| 734 | $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
|
---|
| 735 | } else
|
---|
| 736 | $percento="<b>$voti</b>";
|
---|
| 737 | $ar[1+$numsezmax][$key]=$percento;
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
| 740 | if ($visvot!='cand') {
|
---|
| 741 | $key=$offset+1;
|
---|
[353] | 742 |
|
---|
| 743 | # if(!defined('_NULLISTA'))
|
---|
| 744 | if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA'))
|
---|
| 745 | $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
|
---|
| 746 | else $tmp=array($sevaltot,$senultot,$sebiatot,$secontot);
|
---|
[254] | 747 | if($perc) $temp3=arrayperc($tmp,$voticompl);
|
---|
[344] | 748 |
|
---|
| 749 | foreach($tmp as $k=>$voti) {
|
---|
[254] | 750 | if ($perc=='true' and $voticompl)
|
---|
| 751 | {
|
---|
| 752 | $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
|
---|
| 753 | } else $percento="<b>$voti</b>";
|
---|
| 754 | $ar[1+$numsezmax][++$key]=$percento;
|
---|
| 755 |
|
---|
| 756 | }
|
---|
| 757 | }
|
---|
| 758 | }
|
---|
| 759 | if($orvert!=1) {
|
---|
| 760 | $i=0;
|
---|
| 761 | foreach ( $ar as $riga) {
|
---|
| 762 | $y=0;
|
---|
| 763 | foreach($riga as $cella) {
|
---|
| 764 | $ra[$y++][$i]=$cella;
|
---|
| 765 | }
|
---|
| 766 | $i++;
|
---|
| 767 | }
|
---|
| 768 | crea_tabella($ra);
|
---|
| 769 | }else{
|
---|
| 770 | crea_tabella($ar);
|
---|
| 771 | }
|
---|
| 772 | //e' un referendum
|
---|
| 773 | }else{
|
---|
[318] | 774 | $sql="SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo";
|
---|
| 775 | $res_lis = $dbi->prepare("$sql");
|
---|
| 776 | $res_lis->execute();
|
---|
[254] | 777 |
|
---|
[265] | 778 | if($res_lis) $numliste=$res_lis->rowCount(); else $numliste=0;
|
---|
| 779 |
|
---|
[254] | 780 | if (!isset($offset)) $offset=10;
|
---|
| 781 | if (!isset($min)) $min=1;
|
---|
| 782 | if (!isset($offsetsez)) $offsetsez=25; //lo 0 viene sostituito dal totale di sezioni presenti
|
---|
| 783 | if (!isset($minsez)) $minsez=1;
|
---|
| 784 | if (!$csv){
|
---|
| 785 | echo "<div><h5>$pagina</h5></div>";
|
---|
| 786 | echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
|
---|
| 787 | echo "<div style=\"text-align:left;width:700px;margin:auto;font-size:12px \">
|
---|
| 788 | <input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
|
---|
| 789 | echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
|
---|
| 790 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
|
---|
| 791 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
|
---|
| 792 | echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">";
|
---|
| 793 | if($res_lis)
|
---|
[265] | 794 | while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
|
---|
[254] | 795 | if (!$id_gruppo) $id_gruppo=$id_rif;
|
---|
| 796 | $sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : "";
|
---|
| 797 | echo "<option value=\"$id_rif\" $sel>";
|
---|
| 798 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
| 799 | echo $num_lis.") ".strip_tags(substr($descrizione,0,50))."</option>";
|
---|
| 800 | }
|
---|
| 801 | echo "</select>";
|
---|
| 802 | echo "<br />"._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
|
---|
| 803 | if($perc=='true') echo " checked=\"true\"";
|
---|
| 804 | echo ">";
|
---|
| 805 | echo "<br /><input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></form></div>";
|
---|
| 806 |
|
---|
| 807 |
|
---|
| 808 |
|
---|
| 809 | }
|
---|
| 810 |
|
---|
[318] | 811 | $sql="select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo";
|
---|
| 812 | $res_ref = $dbi->prepare("$sql");
|
---|
| 813 | $res_ref ->execute();
|
---|
[265] | 814 |
|
---|
| 815 | $sql="select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo,
|
---|
[254] | 816 | sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati)
|
---|
| 817 | from ".$prefix."_ele_gruppo as t1
|
---|
| 818 | left join ".$prefix."_ele_voti_ref as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 819 | left join ".$prefix."_ele_sezioni as t3 on (t2.id_sez=t3.id_sez)
|
---|
| 820 | left join ".$prefix."_ele_sede as t4 on (t3.id_sede=t4.id_sede)
|
---|
| 821 | left join ".$prefix."_ele_circoscrizione as t5 on (t4.id_circ=t5.id_circ)
|
---|
| 822 | where t1.id_cons='$id_cons' and t1.id_gruppo=$id_gruppo
|
---|
[320] | 823 | group by t2.id_gruppo,$tab2, t1.num_gruppo, t1.descrizione , t1.simbolo
|
---|
[254] | 824 | order by $tab3, t1.num_gruppo
|
---|
[318] | 825 | ";
|
---|
| 826 | $res = $dbi->prepare("$sql");
|
---|
| 827 | $res->execute();
|
---|
[265] | 828 |
|
---|
| 829 | if($res) $num_sez=$res->rowCount(); else $num_sez=0;
|
---|
| 830 | if($res_ref) list($num_gruppo,$descr)= $res_ref->fetch(PDO::FETCH_NUM); else {$num_gruppo=0;$descr='';}
|
---|
[254] | 831 |
|
---|
| 832 | if (!$csv){
|
---|
| 833 | # stampa
|
---|
| 834 |
|
---|
| 835 | $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> ";
|
---|
| 836 | $datipdf .="<br/><b>Referendum n. ".$num_gruppo." </b><br/>".$descr."";
|
---|
| 837 | echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:20px;font-size:12px \">";
|
---|
| 838 | echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
|
---|
| 839 |
|
---|
| 840 | echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&perc=$perc&id_gruppo=$id_gruppo&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
|
---|
| 841 | echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&perc=$perc&id_gruppo=$id_gruppo&xls=1&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
|
---|
| 842 |
|
---|
| 843 | //echo "<a href=\"modules.php?name=Elezioni&op=$op&id_cons_gen=$id_cons_gen&id_comune=$id_comune&csv=1&perc=$perc&id_gruppo=$id_gruppo&pdf=1&datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"Export Pdf\" /></a>";
|
---|
| 844 |
|
---|
| 845 |
|
---|
| 846 | echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
|
---|
| 847 |
|
---|
| 848 | echo " </td></tr>";
|
---|
| 849 |
|
---|
| 850 |
|
---|
| 851 | echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
|
---|
| 852 |
|
---|
| 853 | echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
|
---|
| 854 | echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
|
---|
| 855 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
|
---|
| 856 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
|
---|
| 857 | echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
|
---|
| 858 | echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
|
---|
| 859 | echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
|
---|
| 860 | echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
|
---|
| 861 | echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
|
---|
| 862 | echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
|
---|
| 863 | echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
|
---|
| 864 | echo "<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"></input>";
|
---|
| 865 | echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
|
---|
| 866 | echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
|
---|
| 867 | echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
|
---|
| 868 |
|
---|
| 869 | echo "<tr><td>";
|
---|
| 870 | echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
|
---|
| 871 | echo " L <input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P <input
|
---|
| 872 | type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
|
---|
| 873 | echo " A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
|
---|
| 874 | type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
|
---|
| 875 |
|
---|
| 876 |
|
---|
| 877 | echo " </td></tr></table></form> ";
|
---|
| 878 |
|
---|
| 879 |
|
---|
| 880 |
|
---|
| 881 |
|
---|
| 882 |
|
---|
| 883 |
|
---|
| 884 |
|
---|
| 885 |
|
---|
| 886 |
|
---|
| 887 | echo "</div>";
|
---|
| 888 |
|
---|
| 889 |
|
---|
| 890 | // numero sezioni scrutinate
|
---|
[320] | 891 | $sql="select t3.id_sez from ".$prefix."_ele_voti_ref as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' group by t3.id_sez ";
|
---|
[318] | 892 | $res4 = $dbi->prepare("$sql");
|
---|
| 893 | $res4->execute();
|
---|
[265] | 894 |
|
---|
| 895 | $numero=$res4->rowCount();
|
---|
[318] | 896 | $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' ";
|
---|
| 897 | $res5 = $dbi->prepare("$sql");
|
---|
| 898 | $res5->execute();
|
---|
[265] | 899 |
|
---|
| 900 | $sezioni=$res5->rowCount();
|
---|
[254] | 901 | if ($numero!=0) echo "<h5><i> "._SEZSCRU." $numero "._SU." $sezioni </i></h5>";
|
---|
| 902 |
|
---|
| 903 | }
|
---|
[318] | 904 | $sql="select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 905 | $res5 = $dbi->prepare("$sql");
|
---|
| 906 | $res5->execute();
|
---|
[254] | 907 |
|
---|
[265] | 908 | list($num_sez) = $res5->fetch(PDO::FETCH_NUM);
|
---|
[254] | 909 |
|
---|
| 910 |
|
---|
| 911 |
|
---|
| 912 |
|
---|
[265] | 913 |
|
---|
[254] | 914 | if (!$csv)echo "<b>Referendum n. ".$num_gruppo." </b><br />".$descr."";
|
---|
| 915 |
|
---|
| 916 | $y=1;
|
---|
| 917 | $ar[0][0]=$tipo2;
|
---|
| 918 | $ar[0][1]=_SI;
|
---|
| 919 | $ar[0][2]=_NO;
|
---|
| 920 | $ar[0][3]=_VALIDI;
|
---|
| 921 | $ar[0][4]=_NULLI;
|
---|
| 922 | $ar[0][5]=_BIANCHI;
|
---|
| 923 | $ar[0][6]=_CONTESTATI;
|
---|
| 924 | if($res_ref)
|
---|
[265] | 925 | while (list($num_gruppo,$desc_ref) = $res_ref->fetch(PDO::FETCH_NUM)){
|
---|
[254] | 926 | $ar[0][$i++]= $num_gruppo.") ".$desc_ref;
|
---|
| 927 | $ar[1][$y++]= "SI";
|
---|
| 928 | $ar[1][$y++]= "NO";
|
---|
| 929 | }
|
---|
| 930 | $num_sez++;
|
---|
| 931 | $tot_si=0;
|
---|
| 932 | $tot_no=0;
|
---|
| 933 | $tot_va=0;
|
---|
| 934 | $tot_nu=0;
|
---|
| 935 | $tot_bi=0;
|
---|
| 936 | $tot_co=0;
|
---|
| 937 | if($res)
|
---|
[265] | 938 | while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[254] | 939 | $i=1;
|
---|
| 940 | $votanti=$validi+$nulli+$bianchi+$contestati;
|
---|
| 941 | $tot_si+=$si;
|
---|
| 942 | $tot_no+=$no;
|
---|
| 943 | $tot_va+=$validi;
|
---|
| 944 | $tot_nu+=$nulli;
|
---|
| 945 | $tot_bi+=$bianchi;
|
---|
| 946 | $tot_co+=$contestati;
|
---|
| 947 | $ar[$num_circ][0]=$num_circ."<br />".$desc_circ;
|
---|
| 948 | if($validi){
|
---|
| 949 | $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>".number_format($si*100/$validi,2)."%</i></span>":$si;
|
---|
| 950 | $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>".number_format($no*100/$validi,2)."%</i></span>":$no;
|
---|
| 951 | }else{
|
---|
| 952 | $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>0.00%</i></span>":$si;
|
---|
| 953 | $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>0.00%</i></span>":$no;
|
---|
| 954 | }
|
---|
| 955 | if($votanti){
|
---|
| 956 | $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>".number_format($validi*100/$votanti,2)."%</i></span>":$validi;
|
---|
| 957 | $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>".number_format($nulli*100/$votanti,2)."%</i></span>":$nulli;
|
---|
| 958 | $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>".number_format($bianchi*100/$votanti,2)."%</i></span>":$bianchi;
|
---|
| 959 | $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>".number_format($contestati*100/$votanti,2)."%</i></span>":$contestati;
|
---|
| 960 | }else{
|
---|
| 961 | $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>0.00%</i></span>":$validi;
|
---|
| 962 | $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>0.00%</i></span>":$nulli;
|
---|
| 963 | $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>0.00%</i></span>":$bianchi;
|
---|
| 964 | $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>0.00%</i></span>":$contestati;
|
---|
| 965 | }
|
---|
| 966 | }
|
---|
| 967 | $i=1;
|
---|
| 968 | $tot_vo=$tot_va+$tot_nu+$tot_bi+$tot_co;
|
---|
| 969 | # if($tot_va==0) $tot_va=1;
|
---|
| 970 | # if($tot_vo==0) $tot_vo=1;
|
---|
| 971 | $ar[$num_sez][0]=_TOT."<br />"._COMPLESSIVO;
|
---|
| 972 | if($tot_va){
|
---|
| 973 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">".number_format($tot_si*100/$tot_va,2)."%</span>":$tot_si;
|
---|
| 974 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">".number_format($tot_no*100/$tot_va,2)."%</span>":$tot_no;
|
---|
| 975 | }else{
|
---|
| 976 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">0.00%</span>":$tot_si;
|
---|
| 977 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">0.00%</span>":$tot_no;
|
---|
| 978 | }
|
---|
| 979 | if($tot_vo){
|
---|
| 980 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">".number_format($tot_va*100/$tot_vo,2)."%</span>":$tot_va;
|
---|
| 981 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">".number_format($tot_nu*100/$tot_vo,2)."%</span>":$tot_nu;
|
---|
| 982 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">".number_format($tot_bi*100/$tot_vo,2)."%</span>":$tot_bi;
|
---|
| 983 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">".number_format($tot_co*100/$tot_vo,2)."%</span>":$tot_co;
|
---|
| 984 | }else{
|
---|
| 985 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">0.00%</span>":$tot_va;
|
---|
| 986 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">0.00%</span>":$tot_nu;
|
---|
| 987 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">0.00%</span>":$tot_bi;
|
---|
| 988 | $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">0.00%</span>":$tot_co;
|
---|
| 989 | }
|
---|
| 990 | crea_tabella($ar);
|
---|
| 991 | }
|
---|
| 992 | if ($csv) echo "</body>\n</html>";
|
---|
| 993 | }
|
---|
| 994 |
|
---|
| 995 | ?>
|
---|