diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 57032a8eae2..09d3351fb4d 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_closing = '.$user->id; + $sql.= ", date_closing = '".$this->db->idate($now)."'"; $sql.= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); @@ -2195,7 +2199,9 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; + $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,'; + $sql.= ' date_closing=null,'; + $sql.= ' fk_user_closing=null'; $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_closing as dateclosing,'; + $sql.= ' fk_user_author, fk_user_valid, fk_user_closing'; $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_closing) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_closing); + $this->user_closing = $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_closing = $this->db->jdate($obj->dateclosing); } $this->db->free($result); } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 0fe0d00832b..c11d5796109 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -181,6 +181,7 @@ $arrayfields=array( 'rtp'=>array('label'=>"Rest", 'checked'=>0), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); @@ -382,7 +383,7 @@ $sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_publ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; -$sql.= ' f.datec as date_creation, f.tms as date_update,'; +$sql.= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,'; @@ -497,7 +498,7 @@ if (! $sall) $sql.= ' f.localtax1, f.localtax2,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; - $sql.= ' f.datec, f.tms,'; + $sql.= ' f.datec, f.tms, f.date_closing,'; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; $sql.= ' typent.code,'; $sql.= ' state.code_departement, state.nom,'; @@ -866,6 +867,12 @@ if ($resql) print '