Ejemplo n.º 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/international/international_currency.php';
     $Currency = new international_currency();
     if ($_POST['client']['customer']['currency_code']) {
         $_SESSION['client']['customer']['currency_code'] = $_POST['client']['customer']['currency_code'];
     } else {
         $_SESSION['client']['customer']['currency_code'] = $Currency->conf['default'];
     }
     $selected = $_SESSION['client']['customer']['currency_code'];
     $allowed = $Currency->conf['allowed'];
     $allowed_count = count($allowed);
     if ($allowed[0] == 'all') {
         $where = '';
     } else {
         $where = "code=";
         for ($i = 0; $i < $allowed_count; $i++) {
             if ($i == $allowed_count - 1) {
                 $where = $where . "'{$allowed[$i]}'";
             } else {
                 $where = $where . "'{$allowed[$i]}' OR code=";
             }
         }
     }
     $currencies = $Currency->listing($where, 'name ASC');
     foreach ($currencies as $c) {
         if ($c['code'] == $selected) {
             $c['selected'] = "selected='selected'";
         } else {
             $c['selected'] = '';
         }
         $this->tpl->assign('currency', $c);
         $this->tpl->parse("content.item");
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * get currencies
  */
 function getCurrencies($currency_code = 'conf')
 {
     require_once 'models/international/international_currency.php';
     $Currency = new international_currency();
     $international_currency_conf = international_currency::initConfiguration();
     if ($currency_code == 'conf') {
         $cs = $Currency->conf['allowed'];
         $count = count($cs);
         for ($i = 0; $i < $count; $i++) {
             $where .= "code = '{$cs[$i]}'";
             if ($i + 1 < $count) {
                 $where .= " OR ";
             }
         }
     } else {
         if ($currency_code != 'all') {
             $where = "code = '{$currency_code}'";
         } else {
             $where = '';
         }
     }
     $curs = $Currency->listing($where);
     foreach ($curs as $cur) {
         if ($cur['symbol_left'] == '' && $cur['symbol_right'] == '') {
             $cur['symbol_right'] = "&nbsp;" . $cur['code'];
         }
         $result[$cur['code']] = $cur;
     }
     return $result;
 }