26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/multicurrency.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
33 $langs->loadLangs(array(
'admin',
'multicurrency'));
41 $action =
GETPOST(
'action',
'aZ09');
49 if (preg_match(
'/set_([a-z0-9_\-]+)/i', $action, $reg)) {
51 $value =
GETPOST($code,
'alpha');
59 if (preg_match(
'/del_([a-z0-9_\-]+)/i', $action, $reg)) {
68 if ($action ==
'add_currency') {
71 $langs->loadCacheCurrencies(
'');
73 $code =
GETPOST(
'code',
'alpha');
76 $currency->code = $code;
77 $currency->name = !empty($langs->cache_currencies[$code][
'label']) ? $langs->cache_currencies[$code][
'label'].
' ('.$langs->getCurrencySymbol($code).
')' : $code;
79 if (empty($currency->code) || $currency->code ==
'-1') {
80 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Currency")),
null,
'errors');
84 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Rate")),
null,
'errors');
89 if ($currency->create($user) > 0) {
90 if ($currency->addRate($rate)) {
96 setEventMessages($langs->trans(
'ErrorAddCurrencyFail'), $currency->errors,
'errors');
99 } elseif ($action ==
'update_currency') {
102 if (
GETPOST(
'updatecurrency',
'alpha')) {
103 $fk_multicurrency =
GETPOST(
'fk_multicurrency',
'int');
108 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Rate")),
null,
'errors');
112 if ($currency->fetch($fk_multicurrency) > 0) {
113 $result = $currency->updateRate($rate);
119 } elseif (
GETPOST(
'deletecurrency',
'alpha')) {
120 $fk_multicurrency =
GETPOST(
'fk_multicurrency',
'int');
123 if ($currency->fetch($fk_multicurrency) > 0) {
124 if ($currency->delete() > 0) {
127 setEventMessages($langs->trans(
'ErrorDeleteCurrencyFail'), array(),
'errors');
131 } elseif ($action ==
'setapilayer') {
146 $TCurrency = array();
147 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"multicurrency WHERE entity = ".((int) $conf->entity);
148 $resql = $db->query($sql);
150 while ($obj = $db->fetch_object(
$resql)) {
152 $currency->fetch($obj->rowid);
153 $TCurrency[] = $currency;
164 $page_name =
"MultiCurrencySetup";
170 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
175 print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"multicurrency");
178 print
'<div class="div-table-responsive-no-min">';
179 print
'<table class="noborder centpercent">';
180 print
'<tr class="liste_titre">';
181 print
'<td>'.$langs->trans(
"Parameters").
'</td>'.
"\n";
182 print
'<td class="center">'.$langs->trans(
"Status").
'</td>'.
"\n";
185 print
'<tr class="oddeven">';
186 print
'<td>'.$langs->transnoentitiesnoconv(
"MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").
'</td>';
187 print
'<td class="center">';
188 if ($conf->use_javascript_ajax) {
191 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
192 print
$form->selectarray(
"MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE);
197 print
'<tr class="oddeven">';
198 print
'<td>'.$langs->transnoentitiesnoconv(
"multicurrency_useOriginTx").
'</td>';
199 print
'<td class="center">';
200 if ($conf->use_javascript_ajax) {
201 print
ajax_constantonoff(
'MULTICURRENCY_USE_ORIGIN_TX',
null,
null, 0, 0, 0, 2, 0, 1);
203 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
204 print
$form->selectarray(
"MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX);
209 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
210 print
'<tr class="oddeven">';
211 print
'<td>'.$langs->transnoentitiesnoconv(
"MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").
'</td>';
212 print
'<td class="center">';
213 if ($conf->use_javascript_ajax) {
216 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
217 print
$form->selectarray(
"MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT);
256 if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) {
257 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" id="form_sync">';
258 print
'<input type="hidden" name="token" value="'.newToken().
'">';
259 print
'<input type="hidden" name="action" value="setapilayer">';
261 print
'<div class="div-table-responsive-no-min">';
262 print
'<table class="noborder centpercent">';
264 $urlforapilayer =
'https://currencylayer.com';
266 print
'<tr class="liste_titre">';
267 print
'<td>'.$form->textwithpicto($langs->trans(
"CurrencyLayerAccount"), $langs->trans(
"CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).
'</td>'.
"\n";
268 print
'<td class="right">';
269 print
'<textarea id="response" class="hideobject" name="response"></textarea>';
270 print
'<input type="submit" name="modify_apilayer" class="button buttongen" value="'.$langs->trans(
"Modify").
'">';
271 print
'<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button buttongen" value="'.$langs->trans(
'Synchronize').
'" />';
274 print
'<tr class="oddeven">';
275 print
'<td class="fieldrequired"><a target="_blank" rel="noopener noreferrer external" href="'.$urlforapilayer.
'">'.$langs->transnoentitiesnoconv(
"multicurrency_appId").
'</a></td>';
276 print
'<td class="right">';
277 print
'<input type="text" name="MULTICURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.
'" size="28" /> ';
280 print
'<tr class="oddeven">';
281 print
'<td>'.$langs->transnoentitiesnoconv(
"multicurrency_appCurrencySource").
'</td>';
282 print
'<td class="right">';
283 print
'<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'.$conf->global->MULTICURRENCY_APP_SOURCE.
'" size="10" placeholder="USD" /> ';
300 print
'<div class="div-table-responsive-no-min">';
301 print
'<table class="noborder centpercent nomarginbottom">';
303 print
'<tr class="liste_titre">';
304 print
'<td>'.$form->textwithpicto($langs->trans(
"CurrenciesUsed"), $langs->transnoentitiesnoconv(
"CurrenciesUsed_help_to_add")).
'</td>'.
"\n";
305 print
'<td class="right">'.$langs->trans(
"Rate").
' / '.$langs->getCurrencySymbol($conf->currency).
'</td>'.
"\n";
308 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'">';
309 print
'<input type="hidden" name="token" value="'.newToken().
'">';
310 print
'<input type="hidden" name="action" value="add_currency">';
312 print
'<tr class="oddeven">';
313 print
'<td>'.$form->selectCurrency(
'',
'code', 1,
'1').
'</td>';
314 print
'<td class="right">';
315 print
'<input type="text" name="rate" value="" class="width75 right" placeholder="'.$langs->trans(
'Rate').
'" /> ';
316 print
'<input type="submit" class="button button-add smallpaddingimp" value="'.$langs->trans(
"Add").
'">';
322 print
'<tr class="oddeven">';
323 print
'<td>'.$conf->currency;
324 print
' ('.$langs->getCurrencySymbol($conf->currency).
')';
325 print
$form->textwithpicto(
' ', $langs->trans(
"BaseCurrency")).
'</td>';
326 print
'<td class="right">1</td>';
329 foreach ($TCurrency as &$currency) {
330 if ($currency->code == $conf->currency) {
334 print
'<tr class="oddeven">';
335 print
'<td>'.$currency->code.
' - '.$currency->name.
'</td>';
336 print
'<td class="right">';
337 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'">';
338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
339 print
'<input type="hidden" name="action" value="update_currency">';
340 print
'<input type="hidden" name="fk_multicurrency" value="'.$currency->id.
'">';
341 print
'1 '.$conf->currency.
' = ';
342 print
'<input type="text" name="rate" class="width75 right" value="'.($currency->rate->rate ? $currency->rate->rate :
'').
'" size="13"> '.$currency->code.
' ';
343 print
'<input type="submit" name="updatecurrency" class="button button-edit smallpaddingimp" value="'.$langs->trans(
"Modify").
'"> ';
344 print
'<input type="submit" name="deletecurrency" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'">';
353 <script type="text/javascript">
356 $("#bt_sync").attr("disabled", true);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
multicurrencyAdminPrepareHead()
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.