From 327a8d0dbc8a2bc56c45a2c3ef1225f370695ab8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Mar 2011 10:59:09 +0000 Subject: [PATCH] Fix: Restore broken feature. Reset of number can not be done if year-month in correct order. --- htdocs/lib/functions2.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 3649d2a48da..abc27c54a21 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -423,10 +423,11 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define reg - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y)+\}\{(m)+\}/i',$maskwithonlyymcode,$reg) && ! preg_match('/^(.*)\{(m)+\}\{(y)+\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y)+\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; + //if ($maskraz > 1 && ! preg_match('/^(.*)\{(y)+\}\{(m)+\}/i',$maskwithonlyymcode,$reg) && ! preg_match('/^(.*)\{(m)+\}\{(y)+\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; //print "x".$maskwithonlyymcode." ".$maskraz; - + // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) $monthcomp=$maskraz; $yearoffset=0;