currency.php 985 Bytes
<?php
class Flora_Model_Shop_Currency extends Flora_Model
{
    public $name;
    public $usdvalue;
    public $format;
    public $title;
    public $description;
    public $rounding;
    public $rounding_direction;
    public $floor_to;

    public function convert($usdvalue)
    {
        return $this->formatvalue($this->convert2int($usdvalue));
    }

    public function formatvalue($value)
    {
        return sprintf($this->format, $value);
    }

    public function convert2int($usdvalue)
    {
        return $this->round($this->usdvalue * $usdvalue, 2);
    }

    public function round($value, $decimals = 0)
    {
        if (!$this->rounding) {
            return round($value, $decimals);
        } else {
            $value = $this->rounding * ceil($value / $this->rounding);
            if ($this->rounding_direction == 'asc') {
                $value = $this->rounding * floor($value / $this->rounding);
            }
            return $value;
        }
    }
}