Fix logs
This commit is contained in:
parent
3c572c1909
commit
1c01972bfe
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
@ -29,6 +29,7 @@
|
|||||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
|
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Currency
|
* Class Currency
|
||||||
*
|
*
|
||||||
@ -92,6 +93,7 @@ class MultiCurrency extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $rate;
|
public $rate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -99,7 +101,7 @@ class MultiCurrency extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function __construct(DoliDB $db)
|
public function __construct(DoliDB $db)
|
||||||
{
|
{
|
||||||
$this->db = &$db;
|
$this->db = $db;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -109,14 +111,13 @@ class MultiCurrency extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param User $user User that creates
|
* @param User $user User that creates
|
||||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||||
*
|
|
||||||
* @return int <0 if KO, Id of created object if OK
|
* @return int <0 if KO, Id of created object if OK
|
||||||
*/
|
*/
|
||||||
public function create(User $user, $trigger = true)
|
public function create(User $user, $trigger = true)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
dol_syslog('Currency::create', LOG_DEBUG);
|
dol_syslog('MultiCurrency::create', LOG_DEBUG);
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ class MultiCurrency extends CommonObject
|
|||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog('Currency::create ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog('MultiCurrency::create ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
@ -182,12 +183,11 @@ class MultiCurrency extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
* @param string $code code
|
* @param string $code code
|
||||||
*
|
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetch($id, $code = null)
|
public function fetch($id, $code = null)
|
||||||
{
|
{
|
||||||
dol_syslog('Currency::fetch', LOG_DEBUG);
|
dol_syslog('MultiCurrency::fetch', LOG_DEBUG);
|
||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ class MultiCurrency extends CommonObject
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog('MultiCurrency::fetch ' . join(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ class MultiCurrency extends CommonObject
|
|||||||
return $num;
|
return $num;
|
||||||
} else {
|
} else {
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog('Currency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog('MultiCurrency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
@ -271,14 +271,13 @@ class MultiCurrency extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param User $user User that modifies
|
* @param User $user User that modifies
|
||||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||||
*
|
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function update(User $user, $trigger = true)
|
public function update(User $user, $trigger = true)
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
dol_syslog('Currency::update', LOG_DEBUG);
|
dol_syslog('MultiCurrency::update', LOG_DEBUG);
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->name = trim($this->name);
|
$this->name = trim($this->name);
|
||||||
@ -287,7 +286,7 @@ class MultiCurrency extends CommonObject
|
|||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($this->code)) {
|
if (empty($this->code)) {
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog('Currency::update $this->code can not be empty', LOG_ERR);
|
dol_syslog('MultiCurrency::update $this->code can not be empty', LOG_ERR);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -298,14 +297,13 @@ class MultiCurrency extends CommonObject
|
|||||||
$sql .= ' code=\''.$this->db->escape($this->code).'\'';
|
$sql .= ' code=\''.$this->db->escape($this->code).'\'';
|
||||||
$sql .= ' WHERE rowid=' . $this->id;
|
$sql .= ' WHERE rowid=' . $this->id;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog('Currency::update ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog('MultiCurrency::update ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && $trigger) {
|
if (!$error && $trigger) {
|
||||||
@ -329,14 +327,13 @@ class MultiCurrency extends CommonObject
|
|||||||
* Delete object in database
|
* Delete object in database
|
||||||
*
|
*
|
||||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||||
*
|
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function delete($trigger = true)
|
public function delete($trigger = true)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
dol_syslog('Currency::delete', LOG_DEBUG);
|
dol_syslog('MultiCurrency::delete', LOG_DEBUG);
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -363,7 +360,7 @@ class MultiCurrency extends CommonObject
|
|||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog('MultiCurrency::delete ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,16 +395,15 @@ class MultiCurrency extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete rate in database
|
* Add a Rate into database
|
||||||
*
|
*
|
||||||
* @param double $rate rate value
|
* @param double $rate rate value
|
||||||
*
|
|
||||||
* @return int -1 if KO, 1 if OK
|
* @return int -1 if KO, 1 if OK
|
||||||
*/
|
*/
|
||||||
public function addRate($rate)
|
public function addRate($rate)
|
||||||
{
|
{
|
||||||
$currencyRate = new CurrencyRate($this->db);
|
$currencyRate = new CurrencyRate($this->db);
|
||||||
$currencyRate->rate = $rate;
|
$currencyRate->rate = price2num($rate);
|
||||||
|
|
||||||
if ($currencyRate->create($this->id) > 0)
|
if ($currencyRate->create($this->id) > 0)
|
||||||
{
|
{
|
||||||
@ -427,7 +423,6 @@ class MultiCurrency extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $code currency code
|
* @param string $code currency code
|
||||||
* @param double $rate new rate
|
* @param double $rate new rate
|
||||||
*
|
|
||||||
* @return int -1 if KO, 1 if OK, 2 if label found and OK
|
* @return int -1 if KO, 1 if OK, 2 if label found and OK
|
||||||
*/
|
*/
|
||||||
public function addRateFromDolibarr($code, $rate)
|
public function addRateFromDolibarr($code, $rate)
|
||||||
@ -459,10 +454,9 @@ class MultiCurrency extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add new entry into llx_multicurrency_rate to historise
|
* Add new entry into llx_multicurrency_rate
|
||||||
*
|
*
|
||||||
* @param double $rate rate value
|
* @param double $rate rate value
|
||||||
*
|
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function updateRate($rate)
|
public function updateRate($rate)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user