Fix method getListOfPayments in the wrong class
This commit is contained in:
parent
41638e6dff
commit
4866d63ece
@ -3219,62 +3219,6 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return list of payments
|
|
||||||
*
|
|
||||||
* @param string $filtertype 1 to filter on type of payment == 'PRE'
|
|
||||||
* @return array Array with list of payments
|
|
||||||
*/
|
|
||||||
function getListOfPayments($filtertype='')
|
|
||||||
{
|
|
||||||
$retarray=array();
|
|
||||||
|
|
||||||
$table='paiement_facture';
|
|
||||||
$table2='paiement';
|
|
||||||
$field='fk_facture';
|
|
||||||
$field2='fk_paiement';
|
|
||||||
$sharedentity='facture';
|
|
||||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
|
||||||
{
|
|
||||||
$table='paiementfourn_facturefourn';
|
|
||||||
$table2='paiementfourn';
|
|
||||||
$field='fk_facturefourn';
|
|
||||||
$field2='fk_paiementfourn';
|
|
||||||
$sharedentity='facture_fourn';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
|
|
||||||
$sql.= ' WHERE pf.'.$field.' = '.$this->id;
|
|
||||||
//$sql.= ' WHERE pf.'.$field.' = 1';
|
|
||||||
$sql.= ' AND pf.'.$field2.' = p.rowid';
|
|
||||||
$sql.= ' AND p.fk_paiement = t.id';
|
|
||||||
$sql.= ' AND p.entity IN (' . getEntity($sharedentity).')';
|
|
||||||
if ($filtertype) $sql.=" AND t.code='PRE'";
|
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
$i=0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$this->db->free($resql);
|
|
||||||
return $retarray;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->lasterror();
|
|
||||||
dol_print_error($this->db);
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next reference of customer invoice not already used (or last reference)
|
* Return next reference of customer invoice not already used (or last reference)
|
||||||
|
|||||||
@ -274,6 +274,63 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of payments
|
||||||
|
*
|
||||||
|
* @param string $filtertype 1 to filter on type of payment == 'PRE'
|
||||||
|
* @return array Array with list of payments
|
||||||
|
*/
|
||||||
|
function getListOfPayments($filtertype='')
|
||||||
|
{
|
||||||
|
$retarray=array();
|
||||||
|
|
||||||
|
$table='paiement_facture';
|
||||||
|
$table2='paiement';
|
||||||
|
$field='fk_facture';
|
||||||
|
$field2='fk_paiement';
|
||||||
|
$sharedentity='facture';
|
||||||
|
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||||
|
{
|
||||||
|
$table='paiementfourn_facturefourn';
|
||||||
|
$table2='paiementfourn';
|
||||||
|
$field='fk_facturefourn';
|
||||||
|
$field2='fk_paiementfourn';
|
||||||
|
$sharedentity='facture_fourn';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
|
||||||
|
$sql.= ' WHERE pf.'.$field.' = '.$this->id;
|
||||||
|
//$sql.= ' WHERE pf.'.$field.' = 1';
|
||||||
|
$sql.= ' AND pf.'.$field2.' = p.rowid';
|
||||||
|
$sql.= ' AND p.fk_paiement = t.id';
|
||||||
|
$sql.= ' AND p.entity IN (' . getEntity($sharedentity).')';
|
||||||
|
if ($filtertype) $sql.=" AND t.code='PRE'";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$i=0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
return $retarray;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if an invoice can be deleted
|
* Return if an invoice can be deleted
|
||||||
* Rule is:
|
* Rule is:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user