[ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 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 = '', $currency_value = '') { 36 global $currency; 37 38 if (empty($currency_type)) $currency_type = $currency; 39 40 if ($calculate_currency_value == true) { 41 $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; 42 $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; 43 // if the selected currency is in the european euro-conversion and the default currency is euro, 44 // the currency will displayed in the national currency and euro currency 45 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') ) { 46 $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>'; 47 } 48 } else { 49 $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; 50 } 51 52 return $format_string; 53 } 54 55 function is_set($code) { 56 if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) { 57 return true; 58 } else { 59 return false; 60 } 61 } 62 63 function get_value($code) { 64 return $this->currencies[$code]['value']; 65 } 66 67 function get_decimal_places($code) { 68 return $this->currencies[$code]['decimal_places']; 69 } 70 71 function display_price($products_price, $products_tax, $quantity = 1) { 72 return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); 73 } 74 } 75 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |