Fix switch currency on document do not get the associate rate
This commit is contained in:
parent
e3a5af6ad4
commit
495ce2463d
@ -1433,7 +1433,7 @@ if ($action == 'create')
|
||||
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
$currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 1);
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -3812,7 +3812,7 @@ class Form
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
print $this->selectMultiCurrency($selected, $htmlname, 1);
|
||||
print $this->selectMultiCurrency($selected, $htmlname, 0);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
@ -4091,7 +4091,7 @@ class Form
|
||||
|
||||
$out='';
|
||||
$out.= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
if ($useempty) $out .= '<option value="'.$conf->currency.'"'.((empty($selected) || $selected == $conf->currency)?' selected="selected"':'').'>'.$langs->cache_currencies[$conf->currency]['label'].'</option>';
|
||||
if ($useempty) $out .= '<option value=""></option>';
|
||||
if (count($TCurrency) > 0)
|
||||
{
|
||||
foreach ($langs->cache_currencies as $code_iso => $currency)
|
||||
|
||||
@ -512,9 +512,10 @@ class MultiCurrency extends CommonObject
|
||||
{
|
||||
$sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
|
||||
// FIXME Is this comptible with SQL ?
|
||||
$sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)';
|
||||
$sql.= " AND m.entity IN '".getEntity('multicurrency', 1)."'";
|
||||
$sql.= ' WHERE m.code = "'.$db->escape($code).'"';
|
||||
$sql.= " AND m.entity IN (".getEntity('multicurrency', 1).")";
|
||||
$sql.= ' ORDER BY mc.date_sync DESC LIMIT 1';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
|
||||
else return array(0, 1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user