[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/includes/classes/ -> currencies.php (source)

   1  <?php
   2  /*

   3  $Id: currencies.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  ////

  14  // Class to handle currencies

  15  // TABLES: currencies

  16    class currencies {
  17      var $currencies;
  18  
  19  // class constructor

  20      function currencies() {
  21        $this->currencies = array();
  22        $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
  23        while ($currencies = tep_db_fetch_array($currencies_query)) {
  24          $this->currencies[$currencies['code']] = array('title' => $currencies['title'],
  25                                                         'symbol_left' => $currencies['symbol_left'],
  26                                                         'symbol_right' => $currencies['symbol_right'],
  27                                                         'decimal_point' => $currencies['decimal_point'],
  28                                                         'thousands_point' => $currencies['thousands_point'],
  29                                                         'decimal_places' => $currencies['decimal_places'],
  30                                                         'value' => $currencies['value']);
  31        }
  32      }
  33  
  34  // class methods

  35      function format($number, $calculate_currency_value = true, $currency_type = DEFAULT_CURRENCY, $currency_value = '') {
  36        if ($calculate_currency_value) {
  37          $rate = ($currency_value) ? $currency_value : $this->currencies[$currency_type]['value'];
  38          $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number * $rate, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  39  // if the selected currency is in the european euro-conversion and the default currency is euro,

  40  // the currency will displayed in the national currency and euro currency

  41          if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) {
  42            $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>';
  43          }
  44        } else {
  45          $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  46        }
  47  
  48        return $format_string;
  49      }
  50  
  51      function get_value($code) {
  52        return $this->currencies[$code]['value'];
  53      }
  54  
  55      function display_price($products_price, $products_tax, $quantity = 1, $currency_type = DEFAULT_CURRENCY) {
  56        return $this->format(tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency_type]['decimal_places']) * $quantity);
  57      }
  58    }
  59  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7