Ignore:
Timestamp:
Mar 30, 2010, 5:25:30 PM (14 years ago)
Author:
roby
Message:

creata funzione per gestione calcolo percentuali in visualizzazione completa di arrotondamento (applicata solo ai totali in visualizzazione griglia per verifica)

File:
1 edited

Legend:

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

    r26 r65  
    412412               
    413413}
     414
     415function arrayperc($temp,$sevaltot)
     416{
     417                                        $temp2tot=0;$temp2=array();
     418                                        while (list($key,$voti)= each($temp)) {
     419                                                $temp2[$key]=(ceil($voti*1000/$sevaltot)-($voti*1000/$sevaltot));
     420                        $valperc=number_format($voti*100/$sevaltot,2);
     421                                                $temp3[$key]=$valperc;
     422                                                $temp2tot+=$valperc;
     423                                        }
     424                                        while ($temp2tot>100){
     425                                                    foreach ($temp2 as $key => $val) {
     426                                                if ($val == max($temp2)) {$temp3[$key]-=0.01;$temp2tot-=0.01;$temp2[$key]=0;break;}
     427                                                }
     428                                        }
     429                                        while ($temp2tot<100){
     430                                                    foreach ($temp2 as $key => $val) {
     431                                                if ($val == min($temp2)) {$temp3[$key]+=0.01;$temp2tot+=0.01;$temp2[$key]=1;break;}
     432                                                        }
     433                                         
     434                                        }
     435                                        return($temp3);
     436
     437}
    414438?>
Note: See TracChangeset for help on using the changeset viewer.