From cabd6b8ae23e965752115dfc4f266fa69d83b422 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 4 Jan 2007 19:05:56 +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_diamant.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/modules/propale/mod_propale_diamant.php b/htdocs/includes/modules/propale/mod_propale_diamant.php index b3b69640861..4615a53db37 100644 --- a/htdocs/includes/modules/propale/mod_propale_diamant.php +++ b/htdocs/includes/modules/propale/mod_propale_diamant.php @@ -94,7 +94,12 @@ class mod_propale_diamant extends ModeleNumRefPropales global $db, $conf; // 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}%'"; @@ -103,12 +108,19 @@ class mod_propale_diamant 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; + } } //on vérifie si il y a une année précédente //sinon le delta sera appliqué de nouveau sur la nouvelle année - $lastyy = 'PR'.strftime("%y",mktime(0,0,0,date("m"),date("d"),date("Y")-1)); + $lastyy = 'PR'.$last_year; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref like '${lastyy}%'";