Bug #6057 - Improve finding next stock number
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
8ae5719d16
commit
00354d93bb
1 changed files with 3 additions and 6 deletions
|
@ -53,14 +53,11 @@ sub plugin_javascript {
|
||||||
|
|
||||||
my $branchcode = C4::Context->userenv->{'branch'};
|
my $branchcode = C4::Context->userenv->{'branch'};
|
||||||
|
|
||||||
$query = "SELECT MAX(CAST(SUBSTRING_INDEX(stocknumber,'_',-1) AS SIGNED)) FROM items WHERE homebranch = ?";
|
$query = "SELECT MAX(CAST(SUBSTRING_INDEX(stocknumber,'_',-1) AS SIGNED))+1 FROM items WHERE homebranch = ? AND stocknumber LIKE ?";
|
||||||
my $sth=$dbh->prepare($query);
|
my $sth=$dbh->prepare($query);
|
||||||
$sth->execute($branchcode);
|
|
||||||
while (my ($count)= $sth->fetchrow_array) {
|
|
||||||
$nextnum = $count;
|
|
||||||
}
|
|
||||||
$nextnum++;
|
|
||||||
|
|
||||||
|
$sth->execute($branchcode,$branchcode."_%");
|
||||||
|
my ($nextnum) = $sth->fetchrow;
|
||||||
my $nextnum = $branchcode.'_'.$nextnum;
|
my $nextnum = $branchcode.'_'.$nextnum;
|
||||||
|
|
||||||
my $scr = <<END_OF_JS;
|
my $scr = <<END_OF_JS;
|
||||||
|
|
Loading…
Reference in a new issue