Changeset 66 for trunk


Ignore:
Timestamp:
Mar 31, 2010, 1:47:45 PM (14 years ago)
Author:
roby
Message:

funzione per gestione calcolo percentuali: applicata a intera griglia

Location:
trunk/client/modules/Elezioni
Files:
2 edited

Legend:

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

    r65 r66  
    422422                                                $temp2tot+=$valperc;
    423423                                        }
     424                                        if($temp2tot>100)
    424425                                        while ($temp2tot>100){
    425426                                                    foreach ($temp2 as $key => $val) {
    426                                                 if ($val == max($temp2)) {$temp3[$key]-=0.01;$temp2tot-=0.01;$temp2[$key]=0;break;}
     427                                                if ($val == max($temp2)) {$temp3[$key]-=0.01;$temp2tot-=0.01;$temp2[$key]=0; break;}
    427428                                                }
    428429                                        }
    429                                         while ($temp2tot<100){
     430                                        if("$temp2tot"=="100") return($temp3);
     431                                        while ($temp2tot<100.00){
    430432                                                    foreach ($temp2 as $key => $val) {
    431433                                                if ($val == min($temp2)) {$temp3[$key]+=0.01;$temp2tot+=0.01;$temp2[$key]=1;break;}
  • trunk/client/modules/Elezioni/gruppo.php

    r65 r66  
    416416                        $secontot=0;
    417417                        $sevnutot=0;
     418                        $valar=array();$percar=array();
    418419                      ////////////////////////////////////////////////////////////////////
    419420                      // sandro: carica i numeri di sezione dal DB - giugno 2009
     
    426427                                        $ar[$z][0]=$res[0];
    427428                                        $pos[$z]=$res[0];
     429                                        #$valar[$z]=array();
    428430                                }
    429431                        if (!isset($pos)) $pos[0]=0;
     
    458460                        $onetime="";
    459461                        if ($res_voti)
     462                        {
     463                                if ($perc=='true'){
     464                                        while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti))
     465                                        if ($num_cand>=$min and $num_cand<=$offset){
     466                                                $z=array_search($num_circ, $pos);
     467                                                if($num_circ>=$minpos and $num_circ <=$maxpos){
     468                                                                $valar[($z)][$num_cand]=$voti;
     469                                                }
     470                                                foreach ($valar as $key=>$val){
     471                                                        $percar[$key]=arrayperc($val,$votitot[($key)]);
     472                                                        foreach($percar as $key2=>$val2);
     473                                                }
     474                                        }
     475                                         mysql_data_seek($res_voti,0);                 
     476                                }
    460477                        while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){
    461478                                if ($num_cand>=$min and $num_cand<=$offset){
     
    467484                                                if ($perc=='true' and $votitot[($z)])
    468485                                                {
    469                                                         $percento=$voti."<br /><span class=\"red\"><i>".number_format($voti*100/$votitot[($z)],2)." %</i></span>";
     486                                                        $percento=$voti."<br /><span class=\"red\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>";
    470487                                                }
    471488                                                $ar[($z)][$num_cand]=$percento;
     
    492509                                }
    493510                        }
     511                        }
    494512                        if (($offsetsez+1)>=$num_sez){
    495513                                $ar[(2+$offsetsez-$minsez)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>";
    496514                                if(isset($temp)) {
    497 ######################
    498515                     if($tab15=="gruppo"){
    499516                          $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
    500517                     }else{
    501                          /* if ($votog) $votigl=" (validi_lista),(nulli),(bianchi),(contestati_lista),(voti_nulli_lista)";
    502                           else */
    503518                          $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista)";
    504519                     }
     
    510525                                        $temp3=arrayperc($temp,$sevaltot);
    511526                                        while (list($key,$voti)= each($temp)) {
    512                                                 $percento="<b>$voti</b>";
    513527                                                if ($perc=='true' and $voticompl)
    514528                                                {
    515  #                      $valperc2=round($valperc,2);
    516529                                                        $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
    517                                                 }
     530                                                } else
     531                                                        $percento="<b>$voti</b>";
    518532                                                $ar[2+$offsetsez-$minsez][$key]=$percento;
    519533                                        }
     
    523537                                $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
    524538                                $temp3=arrayperc($tmp,$voticompl);
    525                                 #foreach($temp3 as $key=>$val) echo "$key: $val<br>";
    526539                                while(list($k,$voti)= each($tmp)) {
    527540                                       
    528541                    if ($perc=='true' and $voticompl)
    529542                    {
    530                         $valperc=number_format($voti*100/$voticompl,3);
    531                         $valperc=number_format($valperc,2);
    532543                         $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
    533544                     } else $percento="<b>$voti</b>";
Note: See TracChangeset for help on using the changeset viewer.