Browse Source

fix upload/download As K

Luciano Andrade 7 years ago
parent
commit
7d7b572fe9
1 changed files with 3 additions and 18 deletions
  1. 3 18
      src/FTTHBundle/Entity/Profile.php

+ 3 - 18
src/FTTHBundle/Entity/Profile.php

@@ -132,24 +132,9 @@ class Profile implements TenancyIdTraitInterface
         return $this->download;
     }
 
-    function units($value, $prefered=false, $mode = 'short', $decimals = 2, $prefix_grows=1000){
-        $units = array('long' => array('', 'kilo', 'mega','giga', 'tera', 'peta',' exa','zetta', 'yotta'),
-                       'short' => array('', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y',)
-        );
-        $unit = '';
-        for($i = 0; $i < count($units[$mode]); $i++) {
-                $unit = $units[$mode][$i];
-                if($unit === $prefered) break;
-                if($value > $prefix_grows) {
-                        $value /= $prefix_grows;
-                } else {
-                        break;
-                }
-        }
-        return round($value, $decimals) .  $unit;
-    }
 
-    function getDownloadAsK(){return $this->units($this->getDownload(), "k"); }
-    function getUploadAsK()  {return $this->units($this->getUpload()  , "k"); }
+    function getDownloadAsK(){return round($this->getDownload()/1000,2)."k"; }
+    function getUploadAsK()  {return round($this->getUpload()/1000,2)."k"; }
+
     function getRadiusName()  {return preg_replace("|[^A-Za-z0-9]|", "-", $this->name); }
 }