Merge pull request #14718 from c3do/patch-12
NEW ref_ext for llx_paiement
This commit is contained in:
commit
7b13730a84
@ -143,6 +143,10 @@ class Paiement extends CommonObject
|
||||
*/
|
||||
public $fk_paiement; // Type of payment
|
||||
|
||||
/**
|
||||
* @var string payment external reference
|
||||
*/
|
||||
public $ref_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -164,7 +168,7 @@ class Paiement extends CommonObject
|
||||
*/
|
||||
public function fetch($id, $ref = '', $fk_bank = '')
|
||||
{
|
||||
$sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,';
|
||||
$sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,';
|
||||
$sql .= ' c.code as type_code, c.libelle as type_label,';
|
||||
$sql .= ' p.num_paiement as num_payment, p.note,';
|
||||
$sql .= ' b.fk_account';
|
||||
@ -187,6 +191,7 @@ class Paiement extends CommonObject
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref ? $obj->ref : $obj->rowid;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->date = $this->db->jdate($obj->dp);
|
||||
$this->datepaye = $this->db->jdate($obj->dp);
|
||||
$this->num_paiement = $obj->num_payment; // deprecated
|
||||
@ -279,6 +284,10 @@ class Paiement extends CommonObject
|
||||
|
||||
$this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
|
||||
|
||||
if (empty($this->ref_ext)) {
|
||||
$this->ref_ext = '';
|
||||
}
|
||||
|
||||
if ($way == 'dolibarr')
|
||||
{
|
||||
$total = $totalamount;
|
||||
@ -291,8 +300,8 @@ class Paiement extends CommonObject
|
||||
$num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
|
||||
$note = ($this->note_public ? $this->note_public : $this->note);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
|
||||
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -297,6 +297,7 @@ abstract class CommonInvoice extends CommonObject
|
||||
$table2 = 'paiement';
|
||||
$field = 'fk_facture';
|
||||
$field2 = 'fk_paiement';
|
||||
$field3=', p.ref_ext';
|
||||
$sharedentity = 'facture';
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
@ -304,10 +305,11 @@ abstract class CommonInvoice extends CommonObject
|
||||
$table2 = 'paiementfourn';
|
||||
$field = 'fk_facturefourn';
|
||||
$field2 = 'fk_paiementfourn';
|
||||
$field3='';
|
||||
$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 = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3;
|
||||
$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';
|
||||
@ -325,7 +327,11 @@ abstract class CommonInvoice extends CommonObject
|
||||
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);
|
||||
$tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
|
||||
if (!empty($field3)) {
|
||||
$tmp['ref_ext'] = $obj->ref_ext;
|
||||
}
|
||||
$retarray[]=$tmp;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
@ -320,3 +320,5 @@ ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL;
|
||||
|
||||
ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL;
|
||||
|
||||
ALTER TABLE llx_paiement ADD COLUMN ref_ext varchar(255) AFTER ref;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ create table llx_paiement
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
ref varchar(30) NULL, -- payment reference number
|
||||
ref_ext varchar(255) NULL, -- payment external reference
|
||||
entity integer DEFAULT 1 NOT NULL, -- Multi company id
|
||||
datec datetime, -- date de creation
|
||||
tms timestamp,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user