Changeset 265 for trunk/client/modules/Elezioni/gruppo.php
- Timestamp:
- Apr 13, 2019, 8:05:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/modules/Elezioni/gruppo.php
r254 r265 58 58 include("crea_pagina.php"); 59 59 60 $res = mysql_query("SELECT descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'" , $dbi); 61 list($descr_comune) = mysql_fetch_row($res); 62 63 $res = mysql_query("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' ", $dbi); 64 list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = mysql_fetch_row($res); 65 $res = mysql_query("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'" , $dbi); 66 list($id_cons,$dettnulli,$disgiunto) = mysql_fetch_row($res); 60 $sql="SELECT descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'" ; 61 $res = $dbi->prepare("$sql"); 62 $res->execute(); 63 64 list($descr_comune) = $res->fetch(PDO::FETCH_NUM); 65 66 $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' "; 67 $res = $dbi->prepare("$sql"); 68 $res->execute(); 69 70 list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM); 71 $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'" ; 72 $res = $dbi->prepare("$sql"); 73 $res->execute(); 74 75 list($id_cons,$dettnulli,$disgiunto) = $res->fetch(PDO::FETCH_NUM); 67 76 68 77 … … 89 98 if($op=="candidato_sezione") $pagina=_CONSI." "._PER." "._SEZIONI; 90 99 if($op=="consiglieri") $pagina=_CALCONS; 91 92 93 94 95 100 if (strstr( $op,'circo')) { //$op=='gruppo_circo' or $op=='lista_circo') { 96 101 $tab1="circ"; … … 160 165 } 161 166 if (!$csv){ 162 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";163 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>";164 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>";167 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">"; 168 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>"; 169 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>"; 165 170 } 166 171 $condcirc=''; 167 172 if ($circo){ //gestione circoscrizionali 168 173 if(!$id_circ){ 169 $res_cir = mysql_query("SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ=1",$dbi); //se non si e' scelta una circoscr. prende la prima 170 list($id_circ)=mysql_fetch_row($res_cir); 171 } 172 $res_cir = mysql_query("SELECT num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ",$dbi); //estrae il numero della circoscrizione 173 list($num_circ)=mysql_fetch_row($res_cir); 174 $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ=1"; 175 $res_cir = $dbi->prepare("$sql"); 176 $res_cir->execute(); 177 //se non si e' scelta una circoscr. prende la prima 178 list($id_circ)=$res_cir->fetch(PDO::FETCH_NUM); 179 } 180 $sql="SELECT num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ"; 181 $res_cir = $dbi->prepare("$sql"); 182 $res_cir->execute(); 183 //estrae il numero della circoscrizione 184 list($num_circ)=$res_cir->fetch(PDO::FETCH_NUM); 174 185 $condcirc="and id_circ=$id_circ"; //variabile aggiunta nelle select per le circ. 175 $res_sez = mysql_query("SELECT count(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",$dbi); //numero di sezioni nella circoscrizione 176 $res_min = mysql_query("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",$dbi); //setta minsez sulla prima sezione della circoscrizione 177 list($minsez)=mysql_fetch_row($res_min); 178 } 179 elseif (strstr( $op,'circo')) 180 $res_sez = mysql_query("SELECT count(num_circ),min(num_circ),max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons",$dbi); 181 else 182 $res_sez = mysql_query("SELECT count(num_sez),min(num_sez),max(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons",$dbi); 183 if($res_sez) list($tot_sez,$numsezmin,$numsezmax)=mysql_fetch_row($res_sez); 184 $res_sez = mysql_query("SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons",$dbi); 185 list($tuttelesez)=mysql_fetch_row($res_sez); 186 $sql="SELECT count(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"; 187 $res_sez = $dbi->prepare("$sql"); 188 $res_sez->execute(); 189 //numero di sezioni nella circoscrizione 190 $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"; 191 $res_min = $dbi->prepare("$sql"); 192 $res_min->execute(); 193 //setta minsez sulla prima sezione della circoscrizione 194 list($minsez)=$res_min->fetch(PDO::FETCH_NUM); 195 } 196 elseif (strstr( $op,'circo')){ 197 $sql="SELECT count(num_circ),min(num_circ),max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons"; 198 $res_sez = $dbi->prepare("$sql"); 199 $res_sez->execute(); 200 } 201 else{ 202 $sql="SELECT count(num_sez),min(num_sez),max(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons"; 203 $res_sez = $dbi->prepare("$sql"); 204 $res_sez->execute(); 205 } 206 if($res_sez) list($tot_sez,$numsezmin,$numsezmax)=$res_sez->fetch(PDO::FETCH_NUM); 207 $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons"; 208 $res_sez = $dbi->prepare("$sql"); 209 $res_sez->execute(); 210 211 list($tuttelesez)=$res_sez->fetch(PDO::FETCH_NUM); 186 212 187 213 $num_sez=$tot_sez;//mysql_data_seek($res_sez,0); 188 214 if ($circo) $offsetsez=$numsezmax; //$num_sez+$minsez-1;//setta offsetsez sull'ultima sezione della circoscrizione 189 # if(strstr( $op,"circo")) { 190 # $res_sez = mysql_query("SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons",$dbi); //estrae il numero delle circoscrizioni 191 # list($num_sez)=mysql_fetch_row($res_sez); 192 # } 193 #Tolgo la scelta della circoscrizione o collegio perché gestita per tutte le pagine in index.php 194 /* if ($circo){ // elenco per scelta circoscrizione 195 $res_sez = mysql_query("SELECT id_circ,descrizione,num_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons",$dbi); 196 echo "<div >"._SCELTA_CIR.": 197 <select name=\"id_circ\" class=\"modulo\" onChange=\"top.location.href=this.form.pagina.value+this.form.id_circ.options[this.form.id_circ.selectedIndex].value;return false\">"; 198 while(list($id_rif,$descrizione,$num_cir)=mysql_fetch_row($res_sez)) { 199 if (!$id_circ) $id_circ=$id_rif; 200 $sel = ($id_rif == $id_circ) ? "selected=\"selected\"" : ""; 215 216 $visvot=''; 217 218 if (!$csv) echo "<div><h5>$pagina</h5></div>"; 219 if (!$csv) echo "<div style=\" text-align:left; margin-left:20px;\">"; 220 221 if(strstr( $op,'candidato')){ 222 // $numliste=mysql_num_rows($res_lis); 223 $visvot="cand"; 224 if (!$csv){ 225 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $condcirc order by num_lista"; 226 $res_lis = $dbi->prepare("$sql"); 227 $res_lis->execute(); 228 229 //elenco delle liste per la scelta 230 echo "<p>"._SCEGLI_LISTA.": 231 <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\">"; 232 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) { 233 if (!$id_lista) $id_lista=$id_rif; 234 $sel = ($id_rif == $id_lista) ? "selected=\"selected\"" : ""; 201 235 echo "<option value=\"$id_rif\" $sel>"; 202 for ($j=strlen($num_ cir);$j<2;$j++) { echo " ";}203 echo $num_ cir.") ".$descrizione."</option>";236 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 237 echo $num_lis.") ".$descrizione."</option>"; 204 238 } 205 echo "</select></div>"; 206 207 } 208 */ 209 $visvot=''; 210 211 if (!$csv) echo "<div><h5>$pagina</h5></div>"; 212 if (!$csv) echo "<div style=\" text-align:left; margin-left:20px;\">"; 213 214 if(strstr( $op,'candidato')){ 215 // $numliste=mysql_num_rows($res_lis); 216 $visvot="cand"; 217 if (!$csv){ 218 219 220 $res_lis = mysql_query("SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $condcirc order by num_lista",$dbi); 221 //elenco delle liste per la scelta 222 echo "<p>"._SCEGLI_LISTA.": 223 <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\">"; 224 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) { 225 if (!$id_lista) $id_lista=$id_rif; 226 $sel = ($id_rif == $id_lista) ? "selected=\"selected\"" : ""; 227 echo "<option value=\"$id_rif\" $sel>"; 228 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 229 echo $num_lis.") ".$descrizione."</option>"; 230 } 231 echo "</select></p>"; 232 } 233 $res_scr = mysql_query("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",$dbi); 234 $res_cand = mysql_query("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",$dbi); 235 if ($circo) $condcirc="and t5.id_circ=$id_circ"; 236 237 $res_voti = mysql_query("select $tab2, t1.num_cand, concat(t1.cognome,' ', t1.nome), sum(t2.voti),'','','','','' 238 from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2, " 239 .$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5 240 where t1.id_lista=$id_lista 241 and t1.id_cons=$id_cons 242 and t1.id_cand=t2.id_cand 243 and t2.id_sez=t3.id_sez 244 and t3.id_sede=t4.id_sede 245 and t4.id_circ=t5.id_circ $condcirc 246 group by t1.num_cand,$tab3 247 order by $tab3,t1.num_cand",$dbi); 248 239 echo "</select></p>"; 240 } 241 $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"; 242 $res_scr = $dbi->prepare("$sql"); 243 $res_scr->execute(); 244 245 $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"; 246 $res_cand = $dbi->prepare("$sqlc"); 247 $res_cand->execute(); 248 249 if ($circo) $condcirc="and t5.id_circ=$id_circ"; 250 251 $sqlvoti="select $tab2, t1.num_cand, concat(t1.cognome,' ', t1.nome), sum(t2.voti),'','','','','' 252 from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2, " 253 .$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5 254 where t1.id_lista=$id_lista 255 and t1.id_cons=$id_cons 256 and t1.id_cand=t2.id_cand 257 and t2.id_sez=t3.id_sez 258 and t3.id_sede=t4.id_sede 259 and t4.id_circ=t5.id_circ $condcirc 260 group by t1.num_cand,$tab3 261 order by $tab3,t1.num_cand"; 262 $res_voti = $dbi->prepare("$sqlvoti"); 263 $res_voti->execute(); 249 264 }else{ 250 265 if (!$csv) 251 266 echo "<input type=\"hidden\" name=\"id_lista\" value=\"\"></input>"; 252 267 253 // camera e senato nel 2006 aggiunte le somme della coalizione 254 // divise per circo e sez. in quanto nella tabella del gruppo 255 // all'atto dell'immsione non viene fatta la somma 256 // quindi leggere prima i voti di lista e poi agganciali al gruppo 257 // la var $tab diviene lista, $tab15 diviene gruppo in caso di somma 258 // dei voti di lista...oltre naturalmnte alle condizioni messe in variabile 259 // 4 aprile 2006 by luc 260 if ($votog && $tab=="gruppo"){ // camera e senato 2006 261 $t="t9"; 262 $tab="lista"; 263 $tab15="gruppo"; 264 $add_1= ",".$prefix."_ele_gruppo as t9"; 265 $and_1="and t1.id_gruppo=t9.id_gruppo"; 266 }else{ 267 $t="t1"; 268 $tab15=$tab; 269 $add_1=''; 270 $and_1=''; 271 } 272 // fine della modifica 273 274 $res_scr = mysql_query("SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15",$dbi); //numero sezioni scrutinate 275 $res_cand = mysql_query("SELECT id_$tab15, descrizione, num_$tab15 from ".$prefix."_ele_$tab15 where id_cons='$id_cons' $condcirc order by num_$tab15",$dbi); 276 if ($circo) $condcirc="and t5.id_circ=$id_circ"; 277 if ($tab=="gruppo") 278 $votigl=" sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli)"; 279 else 280 if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli)"; 281 else $votigl=" sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli)"; 282 283 284 285 $res_voti = mysql_query("select $tab2, $t.num_$tab15, $t.descrizione, sum(t2.voti), $votigl 286 from 287 ".$prefix."_ele_$tab as t1, 288 ".$prefix."_ele_voti_$tab as t2, 289 ".$prefix."_ele_sezioni as t3, 290 ".$prefix."_ele_sede as t4, 291 ".$prefix."_ele_circoscrizione as t5 292 $add_1 293 294 where t1.id_cons=$id_cons 295 and t1.id_$tab=t2.id_$tab 296 $and_1 297 298 and t2.id_sez=t3.id_sez 299 and t3.id_sede=t4.id_sede 300 and t4.id_circ=t5.id_circ $condcirc 301 302 303 group by $t.num_$tab15,$tab3 304 order by $tab3,$t.num_$tab15",$dbi); 268 // camera e senato nel 2006 aggiunte le somme della coalizione 269 // divise per circo e sez. in quanto nella tabella del gruppo 270 // all'atto dell'immsione non viene fatta la somma 271 // quindi leggere prima i voti di lista e poi agganciali al gruppo 272 // la var $tab diviene lista, $tab15 diviene gruppo in caso di somma 273 // dei voti di lista...oltre naturalmnte alle condizioni messe in variabile 274 // 4 aprile 2006 by luc 275 if ($votog && $tab=="gruppo"){ // camera e senato 2006 276 $t="t9"; 277 $tab="lista"; 278 $tab15="gruppo"; 279 $add_1= ",".$prefix."_ele_gruppo as t9"; 280 $and_1="and t1.id_gruppo=t9.id_gruppo"; 281 }else{ 282 $t="t1"; 283 $tab15=$tab; 284 $add_1=''; 285 $and_1=''; 286 } 287 // fine della modifica 288 289 $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15"; 290 $res_scr = $dbi->prepare("$sql"); 291 $res_scr->execute(); 292 //numero sezioni scrutinate 293 $sqlc="SELECT id_$tab15, descrizione, num_$tab15 from ".$prefix."_ele_$tab15 where id_cons='$id_cons' $condcirc order by num_$tab15"; 294 $res_cand = $dbi->prepare("$sqlc"); 295 $res_cand->execute(); 296 297 if ($circo) $condcirc="and t5.id_circ=$id_circ"; 298 if ($tab=="gruppo") 299 $votigl=" sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli)"; 300 else 301 if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli)"; 302 else $votigl=" sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli)"; 303 $sqlvoti="select $tab2, $t.num_$tab15, $t.descrizione, sum(t2.voti), $votigl 304 from 305 ".$prefix."_ele_$tab as t1, 306 ".$prefix."_ele_voti_$tab as t2, 307 ".$prefix."_ele_sezioni as t3, 308 ".$prefix."_ele_sede as t4, 309 ".$prefix."_ele_circoscrizione as t5 310 $add_1 305 311 306 } 307 if ($res_scr) list($tot_scr)=mysql_fetch_row($res_scr);else $tot_scr=0; 308 if ($res_cand) $num_cand=mysql_num_rows($res_cand); else $num_cand=0; 309 if(!$circo){ 310 if (!(0 < $minsez and $minsez<=$numsezmax)) $minsez=1; 311 if (!(0<$offsetsez and $offsetsez<=$numsezmax)) $offsetsez=$numsezmax; 312 } 313 if (!(0 < $min and $min<=$num_cand)) $min=1; 314 if (!(0<$offset and $offset<=$num_cand)) $offset=$num_cand; 315 if (!$csv) { 316 if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;} 317 echo "<p>$scelta "._DA.": <select name=\"min\" class=\"modulo\">"; 318 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_cand)) { 319 if (!$min) $min=$num_lis; 320 $sel = ($num_lis == $min) ? "selected=\"selected\"" : ""; 321 echo "<option value=\"$num_lis\" $sel>"; 322 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 323 echo $num_lis.") ".$descrizione."</option>"; 324 325 } 326 echo "</select>"; 327 echo " "._A.": <select name=\"offset\" class=\"modulo\">"; 328 mysql_data_seek($res_cand,0); 329 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_cand)) { 330 if (!$offset) $offset=$num_lis; 331 $sel = ($num_lis == $offset) ? "selected=\"selected\"" : ""; 332 echo "<option value=\"$num_lis\" $sel>"; 333 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 334 echo $num_lis.") ".$descrizione."</option>"; 335 336 } 337 echo "</select></p>"; 338 //echo "<div style=\"text-align:left; margin-left:20px;\">"; 339 if(!$circo){ 312 where t1.id_cons=$id_cons 313 and t1.id_$tab=t2.id_$tab 314 $and_1 315 316 and t2.id_sez=t3.id_sez 317 and t3.id_sede=t4.id_sede 318 and t4.id_circ=t5.id_circ $condcirc 319 320 321 group by $t.num_$tab15,$tab3 322 order by $tab3,$t.num_$tab15"; 323 $res_voti = $dbi->prepare("$sqlvoti"); 324 $res_voti->execute(); 325 } 326 if ($res_scr) list($tot_scr)=$res_scr->fetch(PDO::FETCH_NUM);else $tot_scr=0; 327 if ($res_cand) $num_cand=$res_cand->rowCount(); else $num_cand=0; 328 if(!$circo){ 329 if (!(0 < $minsez and $minsez<=$numsezmax)) $minsez=1; 330 if (!(0<$offsetsez and $offsetsez<=$numsezmax)) $offsetsez=$numsezmax; 331 } 332 if (!(0 < $min and $min<=$num_cand)) $min=1; 333 if (!(0<$offset and $offset<=$num_cand)) $offset=$num_cand; 334 if (!$csv) { 335 if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;} 336 echo "<p>$scelta "._DA.": <select name=\"min\" class=\"modulo\">"; 337 while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) { 338 if (!$min) $min=$num_lis; 339 $sel = ($num_lis == $min) ? "selected=\"selected\"" : ""; 340 echo "<option value=\"$num_lis\" $sel>"; 341 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 342 echo $num_lis.") ".$descrizione."</option>"; 343 } 344 echo "</select>"; 345 echo " "._A.": <select name=\"offset\" class=\"modulo\">"; 346 $res_cand = $dbi->prepare("$sqlc"); 347 $res_cand->execute(); 348 349 while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) { 350 if (!$offset) $offset=$num_lis; 351 $sel = ($num_lis == $offset) ? "selected=\"selected\"" : ""; 352 echo "<option value=\"$num_lis\" $sel>"; 353 for ($j=strlen($num_lis);$j<2;$j++) { echo " ";} 354 echo $num_lis.") ".$descrizione."</option>"; 355 356 } 357 echo "</select></p>"; 358 //echo "<div style=\"text-align:left; margin-left:20px;\">"; 359 if(!$circo){ 340 360 echo "<p>"._SCEGLI." $tipo1 n. <input name=\"minsez\" value=\"$minsez\" size=\"4\" ></input>"; 341 361 echo _A." n. <input name=\"offsetsez\" value=\"$offsetsez\" size=\"4\" ></input> (max. $numsezmax)"; 342 343 362 } 363 # pagine 344 364 ############ 345 if (strstr( $op,'circo')) 346 $resnsez = mysql_query("SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ>=$minsez and num_circ<=$offsetsez",$dbi); 347 else 348 $resnsez = mysql_query("SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons and num_sez>=$minsez and num_sez<=$offsetsez",$dbi); 349 list($diff)=mysql_fetch_row($resnsez); 350 ######## 365 if (strstr( $op,'circo')) 366 $sql="SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ>=$minsez and num_circ<=$offsetsez"; 367 368 369 else 370 $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons and num_sez>=$minsez and num_sez<=$offsetsez"; 371 372 $resnsez = $dbi->prepare("$sql"); 373 $resnsez->execute(); 374 list($diff)=$resnsez->fetch(PDO::FETCH_NUM); 375 ######## 351 376 # $diff=($offsetsez-$minsez); 352 377 if ($minsez>1){ 353 $minsez_p= ($minsez-$diff)>1 ? $minsez-$diff:1; 354 355 $offsetsez_p=$offsetsez-$diff; 356 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>"; 357 }else{echo "";} 358 359 if ($offsetsez<$numsezmax){ 360 $minsez_s=$minsez+$diff; 361 $offsetsez_s= ($offsetsez+$diff)>$num_sez ? $num_sez: $offsetsez+$diff; 362 363 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>"; 364 }else{echo "";} 365 366 367 368 369 370 if(!$circo) 371 378 $minsez_p= ($minsez-$diff)>1 ? $minsez-$diff:1; 379 $offsetsez_p=$offsetsez-$diff; 380 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>"; 381 }else{echo "";} 382 if ($offsetsez<$numsezmax){ 383 $minsez_s=$minsez+$diff; 384 $offsetsez_s= ($offsetsez+$diff)>$num_sez ? $num_sez: $offsetsez+$diff; 385 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>"; 386 }else{echo "";} 387 if(!$circo) 372 388 echo "<div style=\"margin-left:10px;\"><br/>"._MOSTRA." $tipo2 "._PERCOL."<input type=\"radio\" name=\"orvert\" $righe value=\"0\"></input>"._PERRIGHE." <input 373 389 type=\"radio\" name=\"orvert\" $colonne value=\"1\"></input>"; 374 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input> 375 </div>"; 376 377 378 379 echo "<p>"; 380 if (!strstr( $op,'candidato')) { 381 echo ""._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\""; 382 if($perc=='true') echo " checked=\"true\""; 383 echo "></input><br/>"; 384 } 385 echo ""; 390 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input></div>"; 391 echo "<p>"; 392 if (!strstr( $op,'candidato')) { 393 echo ""._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\""; 394 if($perc=='true') echo " checked=\"true\""; 395 echo "></input><br/>"; 396 } 397 echo ""; 386 398 if($circo) 387 399 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>"; … … 402 414 # liste e gruppi da.... a 403 415 if (!strstr( $op,'candidato')) { 404 $res_cand2 = mysql_query("SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$min'",$dbi); 405 list($descrizione)= mysql_fetch_row($res_cand2); 416 $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$min'"; 417 $res_cand2 = $dbi->prepare("$sql"); 418 $res_cand2->execute(); 419 420 list($descrizione)= $res_cand2->fetch(PDO::FETCH_NUM); 406 421 $list1 ="da $descrizione "; 407 422 408 423 409 424 410 $res_cand3 = mysql_query("SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$offset'",$dbi); 411 list($descrizione)= mysql_fetch_row($res_cand3); 425 $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$offset'"; 426 $res_cand3 = $dbi->prepare("$sql"); 427 $res_cand3->execute(); 428 429 list($descrizione)= $res_cand3->fetch(PDO::FETCH_NUM); 412 430 $list1 .=" a $descrizione <br/>"; 413 431 … … 417 435 if (!isset($list2)) $list2=''; 418 436 if (strstr( $op,'candidato')) { 419 $res_lis2 = mysql_query("SELECT num_lista, descrizione from ".$prefix."_ele_lista where id_lista=$id_lista",$dbi); 420 list($num_lista2,$descr_lista2)= mysql_fetch_row($res_lis2); 437 $sql="SELECT num_lista, descrizione from ".$prefix."_ele_lista where id_lista=$id_lista"; 438 $res_lis2 = $dbi->prepare("$sql"); 439 $res_lis2->execute(); 440 441 list($num_lista2,$descr_lista2)= $res_lis2->fetch(PDO::FETCH_NUM); 421 442 $nomefile=" Lista n. $num_lista2 - $descr_lista2 "; 422 443 $list2 .=" Lista n. $num_lista2 - $descr_lista2 <br/>"; 423 444 424 $res_cand4 = mysql_query("SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$min",$dbi); 425 list($descrizione)= mysql_fetch_row($res_cand4); 445 $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$min"; 446 $res_cand4 = $dbi->prepare("$sql"); 447 $res_cand4->execute(); 448 449 list($descrizione)= $res_cand4->fetch(PDO::FETCH_NUM); 426 450 $list3 ="da $descrizione "; 427 $res_cand5 = mysql_query("SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$offset",$dbi); 428 list($descrizione)= mysql_fetch_row($res_cand5); 451 $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$offset"; 452 $res_cand5 = $dbi->prepare("$sql"); 453 $res_cand5->execute(); 454 455 list($descrizione)= $res_cand5->fetch(PDO::FETCH_NUM); 429 456 $list3 .="a $descrizione <br/>"; 430 457 … … 433 460 $nomefile.="$descr_cons $tab15"; 434 461 $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile)); 435 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 "; 436 437 438 # verificare la stampa sulle circoscrizioni 439 440 echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:0px;font-size:12px; \">"; 441 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />"; 442 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>"; 462 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 "; 463 # verificare la stampa sulle circoscrizioni 464 echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:0px;font-size:12px; \">"; 465 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />"; 466 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>"; 443 467 }else{ 444 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>"; 445 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>"; 446 447 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />"; 448 449 echo " </td></tr> "; 450 451 # stampa pdf 452 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">"; 453 454 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>"; 455 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>"; 456 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>"; 457 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>"; 458 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>"; 459 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>"; 460 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>"; 468 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>"; 469 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>"; 470 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />"; 471 echo " </td></tr> "; 472 # stampa pdf 473 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">"; 474 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>"; 475 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>"; 476 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>"; 477 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>"; 478 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>"; 479 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>"; 480 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>"; 461 481 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>"; 462 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>"; 463 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>"; 464 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>"; 465 echo "<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\"></input>"; 466 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>"; 467 echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>"; 468 # echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>"; 469 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>"; 470 471 echo "<tr><td>"; 472 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">"; 473 474 echo " L <input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P <input 475 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />"; 476 echo " A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input 477 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>"; 478 479 480 echo " </td></tr></table></form> "; 481 482 482 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>"; 483 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>"; 484 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>"; 485 echo "<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\"></input>"; 486 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>"; 487 echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>"; 488 # echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>"; 489 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>"; 490 echo "<tr><td>"; 491 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">"; 492 echo " L <input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P <input 493 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />"; 494 echo " A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input 495 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>"; 496 echo " </td></tr></table></form> "; 483 497 } 484 485 486 487 498 echo "</div></br />"; 488 /* 489 490 if (!$circo) 491 echo "dalla $tipo3 n. <b>$minsez</b> alla $tipo3 n. <b>$offsetsez</b> di <b>$num_sez</b> $tipo2<br/><br/>"; 492 else echo "<br/><br/>"; 493 494 if (strstr( $op,'candidato')) echo $list2; 495 */ 496 497 } 498 499 } 499 500 if (!$csv){ 500 501 echo "<h5> Sezioni scrutinate"; … … 518 519 // caso: sezioni in collegi diversi non consecutive 519 520 if (strstr( $op,'circo')) 520 $ res_numsez=mysql_query("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",$dbi);521 $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"; 521 522 else{ 522 523 if($circo) { $secirco=" and t2.id_circ=$id_circ";} else $secirco="and t1.num_sez >= $minsez and t1.num_sez <= $offsetsez"; 523 524 $numsezioni = $offsetsez-$ominsez; 524 $ res_numsez = mysql_query("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",$dbi);525 } 526 # for ($z=1;$z<=($offsetsez-$ominsez);$z++) { 527 while($res=mysql_fetch_row($res_numsez)) {528 $z=$res[0]; 529 525 $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"; 526 } 527 $res_numsez = $dbi->prepare("$sql"); 528 $res_numsez->execute();# for ($z=1;$z<=($offsetsez-$ominsez);$z++) { 529 while($res=$res_numsez->fetch(PDO::FETCH_NUM)) { 530 $z=$res[0]; 530 531 ##############inserimento percentuale di scrutinio nella sezione 531 $scruvalidi=0; 532 $scrunulli=0; 533 $grpercscru=0; 534 $altri=0; 535 $votiscru=0; 536 if($op=="gruppo_sezione"){ 537 $resperc=mysql_query("select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'",$dbi); 538 $votiperc=mysql_query("select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'",$dbi); 539 } 540 elseif($op=="lista_sezione"){ 541 $resperc=mysql_query("select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'",$dbi); 542 $votiperc=mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'",$dbi); 543 } 544 if (isset($resperc) and $resperc) 545 list($scruvalidi,$scrunulli)=mysql_fetch_row($resperc); 546 if (isset($votiperc) and $votiperc) 547 list($votiscru)=mysql_fetch_row($votiperc); 548 $resperc = mysql_query("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 ",$dbi); 549 if ($resperc) 550 list($totschede)=mysql_fetch_row($resperc); 551 if (isset($scruvalidi) and $scruvalidi>0 ) 552 $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0; 532 $scruvalidi=0; 533 $scrunulli=0; 534 $grpercscru=0; 535 $altri=0; 536 $votiscru=0; 537 if($op=="gruppo_sezione"){ 538 $sqlr="select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'"; 539 $sqlv="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'"; 540 $resperc = $dbi->prepare("$sqlr"); 541 $resperc->execute(); 542 $votiperc = $dbi->prepare("$sqlv"); 543 $votiperc->execute(); 544 } 545 elseif($op=="lista_sezione"){ 546 $sqlr="select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'"; 547 $sqlv="select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'"; 548 $resperc = $dbi->prepare("$sqlr"); 549 $resperc->execute(); 550 $votiperc = $dbi->prepare("$sqlv"); 551 $votiperc->execute(); 552 } 553 if (isset($resperc) and $resperc) 554 list($scruvalidi,$scrunulli)=$resperc->fetch(PDO::FETCH_NUM); 555 if (isset($votiperc) and $votiperc) 556 list($votiscru)=$votiperc->fetch(PDO::FETCH_NUM); 557 $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 "; 558 $resperc = $dbi->prepare("$sql"); 559 $resperc->execute(); 560 561 if ($resperc) 562 list($totschede)=$resperc->fetch(PDO::FETCH_NUM); 563 if (isset($scruvalidi) and $scruvalidi>0 ) 564 $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0; 553 565 554 566 ################### <span class=\"red\"><i>".$temp3[$key]." %</i></span> 555 $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>"; } 556 $pos[$z]=$res[0]; 557 #$valar[$z]=array(); 558 } 559 560 567 $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>"; } 568 $pos[$z]=$res[0]; 569 #$valar[$z]=array(); 570 } 561 571 if (!isset($pos)) $pos[0]=0; 562 572 $minpos=min($pos); … … 564 574 //////////////////////////////////////////////////////////////////// 565 575 566 if ($res_voti )567 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){568 576 if ($res_voti->rowCount()) 577 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ 578 $z=array_search($num_circ, $pos); 569 579 if (!isset($votitot[($z)])) { 570 $votitot[($z)]=0; 571 $sevaltot+=$sevalidi;572 $senultot+=$senulli;573 $sebiatot+=$sebianchi;574 $secontot+=$secontestati;575 $sevnutot+=$sevonulli;580 $votitot[($z)]=0; 581 if($sevalidi) $sevaltot+=$sevalidi; 582 if($senulli) $senultot+=$senulli; 583 if($sebianchi) $sebiatot+=$sebianchi; 584 if($secontestati) $secontot+=$secontestati; 585 if($sevonulli) $sevnutot+=$sevonulli; 576 586 } 577 587 $votitot[($z)]+=$voti; 578 588 $voticompl+=$voti; 579 589 } 580 if ($voticompl) mysql_data_seek($res_voti,0); 590 if ($voticompl) { 591 $res_voti = $dbi->prepare("$sqlvoti"); 592 $res_voti->execute(); 593 } 581 594 $piuvot=0; 582 595 if ($visvot!='cand') $piuvot=5; 583 584 585 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" "; 586 if (strstr( $op,'circo')) 587 $lis_sez=mysql_query("select num_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ",$dbi); 588 else 589 $lis_sez=mysql_query("select num_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez>='$minsez' and num_sez<='$offsetsez' order by num_sez",$dbi); 590 $nsezsel=mysql_num_rows($lis_sez); 591 while(list($z)=mysql_fetch_row($lis_sez)) 592 { for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" ";} //inizializza le celle interne 596 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" "; 597 if (strstr( $op,'circo')) 598 $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"; 599 else 600 $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"; 601 $lis_sez = $dbi->prepare("$sql"); 602 $lis_sez->execute(); 603 $nsezsel=$lis_sez->rowCount(); 604 while(list($z)=$lis_sez->fetch(PDO::FETCH_NUM)) 605 { 606 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" ";} //inizializza le celle interne 593 607 594 608 ################################################################### … … 596 610 # for ($z=1;$z<=($offsetsez-$ominsez);$z++) 597 611 # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" "; //inizializza le celle interne 598 $onetime="";599 if ($res_voti)600 {601 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){612 $onetime=""; 613 if ($res_voti) 614 { 615 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ 602 616 $z=array_search($num_circ, $pos); 603 617 $valar[($z)][$num_cand]=$voti; 604 618 } 605 619 foreach ($valar as $key=>$val){ … … 607 621 $percar[$key]=arrayperc($val,$votitot[($key)]); 608 622 } 609 610 if(mysql_num_rows($res_voti)) mysql_data_seek($res_voti,0); 611 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){ 612 if($num_cand<$min or $num_cand>$offset) continue; 613 614 if (!isset($temp[$num_cand])) $temp[$num_cand]=0; 615 $temp[$num_cand]+=$voti; 616 $z=array_search($num_circ, $pos); if (!$z) continue; 617 if ($num_cand>=$min and $num_cand<=$offset){ 618 if($num_circ>=$minpos and $num_circ <=$maxpos){ 619 $ar[0][$num_cand]=$num_cand.") ".$nome; 620 if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;} 621 $percento=$voti; 622 if ($perc=='true' and $votitot[($z)]) 623 { 624 $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>"; 623 if($res_voti->rowCount()) { 624 $res_voti = $dbi->prepare("$sqlvoti"); 625 $res_voti->execute(); 626 } 627 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ 628 if($num_cand<$min or $num_cand>$offset) continue; 629 if (!isset($temp[$num_cand])) $temp[$num_cand]=0; 630 $temp[$num_cand]+=$voti; 631 $z=array_search($num_circ, $pos); 632 if (!$z) continue; 633 if ($num_cand>=$min and $num_cand<=$offset){ 634 if($num_circ>=$minpos and $num_circ <=$maxpos){ 635 $ar[0][$num_cand]=$num_cand.") ".$nome; 636 if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;} 637 $percento=$voti; 638 if ($perc=='true' and $votitot[($z)]) 639 { 640 $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>"; 641 } 642 $ar[($z)][$num_cand]=$percento; 643 } 625 644 } 626 $ar[($z)][$num_cand]=$percento; 645 if (!strstr( $op,'candidato')){ 646 if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0; 647 $tempar[$num_cand]+=$voti; 648 } 649 if ($visvot!='cand'){ 650 $posvoti=($offset); 651 $ar[0][$posvoti+1]='<b>Voti Validi</b>'; 652 $ar[0][$posvoti+2]='<b>Schede Nulle</b>'; 653 $ar[0][$posvoti+3]='<b>Schede Bianche</b>'; 654 $ar[0][$posvoti+4]='<b>Voti Contestati</b>'; 655 $ar[0][$posvoti+5]='<b>Voti Nulli</b>'; 656 if (($maxpos)>=$num_circ and $minpos<=$num_circ){ 657 //$posvoti++; 658 $ar[($z)][$posvoti+1]="<b>$sevalidi</b>"; 659 $ar[($z)][$posvoti+2]="<b>$senulli</b>"; 660 $ar[($z)][$posvoti+3]="<b>$sebianchi</b>"; 661 $ar[($z)][$posvoti+4]="<b>$secontestati</b>"; 662 $ar[($z)][$posvoti+5]="<b>$sevonulli</b>"; 663 } 664 } 627 665 } 628 629 630 631 666 } 632 if (!strstr( $op,'candidato')){ 633 if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0; 634 $tempar[$num_cand]+=$voti;} 635 if ($visvot!='cand'){ 636 $posvoti=($offset); 637 $ar[0][$posvoti+1]='<b>Voti Validi</b>'; 638 $ar[0][$posvoti+2]='<b>Schede Nulle</b>'; 639 $ar[0][$posvoti+3]='<b>Schede Bianche</b>'; 640 $ar[0][$posvoti+4]='<b>Voti Contestati</b>'; 641 $ar[0][$posvoti+5]='<b>Voti Nulli</b>'; 642 if (($maxpos)>=$num_circ and $minpos<=$num_circ){ 643 //$posvoti++; 644 $ar[($z)][$posvoti+1]="<b>$sevalidi</b>"; 645 $ar[($z)][$posvoti+2]="<b>$senulli</b>"; 646 $ar[($z)][$posvoti+3]="<b>$sebianchi</b>"; 647 $ar[($z)][$posvoti+4]="<b>$secontestati</b>"; 648 $ar[($z)][$posvoti+5]="<b>$sevonulli</b>"; 649 } 650 } 651 } 652 } 653 654 if (($offsetsez+1)>=$num_sez){ 655 $ar[(1+$numsezmax)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>"; 656 if(isset($temp)) { 657 if (!isset($tab15) or !$tab15) $tab15="candidati"; 658 if($tab15=="gruppo"){ 667 668 if (($offsetsez+1)>=$num_sez){ 669 $ar[(1+$numsezmax)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>"; 670 if(isset($temp)) { 671 if (!isset($tab15) or !$tab15) $tab15="candidati"; 672 if($tab15=="gruppo"){ 659 673 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)"; 660 674 }elseif($votog){ 661 675 $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)"; 662 663 664 665 676 }else{ 677 if($dettnulli) $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista)"; 678 else $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)"; 679 } 666 680 if($circo) 667 $resv = mysql_query("SELECT $votigl from ".$prefix."_ele_sezioni AS t1 668 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",$dbi); 681 $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"; 669 682 else 670 $resv = mysql_query("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)",$dbi); 671 672 list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= mysql_fetch_row($resv); 683 $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)"; 684 $resv = $dbi->prepare("$sql"); 685 $resv->execute(); 686 list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= $resv->fetch(PDO::FETCH_NUM); 673 687 $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot; 674 $resvt = mysql_query("SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'",$dbi); 675 if($resvt) list($votlt)=mysql_fetch_row($resvt); else $votlt=0; 688 $sql="SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'"; 689 $resvt = $dbi->prepare("$sql"); 690 $resvt->execute(); 691 if($resvt) list($votlt)=$resvt->fetch(PDO::FETCH_NUM); else $votlt=0; 676 692 if($perc) $temp3=arrayperc($temp,$sevaltot); 677 693 while (list($key,$voti)= each($temp)) { … … 714 730 //e' un referendum 715 731 }else{ 716 $res_lis = mysql_query("SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo",$dbi); 717 if($res_lis) $numliste=mysql_num_rows($res_lis); else $numliste=0; 732 $sql="SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo"; 733 $res_lis = $dbi->prepare("$sql"); 734 $res_lis->execute(); 735 736 if($res_lis) $numliste=$res_lis->rowCount(); else $numliste=0; 718 737 719 738 if (!isset($offset)) $offset=10; … … 731 750 echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">"; 732 751 if($res_lis) 733 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {752 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) { 734 753 if (!$id_gruppo) $id_gruppo=$id_rif; 735 754 $sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : ""; … … 748 767 } 749 768 750 $res_ref= mysql_query("select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo", $dbi); 751 $res = mysql_query("select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo, 769 $sql="select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo"; 770 $res_ref = $dbi->prepare("$sql"); 771 $res_ref ->execute(); 772 773 $sql="select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo, 752 774 sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati) 753 775 from ".$prefix."_ele_gruppo as t1 … … 759 781 group by t2.id_gruppo,$tab3 760 782 order by $tab3, t1.num_gruppo 761 ", $dbi); 762 if($res) $num_sez=mysql_num_rows($res); else $num_sez=0; 763 if($res_ref) list($num_gruppo,$descr)= mysql_fetch_row($res_ref); else {$num_gruppo=0;$descr='';} 783 "; 784 $res = $dbi->prepare("$sql"); 785 $res->execute(); 786 787 if($res) $num_sez=$res->rowCount(); else $num_sez=0; 788 if($res_ref) list($num_gruppo,$descr)= $res_ref->fetch(PDO::FETCH_NUM); else {$num_gruppo=0;$descr='';} 764 789 765 790 if (!$csv){ … … 822 847 823 848 // numero sezioni scrutinate 824 $res4 = mysql_query("select t3.* 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 ",$dbi); 825 $numero=mysql_num_rows($res4); 826 $res5 = mysql_query("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' ",$dbi); 827 $sezioni=mysql_num_rows($res5); 849 $sql="select t3.* 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 "; 850 $res4 = $dbi->prepare("$sql"); 851 $res4->execute(); 852 853 $numero=$res4->rowCount(); 854 $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' "; 855 $res5 = $dbi->prepare("$sql"); 856 $res5->execute(); 857 858 $sezioni=$res5->rowCount(); 828 859 if ($numero!=0) echo "<h5><i> "._SEZSCRU." $numero "._SU." $sezioni </i></h5>"; 829 860 830 861 } 831 $res5=mysql_query("select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi); 832 list($num_sez) = mysql_fetch_row($res5); 862 $sql="select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'"; 863 $res5 = $dbi->prepare("$sql"); 864 $res5->execute(); 865 866 list($num_sez) = $res5->fetch(PDO::FETCH_NUM); 833 867 834 868 … … 847 881 $ar[0][6]=_CONTESTATI; 848 882 if($res_ref) 849 while (list($num_gruppo,$desc_ref) = mysql_fetch_row($res_ref)){883 while (list($num_gruppo,$desc_ref) = $res_ref->fetch(PDO::FETCH_NUM)){ 850 884 $ar[0][$i++]= $num_gruppo.") ".$desc_ref; 851 885 $ar[1][$y++]= "SI"; … … 860 894 $tot_co=0; 861 895 if($res) 862 while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = mysql_fetch_row($res)){896 while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = $res->fetch(PDO::FETCH_NUM)){ 863 897 $i=1; 864 898 $votanti=$validi+$nulli+$bianchi+$contestati;
Note:
See TracChangeset
for help on using the changeset viewer.