[429] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | /************************************************************************/
|
---|
| 4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 5 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 6 | /* http://www.eleonline.it */
|
---|
| 7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 8 | /************************************************************************/
|
---|
| 9 | /* Modulo Controllo dei voti */
|
---|
| 10 | /* Amministrazione */
|
---|
| 11 | /************************************************************************/
|
---|
| 12 |
|
---|
| 13 | if (!defined('ADMIN_FILE')) {
|
---|
| 14 | die ("You can't access this file directly...");
|
---|
| 15 | }
|
---|
| 16 | global $dbi;
|
---|
| 17 | $aid=$_SESSION['aid'];
|
---|
| 18 | $prefix=$_SESSION['prefix'];
|
---|
| 19 | $currentlang=$_SESSION['lang'];
|
---|
| 20 | $id_comune=$_SESSION['id_comune'];
|
---|
| 21 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
| 22 | $bgcolor1=$_SESSION['bgcolor1'];
|
---|
| 23 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
| 24 |
|
---|
| 25 | $perms=ChiSei($id_cons_gen);
|
---|
| 26 | if ($perms<16 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 27 | $sql="SELECT id_cons FROM ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen=$id_cons_gen";
|
---|
| 28 | $sth = $dbi->prepare("$sql");
|
---|
| 29 | $sth->execute();
|
---|
| 30 | list($id_cons)=$sth->fetch(PDO::FETCH_NUM);
|
---|
| 31 | $sql="select id_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 32 | $sth = $dbi->prepare("$sql");
|
---|
| 33 | $sth->execute();
|
---|
| 34 | $tot_sez = $sth->rowCount();
|
---|
| 35 |
|
---|
| 36 | # Scelta argomento estrazione (gruppo,lista,candidati)
|
---|
| 37 | $estrae='candidati';
|
---|
| 38 | # Carica array
|
---|
| 39 |
|
---|
| 40 | $sql="select t2.num_lista,t2.descrizione,t1.num_cand,t1.cognome,t1.nome,t3.voti,t4.num_sez from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on t1.id_lista=t2.id_lista left join ".$prefix."_ele_voti_candidati as t3 on t1.id_cand=t3.id_cand left join ".$prefix."_ele_sezioni as t4 on t3.id_sez=t4.id_sez where t1.id_cons='$id_cons' order by t2.num_lista,t1.num_cand,t4.num_sez";
|
---|
| 41 | $sth = $dbi->prepare("$sql");
|
---|
| 42 | $sth->execute();
|
---|
| 43 | $arsez=array();
|
---|
| 44 | $ar=array();
|
---|
| 45 | for ($i=1;$i<=$tot_sez;$i++) $arsez[$i+1]=$i;
|
---|
| 46 | $arsez[$i+1]='TOTALE';
|
---|
| 47 | while(list($num_lista,$desc_lista,$num_cand,$cognome,$nome,$voti,$num_sez)=$sth->fetch(PDO::FETCH_NUM)) {
|
---|
| 48 | /* $ar["$num_lista.0"][0]="\n$desc_lista";
|
---|
| 49 | $ar["$num_lista.$num_cand"][0]=str_replace("\t"," ","$cognome $nome");
|
---|
| 50 | if(!isset($ar["$num_lista.$num_cand"][1]))
|
---|
| 51 | for($i=1;$i<=$tot_sez;$i++) */
|
---|
| 52 | $ar["$num_lista.$num_cand"][0]=str_replace("\t"," ","\n$cognome $nome");
|
---|
| 53 | $ar["$num_lista.$num_cand"][1]="$desc_lista";
|
---|
| 54 | if(!isset($ar["$num_lista.$num_cand"][2]))
|
---|
| 55 | for($i=1;$i<=$tot_sez;$i++)
|
---|
| 56 | $ar["$num_lista.$num_cand"][$i+1]="0";
|
---|
| 57 | $ar["$num_lista.$num_cand"][$num_sez+1]="$voti";
|
---|
| 58 | if(!isset($ar["$num_lista.$num_cand"][$i+1])) $ar["$num_lista.$num_cand"][$i+1]=0;
|
---|
| 59 | $ar["$num_lista.$num_cand"][$i+1]+=$voti;
|
---|
| 60 | }
|
---|
| 61 | crea_tabella($ar,$arsez);
|
---|
| 62 |
|
---|
| 63 | function crea_tabella($ar,$arsez) {
|
---|
| 64 | global $dbi,$prefix,$id_comune,$id_cons_gen;
|
---|
| 65 | $sql="SELECT descrizione,simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
|
---|
| 66 | $res = $dbi->prepare("$sql");
|
---|
| 67 | $res->execute();
|
---|
| 68 | list($descr_comune,$simbolo,$stemma) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 69 | $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
|
---|
| 70 | $res = $dbi->prepare("$sql");
|
---|
| 71 | $res->execute();
|
---|
| 72 | list($descr_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 73 | $datipdf="<b>Comune di $descr_comune</b> - Consultazione: $descr_cons<br/>";
|
---|
| 74 | $datipdf=stripslashes($datipdf);
|
---|
| 75 | $data=date("d-m-y G:i");
|
---|
| 76 | $nomefile=strip_tags(str_replace(array('"', "'", ' ', ','), "_", $datipdf).".xls");
|
---|
| 77 | header ("Content-Type: application/vnd.ms-excel");
|
---|
| 78 | header ("Content-Disposition: inline; filename=$nomefile");
|
---|
| 79 | $datipdf=str_replace("<br/>","\n",$datipdf);
|
---|
| 80 | $datipdf=strip_tags($datipdf);
|
---|
| 81 | echo "$datipdf";
|
---|
| 82 | echo "\t";
|
---|
| 83 | foreach($arsez as $key=>$val) echo "\t$val";
|
---|
| 84 | foreach ($ar as $key1=>$riga2) {
|
---|
| 85 | foreach ($riga2 as $key2=>$cella) {
|
---|
| 86 | echo "$cella \t";
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | # echo"\n\n\nPowered by Eleonline http://www.eleonline.it \t \n";
|
---|
| 90 | # echo"by luciano apolito & roberto gigli - stampato: $data \t \n";
|
---|
| 91 | die();
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | ?>
|
---|