function display_rate_edit()
{
    global $selected_id, $Ajax, $xr_providers, $dflt_xr_provider;
    $xchg_rate_provider = isset($xr_providers) && isset($dflt_xr_provider) ? $xr_providers[$dflt_xr_provider] : 'ECB';
    start_table(TABLESTYLE2);
    if ($selected_id != "") {
        //editing an existing exchange rate
        $myrow = get_exchange_rate($selected_id);
        $_POST['date_'] = sql2date($myrow["date_"]);
        $_POST['BuyRate'] = maxprec_format($myrow["rate_buy"]);
        hidden('selected_id', $selected_id);
        hidden('date_', $_POST['date_']);
        label_row(_("Date to Use From:"), $_POST['date_']);
    } else {
        $_POST['date_'] = Today();
        $_POST['BuyRate'] = '';
        date_row(_("Date to Use From:"), 'date_');
    }
    if (isset($_POST['get_rate'])) {
        $_POST['BuyRate'] = maxprec_format(retrieve_exrate($_POST['curr_abrev'], $_POST['date_']));
        $Ajax->activate('BuyRate');
    }
    amount_row(_("Exchange Rate:"), 'BuyRate', null, '', submit('get_rate', _("Get"), false, _('Get current rate from') . ' ' . $xchg_rate_provider, true), 'max');
    end_table(1);
    submit_add_or_update_center($selected_id == '', '', 'both');
    display_note(_("Exchange rates are entered against the company currency."), 1);
}
Exemple #2
0
 public static function update_rate($from, $to)
 {
     $rate = get_exchange_rate($from, $to);
     if ($rate) {
         $er = new exchangeRate();
         $er->set_value("exchangeRateCreatedDate", date("Y-m-d"));
         $er->set_value("fromCurrency", $from);
         $er->set_value("toCurrency", $to);
         $er->set_value("exchangeRate", $rate);
         $er->save();
         return $from . " -> " . $to . ":" . $rate . " ";
     } else {
         echo date("Y-m-d H:i:s") . "Unable to obtain exchange rate information for " . $from . " to " . $to . "!";
     }
 }
Exemple #3
0
    // $payment_module = $payment_module; // Really - do nothing
} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
    reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
    $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
} elseif (count($sn_module_list['payment']) == 1) {
    $payment_module = $module_name;
} else {
    $payment_module = '';
}
if ($payment_type_selected && $payment_method_selected) {
    foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
        $template->assign_block_vars('payment_module', array('ID' => $module_name, 'NAME' => $lang["module_{$module_name}_name"], 'DESCRIPTION' => $lang["module_{$module_name}_description"]));
    }
}
foreach ($lang['pay_currency_list'] as $key => $value) {
    $course = get_exchange_rate($key);
    //  if(!$course || $key == $config->payment_currency_default) {
    if (!$course) {
        continue;
    }
    $template->assign_block_vars('exchange', array('SYMBOL' => $key, 'TEXT' => $value, 'COURSE_DIRECT' => pretty_number($course, 4), 'COURSE_REVERSE' => pretty_number(1 / $course, 4), 'MM_PER_CURRENCY' => pretty_number(sn_module_payment::currency_convert(1, $key, 'MM_')), 'LOT_PRICE' => sn_module_payment::currency_convert(get_mm_cost(), 'MM_', $key), 'DEFAULT' => $key == $config->payment_currency_default));
}
if ($request['metamatter'] && $payment_module) {
    try {
        // Any possible errors about generating paylink should be raised in module!
        $pay_link = $sn_module[$payment_module]->compile_request($request);
        // Поддержка дополнительной информации
        if (is_array($pay_link['RENDER'])) {
            foreach ($pay_link['RENDER'] as $html_data) {
                $template->assign_block_vars('render', $html_data);
                if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
Exemple #4
0
function display_rate_edit()
{
    global $selected_id, $table_style2;
    start_table($table_style2);
    if (isset($_POST['get_rate'])) {
        $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev']));
    }
    if ($selected_id != "") {
        //editing an existing exchange rate
        $myrow = get_exchange_rate($selected_id);
        $_POST['date_'] = sql2date($myrow["date_"]);
        $_POST['BuyRate'] = exrate_format($myrow["rate_buy"]);
        hidden('selected_id', $selected_id);
        hidden('date_', $_POST['date_']);
        hidden('curr_abrev', $_POST['curr_abrev']);
        label_row(tr("Date to Use From:"), $_POST['date_']);
    } else {
        date_row(tr("Date to Use From:"), 'date_');
    }
    small_amount_row(tr("Exchange Rate:"), 'BuyRate', null, '', submit('get_rate', tr("Get")), user_exrate_dec());
    end_table(1);
    submit_add_or_update_center($selected_id == "");
    display_note(tr("Exchange rates are entered against the company currency."), 1);
}
 /**
  * Внутриигровая конвертация валют
  *
  * @param        $value
  * @param string $currency_from
  * @param string $currency_to
  * @param int    $round
  *
  * @return float|int
  */
 public static function currency_convert($value, $currency_from = '', $currency_to = '', $round = 2)
 {
     //    global $config;
     $currency_from = strtolower($currency_from);
     $currency_to = strtolower($currency_to);
     if ($currency_from != $currency_to) {
         //      $config_currency_from_name = 'payment_currency_exchange_' . $currency_from;
         //      $config_currency_to_name = 'payment_currency_exchange_' . $currency_to;
         //      $exchange_from = floatval($currency_from == 'mm_' ? get_mm_cost() : $config->$config_currency_from_name);
         //      $exchange_to = floatval($currency_to == 'mm_' ? get_mm_cost() : $config->$config_currency_to_name);
         $exchange_from = get_exchange_rate($currency_from);
         $exchange_to = get_exchange_rate($currency_to);
         $value = $exchange_from ? $value / $exchange_from * $exchange_to * pow(10, $round) : 0;
         $value = ceil($value) / pow(10, $round);
     }
     return $value;
 }