From 1330ce6b3f93f60b1d761e9e625317183ea8fa1f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 4 Jan 2007 18:50:30 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20il=20y=20avait=20une=20remise=20=E0=20ze?= =?UTF-8?q?ro=20en=20d=E9but=20d'ann=E9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/propale/mod_propale_ivoire.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/modules/propale/mod_propale_ivoire.php b/htdocs/includes/modules/propale/mod_propale_ivoire.php index ea79dc92d94..834d1ce3643 100644 --- a/htdocs/includes/modules/propale/mod_propale_ivoire.php +++ b/htdocs/includes/modules/propale/mod_propale_ivoire.php @@ -73,7 +73,12 @@ class mod_propale_ivoire extends ModeleNumRefPropales global $db; // D'abord on récupère la valeur max (réponse immédiate car champ indéxé) - $pryy = 'PR'.strftime("%y",time()); + + $current_year = strftime("%y",time()); + $last_year = strftime("%y",mktime(0,0,0,date("m"),date("d"),date("Y")+1)); + + $pryy = 'PR'.$current_year; + $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref like '${pryy}%'"; @@ -82,7 +87,14 @@ class mod_propale_ivoire extends ModeleNumRefPropales { $row = $db->fetch_row($resql); $pryy=''; - if ($row) $pryy = substr($row[0],0,4); + if ($row) + { + $pryy = substr($row[0],0,4); + } + else + { + $pryy = 'PR'.$last_year; + } } // Si au moins un champ respectant le modèle a été trouvée