dolibarr  17.0.3
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 
501  public static function getIdFromCode($dbs, $code)
502  {
503  global $conf;
504 
505  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE code = '".$dbs->escape($code)."' AND entity = ".((int) $conf->entity);
506 
507  dol_syslog(__METHOD__, LOG_DEBUG);
508  $resql = $dbs->query($sql);
509  if ($resql && $obj = $dbs->fetch_object($resql)) {
510  return $obj->rowid;
511  } else {
512  return 0;
513  }
514  }
515 
526  public static function getIdAndTxFromCode($dbs, $code, $date_document = '')
527  {
528  global $conf;
529 
530  $sql1 = "SELECT m.rowid, mc.rate FROM ".MAIN_DB_PREFIX."multicurrency m";
531 
532  $sql1 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
533  $sql1 .= " WHERE m.code = '".$dbs->escape($code)."'";
534  $sql1 .= " AND m.entity IN (".getEntity('multicurrency').")";
535  $sql2 = '';
536  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) { // Use last known rate compared to document date
537  $tmparray = dol_getdate($date_document);
538  $sql2 .= " AND mc.date_sync <= '".$dbs->idate(dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], true))."'";
539  }
540  $sql3 = " ORDER BY mc.date_sync DESC LIMIT 1";
541 
542  dol_syslog(__METHOD__, LOG_DEBUG);
543  $resql = $dbs->query($sql1.$sql2.$sql3);
544 
545  if ($resql && $obj = $dbs->fetch_object($resql)) {
546  return array($obj->rowid, $obj->rate);
547  } else {
548  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) {
549  $resql = $dbs->query($sql1.$sql3);
550  if ($resql && $obj = $dbs->fetch_object($resql)) {
551  return array($obj->rowid, $obj->rate);
552  }
553  }
554 
555  return array(0, 1);
556  }
557  }
558 
568  public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture')
569  {
570  $multicurrency_tx = self::getInvoiceRate($fk_facture, $table);
571 
572  if ($multicurrency_tx) {
573  if ($way == 'dolibarr') {
574  return price2num($amount * $multicurrency_tx, 'MU');
575  } else {
576  return price2num($amount / $multicurrency_tx, 'MU');
577  }
578  } else {
579  return false;
580  }
581  }
582 
590  public static function getInvoiceRate($fk_facture, $table = 'facture')
591  {
592  global $db;
593 
594  $sql = "SELECT multicurrency_tx FROM ".MAIN_DB_PREFIX.$table." WHERE rowid = ".((int) $fk_facture);
595 
596  dol_syslog(__METHOD__, LOG_DEBUG);
597  $resql = $db->query($sql);
598  if ($resql && ($line = $db->fetch_object($resql))) {
599  return $line->multicurrency_tx;
600  }
601 
602  return false;
603  }
604 
612  public function recalculRates(&$TRate)
613  {
614  global $conf;
615 
616  if ($conf->currency != getDolGlobalString('MULTICURRENCY_APP_SOURCE')) {
617  $alternate_source = 'USD'.$conf->currency;
618  if (!empty($TRate->$alternate_source)) {
619  $coef = $TRate->USDUSD / $TRate->$alternate_source;
620  foreach ($TRate as $attr => &$rate) {
621  $rate *= $coef;
622  }
623 
624  return 1;
625  }
626 
627  return -1; // Alternate souce not found
628  }
629 
630  return 0; // Nothing to do
631  }
632 
640  public function syncRates($key, $addifnotfound = 0)
641  {
642  global $conf, $db, $langs;
643 
644  include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
645 
646  $urlendpoint = 'http://api.currencylayer.com/live?access_key='.$key;
647  $urlendpoint .= '&source=' . (empty($conf->global->MULTICURRENCY_APP_SOURCE) ? 'USD' : $conf->global->MULTICURRENCY_APP_SOURCE);
648 
649  dol_syslog("Call url endpoint ".$urlendpoint);
650 
651  $resget = getURLContent($urlendpoint);
652 
653  if ($resget['content']) {
654  $response = $resget['content'];
655  $response = json_decode($response);
656 
657  if ($response->success) {
658  $TRate = $response->quotes;
659  //$timestamp = $response->timestamp;
660 
661  if ($this->recalculRates($TRate) >= 0) {
662  foreach ($TRate as $currency_code => $rate) {
663  $code = substr($currency_code, 3, 3);
664  $obj = new MultiCurrency($db);
665  if ($obj->fetch(null, $code) > 0) {
666  $obj->updateRate($rate);
667  } elseif ($addifnotfound) {
668  $this->addRateFromDolibarr($code, $rate);
669  }
670  }
671  }
672 
673  return 1;
674  } else {
675  dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING);
676  setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
677 
678  return -1;
679  }
680  }
681  }
682 
689  public function checkCodeAlreadyExists($code)
690  {
691  $currencytmp = new MultiCurrency($this->db);
692  if ($currencytmp->fetch('', $code) > 0) {
693  return true;
694  } else {
695  return false;
696  }
697  }
698 }
699 
700 
705 {
709  public $element = 'multicurrency_rate';
710 
714  public $table_element = 'multicurrency_rate';
715 
719  public $id;
720 
724  public $rate;
725 
729  public $date_sync;
730 
734  public $fk_multicurrency;
735 
739  public $entity;
740 
741 
747  public function __construct(DoliDB $db)
748  {
749  $this->db = $db;
750 
751  return 1;
752  }
753 
761  public function create($fk_multicurrency, $trigger = true)
762  {
763  global $conf, $user;
764 
765  dol_syslog('CurrencyRate::create', LOG_DEBUG);
766 
767  $error = 0;
768  $this->rate = price2num($this->rate);
769  if (empty($this->entity) || $this->entity <= 0) {
770  $this->entity = $conf->entity;
771  }
772  $now = empty($this->date_sync) ? dol_now() : $this->date_sync;
773 
774  // Insert request
775  $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
776  $sql .= ' rate,';
777  $sql .= ' date_sync,';
778  $sql .= ' fk_multicurrency,';
779  $sql .= ' entity';
780  $sql .= ') VALUES (';
781  $sql .= ' '.((float) $this->rate).',';
782  $sql .= " '".$this->db->idate($now)."',";
783  $sql .= " ".((int) $fk_multicurrency).",";
784  $sql .= " ".((int) $this->entity);
785  $sql .= ')';
786 
787  $this->db->begin();
788 
789  dol_syslog(__METHOD__, LOG_DEBUG);
790  $resql = $this->db->query($sql);
791  if (!$resql) {
792  $error++;
793  $this->errors[] = 'Error '.$this->db->lasterror();
794  dol_syslog('CurrencyRate::create '.join(',', $this->errors), LOG_ERR);
795  }
796 
797  if (!$error) {
798  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
799  $this->fk_multicurrency = $fk_multicurrency;
800  $this->date_sync = $now;
801 
802  if ($trigger) {
803  $result = $this->call_trigger('CURRENCYRATE_CREATE', $user);
804  if ($result < 0) {
805  $error++;
806  }
807  }
808  }
809 
810  if ($error) {
811  $this->db->rollback();
812 
813  return -1 * $error;
814  } else {
815  $this->db->commit();
816 
817  return $this->id;
818  }
819  }
820 
827  public function fetch($id)
828  {
829  dol_syslog('CurrencyRate::fetch', LOG_DEBUG);
830 
831  $sql = "SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity";
832  $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." AS cr";
833  $sql .= " WHERE cr.rowid = ".((int) $id);
834 
835  dol_syslog(__METHOD__, LOG_DEBUG);
836  $resql = $this->db->query($sql);
837  if ($resql) {
838  $numrows = $this->db->num_rows($resql);
839  if ($numrows) {
840  $obj = $this->db->fetch_object($resql);
841 
842  $this->id = $obj->rowid;
843  $this->rate = $obj->rate;
844  $this->date_sync = $this->db->jdate($obj->date_sync);
845  $this->fk_multicurrency = $obj->fk_multicurrency;
846  $this->entity = $obj->entity;
847  }
848  $this->db->free($resql);
849 
850  if ($numrows) {
851  return 1;
852  } else {
853  return 0;
854  }
855  } else {
856  $this->errors[] = 'Error '.$this->db->lasterror();
857  dol_syslog('CurrencyRate::fetch '.join(',', $this->errors), LOG_ERR);
858 
859  return -1;
860  }
861  }
862 
869  public function update($trigger = true)
870  {
871  global $user;
872 
873  $error = 0;
874 
875  dol_syslog('CurrencyRate::update', LOG_DEBUG);
876 
877  $this->rate = price2num($this->rate);
878 
879  // Update request
880  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
881  $sql .= "SET rate = ".((float) $this->rate);
882  if (!empty($this->date_sync)) {
883  $sql .= ", date_sync = '".$this->db->idate($this->date_sync)."'";
884  }
885  if (!empty($this->fk_multicurrency)) {
886  $sql .= ', fk_multicurrency = '.((int) $this->fk_multicurrency);
887  }
888  $sql .= " WHERE rowid =".((int) $this->id);
889 
890  $this->db->begin();
891 
892  dol_syslog(__METHOD__, LOG_DEBUG);
893  $resql = $this->db->query($sql);
894  if (!$resql) {
895  $error++;
896  $this->errors[] = 'Error '.$this->db->lasterror();
897  dol_syslog('CurrencyRate::update '.join(',', $this->errors), LOG_ERR);
898  }
899 
900  if (!$error && $trigger) {
901  $result = $this->call_trigger('CURRENCYRATE_MODIFY', $user);
902  if ($result < 0) {
903  $error++;
904  }
905  }
906 
907  // Commit or rollback
908  if ($error) {
909  $this->db->rollback();
910 
911  return -1 * $error;
912  } else {
913  $this->db->commit();
914 
915  return 1;
916  }
917  }
918 
925  public function delete($trigger = true)
926  {
927  global $user;
928 
929  dol_syslog('CurrencyRate::delete', LOG_DEBUG);
930 
931  $error = 0;
932 
933  $this->db->begin();
934 
935  if ($trigger) {
936  $result = $this->call_trigger('CURRENCYRATE_DELETE', $user);
937  if ($result < 0) {
938  $error++;
939  }
940  }
941 
942  if (!$error) {
943  $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
944  $sql .= ' WHERE rowid='.((int) $this->id);
945 
946  dol_syslog(__METHOD__, LOG_DEBUG);
947  $resql = $this->db->query($sql);
948  if (!$resql) {
949  $error++;
950  $this->errors[] = 'Error '.$this->db->lasterror();
951  dol_syslog('CurrencyRate::delete '.join(',', $this->errors), LOG_ERR);
952  }
953  }
954 
955  // Commit or rollback
956  if ($error) {
957  $this->db->rollback();
958 
959  return -1 * $error;
960  } else {
961  $this->db->commit();
962 
963  return 1;
964  }
965  }
966 }
db
$conf db
API class for accounts.
Definition: inc.php:41
CurrencyRate\fetch
fetch($id)
Load object in memory from the database.
Definition: multicurrency.class.php:827
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:761
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:612
name
$conf db name
Definition: repair.php:122
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:44
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:5823
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
$resql
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.
Definition: index.php:745
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
User
Class to manage Dolibarr users.
Definition: user.class.php:46
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2951
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:869
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5818
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8466
CurrencyRate
Class CurrencyRate.
Definition: multicurrency.class.php:704
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:747
MultiCurrency\checkCodeAlreadyExists
checkCodeAlreadyExists($code)
Check in database if the current code already exists.
Definition: multicurrency.class.php:689