Changeset 295 for trunk


Ignore:
Timestamp:
May 4, 2019, 4:37:22 PM (5 years ago)
Author:
roby
Message:
 
Location:
trunk/client/modules/Elezioni
Files:
2 edited

Legend:

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

    r225 r295  
    2323if (isset($param['listecol'])) $listecol=intval($param['listecol']); else $listecol=0;
    2424
    25 $result = mysql_query("select id_conf,id_fascia from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
    26 list($id_conf,$fascia) = mysql_fetch_row($result);
    27 
    28 $res = mysql_query("SELECT limite,consin,infpremio,supsbarramento,suppremio,listinfsbar,listinfconta,listsupconta,supminpremio,infminpremio from ".$prefix."_ele_conf where id_conf='$id_conf'",$dbi);
    29 list($limite,$consin,$infpremio,$supsbarramento,$suppremio,$listinfsbar,$listinfconta,$listsupconta,$supminpremio,$infminpremio) = mysql_fetch_row($res);
     25$sql = "select id_conf,id_fascia from ".$prefix."_ele_cons_comune where id_cons='$id_cons'"
     26$result = $dbi->prepare("$sql");
     27$result->execute();
     28
     29list($id_conf,$fascia) = $result->fetch(PDO::FETCH_NUM);
     30
     31$sql = "SELECT limite,consin,infpremio,supsbarramento,suppremio,listinfsbar,listinfconta,listsupconta,supminpremio,infminpremio from ".$prefix."_ele_conf where id_conf='$id_conf'"
     32$res = $dbi->prepare("$sql");
     33$res->execute();
     34
     35list($limite,$consin,$infpremio,$supsbarramento,$suppremio,$listinfsbar,$listinfconta,$listsupconta,$supminpremio,$infminpremio) = $res->fetch(PDO::FETCH_NUM);
    3036$numcons=0;
    3137
     
    4450        $x++;
    4551}
    46 $res = mysql_query("SELECT t1.tipo_cons,t2.id_cons,t2.id_fascia,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_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
    47 if (mysql_num_rows($res)){
    48         list($tipo_cons,$id_cons,$fascia,$conf) = mysql_fetch_row($res);
    49         $result = mysql_query("select capoluogo from ".$prefix."_ele_comuni where id_comune='$id_comune'", $dbi);
    50         list($capoluogo) = mysql_fetch_row($result);
    51         $result = mysql_query("select fascia_capoluogo from ".$prefix."_ele_conf where id_conf='$conf'", $dbi);
    52         list($fascia2) = mysql_fetch_row($result);
     52$sql = "SELECT t1.tipo_cons,t2.id_cons,t2.id_fascia,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_gen='$id_cons_gen' and t2.id_comune='$id_comune'"
     53$res = $dbi->prepare("$sql");
     54$res->execute();
     55
     56if ($res->rowCount()){
     57        list($tipo_cons,$id_cons,$fascia,$conf) = $res->fetch(PDO::FETCH_NUM);
     58        $sql = "select capoluogo from ".$prefix."_ele_comuni where id_comune='$id_comune'"
     59$result = $dbi->prepare("$sql");
     60$result->execute();
     61
     62        list($capoluogo) = $result->fetch(PDO::FETCH_NUM);
     63        $sql = "select fascia_capoluogo from ".$prefix."_ele_conf where id_conf='$conf'"
     64$result = $dbi->prepare("$sql");
     65$result->execute();
     66
     67        list($fascia2) = $result->fetch(PDO::FETCH_NUM);
    5368        if($fascia<$fascia2 and $capoluogo) $fascia=$fascia2;
    5469
    55                 $result = mysql_query("SELECT seggi from ".$prefix."_ele_fasce where id_fascia='$fascia' and id_conf=$id_conf",$dbi);
    56                 list($numcons) = mysql_fetch_row($result);
    57 $res_val= mysql_query("SELECT id_cand, sum(voti) from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_cand",$dbi);
    58 $num_cons= mysql_num_rows($res_val);
     70                $sql = "SELECT seggi from ".$prefix."_ele_fasce where id_fascia='$fascia' and id_conf=$id_conf"
     71$result = $dbi->prepare("$sql");
     72$result->execute();
     73
     74                list($numcons) = $result->fetch(PDO::FETCH_NUM);
     75$sql = "SELECT id_cand, sum(voti) from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_cand"
     76$res_val = $dbi->prepare("$sql");
     77$res_val->execute();
     78
     79$num_cons= $res_val->rowCount();
    5980if ($num_cons<$numcons){
    6081        echo "Il numero di candidati al consiglio inseriti con preferenza ($num_cons) e' inferiore al numero di seggi previsti ($numcons). Non e' possibile procedere con il calcolo";
     
    6384}
    6485        if (!$gruppo){
    65                 $res_val = mysql_query("SELECT sum(validi) from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
    66                 list($validi) = mysql_fetch_row($res_val);
    67                 $res_lis = mysql_query("SELECT t1.num_gruppo,sum(t2.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_voti_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo group by t1.num_gruppo order by voti desc limit 0,2",$dbi);
     86                $sql = "SELECT sum(validi) from ".$prefix."_ele_sezioni where id_cons='$id_cons'"
     87$res_val = $dbi->prepare("$sql");
     88$res_val->execute();
     89
     90                list($validi) = $res_val->fetch(PDO::FETCH_NUM);
     91                $sql = "SELECT t1.num_gruppo,sum(t2.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_voti_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo group by t1.num_gruppo order by voti desc limit 0,2"
     92$res_lis = $dbi->prepare("$sql");
     93$res_lis->execute();
     94
    6895                $test=0;$flag=0;
    69                 while (list($num_gruppo,$voti)= mysql_fetch_row($res_lis)){
     96                while (list($num_gruppo,$voti)= $res_lis->fetch(PDO::FETCH_NUM)){
    7097                        if ($voti>($validi/2)) {$gruppo=$num_gruppo;$primoturno=1;}
    7198                        if ($voti==$test) $flag=1; else $test=$voti;
     
    73100        }
    74101        if ($fascia<=$limite){
    75                 $res_lis = mysql_query("SELECT t1.num_gruppo,sum(t2.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_voti_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo group by t1.num_gruppo order by voti desc limit 0,2",$dbi);
    76                 list($num_gruppo1,$voti1)= mysql_fetch_row($res_lis);
    77                 list($num_gruppo2,$voti2)= mysql_fetch_row($res_lis);
     102                $sql = "SELECT t1.num_gruppo,sum(t2.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_voti_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo group by t1.num_gruppo order by voti desc limit 0,2"
     103$res_lis = $dbi->prepare("$sql");
     104$res_lis->execute();
     105
     106                list($num_gruppo1,$voti1)= $res_lis->fetch(PDO::FETCH_NUM);
     107                list($num_gruppo2,$voti2)= $res_lis->fetch(PDO::FETCH_NUM);
    78108                if ($voti1>$voti2)
    79109                        $numgruppo=$num_gruppo1;
     
    82112        elseif ($gruppo>0) conssup($fascia,$gruppo,$collegate,$collperd,$primoturno);
    83113        elseif ($numgruppo>0){
    84                 $res_lis = mysql_query("SELECT t1.id_lista,t1.num_lista,t1.descrizione,t1.id_gruppo from ".$prefix."_ele_lista as t1, ".$prefix."_ele_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t2.num_gruppo not in (".$_SESSION['ballo1'].",".$_SESSION['ballo2'].")",$dbi);
    85                 $yy=mysql_num_rows($res_lis);
    86                         $res_voti = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'",$dbi);
    87                         list($validilista) = mysql_fetch_row($res_voti);
     114                $sqllis = "SELECT t1.id_lista,t1.num_lista,t1.descrizione,t1.id_gruppo from ".$prefix."_ele_lista as t1, ".$prefix."_ele_gruppo as t2 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t2.num_gruppo not in (".$_SESSION['ballo1'].",".$_SESSION['ballo2'].")"
     115$res_lis = $dbi->prepare("$sqllis");
     116$res_lis->execute();
     117
     118                $yy=$res_lis->rowCount();
     119                        $sql = "select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'"
     120$res_voti = $dbi->prepare("$sql");
     121$res_voti->execute();
     122
     123                        list($validilista) = $res_voti->fetch(PDO::FETCH_NUM);
    88124                if ($yy){
    89 while(list($id_lista,$num_lista,$descr,$pgrup) = mysql_fetch_row($res_lis)) {
    90                         $res_voti = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$id_lista'",$dbi);
    91                         list($votilista) = mysql_fetch_row($res_voti);
     125while(list($id_lista,$num_lista,$descr,$pgrup) = $res_lis->fetch(PDO::FETCH_NUM)) {
     126                        $sql = "select sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$id_lista'"
     127$res_voti = $dbi->prepare("$sql");
     128$res_voti->execute();
     129
     130                        list($votilista) = $res_voti->fetch(PDO::FETCH_NUM);
    92131                        if(!isset($voti[$pgrup])) $voti[$pgrup]=0;
    93132                        $voti[$pgrup]+=$votilista;
    94133}
    95134                        foreach ($voti as $key=>$val){if($val<($validilista*3/100)) unset($voti[$key]);} ##################################################
    96                         mysql_data_seek($res_lis,0);
     135                        $res_lis = $dbi->prepare("$sqllis");
     136                        $res_lis->execute();
    97137                        echo "<br/>";
    98138                        echo "<form id=\"gruppo\" action=\"modules.php\">";
     
    107147                       
    108148                        $z=1;
    109                         while(list($id_lista,$num_lista,$descr,$pgrup) = mysql_fetch_row($res_lis)) {
     149                        while(list($id_lista,$num_lista,$descr,$pgrup) = $res_lis->fetch(PDO::FETCH_NUM)) {
    110150                                if(!isset($voti[$pgrup])) continue;
    111151                                $x=$_SESSION['ballo1'];
     
    128168                echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>";
    129169                echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>";
    130                 $res = mysql_query("SELECT t1.id_gruppo,t1.num_gruppo,t1.descrizione, sum(t2.voti) as pref FROM ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_voti_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' group by t1.num_gruppo,t1.descrizione order by pref desc limit 0,2", $dbi);
    131                 while(list($id_gruppo,$num_gruppo, $descr_gruppo,$pref) = mysql_fetch_row($res)) {
     170                $sql = "SELECT t1.id_gruppo,t1.num_gruppo,t1.descrizione, sum(t2.voti) as pref FROM ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_voti_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' group by t1.num_gruppo,t1.descrizione order by pref desc limit 0,2"
     171$res = $dbi->prepare("$sql");
     172$res->execute();
     173
     174                while(list($id_gruppo,$num_gruppo, $descr_gruppo,$pref) = $res->fetch(PDO::FETCH_NUM)) {
    132175                        if (!isset($_SESSION['ballo1'])) {
    133176                                $_SESSION['ballo1']=$num_gruppo;
     
    169212#carica numero di liste e voti, i voti sono quelli del gruppo se non c'e' voto di lista
    170213if($votolista=='0')
    171         $res_val = mysql_query("SELECT sum(validi) from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
     214        $sql = "SELECT sum(validi) from ".$prefix."_ele_sezioni where id_cons='$id_cons'"
    172215else
    173         $res_val = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'",$dbi);
    174 list($validi) = mysql_fetch_row($res_val);
     216        $sql = "SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'"
     217$res_val = $dbi->prepare("$sql");
     218$res_val->execute();
     219
     220list($validi) = $res_val->fetch(PDO::FETCH_NUM);
    175221#se votolista==1, Ú abilitato il voto di lista ed Ú quello su cui si calcola l'assegnazione dei seggi
    176222if ($fisso==1){
    177223        #seleziona il sindaco
    178 $res_per = mysql_query("SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_gruppo as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t1.id_gruppo=t3.id_gruppo group by t1.descrizione, t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc limit 0,1",$dbi);
    179         list($descr,$num_gruppo,$id_lista1,$num_lista,$descr_lista,$voti)= mysql_fetch_row($res_per);
    180 $res_per = mysql_query("SELECT t2.id_lista, sum(t2.voti) as voti from ".$prefix."_ele_voti_lista as t2 where t2.id_cons='$id_cons' and t2.id_lista!='$id_lista1' group by t2.id_lista order by voti desc limit 0,1",$dbi);
    181         list($id_lista2,$voti)= mysql_fetch_row($res_per);
     224$sql = "SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_gruppo as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t1.id_gruppo=t3.id_gruppo group by t1.descrizione, t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc limit 0,1"
     225$res_per = $dbi->prepare("$sql");
     226$res_per->execute();
     227
     228        list($descr,$num_gruppo,$id_lista1,$num_lista,$descr_lista,$voti)= $res_per->fetch(PDO::FETCH_NUM);
     229$sql = "SELECT t2.id_lista, sum(t2.voti) as voti from ".$prefix."_ele_voti_lista as t2 where t2.id_cons='$id_cons' and t2.id_lista!='$id_lista1' group by t2.id_lista order by voti desc limit 0,1"
     230$res_per = $dbi->prepare("$sql");
     231$res_per->execute();
     232
     233        list($id_lista2,$voti)= $res_per->fetch(PDO::FETCH_NUM);
    182234      #e la lista di minoranza
    183235        $ordine= $id_lista1>$id_lista2 ? "desc":"";
    184 $res_per = mysql_query("SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_lista as t3 where (t2.id_lista='$id_lista1' or t2.id_lista='$id_lista2') and t1.id_gruppo=t2.id_gruppo and t2.id_lista=t3.id_lista group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by t2.id_lista $ordine",$dbi);
     236$sql = "SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_lista as t3 where (t2.id_lista='$id_lista1' or t2.id_lista='$id_lista2') and t1.id_gruppo=t2.id_gruppo and t2.id_lista=t3.id_lista group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by t2.id_lista $ordine"
     237$res_per = $dbi->prepare("$sql");
     238$res_per->execute();
     239
    185240        }else{
    186 $res_per = mysql_query("SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_gruppo as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t1.id_gruppo=t3.id_gruppo group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc",$dbi);
     241$sql = "SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1, ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_gruppo as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t1.id_gruppo=t3.id_gruppo group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc"
     242$res_per = $dbi->prepare("$sql");
     243$res_per->execute();
     244
    187245
    188246$groups=array();
     
    191249$x=0;
    192250#carica l'array dei gruppi e della cifra di gruppo
    193 while (list($descr,$num_gruppo,$id_lista,$num_lista,$descr_lista,$voti)= mysql_fetch_row($res_per)){
     251while (list($descr,$num_gruppo,$id_lista,$num_lista,$descr_lista,$voti)= $res_per->fetch(PDO::FETCH_NUM)){
    194252    $desgruppi[$num_gruppo]=$descr;
    195253    $desliste[$num_lista]=$num_lista.") ".$descr_lista;
     
    221279    foreach ($listagruppo as $lista=>$val){
    222280    $id_lista=$idlst[$lista];
    223     $res_can = mysql_query("SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,t1.num_cand",$dbi);
     281    $sql = "SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,t1.num_cand"
     282$res_can = $dbi->prepare("$sql");
     283$res_can->execute();
     284
    224285   
    225     $num_candlst[$lista]=mysql_num_rows($res_can);
     286    $num_candlst[$lista]=$res_can->rowCount();
    226287    $pos=0;
    227     while(list($cand,$pre)=mysql_fetch_row($res_can)){
     288    while(list($cand,$pre)=$res_can->fetch(PDO::FETCH_NUM)){
    228289        if(!isset($lists[$lista])) $lists[$lista]=0;
    229290        $cifra[$lista][$pos]=$lists[$lista]+$pre;
     
    415476#per voti validi non si intendono i voti validi alle liste ma i voti validi espressi
    416477#$res_val = mysql_query("SELECT sum(validi_lista) from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
    417 $res_val = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons'",$dbi);
    418 list($validi) = mysql_fetch_row($res_val);
     478$sql = "SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons'"
     479$res_val = $dbi->prepare("$sql");
     480$res_val->execute();
     481 
     482list($validi) = $res_val->fetch(PDO::FETCH_NUM);
    419483
    420484$sbarra=($validi*$supsbarramento)/100;
    421 $res_per = mysql_query("SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_lista as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t2.id_lista=t3.id_lista group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc",$dbi);
     485$sql = "SELECT t1.descrizione,t1.num_gruppo,t2.id_lista,t2.num_lista,t2.descrizione,sum(t3.voti) as voti from ".$prefix."_ele_gruppo as t1,  ".$prefix."_ele_lista as t2, ".$prefix."_ele_voti_lista as t3 where t1.id_cons='$id_cons' and t1.id_gruppo=t2.id_gruppo and t2.id_lista=t3.id_lista group by t1.descrizione,t1.num_gruppo,t2.num_lista,t2.descrizione order by voti desc"
     486$res_per = $dbi->prepare("$sql");
     487$res_per->execute();
     488
    422489$groups=array();
    423490$premio=0;
    424491//10-05-2009 gestione differenziata delle norme elettorali
    425492#carica l'array dei gruppi e della cifra di gruppo
    426 while (list($descr,$num_gruppo,$id_lista,$num_lista,$descr_lista,$voti)= mysql_fetch_row($res_per)){
     493while (list($descr,$num_gruppo,$id_lista,$num_lista,$descr_lista,$voti)= $res_per->fetch(PDO::FETCH_NUM)){
    427494 if ($listsupconta or $voti>=$sbarra){
    428495    if (! isset($groups[($num_gruppo)])) $groups[($num_gruppo)]=0;
     
    437504################### carica array ... 25  maggio 2014
    438505foreach($collegate as $key=>$val){     
    439         $res = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where num_lista='$val' and id_cons='$id_cons'",$dbi);
    440                 list($tempig)=mysql_fetch_row($res);
    441                 $res = mysql_query("SELECT num_gruppo from ".$prefix."_ele_gruppo where id_gruppo='$tempig' and id_cons='$id_cons'",$dbi);
    442                 list($tempng)=mysql_fetch_row($res);
     506        $sql = "SELECT id_gruppo from ".$prefix."_ele_lista where num_lista='$val' and id_cons='$id_cons'"
     507$res = $dbi->prepare("$sql");
     508$res->execute();
     509
     510                list($tempig)=$res->fetch(PDO::FETCH_NUM);
     511                $sql = "SELECT num_gruppo from ".$prefix."_ele_gruppo where id_gruppo='$tempig' and id_cons='$id_cons'"
     512$res = $dbi->prepare("$sql");
     513$res->execute();
     514
     515                list($tempng)=$res->fetch(PDO::FETCH_NUM);
    443516                $grpinc[$val]=$tempng;
    444517}
     
    539612                $z=0;
    540613                $arvin[$x][$pos++]=$desliste[$lst];
    541                 $res_can = mysql_query("SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,num_cand",$dbi);
    542                 $num_candlst[$x]=mysql_num_rows($res_can);
    543                 while(list($cand,$pre)=mysql_fetch_row($res_can)){
     614                $sql = "SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,num_cand"
     615$res_can = $dbi->prepare("$sql");
     616$res_can->execute();
     617
     618                $num_candlst[$x]=$res_can->rowCount();
     619                while(list($cand,$pre)=$res_can->fetch(PDO::FETCH_NUM)){
    544620                        $cifra[$x][$pos]=$y+$pre;
    545621                        $arvin[$x][$pos++]=$cand;
     
    560636        if($vall==0) continue;
    561637
    562                 $res = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where num_lista='$keyl' and id_cons='$id_cons'",$dbi);
    563                 list($tempig)=mysql_fetch_row($res);
    564                 $res = mysql_query("SELECT num_gruppo from ".$prefix."_ele_gruppo where id_gruppo='$tempig' and id_cons='$id_cons'",$dbi);
    565                 list($tempng)=mysql_fetch_row($res); #foreach ($sindseggio as $keyl=>$vall) echo "<br> listdecseggi: $keyl - $vall - $tempng";
     638                $sql = "SELECT id_gruppo from ".$prefix."_ele_lista where num_lista='$keyl' and id_cons='$id_cons'"
     639$res = $dbi->prepare("$sql");
     640$res->execute();
     641
     642                list($tempig)=$res->fetch(PDO::FETCH_NUM);
     643                $sql = "SELECT num_gruppo from ".$prefix."_ele_gruppo where id_gruppo='$tempig' and id_cons='$id_cons'"
     644$res = $dbi->prepare("$sql");
     645$res->execute();
     646
     647                list($tempng)=$res->fetch(PDO::FETCH_NUM); #foreach ($sindseggio as $keyl=>$vall) echo "<br> listdecseggi: $keyl - $vall - $tempng";
    566648                if (isset($sindseggio[$tempng])) {$listdec[$tempng][]=$keyl;}
    567649#               if (in_array($tempng,$sindseggio)) {$listdec[$tempng][]=$keyl;}
     
    631713                if(!$premio and $key==$gruppo) $arvin[$x][$pos++]=$desliste[$lst];
    632714                else $arper[$x][$pos++]=$desliste[$lst];
    633                 $res_can = mysql_query("SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,num_cand",$dbi);
    634                 $num_candlst[$x]=mysql_num_rows($res_can);
    635                 while(list($cand,$pre)=mysql_fetch_row($res_can)) {
     715                $sql = "SELECT concat(substring(concat('0',t1.num_cand),-2),') ',t1.cognome,' ',substring(t1.nome from 1 for 1),'.') as descr,sum(t2.voti) as voti from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2 where t1.id_lista='$id_lista' and t1.id_cand=t2.id_cand GROUP BY descr order by voti desc,num_cand"
     716$res_can = $dbi->prepare("$sql");
     717$res_can->execute();
     718
     719                $num_candlst[$x]=$res_can->rowCount();
     720                while(list($cand,$pre)=$res_can->fetch(PDO::FETCH_NUM)) {
    636721                        $cifra[$x][$pos]=$y+$pre;
    637722                        if(!$premio and $key==$gruppo)
  • trunk/client/modules/Elezioni/gruppo.php

    r265 r295  
    287287                        // fine della modifica
    288288                         
    289                         $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15";
     289                        $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15"; 
    290290                        $res_scr = $dbi->prepare("$sql");
    291291                        $res_scr->execute();
Note: See TracChangeset for help on using the changeset viewer.