Changeset 65


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)

Location:
trunk/client/modules/Elezioni
Files:
3 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?>
  • trunk/client/modules/Elezioni/grafici.php

    r53 r65  
    512512
    513513
    514                 echo "</table></td><td valign=\"top\"><br />";
     514                echo "</table></td>";
     515                global $tema;
     516                if($tema!="tour") echo "</tr><tr>";
     517                echo "<td valign=\"top\"><br />";
    515518                # grafico statico
    516519                echo "<img  src='modules/Elezioni/grafici/barre.php?dati1=$dati1&amp;dati2=$dati2&amp;i=$i&amp;cop=$copy&amp;titolo=$titolo&amp;descr=$descr_cons&amp;l=$l&amp;w=$w&amp;logo=$logo'  alt=\"Grafico\" />";
  • trunk/client/modules/Elezioni/gruppo.php

    r64 r65  
    508508                                        $resvt = mysql_query("SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'",$dbi);
    509509                                        list($votlt)=mysql_fetch_row($resvt);
     510                                        $temp3=arrayperc($temp,$sevaltot);
    510511                                        while (list($key,$voti)= each($temp)) {
    511512                                                $percento="<b>$voti</b>";
    512513                                                if ($perc=='true' and $voticompl)
    513514                                                {
    514                                                         $percento="<b>$voti<br /><span class=\"red\"><i>".number_format($voti*100/$sevaltot,2)." %</i></span></b>";
     515 #                      $valperc2=round($valperc,2);
     516                                                        $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
    515517                                                }
    516518                                                $ar[2+$offsetsez-$minsez][$key]=$percento;
     
    520522                                $key=$offset+1;
    521523                                $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
    522                                 while(list($k,$voti)= each($tmp)) {
    523                                         $percento="<b>$voti</b>";
    524                                                 if ($perc=='true' and $voticompl)
    525                                                 {
    526                                                         $percento="<b>$voti<br /><span class=\"red\"><i>".number_format($voti*100/$voticompl,2)." %</i></span></b>";
    527                                                 }
    528                                                 $ar[2+$offsetsez-$minsez][++$key]=$percento;
     524                                $temp3=arrayperc($tmp,$voticompl);
     525                                #foreach($temp3 as $key=>$val) echo "$key: $val<br>";
     526                                while(list($k,$voti)= each($tmp)) {
     527                                       
     528                    if ($perc=='true' and $voticompl)
     529                    {
     530                        $valperc=number_format($voti*100/$voticompl,3);
     531                        $valperc=number_format($valperc,2);
     532                         $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
     533                     } else $percento="<b>$voti</b>";
     534                     $ar[2+$offsetsez-$minsez][++$key]=$percento;
    529535
    530536                                }
Note: See TracChangeset for help on using the changeset viewer.