Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
e3a5af6a
Commit
e3a5af6a
authored
8 years ago
by
Phf
Browse files
Options
Downloads
Patches
Plain Diff
Fix clean multicurrency admin
parent
923952fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/admin/multicurrency.php
+70
-60
70 additions, 60 deletions
htdocs/admin/multicurrency.php
htdocs/multicurrency/class/multicurrency.class.php
+23
-1
23 additions, 1 deletion
htdocs/multicurrency/class/multicurrency.class.php
with
93 additions
and
61 deletions
htdocs/admin/multicurrency.php
+
70
−
60
View file @
e3a5af6a
...
...
@@ -77,20 +77,20 @@ if (preg_match('/del_(.*)/',$action,$reg))
if
(
$action
==
'add_currency'
)
{
$langs
->
loadCacheCurrencies
(
''
);
$code
=
GETPOST
(
'code'
,
'alpha'
);
$name
=
GETPOST
(
'name'
,
'alpha'
);
$rate
=
GETPOST
(
'rate'
,
'alpha'
);
$currency
=
new
MultiCurrency
(
$db
);
$currency
->
code
=
$code
;
$currency
->
name
=
$nam
e
;
$currency
->
name
=
!
empty
(
$langs
->
cache_currencies
[
$code
][
'label'
])
?
$langs
->
cache_currencies
[
$code
][
'label'
]
.
' ('
.
$langs
->
getCurrencySymbol
(
$code
)
.
')'
:
$cod
e
;
if
(
$currency
->
create
(
$user
)
>
0
)
{
if
(
$currency
->
addRate
(
$rate
))
setEventMessages
(
$langs
->
trans
(
'RecordSaved'
),
array
());
else
setEventMessages
(
$langs
->
trans
(
'ErrorAddRateFail'
),
array
(),
'errors'
);
}
else
setEventMessages
(
$langs
->
trans
(
'ErrorAddCurrencyFail'
),
array
()
);
else
setEventMessages
(
$langs
->
trans
(
'ErrorAddCurrencyFail'
),
$currency
->
errors
,
'errors'
);
}
elseif
(
$action
==
'update_currency'
)
{
...
...
@@ -182,6 +182,7 @@ print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print
'<td align="center" width="20"> </td>'
;
print
'<td align="center" width="100">'
.
$langs
->
trans
(
"Value"
)
.
'</td>'
.
"
\n
"
;
/* TODO uncomment when the functionality will integrated
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_useRateOnInvoiceDate").'</td>';
...
...
@@ -194,6 +195,7 @@ print $form->selectyesno("MULTICURRENCY_USE_RATE_ON_INVOICE_DATE",$conf->global-
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
*/
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
...
...
@@ -208,6 +210,7 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print
'</form>'
;
print
'</td></tr>'
;
/* TODO uncomment when the functionality will integrated
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_buyPriceInCurrency").'</td>';
...
...
@@ -220,7 +223,9 @@ print $form->selectyesno("MULTICURRENCY_BUY_PRICE_IN_CURRENCY",$conf->global->MU
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
*/
/* TODO uncomment when the functionality will integrated
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").'</td>';
...
...
@@ -236,63 +241,67 @@ print '</td></tr>';
print '</table>';
print '<br />';
*/
$var
=
false
;
print
'<table class="noborder" width="100%">'
;
print
'<tr class="liste_titre">'
;
print
'<td>'
.
$langs
->
trans
(
"CurrencyLayerAccount"
)
.
'</td>'
.
"
\n
"
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="100">'
;
print
'<form id="form_sync" action="" method="POST">'
;
print
'<input type="hidden" name="action" value="synchronize" />'
;
print
'<textarea id="response" class="hideobject" name="response"></textarea>'
;
print
$langs
->
trans
(
"Value"
)
.
' <input type="button" id="bt_sync" class="button" onclick="javascript:getRates();" value="'
.
$langs
->
trans
(
'Synchronize'
)
.
'" />'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td><a target="_blank" href="https://currencylayer.com">'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_appId"
)
.
'</a></td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_APP_ID">'
;
print
'<input type="text" name="MULTICURRENCY_APP_ID" value="'
.
$conf
->
global
->
MULTICURRENCY_APP_ID
.
'" size="28" /> '
;
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td>'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_appCurrencySource"
)
.
'</td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_APP_SOURCE">'
;
print
'<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'
.
$conf
->
global
->
MULTICURRENCY_APP_SOURCE
.
'" size="10" placeholder="USD" /> '
;
// Default: USD
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td>'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_alternateCurrencySource"
)
.
'</td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_ALTERNATE_SOURCE">'
;
print
'<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'
.
$conf
->
global
->
MULTICURRENCY_ALTERNATE_SOURCE
.
'" size="10" placeholder="EUR" /> '
;
// Example: EUR
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
if
(
!
empty
(
$conf
->
global
->
MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION
))
{
$var
=
false
;
print
'<table class="noborder" width="100%">'
;
print
'<tr class="liste_titre">'
;
print
'<td>'
.
$langs
->
trans
(
"CurrencyLayerAccount"
)
.
'</td>'
.
"
\n
"
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="100">'
;
print
'<form id="form_sync" action="" method="POST">'
;
print
'<input type="hidden" name="action" value="synchronize" />'
;
print
'<textarea id="response" class="hideobject" name="response"></textarea>'
;
print
$langs
->
trans
(
"Value"
)
.
' <input type="button" id="bt_sync" class="button" onclick="javascript:getRates();" value="'
.
$langs
->
trans
(
'Synchronize'
)
.
'" />'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td><a target="_blank" href="https://currencylayer.com">'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_appId"
)
.
'</a></td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_APP_ID">'
;
print
'<input type="text" name="MULTICURRENCY_APP_ID" value="'
.
$conf
->
global
->
MULTICURRENCY_APP_ID
.
'" size="28" /> '
;
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td>'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_appCurrencySource"
)
.
'</td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_APP_SOURCE">'
;
print
'<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'
.
$conf
->
global
->
MULTICURRENCY_APP_SOURCE
.
'" size="10" placeholder="USD" /> '
;
// Default: USD
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
$var
=!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
'>'
;
print
'<td>'
.
$langs
->
transnoentitiesnoconv
(
"multicurrency_alternateCurrencySource"
)
.
'</td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="400">'
;
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="set_MULTICURRENCY_ALTERNATE_SOURCE">'
;
print
'<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'
.
$conf
->
global
->
MULTICURRENCY_ALTERNATE_SOURCE
.
'" size="10" placeholder="EUR" /> '
;
// Example: EUR
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Modify"
)
.
'">'
;
print
'</form>'
;
print
'</td></tr>'
;
print
'</table>'
;
print
'<br />'
;
}
print
'</table>'
;
print
'<br />'
;
print
'<table class="noborder" width="100%">'
;
...
...
@@ -306,7 +315,8 @@ print '<tr '.$bc[$var].'>';
print
'<form method="POST" action="'
.
$_SERVER
[
'PHP_SELF'
]
.
'">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="add_currency">'
;
print
'<td><input type="text" name="code" value="" size="5" placeholder="'
.
$langs
->
trans
(
'code'
)
.
'" /> - <input type="text" name="name" value="" size="35" placeholder="'
.
$langs
->
trans
(
'name'
)
.
'" /></td>'
;
//print '<td><input type="text" name="code" value="" size="5" placeholder="'.$langs->trans('code').'" /> - <input type="text" name="name" value="" size="35" placeholder="'.$langs->trans('name').'" /></td>';
print
'<td>'
.
$form
->
selectCurrency
(
''
,
'code'
)
.
'</td>'
;
print
'<td align="center" width="20"> </td>'
;
print
'<td align="right" width="300">'
;
print
'<input type="text" name="rate" value="" size="13" placeholder="'
.
$langs
->
trans
(
'rate'
)
.
'" /> '
;
...
...
This diff is collapsed.
Click to expand it.
htdocs/multicurrency/class/multicurrency.class.php
+
23
−
1
View file @
e3a5af6a
...
...
@@ -107,12 +107,19 @@ class MultiCurrency extends CommonObject
*/
public
function
create
(
User
$user
,
$trigger
=
true
)
{
global
$conf
;
global
$conf
,
$langs
;
dol_syslog
(
'Currency::create'
,
LOG_DEBUG
);
$error
=
0
;
if
(
self
::
checkCodeAlreadyExists
(
$this
->
code
))
{
$error
++
;
$this
->
errors
[]
=
$langs
->
trans
(
'multicurrency_code_already_added'
);
return
-
1
;
}
if
(
empty
(
$this
->
entity
)
||
$this
->
entity
<=
0
)
$this
->
entity
=
$conf
->
entity
;
$now
=
date
(
'Y-m-d H:i:s'
);
...
...
@@ -616,6 +623,21 @@ class MultiCurrency extends CommonObject
}
}
}
/**
* Check in database if the current code already exists
*
* @param string $code current code to search
* @return true if exists, false if not exists
*/
public
static
function
checkCodeAlreadyExists
(
$code
)
{
global
$db
;
$currency
=
new
MultiCurrency
(
$db
);
if
(
$currency
->
fetch
(
''
,
$code
)
>
0
)
return
true
;
else
return
false
;
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment