Allow to fetch a payment by its associated bank line id
This commit is contained in:
parent
17a25ed4a1
commit
f02ba45035
@ -78,11 +78,11 @@ class Paiement extends CommonObject
|
||||
/**
|
||||
* Load payment from database
|
||||
*
|
||||
* @param int $id Id of payment to get
|
||||
* @param int $ref Ref of payment to get (same as $id)
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
* @param int $id Id of payment to get
|
||||
* @param int $fk_bank Id of bank line associated to payment
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
function fetch($id, $ref='')
|
||||
function fetch($id, $fk_bank='')
|
||||
{
|
||||
$sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,';
|
||||
$sql.= ' c.code as type_code, c.libelle as type_libelle,';
|
||||
@ -91,8 +91,8 @@ class Paiement extends CommonObject
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
|
||||
$sql.= ' WHERE p.fk_paiement = c.id';
|
||||
if ($ref)
|
||||
$sql.= ' AND p.rowid = '.$ref;
|
||||
if ($fk_bank)
|
||||
$sql.= ' AND p.fk_bank = '.$fk_bank;
|
||||
else
|
||||
$sql.= ' AND p.rowid = '.$id;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user