From 70c1ea4ab2ec2a55597e63d4434db5ebd187fc37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2009 18:40:16 +0000 Subject: [PATCH] Fix: Option force invoice date to validation date working correctly --- ChangeLog | 1 + htdocs/compta/facture.php | 9 ++++++++- htdocs/facture.class.php | 13 ++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e11b825c683..9617d2fc240 100644 --- a/ChangeLog +++ b/ChangeLog @@ -61,6 +61,7 @@ For users: - Fix: Validation of order if a file was attached. - Fix: A lot of fixes in PDF generators. - Fix: Bad line/pagebreak with long description of products on PDF. +- Fix: Option force invoice date to validation date working correctly. For translators: - Added 10 more new language files. diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a5cf9fe059e..f1401a7aada 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -298,7 +298,7 @@ if ($_POST['action'] == 'set_ref_client') $facture->set_ref_client($_POST['ref_client']); } -// Classe à "validée" +// Classify to validated if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->valider) { $fac = new Facture($db); @@ -1969,7 +1969,14 @@ else $facref = substr($fac->ref, 1, 4); if ($facref == 'PROV') { + $savdate=$fac->date; + if ($conf->global->FAC_FORCE_DATE_VALIDATION) + { + $fac->date=gmmktime(); + $fac->date_lim_reglement=$fac->calculate_date_lim_reglement(); + } $numfa = $fac->getNextNumRef($soc); + //$fac->date=$savdate; } else { diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 566442f9f61..9dc2a912ac3 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1267,6 +1267,12 @@ class Facture extends CommonObject } else if ($facref == 'PROV') { + $savdate=$this->date; + if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date + { + $this->date=gmmktime(); + $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + } $numfa = $this->getNextNumRef($this->client); } else @@ -1279,13 +1285,10 @@ class Facture extends CommonObject // Validation de la facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql.= " SET facnumber='".$numfa."', fk_statut = 1, fk_user_valid = ".$user->id; - if ($conf->global->FAC_FORCE_DATE_VALIDATION) + if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date { - // Si l'option est activée, on force la date de facture - $this->date=time(); - $datelim=$this->calculate_date_lim_reglement(); $sql.= ', datef='.$this->db->idate($this->date); - $sql.= ', date_lim_reglement='.$this->db->idate($datelim); + $sql.= ', date_lim_reglement='.$this->db->idate($this->date_lim_reglement); } $sql.= ' WHERE rowid = '.$this->id;