Exemple #1
0
function display_rates($curr_code)
{
    global $table_style;
    $result = get_exchange_rates($curr_code);
    br(2);
    start_table($table_style);
    $th = array(tr("Date to Use From"), tr("Exchange Rate"), "", "");
    table_header($th);
    $k = 0;
    //row colour counter
    while ($myrow = db_fetch($result)) {
        alt_table_row_color($k);
        label_cell(sql2date($myrow["date_"]));
        label_cell(number_format2($myrow["rate_buy"], user_exrate_dec()), "nowrap align=right");
        edit_link_cell("selected_id=" . $myrow["id"]);
        delete_link_cell("selected_id=" . $myrow["id"] . "&delete=1");
        end_row();
    }
    //END WHILE LIST LOOP
    end_table();
}
Exemple #2
0
/**
 * Get a json object with currency exchange rates
 *
 * Sends a json object with currency exchange rates for given currency
 *
 * @since 1.0.0
 *
 * @param string $currency The base currency for the rates (default USD).
 */
function get_exchange_rates_json($currency = 'USD')
{
    $rates = get_exchange_rates(strtoupper($currency));
    wp_send_json($rates);
}
Exemple #3
0
//_print_r($current_hour_detail1);
//_print_r($current_hour_detail2);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// 10 days graph
$view_data['graph_data1'] = $db->get($config['db']['day_table'], false, $symbol1, false, false, ' ORDER BY Datetime DESC LIMIT 10 ');
$view_data['graph_data2'] = $db->get($config['db']['day_table'], false, $symbol2, false, false, ' ORDER BY Datetime DESC LIMIT 10 ');
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// currency lists for dropdown
$view_data['currencies'] = get_currency_lists($config['symbols']);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// exchange rates for today
foreach ($view_data['currencies'] as $base) {
    $view_data['exchange_rates'][$base] = get_exchange_rates($db, $config['db']['minute_table'], $base, $view_data['currencies']);
}
// _print_r($view_data['exchange_rates']);
// die;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// latest & popular conversions
// get latest conversions
$latest = $db->get($config['db']['conversions'], false, false, false, false, ' ORDER BY Datetime DESC LIMIT 40 ');
$row = [];
for ($i = 0; $i < count($latest); $i++) {
    if ($i % 4 == 0) {
        if ($i > 0) {
            $view_data['latest_conversions'][] = $row;
        }
        $row = [];
Exemple #4
0
 /**
  * Get currency rates API callback function
  *
  * @since 1.4.0
  *
  * @param  string $currency	(optional) Base currency, default US Dollars.
  * @return array  Currency rates.
  */
 public function get_rates($currency = 'USD')
 {
     return get_exchange_rates($currency);
 }
Exemple #5
0
$view_data['amount'] = $amount;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// currency lists for dropdown
$view_data['currencies'] = get_currency_lists($config['symbols']);
$view_data['currency_details'] = $config['currencies'];
$view_data['currency_base'] = $config['currencies'][$symbol1_upper];
$view_data['currency_base']['abrUp'] = $symbol1_upper;
$view_data['currency_base']['abrLo'] = $symbol1;
$view_data['currency_target'] = $config['currencies'][$symbol2_upper];
$view_data['currency_target']['abrUp'] = $symbol2_upper;
$view_data['currency_target']['abrLo'] = $symbol2;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// exchange rates for today
$view_data['exchange_rates'] = get_exchange_rates($db, $config['db']['minute_table'], $symbol1_upper, $view_data['currencies']);
// _print_r($view_data['exchange_rates']);
// die;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// current data for top right corner
// get current conversion
$view_data['current_conversion'] = $db->get($config['db']['minute_table'], 'latest_minute', $symbol1 . $symbol2);
// [base] => gbp
// [target] => eur
// [amount] => 100
$where = ' AND Base="' . $symbol1_upper . '" AND Target="' . $symbol2_upper . '" AND Amount="' . $amount . '" ';
$tmp = $db->get($config['db']['conversions'], false, false, false, false, $where);
//--------------------
// update ( or add ) the number of times the same
// conversion has been done