dolibarr  18.0.0-beta
multicurrency.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
6  * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Put here all includes required by your class file
29 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
31 
32 
40 {
44  public $element = 'multicurrency';
45 
49  public $table_element = 'multicurrency';
50 
54  public $table_element_line = "multicurrency_rate";
55 
59  public $rates = array();
60 
64  public $id;
65 
69  public $code;
70 
74  public $name;
75 
79  public $entity;
80 
84  public $date_create;
85 
89  public $fk_user;
90 
94  public $rate;
95 
96 
102  public function __construct(DoliDB $db)
103  {
104  $this->db = $db;
105 
106  return 1;
107  }
108 
116  public function create(User $user, $trigger = true)
117  {
118  global $conf, $langs;
119 
120  dol_syslog('MultiCurrency::create', LOG_DEBUG);
121 
122  $error = 0;
123 
124  if (self::checkCodeAlreadyExists($this->code)) {
125  $error++;
126  $this->errors[] = $langs->trans('multicurrency_code_already_added');
127  return -1;
128  }
129 
130  if (empty($this->entity) || $this->entity <= 0) {
131  $this->entity = $conf->entity;
132  }
133  $now = dol_now();
134 
135  // Insert request
136  $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
137  $sql .= ' code,';
138  $sql .= ' name,';
139  $sql .= ' entity,';
140  $sql .= ' date_create,';
141  $sql .= ' fk_user';
142  $sql .= ') VALUES (';
143  $sql .= " '".$this->db->escape($this->code)."',";
144  $sql .= " '".$this->db->escape($this->name)."',";
145  $sql .= " ".((int) $this->entity).",";
146  $sql .= " '".$this->db->idate($now)."',";
147  $sql .= " ".((int) $user->id);
148  $sql .= ')';
149 
150  $this->db->begin();
151 
152  dol_syslog(__METHOD__, LOG_DEBUG);
153  $resql = $this->db->query($sql);
154  if (!$resql) {
155  $error++;
156  $this->errors[] = 'Error '.$this->db->lasterror();
157  dol_syslog('MultiCurrency::create '.join(',', $this->errors), LOG_ERR);
158  }
159 
160  if (!$error) {
161  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
162  $this->date_create = $now;
163  $this->fk_user = $user->id;
164 
165  if ($trigger) {
166  $result = $this->call_trigger('CURRENCY_CREATE', $user);
167  if ($result < 0) {
168  $error++;
169  }
170  }
171  }
172 
173  if ($error) {
174  $this->db->rollback();
175 
176  return -1 * $error;
177  } else {
178  $this->db->commit();
179 
180  return $this->id;
181  }
182  }
183 
191  public function fetch($id, $code = null)
192  {
193  dol_syslog('MultiCurrency::fetch', LOG_DEBUG);
194 
195  global $conf;
196 
197  $sql = "SELECT";
198  $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user';
199  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS c';
200  if (!empty($code)) {
201  $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity;
202  } else {
203  $sql .= ' WHERE c.rowid = '.((int) $id);
204  }
205 
206  dol_syslog(__METHOD__, LOG_DEBUG);
207  $resql = $this->db->query($sql);
208 
209  if ($resql) {
210  $numrows = $this->db->num_rows($resql);
211  if ($numrows) {
212  $obj = $this->db->fetch_object($resql);
213 
214  $this->id = $obj->rowid;
215  $this->name = $obj->name;
216  $this->code = $obj->code;
217  $this->entity = $obj->entity;
218  $this->date_create = $obj->date_create;
219  $this->fk_user = $obj->fk_user;
220 
221  $this->fetchAllCurrencyRate();
222  $this->getRate();
223  }
224  $this->db->free($resql);
225 
226  if ($numrows) {
227  return 1;
228  } else {
229  return 0;
230  }
231  } else {
232  $this->errors[] = 'Error '.$this->db->lasterror();
233  dol_syslog('MultiCurrency::fetch '.join(',', $this->errors), LOG_ERR);
234 
235  return -1;
236  }
237  }
238 
244  public function fetchAllCurrencyRate()
245  {
246  $sql = "SELECT cr.rowid";
247  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr';
248  $sql .= ' WHERE cr.fk_multicurrency = '.((int) $this->id);
249  $sql .= ' ORDER BY cr.date_sync DESC';
250 
251  $this->rates = array();
252 
253  dol_syslog(__METHOD__, LOG_DEBUG);
254  $resql = $this->db->query($sql);
255  if ($resql) {
256  $num = $this->db->num_rows($resql);
257 
258  while ($obj = $this->db->fetch_object($resql)) {
259  $rate = new CurrencyRate($this->db);
260  $rate->fetch($obj->rowid);
261 
262  $this->rates[] = $rate;
263  }
264  $this->db->free($resql);
265 
266  return $num;
267  } else {
268  $this->errors[] = 'Error '.$this->db->lasterror();
269  dol_syslog('MultiCurrency::fetchAllCurrencyRate '.join(',', $this->errors), LOG_ERR);
270 
271  return -1;
272  }
273  }
274 
282  public function update(User $user, $trigger = true)
283  {
284  $error = 0;
285 
286  dol_syslog('MultiCurrency::update', LOG_DEBUG);
287 
288  // Clean parameters
289  $this->name = trim($this->name);
290  $this->code = trim($this->code);
291 
292  // Check parameters
293  if (empty($this->code)) {
294  $error++;
295  dol_syslog('MultiCurrency::update $this->code can not be empty', LOG_ERR);
296 
297  return -1;
298  }
299 
300  // Update request
301  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
302  $sql .= " name = '".$this->db->escape($this->name)."',";
303  $sql .= " code = '".$this->db->escape($this->code)."'";
304  $sql .= " WHERE rowid = ".((int) $this->id);
305 
306  $this->db->begin();
307 
308  $resql = $this->db->query($sql);
309  if (!$resql) {
310  $error++;
311  $this->errors[] = 'Error '.$this->db->lasterror();
312  dol_syslog('MultiCurrency::update '.join(',', $this->errors), LOG_ERR);
313  }
314 
315  if (!$error && $trigger) {
316  $result = $this->call_trigger('CURRENCY_MODIFY', $user);
317  if ($result < 0) {
318  $error++;
319  }
320  }
321 
322  // Commit or rollback
323  if ($error) {
324  $this->db->rollback();
325 
326  return -1 * $error;
327  } else {
328  $this->db->commit();
329 
330  return 1;
331  }
332  }
333 
340  public function delete($trigger = true)
341  {
342  global $user;
343 
344  dol_syslog('MultiCurrency::delete', LOG_DEBUG);
345 
346  $error = 0;
347 
348  $this->db->begin();
349 
350  if ($trigger) {
351  $result = $this->call_trigger('CURRENCY_DELETE', $user);
352  if ($result < 0) {
353  $error++;
354  }
355  }
356 
357  if (!$error) {
358  // Delete all rates before
359  if (!$this->deleteRates()) {
360  $error++;
361  $this->errors[] = 'Error '.$this->db->lasterror();
362  dol_syslog('Currency::delete '.join(',', $this->errors), LOG_ERR);
363  }
364 
365  $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
366  $sql .= " WHERE rowid = ".((int) $this->id);
367 
368  dol_syslog(__METHOD__, LOG_DEBUG);
369  $resql = $this->db->query($sql);
370  if (!$resql) {
371  $error++;
372  $this->errors[] = 'Error '.$this->db->lasterror();
373  dol_syslog('MultiCurrency::delete '.join(',', $this->errors), LOG_ERR);
374  }
375  }
376 
377  // Commit or rollback
378  if ($error) {
379  $this->db->rollback();
380 
381  return -1 * $error;
382  } else {
383  $this->db->commit();
384 
385  return 1;
386  }
387  }
388 
394  public function deleteRates()
395  {
396  foreach ($this->rates as &$rate) {
397  if ($rate->delete() <= 0) {
398  return false;
399  }
400  }
401 
402  return true;
403  }
404 
411  public function addRate($rate)
412  {
413  $currencyRate = new CurrencyRate($this->db);
414  $currencyRate->rate = price2num($rate);
415 
416  if ($currencyRate->create($this->id) > 0) {
417  $this->rate = $currencyRate;
418  return 1;
419  } else {
420  $this->rate = null;
421  $this->errors = $currencyRate->errors;
422  return -1;
423  }
424  }
425 
433  public function addRateFromDolibarr($code, $rate)
434  {
435  global $user;
436 
437  $currency = new MultiCurrency($this->db);
438  $currency->code = $code;
439  $currency->name = $code;
440 
441  $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'";
442 
443  dol_syslog(__METHOD__, LOG_DEBUG);
444  $resql = $this->db->query($sql);
445  if ($resql && ($line = $this->db->fetch_object($resql))) {
446  $currency->name = $line->label;
447  }
448 
449  if ($currency->create($user) > 0) {
450  $currency->addRate($rate);
451 
452  if (!empty($line)) {
453  return 2;
454  } else {
455  return 1;
456  }
457  }
458 
459  return -1;
460  }
461 
468  public function updateRate($rate)
469  {
470  return $this->addRate($rate);
471  }
472 
478  public function getRate()
479  {
480  $sql = "SELECT cr.rowid";
481  $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line." as cr";
482  $sql .= " WHERE cr.fk_multicurrency = ".((int) $this->id);
483  $sql .= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.$this->table_element_line." AS cr2 WHERE cr2.fk_multicurrency = ".((int) $this->id).")";
484 
485  dol_syslog(__METHOD__, LOG_DEBUG);
486  $resql = $this->db->query($sql);
487  if ($resql && ($obj = $this->db->fetch_object($resql))) {
488  $this->rate = new CurrencyRate($this->db);
489  return $this->rate->fetch($obj->rowid);
490  }
491 
492  return -1;
493  }
494 
503  public static function getIdFromCode($dbs, $code)
504  {
505  global $conf;
506 
507  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE code = '".$dbs->escape($code)."' AND entity = ".((int) $conf->entity);
508 
509  dol_syslog(__METHOD__, LOG_DEBUG);
510  $resql = $dbs->query($sql);
511  if ($resql && $obj = $dbs->fetch_object($resql)) {
512  return $obj->rowid;
513  } else {
514  return 0;
515  }
516  }
517 
528  public static function getIdAndTxFromCode($dbs, $code, $date_document = '')
529  {
530  global $conf;
531 
532  $sql1 = "SELECT m.rowid, mc.rate FROM ".MAIN_DB_PREFIX."multicurrency m";
533 
534  $sql1 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
535  $sql1 .= " WHERE m.code = '".$dbs->escape($code)."'";
536  $sql1 .= " AND m.entity IN (".getEntity('multicurrency').")";
537  $sql2 = '';
538  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) { // Use last known rate compared to document date
539  $tmparray = dol_getdate($date_document);
540  $sql2 .= " AND mc.date_sync <= '".$dbs->idate(dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], true))."'";
541  }
542  $sql3 = " ORDER BY mc.date_sync DESC LIMIT 1";
543 
544  dol_syslog(__METHOD__, LOG_DEBUG);
545  $resql = $dbs->query($sql1.$sql2.$sql3);
546 
547  if ($resql && $obj = $dbs->fetch_object($resql)) {
548  return array($obj->rowid, $obj->rate);
549  } else {
550  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) {
551  $resql = $dbs->query($sql1.$sql3);
552  if ($resql && $obj = $dbs->fetch_object($resql)) {
553  return array($obj->rowid, $obj->rate);
554  }
555  }
556 
557  return array(0, 1);
558  }
559  }
560 
570  public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture')
571  {
572  $multicurrency_tx = self::getInvoiceRate($fk_facture, $table);
573 
574  if ($multicurrency_tx) {
575  if ($way == 'dolibarr') {
576  return price2num($amount * $multicurrency_tx, 'MU');
577  } else {
578  return price2num($amount / $multicurrency_tx, 'MU');
579  }
580  } else {
581  return false;
582  }
583  }
584 
592  public static function getInvoiceRate($fk_facture, $table = 'facture')
593  {
594  global $db;
595 
596  $sql = "SELECT multicurrency_tx FROM ".MAIN_DB_PREFIX.$table." WHERE rowid = ".((int) $fk_facture);
597 
598  dol_syslog(__METHOD__, LOG_DEBUG);
599  $resql = $db->query($sql);
600  if ($resql && ($line = $db->fetch_object($resql))) {
601  return $line->multicurrency_tx;
602  }
603 
604  return false;
605  }
606 
614  public function recalculRates(&$TRate)
615  {
616  global $conf;
617 
618  if ($conf->currency != getDolGlobalString('MULTICURRENCY_APP_SOURCE')) {
619  $alternate_source = 'USD'.$conf->currency;
620  if (!empty($TRate->$alternate_source)) {
621  $coef = $TRate->USDUSD / $TRate->$alternate_source;
622  foreach ($TRate as $attr => &$rate) {
623  $rate *= $coef;
624  }
625 
626  return 1;
627  }
628 
629  return -1; // Alternate souce not found
630  }
631 
632  return 0; // Nothing to do
633  }
634 
642  public function syncRates($key, $addifnotfound = 0)
643  {
644  global $conf, $db, $langs;
645 
646  include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
647 
648  $urlendpoint = 'http://api.currencylayer.com/live?access_key='.$key;
649  $urlendpoint .= '&source=' . (empty($conf->global->MULTICURRENCY_APP_SOURCE) ? 'USD' : $conf->global->MULTICURRENCY_APP_SOURCE);
650 
651  dol_syslog("Call url endpoint ".$urlendpoint);
652 
653  $resget = getURLContent($urlendpoint);
654 
655  if ($resget['content']) {
656  $response = $resget['content'];
657  $response = json_decode($response);
658 
659  if ($response->success) {
660  $TRate = $response->quotes;
661  //$timestamp = $response->timestamp;
662 
663  if ($this->recalculRates($TRate) >= 0) {
664  foreach ($TRate as $currency_code => $rate) {
665  $code = substr($currency_code, 3, 3);
666  $obj = new MultiCurrency($db);
667  if ($obj->fetch(0, $code) > 0) {
668  $obj->updateRate($rate);
669  } elseif ($addifnotfound) {
670  $this->addRateFromDolibarr($code, $rate);
671  }
672  }
673  }
674 
675  return 1;
676  } else {
677  dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING);
678  setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
679 
680  return -1;
681  }
682  } else {
683  return -1;
684  }
685  }
686 
693  public function checkCodeAlreadyExists($code)
694  {
695  $currencytmp = new MultiCurrency($this->db);
696  if ($currencytmp->fetch('', $code) > 0) {
697  return true;
698  } else {
699  return false;
700  }
701  }
702 }
703 
704 
709 {
713  public $element = 'multicurrency_rate';
714 
718  public $table_element = 'multicurrency_rate';
719 
723  public $id;
724 
728  public $rate;
729 
733  public $date_sync;
734 
738  public $fk_multicurrency;
739 
743  public $entity;
744 
745 
751  public function __construct(DoliDB $db)
752  {
753  $this->db = $db;
754 
755  return 1;
756  }
757 
765  public function create($fk_multicurrency, $trigger = true)
766  {
767  global $conf, $user;
768 
769  dol_syslog('CurrencyRate::create', LOG_DEBUG);
770 
771  $error = 0;
772  $this->rate = price2num($this->rate);
773  if (empty($this->entity) || $this->entity <= 0) {
774  $this->entity = $conf->entity;
775  }
776  $now = empty($this->date_sync) ? dol_now() : $this->date_sync;
777 
778  // Insert request
779  $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
780  $sql .= ' rate,';
781  $sql .= ' date_sync,';
782  $sql .= ' fk_multicurrency,';
783  $sql .= ' entity';
784  $sql .= ') VALUES (';
785  $sql .= ' '.((float) $this->rate).',';
786  $sql .= " '".$this->db->idate($now)."',";
787  $sql .= " ".((int) $fk_multicurrency).",";
788  $sql .= " ".((int) $this->entity);
789  $sql .= ')';
790 
791  $this->db->begin();
792 
793  dol_syslog(__METHOD__, LOG_DEBUG);
794  $resql = $this->db->query($sql);
795  if (!$resql) {
796  $error++;
797  $this->errors[] = 'Error '.$this->db->lasterror();
798  dol_syslog('CurrencyRate::create '.join(',', $this->errors), LOG_ERR);
799  }
800 
801  if (!$error) {
802  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
803  $this->fk_multicurrency = $fk_multicurrency;
804  $this->date_sync = $now;
805 
806  if ($trigger) {
807  $result = $this->call_trigger('CURRENCYRATE_CREATE', $user);
808  if ($result < 0) {
809  $error++;
810  }
811  }
812  }
813 
814  if ($error) {
815  $this->db->rollback();
816 
817  return -1 * $error;
818  } else {
819  $this->db->commit();
820 
821  return $this->id;
822  }
823  }
824 
831  public function fetch($id)
832  {
833  dol_syslog('CurrencyRate::fetch', LOG_DEBUG);
834 
835  $sql = "SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity";
836  $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." AS cr";
837  $sql .= " WHERE cr.rowid = ".((int) $id);
838 
839  dol_syslog(__METHOD__, LOG_DEBUG);
840  $resql = $this->db->query($sql);
841  if ($resql) {
842  $numrows = $this->db->num_rows($resql);
843  if ($numrows) {
844  $obj = $this->db->fetch_object($resql);
845 
846  $this->id = $obj->rowid;
847  $this->rate = $obj->rate;
848  $this->date_sync = $this->db->jdate($obj->date_sync);
849  $this->fk_multicurrency = $obj->fk_multicurrency;
850  $this->entity = $obj->entity;
851  }
852  $this->db->free($resql);
853 
854  if ($numrows) {
855  return 1;
856  } else {
857  return 0;
858  }
859  } else {
860  $this->errors[] = 'Error '.$this->db->lasterror();
861  dol_syslog('CurrencyRate::fetch '.join(',', $this->errors), LOG_ERR);
862 
863  return -1;
864  }
865  }
866 
873  public function update($trigger = true)
874  {
875  global $user;
876 
877  $error = 0;
878 
879  dol_syslog('CurrencyRate::update', LOG_DEBUG);
880 
881  $this->rate = price2num($this->rate);
882 
883  // Update request
884  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
885  $sql .= "SET rate = ".((float) $this->rate);
886  if (!empty($this->date_sync)) {
887  $sql .= ", date_sync = '".$this->db->idate($this->date_sync)."'";
888  }
889  if (!empty($this->fk_multicurrency)) {
890  $sql .= ', fk_multicurrency = '.((int) $this->fk_multicurrency);
891  }
892  $sql .= " WHERE rowid =".((int) $this->id);
893 
894  $this->db->begin();
895 
896  dol_syslog(__METHOD__, LOG_DEBUG);
897  $resql = $this->db->query($sql);
898  if (!$resql) {
899  $error++;
900  $this->errors[] = 'Error '.$this->db->lasterror();
901  dol_syslog('CurrencyRate::update '.join(',', $this->errors), LOG_ERR);
902  }
903 
904  if (!$error && $trigger) {
905  $result = $this->call_trigger('CURRENCYRATE_MODIFY', $user);
906  if ($result < 0) {
907  $error++;
908  }
909  }
910 
911  // Commit or rollback
912  if ($error) {
913  $this->db->rollback();
914 
915  return -1 * $error;
916  } else {
917  $this->db->commit();
918 
919  return 1;
920  }
921  }
922 
929  public function delete($trigger = true)
930  {
931  global $user;
932 
933  dol_syslog('CurrencyRate::delete', LOG_DEBUG);
934 
935  $error = 0;
936 
937  $this->db->begin();
938 
939  if ($trigger) {
940  $result = $this->call_trigger('CURRENCYRATE_DELETE', $user);
941  if ($result < 0) {
942  $error++;
943  }
944  }
945 
946  if (!$error) {
947  $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
948  $sql .= ' WHERE rowid='.((int) $this->id);
949 
950  dol_syslog(__METHOD__, LOG_DEBUG);
951  $resql = $this->db->query($sql);
952  if (!$resql) {
953  $error++;
954  $this->errors[] = 'Error '.$this->db->lasterror();
955  dol_syslog('CurrencyRate::delete '.join(',', $this->errors), LOG_ERR);
956  }
957  }
958 
959  // Commit or rollback
960  if ($error) {
961  $this->db->rollback();
962 
963  return -1 * $error;
964  } else {
965  $this->db->commit();
966 
967  return 1;
968  }
969  }
970 }
CurrencyRate\fetch
fetch($id)
Load object in memory from the database.
Definition: multicurrency.class.php:831
MultiCurrency\__construct
__construct(DoliDB $db)
Constructor.
Definition: multicurrency.class.php:102
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
CurrencyRate\create
create($fk_multicurrency, $trigger=true)
Create object into database.
Definition: multicurrency.class.php:765
MultiCurrency\fetchAllCurrencyRate
fetchAllCurrencyRate()
Load all rates in object from the database.
Definition: multicurrency.class.php:244
MultiCurrency\recalculRates
recalculRates(&$TRate)
With free account we can't set source then recalcul all rates to force another source.
Definition: multicurrency.class.php:614
name
$conf db name
Definition: repair.php:123
CommonObjectLine
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Definition: commonobjectline.class.php:32
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
MultiCurrency\addRateFromDolibarr
addRateFromDolibarr($code, $rate)
Try get label of code in llx_currency then add rate.
Definition: multicurrency.class.php:433
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5943
getURLContent
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
Definition: geturl.lib.php:41
MultiCurrency
Class Currency.
Definition: multicurrency.class.php:39
code
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...
Definition: sync_members_ldap2dolibarr.php:60
MultiCurrency\delete
delete($trigger=true)
Delete object in database.
Definition: multicurrency.class.php:340
$sql
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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1732
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8644
User
Class to manage Dolibarr users.
Definition: user.class.php:47
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3046
MultiCurrency\fetch
fetch($id, $code=null)
Load object in memory from the database.
Definition: multicurrency.class.php:191
CurrencyRate\update
update($trigger=true)
Update object into database.
Definition: multicurrency.class.php:873
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5743
CurrencyRate
Class CurrencyRate.
Definition: multicurrency.class.php:708
MultiCurrency\create
create(User $user, $trigger=true)
Create object into database.
Definition: multicurrency.class.php:116
MultiCurrency\update
update(User $user, $trigger=true)
Update object into database.
Definition: multicurrency.class.php:282
CurrencyRate\__construct
__construct(DoliDB $db)
Constructor.
Definition: multicurrency.class.php:751
MultiCurrency\checkCodeAlreadyExists
checkCodeAlreadyExists($code)
Check in database if the current code already exists.
Definition: multicurrency.class.php:693