From 3517b640317577580804a8514d3dd3ec136d9d8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 19 Dec 2015 18:18:24 +0100 Subject: [PATCH] FIX #4228 PHP7 error --- .../compta/paiement/class/paiement.class.php | 20 +++++++++---------- htdocs/fourn/class/paiementfourn.class.php | 20 ++++++++++++++----- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 35d0f838ff9..7e94a1f5448 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -29,8 +29,8 @@ 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 { @@ -78,7 +78,7 @@ class Paiement extends CommonObject * @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 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='') { @@ -96,14 +96,12 @@ class Paiement extends CommonObject else if ($fk_bank) $sql.= ' AND p.fk_bank = '.$fk_bank; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $result = $this->db->query($sql); - - if ($result) + $resql = $this->db->query($sql); + if ($resql) { - 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->ref = $obj->ref; $this->date = $this->db->jdate($obj->dp); @@ -120,12 +118,12 @@ class Paiement extends CommonObject $this->fk_account = $obj->fk_account; $this->bank_line = $obj->fk_bank; - $this->db->free($result); + $this->db->free($resql); return 1; } else { - $this->db->free($result); + $this->db->free($resql); return 0; } } diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 5326bbde85e..df122ef1fff 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -65,18 +65,28 @@ class PaiementFourn extends Paiement /** * Load payment object * - * @param int $id Id if payment to get - * @return int <0 if ko, >0 if ok + * @param int $id Id if payment to get + * @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.= ' c.code as paiement_code, c.libelle as paiement_type,'; $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.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $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); if ($resql) { @@ -99,7 +109,7 @@ class PaiementFourn extends Paiement } else { - $error = -2; + $error = -2; // TODO Use 0 instead } $this->db->free($resql); }