55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?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;
 | 
						|
    }
 | 
						|
} |