function currency_form_submit in Currency 5
Same name and namespace in other branches
- 6 currency.module \currency_form_submit()
- 7 currency.module \currency_form_submit()
File
- ./
currency.module, line 121
Code
function currency_form_submit($form_id, $form_values) {
$from = $form_values['currency_from'];
$to = $form_values['currency_to'];
$amount = $form_values['currency_amount'];
$url = 'http://finance.yahoo.com/q?s=' . $from . $to . '=X';
$ret = currency_api_convert($from, $to, $amount);
if ($ret['status'] == FALSE) {
drupal_set_message(t('currency exchange error: ') . $ret['message']);
}
else {
$result .= '<p>';
$result .= t('@amount @from = @value @to', array(
'@amount' => $amount,
'@from' => currency_api_get_desc($from),
'@value' => $ret['value'],
'@to' => currency_api_get_desc($to),
));
$result .= '</p><p>';
$result .= l(t('Detailed history and chart'), $url);
$result .= '</p>';
}
// Save the last used values in the session
$_SESSION['currency_amount'] = $amount;
$_SESSION['currency_from'] = $from;
$_SESSION['currency_to'] = $to;
drupal_set_message($result);
}