From 5d81b0271d6a6eedae203ddaaefcf6c598aaa16c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 6 Sep 2019 11:40:26 +0200 Subject: [PATCH] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 131f0ee90fd..73323235448 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2136,6 +2136,8 @@ class Facture extends CommonInvoice if ($this->paye != 1) { $this->db->begin(); + + $now=dol_now(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); @@ -2144,6 +2146,8 @@ class Facture extends CommonInvoice if (! $close_code) $sql.= ', paye=1'; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; + $sql.= ', fk_user_cloture = '.$user->id; + $sql.= ", date_cloture = '".$this->db->idate($now)."'"; $sql.= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); @@ -2196,6 +2200,8 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; + $sql.= ' date_cloture as datecloture,'; + $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture'; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); @@ -3521,7 +3527,8 @@ class Facture extends CommonInvoice public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql.= ' fk_user_author, fk_user_valid'; + $sql.= ' date_cloture as datecloture,'; + $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; $sql.= ' WHERE c.rowid = '.$id; @@ -3536,7 +3543,7 @@ class Facture extends CommonInvoice { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -3544,9 +3551,17 @@ class Facture extends CommonInvoice $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_cloture = $this->db->jdate($obj->datecloture); } $this->db->free($result); }