currency.php
985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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;
}
}
}