wefra-odoo11/modules/ClassCurrency.php

55 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2019-10-02 21:28:58 +00:00
<?php
class ClassCurrency extends ClassConfig {
public function __construct(){}
public function __destruct(){}
public function getCurrencyNameById($id){
$this->_id = $id;
foreach($_SESSION['currencies'] as $currency){
if($currency['id'] == $this->_id){
return $currency['name'];
} else {
continue;
}
}
return $rows;
}
public function listCurrencies($order_by=''){
$this->_orderBy = $order_by;
$oPDOLink = ClassConfig::databaseConnect();
$sql="
SELECT *
FROM core_currency
";
if($this->_orderBy != '') $sql .=" ORDER BY ".$this->_orderBy;
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array());
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
return $rows;
}
public function getCurrency($currency_id){
$this->_currencyId = $currency_id;
$oPDOLink = ClassConfig::databaseConnect();
$sql="
SELECT *
FROM core_currency
WHERE id=:currency_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(
':currency_id'=>$this->_currencyId
));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
return $row;
}
public function displayAmountWithCurrency($amount, $decimal_precision, $symbol){
$this->_amount = $amount;
$this->_decimalPrecision = $decimal_precision;
$this->_symbol = $symbol;
return number_format((float)$this->_amount, $this->_decimalPrecision, '.', '').' '.$this->_symbol;
}
}