[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
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 = '', $currency_value = '') { 36 global $currency; 37 38 if (empty($currency_type)) $currency_type = strtoupper($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 } else { 44 $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']; 45 } 46 47 // BOF: MOD - Down for Maintenance 48 if (DOWN_FOR_MAINTENANCE=='true' and DOWN_FOR_MAINTENANCE_PRICES_OFF=='true') { 49 $format_string= ''; 50 } 51 // EOF: MOD - Down for Maintenance 52 53 return $format_string; 54 } 55 56 function calculate_price($products_price, $products_tax, $quantity = 1) { 57 global $currency; 58 59 return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity; 60 } 61 62 function is_set($code) { 63 if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) { 64 return true; 65 } else { 66 return false; 67 } 68 } 69 70 function get_value($code) { 71 return $this->currencies[$code]['value']; 72 } 73 74 function get_decimal_places($code) { 75 return $this->currencies[$code]['decimal_places']; 76 } 77 78 function display_price($products_price, $products_tax, $quantity = 1) { 79 return $this->format($this->calculate_price($products_price, $products_tax, $quantity)); 80 } 81 } 82 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |