Changeset 98


Ignore:
Timestamp:
May 15, 2011, 10:44:15 AM (13 years ago)
Author:
roby
Message:
  • adattata la funzione dei raffronti ai comuni con sistema maggioritario
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/confronti.php

    r13 r98  
    3939global $param,$id_cons_gen, $dbi, $prefix, $id_comune;
    4040$_SESSION['confr']=array();
     41$_SESSION['grulis']=array();
    4142$_SESSION['grp1']=array();
    4243$_SESSION['grp2']=array();
     
    99100//visualizza le liste per consultazione e permette di associarle ai gruppi
    100101function scegliliste(){
    101         global $bgcolor1,$bgcolor2,$param,$id_cons_gen, $dbi, $prefix, $id_comune, $pag, $pags,$id_cons,$grp1,$grp2,$grp3;
     102        global $bgcolor1,$bgcolor2,$param,$id_cons_gen, $dbi, $prefix, $id_comune, $pag, $pags,$id_cons,$grp1,$grp2,$grp3,$fascia;
     103        $limite=0;
    102104        // ipotesi di campi vuoti
    103105        if(!$grp1 && !$grp2 && !$grp3){echo "<span class=\"red\">Metti il nome di almeno un gruppo oppure il check al raffronto totale</span>"; include("footer.php"); exit;}
     
    114116                $y=1;
    115117                while (isset($param['cons'.$x])) {
    116                         if($param[('check'.$x)])
     118                        if(isset($param[('check'.$x)]) and $param[('check'.$x)])
    117119                               
    118120                                {
     
    146148        if($pag>=$pags) return(1); //in $pags il numero delle consultazioni
    147149        $id_cons2=$_SESSION['confr'][$pag];
    148         $res_lis = mysql_query("SELECT t1.descrizione 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='$id_cons2'",$dbi);
    149         list($descr)=mysql_fetch_row($res_lis);
    150 #       $res_lis = mysql_query("SELECT t1.id_lista,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons2' order by t2.num_gruppo",$dbi);
     150        $res_lis = mysql_query("SELECT t1.descrizione,t1.tipo_cons,t2.id_conf 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='$id_cons2'",$dbi);
     151        list($descr,$tipoc,$legge)=mysql_fetch_row($res_lis);
     152        if($legge){
     153                $res_l=mysql_query("SELECT limite from  ".$prefix."_ele_conf where id_conf='$legge'",$dbi);
     154                list($limite)=mysql_fetch_row($res_l);
     155        }
     156if($tipoc==3 and $fascia<=$limite){
     157        $_SESSION['grulis'][$id_cons2]='1';
     158        $res_lis = mysql_query("SELECT t2.id_gruppo,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo",$dbi);
     159}else{
    151160        $res_lis = mysql_query("SELECT t1.id_lista,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo",$dbi);
     161        $_SESSION['grulis'][$id_cons2]='0';
     162        }
    152163        $yy=mysql_num_rows($res_lis);
    153164        if ($yy){
     
    191202        $res= mysql_query("SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons='$x'",$dbi);
    192203        list($elet)=mysql_fetch_row($res);
    193         $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$x'",$dbi);
     204        if($_SESSION['grulis'][$x]=='1')
     205                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_cons='$x'",$dbi);
     206        else
     207                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$x'",$dbi);
    194208        list($tot[$y])=mysql_fetch_row($res);
    195209        $res = mysql_query("SELECT t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' and t2.id_cons='$x'", $dbi);
     
    324338                $ar2[$x]=0;
    325339                $ar3[$x]=0;
     340                $id_cons2=$_SESSION['confr'][$x];
    326341                foreach ($_SESSION['grp1'][$x] as $key=>$val){
    327                         $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
     342                        if($_SESSION['grulis'][$id_cons2]=='1')
     343                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     344                        else
     345                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    328346                        list($voti)=mysql_fetch_row($res);
    329347                        $ar1[$x]+=$voti;
    330348                }
    331349                foreach ($_SESSION['grp2'][$x] as $key=>$val){
    332                         $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
     350                        if($_SESSION['grulis'][$id_cons2]=='1')
     351                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     352                        else
     353                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    333354                        list($voti)=mysql_fetch_row($res);
    334355                        $ar2[$x]+=$voti;
    335356                }
    336357                foreach ($_SESSION['grp3'][$x] as $key=>$val){
    337                         $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
     358                        if($_SESSION['grulis'][$id_cons2]=='1')
     359                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     360                        else
     361                                $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    338362                        list($voti)=mysql_fetch_row($res);
    339363                        $ar3[$x]+=$voti;
Note: See TracChangeset for help on using the changeset viewer.