FIX #4228 PHP7 error

This commit is contained in:
Laurent Destailleur 2015-12-19 18:18:24 +01:00
parent 3b2a921378
commit 3517b64031
2 changed files with 24 additions and 16 deletions

View File

@ -29,8 +29,8 @@
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/** \class Paiement /**
* \brief Classe permettant la gestion des paiements des factures clients * Class to manage payments of customer invoices
*/ */
class Paiement extends CommonObject class Paiement extends CommonObject
{ {
@ -78,7 +78,7 @@ class Paiement extends CommonObject
* @param int $id Id of payment to get * @param int $id Id of payment to get
* @param string $ref Ref of payment to get (currently ref = id but this may change in future) * @param string $ref Ref of payment to get (currently ref = id but this may change in future)
* @param int $fk_bank Id of bank line associated to payment * @param int $fk_bank Id of bank line associated to payment
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
function fetch($id, $ref='', $fk_bank='') function fetch($id, $ref='', $fk_bank='')
{ {
@ -96,14 +96,12 @@ class Paiement extends CommonObject
else if ($fk_bank) else if ($fk_bank)
$sql.= ' AND p.fk_bank = '.$fk_bank; $sql.= ' AND p.fk_bank = '.$fk_bank;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql);
$result = $this->db->query($sql); if ($resql)
if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->date = $this->db->jdate($obj->dp); $this->date = $this->db->jdate($obj->dp);
@ -120,12 +118,12 @@ class Paiement extends CommonObject
$this->fk_account = $obj->fk_account; $this->fk_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank; $this->bank_line = $obj->fk_bank;
$this->db->free($result); $this->db->free($resql);
return 1; return 1;
} }
else else
{ {
$this->db->free($result); $this->db->free($resql);
return 0; return 0;
} }
} }

View File

@ -65,18 +65,28 @@ class PaiementFourn extends Paiement
/** /**
* Load payment object * Load payment object
* *
* @param int $id Id if payment to get * @param int $id Id if payment to get
* @return int <0 if ko, >0 if ok * @param string $ref Ref of payment to get (currently ref = id but this may change in future)
* @param int $fk_bank Id of bank line associated to payment
* @return int <0 if KO, -2 if not found, >0 if OK
*/ */
function fetch($id) function fetch($id, $ref='', $fk_bank='')
{ {
$error=0;
$sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,'; $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,';
$sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' c.code as paiement_code, c.libelle as paiement_type,';
$sql.= ' p.num_paiement, p.note, b.fk_account'; $sql.= ' p.num_paiement, p.note, b.fk_account';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
$sql.= ' WHERE p.fk_paiement = c.id'; $sql.= ' WHERE p.fk_paiement = c.id';
$sql.= ' AND p.rowid = '.$id; if ($id > 0)
$sql.= ' AND p.rowid = '.$id;
else if ($ref)
$sql.= ' AND p.rowid = '.$ref;
else if ($fk_bank)
$sql.= ' AND p.fk_bank = '.$fk_bank;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -99,7 +109,7 @@ class PaiementFourn extends Paiement
} }
else else
{ {
$error = -2; $error = -2; // TODO Use 0 instead
} }
$this->db->free($resql); $this->db->free($resql);
} }