[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

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

   1  <?php
   2  //

   3  // +----------------------------------------------------------------------+

   4  // |zen-cart Open Source E-commerce                                       |

   5  // +----------------------------------------------------------------------+

   6  // | Copyright (c) 2003 The zen-cart developers                           |

   7  // |                                                                      |   

   8  // | http://www.zen-cart.com/index.php                                    |   

   9  // |                                                                      |   

  10  // | Portions Copyright (c) 2003 osCommerce                               |

  11  // +----------------------------------------------------------------------+

  12  // | This source file is subject to version 2.0 of the GPL license,       |

  13  // | that is bundled with this package in the file LICENSE, and is        |

  14  // | available through the world-wide-web at the following url:           |

  15  // | http://www.zen-cart.com/license/2_0.txt.                             |

  16  // | If you did not receive a copy of the zen-cart license and are unable |

  17  // | to obtain it through the world-wide-web, please send a note to       |

  18  // | license@zen-cart.com so we can mail you a copy immediately.          |

  19  // +----------------------------------------------------------------------+

  20  //  $Id: currencies.php 1969 2005-09-13 06:57:21Z drbyte $

  21  //

  22  
  23  ////

  24  // Class to handle currencies

  25  // TABLES: currencies

  26    class currencies {
  27      var $currencies;
  28  
  29  // class constructor

  30      function currencies() {
  31        global $db;
  32        $this->currencies = array();
  33        $currencies = $db->Execute("select code, title, symbol_left, symbol_right, decimal_point, 
  34                                           thousands_point, decimal_places, value 
  35                                    from " . TABLE_CURRENCIES);
  36  
  37        while (!$currencies->EOF) {
  38      $this->currencies[$currencies->fields['code']] = array('title' => $currencies->fields['title'],
  39                                                         'symbol_left' => $currencies->fields['symbol_left'],
  40                                                         'symbol_right' => $currencies->fields['symbol_right'],
  41                                                         'decimal_point' => $currencies->fields['decimal_point'],
  42                                                         'thousands_point' => $currencies->fields['thousands_point'],
  43                                                         'decimal_places' => $currencies->fields['decimal_places'],
  44                                                         'value' => $currencies->fields['value']);
  45          $currencies->MoveNext();
  46        }
  47      }
  48  
  49  // class methods

  50      function format($number, $calculate_currency_value = true, $currency_type = DEFAULT_CURRENCY, $currency_value = '') {
  51        if ($calculate_currency_value) {
  52          $rate = ($currency_value) ? $currency_value : $this->currencies[$currency_type]['value'];
  53          $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'];
  54  // if the selected currency is in the european euro-conversion and the default currency is euro,

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

  56          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') ) {
  57            $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>';
  58          }
  59        } else {
  60          $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'];
  61        }
  62  
  63        return $format_string;
  64      }
  65  
  66      function get_value($code) {
  67        return $this->currencies[$code]['value'];
  68      }
  69  
  70      function display_price($products_price, $products_tax, $quantity = 1) {
  71        return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
  72      }
  73    }
  74  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics