Update paiement.class.php

This commit is contained in:
Cédric 2020-09-12 18:49:52 +02:00 committed by GitHub
parent 48e34c2069
commit d728d268ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -278,6 +283,10 @@ class Paiement extends CommonObject
$this->db->begin();
$this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
if (empty($this->ref_ext)) {
$this->ref_ext = '';
}
if ($way == 'dolibarr')
{
@ -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);