Debug hidden option MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION

This commit is contained in:
Laurent Destailleur 2019-05-02 13:45:49 +02:00
parent 5145680279
commit e81f10c790
4 changed files with 18 additions and 10 deletions

View File

@ -115,7 +115,7 @@ elseif ($action == 'setapilayer')
{
dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
}
else
{
@ -249,8 +249,8 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'</td>'."\n";
print '<td class="right">';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print $langs->trans("Value").'&nbsp;<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button" value="'.$langs->trans('Synchronize').'" />';
print '<input type="submit" name="modify_apilayer" class="button" value="'.$langs->trans("Modify").'">';
print '<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button" value="'.$langs->trans('Synchronize').'" />';
print '</td></tr>';
print '<tr class="oddeven">';
@ -266,11 +266,11 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '</form>';
print '</td></tr>';
print '<tr class="oddeven">';
/*print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR
print '</td></tr>';
print '</td></tr>';*/
print '</table>';
print '</div>';
@ -292,7 +292,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_currency">';
print '<tr class="oddeven">';
print '<td>'.$form->selectCurrency('', 'code').'</td>';
print '<td>'.$form->selectCurrency('', 'code', 1).'</td>';
print '<td class="right">';
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('Rate').'" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';

View File

@ -4781,9 +4781,10 @@ class Form
*
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
* @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code
* @return string
*/
public function selectCurrency($selected = '', $htmlname = 'currency_id')
public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0)
{
global $conf,$langs,$user;
@ -4805,7 +4806,14 @@ class Form
$out.= '<option value="'.$code_iso.'">';
}
$out.= $currency['label'];
$out.= ' ('.$langs->getCurrencySymbol($code_iso).')';
if ($mode == 1)
{
$out.= ' ('.$code_iso.')';
}
else
{
$out.= ' ('.$langs->getCurrencySymbol($code_iso).')';
}
$out.= '</option>';
}
$out.= '</select>';

View File

@ -7,7 +7,7 @@ multicurrency_syncronize_error=Synchronization error: %s
MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Use the date of the document to find the currency rate, instead of using the latest known rate
multicurrency_useOriginTx=When an object is created from another, keep the original rate from the source object (otherwise use the latest known rate)
CurrencyLayerAccount=CurrencyLayer API
CurrencyLayerAccount_help_to_synchronize=You must create an account on website %s to use this functionality.<br>Get your <b>API key</b>.<br>If you use a free account you can't change the <b>currency source</b> (USD by default).<br>If your main currency is not USD you can use the <b>alternate currency source</b> to force your main currency.<br><br>You are limited to 1000 synchronizations per month.
CurrencyLayerAccount_help_to_synchronize=You must create an account on website %s to use this functionality.<br>Get your <b>API key</b>.<br>If you use a free account, you can't change the <b>source currency</b> (USD by default).<br>If your main currency is not USD, the application will automatically recalculate it.<br><br>You are limited to 1000 synchronizations per month.
multicurrency_appId=API key
multicurrency_appCurrencySource=Source currency
multicurrency_alternateCurrencySource=Alternate source currency

View File

@ -603,9 +603,9 @@ class MultiCurrency extends CommonObject
{
global $conf;
if (!empty($conf->global->MULTICURRENCY_ALTERNATE_SOURCE))
if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE)
{
$alternate_source = 'USD'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE;
$alternate_source = 'USD'.$conf->currency;
if (!empty($TRate->{$alternate_source}))
{
$coef = $TRate->USDUSD / $TRate->{$alternate_source};