29include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
50 $this->numero = 40000;
52 $this->rights_class =
'multicurrency';
56 $this->family =
"technic";
58 $this->module_position =
'40';
61 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
63 $this->
description =
"Module to manage several foreign currencies in prices and documents";
66 $this->version =
'dolibarr';
68 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
72 $this->picto =
'multicurrency';
78 $this->module_parts = array();
82 $this->dirs = array();
85 $this->config_page_url = array(
"multicurrency.php");
88 $this->hidden =
false;
89 $this->depends = array();
90 $this->requiredby = array();
91 $this->conflictwith = array();
92 $this->langfiles = array(
"multicurrency");
99 $this->
const = array();
125 $this->tabs = array();
128 if (!isset(
$conf->multicurrency->enabled)) {
130 $conf->multicurrency->enabled = 0;
132 $this->dictionaries = array();
137 $this->boxes = array();
143 $datestart=
dol_mktime(21, 15, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
144 $langs->load(
'multicurrency');
146 $this->cronjobs = array(
149 'label' => $langs->trans(
'MutltiCurrencyAutoUpdateCurrencies'),
150 'jobtype' =>
'method',
151 'class' =>
'multicurrency/class/multicurrency.class.php',
152 'objectname' =>
'MultiCurrency',
153 'method' =>
'syncRates',
154 'parameters' =>
'0,0,cron',
155 'comment' =>
'Update all the currencies using the currencylayer API. An API key needs to be given in the multi-currency module config page to have this job working.<br>First param is not used, Second parameter is 0 to update only already existing currency defined into the Multicurrency module or 1 to add any currency. Third parameter must be "cron".',
157 'unitfrequency' => 604800,
158 'status' => $statusatinstall,
159 'test' =>
'isModEnabled("cron")',
160 'datestart' => $datestart
165 $this->rights = array();
177 $this->rights[$r][0] = 40001;
178 $this->rights[$r][1] =
'Read currencies and their rates';
179 $this->rights[$r][2] =
'r';
180 $this->rights[$r][3] = 1;
181 $this->rights[$r][4] =
'currency';
182 $this->rights[$r][5] =
'read';
185 $this->rights[$r][0] = 40002;
186 $this->rights[$r][1] =
'Create/Update currencies and their rates';
187 $this->rights[$r][2] =
'w';
188 $this->rights[$r][3] = 0;
189 $this->rights[$r][4] =
'currency';
190 $this->rights[$r][5] =
'write';
193 $this->rights[$r][0] = 40003;
194 $this->rights[$r][1] =
'Delete currencies and their rates';
195 $this->rights[$r][2] =
'w';
196 $this->rights[$r][3] = 0;
197 $this->rights[$r][4] =
'currency';
198 $this->rights[$r][5] =
'delete';
202 $this->menu = array();
258 public function init($options =
'')
262 $res = $this->
_init($sql, $options);
279 public function remove($options =
'')
283 return $this->
_remove($sql, $options);
294 global
$conf, $user, $langs;
298 if (! $multicurrency->checkCodeAlreadyExists(
$conf->currency)) {
299 $langs->loadCacheCurrencies(
'');
301 $multicurrency->code =
$conf->currency;
302 $multicurrency->name = $langs->cache_currencies[
$conf->currency][
'label'].
' ('.$langs->getCurrencySymbol(
$conf->currency).
')';
303 $r = $multicurrency->create($user);
306 $multicurrency->addRate(1);
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Description and activation class for module MyModule.
init($options='')
Function called when module is enabled.
createFirstCurrency()
Function called when module is enabled Create the currency from general setting.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_now($mode='auto')
Return date for now.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.