Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
05d71122
Commit
05d71122
authored
14 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Fix: bad commit
parent
23d96f6d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/lib/functions2.lib.php
+25
-12
25 additions, 12 deletions
htdocs/lib/functions2.lib.php
with
25 additions
and
12 deletions
htdocs/lib/functions2.lib.php
+
25
−
12
View file @
05d71122
...
...
@@ -422,33 +422,46 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
{
if
(
$maskraz
>
12
)
return
'ErrorBadMaskBadRazMonth'
;
// Define reg
if
(
$maskraz
>
1
&&
!
preg_match
(
'/^(.*)\{(m+)\}\{(y+)\}/i'
,
$maskwithonlyymcode
,
$reg
)
&&
!
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 posy, posm and reg
if
(
$maskraz
>
1
)
{
if
(
!
preg_match
(
'/^(.*)\{(y+)\}\{(m+)\}/i'
,
$maskwithonlyymcode
)
&&
!
preg_match
(
'/^(.*)\{(m+)\}\{(y+)\}/i'
,
$maskwithonlyymcode
))
return
'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'
;
if
(
preg_match
(
'/^(.*)\{(y+)\}\{(m+)\}/i'
,
$maskwithonlyymcode
,
$reg
))
{
$posy
=
2
;
$posm
=
3
;
}
elseif
(
preg_match
(
'/^(.*)\{(m+)\}\{(y+)\}/i'
,
$maskwithonlyymcode
,
$reg
))
{
$posy
=
3
;
$posm
=
2
;
}
if
(
dol_strlen
(
$reg
[
$posy
])
<
2
)
return
'ErrorCantUseRazWithYearOnOneDigit'
;
}
else
{
if
(
!
preg_match
(
'/^(.*)\{(y+)\}/i'
,
$maskwithonlyymcode
))
return
'ErrorCantUseRazIfNoYearInMask'
;
if
(
preg_match
(
'/^(.*)\{(y+)\}/i'
,
$maskwithonlyymcode
,
$reg
))
{
$posy
=
2
;
$posm
=
0
;
}
}
//print "x".$maskwithonlyymcode." ".$maskraz." ".$posy." ".$posm;
// Define $yearcomp and $monthcomp (that will be use in the select where to search max number)
$monthcomp
=
$maskraz
;
$yearoffset
=
0
;
$yearcomp
=
0
;
if
(
date
(
"m"
,
$date
)
<
$maskraz
)
{
$yearoffset
=-
1
;
}
// If current month lower that month of return to zero, year is previous year
if
(
dol_strlen
(
$reg
[
2
])
==
4
)
$yearcomp
=
sprintf
(
"%04d"
,
date
(
"Y"
,
$date
)
+
$yearoffset
);
if
(
dol_strlen
(
$reg
[
2
])
==
2
)
$yearcomp
=
sprintf
(
"%02d"
,
date
(
"y"
,
$date
)
+
$yearoffset
);
if
(
dol_strlen
(
$reg
[
2
])
==
1
)
$yearcomp
=
substr
(
date
(
"y"
,
$date
),
2
,
1
)
+
$yearoffset
;
if
(
dol_strlen
(
$reg
[
$posy
])
==
4
)
$yearcomp
=
sprintf
(
"%04d"
,
date
(
"Y"
,
$date
)
+
$yearoffset
);
if
(
dol_strlen
(
$reg
[
$posy
])
==
2
)
$yearcomp
=
sprintf
(
"%02d"
,
date
(
"y"
,
$date
)
+
$yearoffset
);
if
(
dol_strlen
(
$reg
[
$posy
])
==
1
)
$yearcomp
=
substr
(
date
(
"y"
,
$date
),
2
,
1
)
+
$yearoffset
;
$sqlwhere
=
''
;
$sqlwhere
.
=
'( (SUBSTRING('
.
$field
.
', '
.
(
dol_strlen
(
$reg
[
1
])
+
1
)
.
', '
.
dol_strlen
(
$reg
[
2
])
.
') >= '
.
$yearcomp
;
if
(
$monthcomp
>
1
)
// Test useless if monthcomp = 1 (or 0 is same as 1)
{
$sqlwhere
.
=
' AND SUBSTRING('
.
$field
.
', '
.
(
dol_strlen
(
$reg
[
1
])
+
dol_strlen
(
$reg
[
2
])
+
1
)
.
', '
.
dol_strlen
(
$reg
[
3
])
.
') >= '
.
$monthcomp
.
')'
;
$sqlwhere
.
=
' OR SUBSTRING('
.
$field
.
', '
.
(
dol_strlen
(
$reg
[
1
])
+
1
)
.
', '
.
dol_strlen
(
$reg
[
2
])
.
') >= '
.
sprintf
(
"%02d"
,(
$yearcomp
+
1
))
.
' )'
;
if
(
dol_strlen
(
$reg
[
$posy
])
==
4
)
$yearcomp1
=
sprintf
(
"%04d"
,
date
(
"Y"
,
$date
)
+
$yearoffset
+
1
);
if
(
dol_strlen
(
$reg
[
$posy
])
==
2
)
$yearcomp1
=
sprintf
(
"%02d"
,
date
(
"y"
,
$date
)
+
$yearoffset
+
1
);
// FIXME If mask is {mm}{yy}, sqlwhere is wrong here
$sqlwhere
.
=
' AND SUBSTRING('
.
$field
.
', '
.
(
dol_strlen
(
$reg
[
1
])
+
dol_strlen
(
$reg
[
2
])
+
1
)
.
', '
.
dol_strlen
(
$reg
[
3
])
.
') >= '
.
$monthcomp
.
')'
;
$sqlwhere
.
=
' OR SUBSTRING('
.
$field
.
', '
.
(
dol_strlen
(
$reg
[
1
])
+
1
)
.
', '
.
dol_strlen
(
$reg
[
2
])
.
') >= '
.
$yearcomp1
.
' )'
;
}
else
{
$sqlwhere
.
=
') )'
;
}
}
//print $sqlwhere;
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset." yearcomp=".$yearcomp."<br>\n";
// Define $sqlstring
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment