Lines 23-40
use Modern::Perl;
Link Here
|
23 |
use CGI qw ( -utf8 ); |
23 |
use CGI qw ( -utf8 ); |
24 |
|
24 |
|
25 |
use C4::Auth; |
25 |
use C4::Auth; |
26 |
use C4::Context; |
|
|
27 |
use C4::Output; |
26 |
use C4::Output; |
|
|
27 |
use Koha::AuthorisedValues; |
28 |
|
28 |
|
29 |
=head1 DESCRIPTION |
29 |
=head1 DESCRIPTION |
30 |
|
30 |
|
31 |
This plugin is based on authorised values INVENTORY. |
31 |
This plugin is based on authorised values INVENTORY. |
32 |
It is used for stocknumber computation. |
32 |
It is used for stocknumber computation. |
33 |
|
33 |
|
34 |
If the user send an empty string, we return a simple incremented stocknumber. |
34 |
If no prefix is submitted, or prefix does not contain only nubers, it returns the inserted code (= keep a field unchanged) |
35 |
If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented. |
35 |
If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented. |
36 |
In this case, a stocknumber has this form : "PREFIX 0009678570". |
36 |
In this case, a stocknumber has this form : "PREFIX 0009678570". |
37 |
- PREFIX is an upercase word |
37 |
- PREFIX contains of letters |
38 |
- a space separator |
38 |
- a space separator |
39 |
- 10 digits, with leading 0s if needed |
39 |
- 10 digits, with leading 0s if needed |
40 |
|
40 |
|
Lines 43-49
In this case, a stocknumber has this form : "PREFIX 0009678570".
Link Here
|
43 |
my $builder = sub { |
43 |
my $builder = sub { |
44 |
my ( $params ) = @_; |
44 |
my ( $params ) = @_; |
45 |
my $res = qq{ |
45 |
my $res = qq{ |
46 |
<script type='text/javascript'> |
46 |
<script> |
47 |
function Click$params->{id}() { |
47 |
function Click$params->{id}() { |
48 |
var code = document.getElementById('$params->{id}'); |
48 |
var code = document.getElementById('$params->{id}'); |
49 |
\$.ajax({ |
49 |
\$.ajax({ |
Lines 81-100
my $launcher = sub {
Link Here
|
81 |
} |
81 |
} |
82 |
); |
82 |
); |
83 |
|
83 |
|
84 |
my $dbh = C4::Context->dbh; |
|
|
85 |
|
86 |
# If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented |
84 |
# If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented |
87 |
$code =~ s/ *$//g; |
85 |
$code =~ s/ *$//g; |
88 |
if ( $code =~ m/^[a-zA-Z]+$/ ) { |
86 |
if ( $code =~ m/^[a-zA-Z]+$/ ) { |
89 |
my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category='INVENTORY' AND authorised_value=?"); |
87 |
my $av = Koha::AuthorisedValues->find({ |
90 |
$sth->execute( $code); |
88 |
'category' => 'INVENTORY', |
91 |
|
89 |
'authorised_value' => $code |
92 |
if ( my $valeur = $sth->fetchrow ) { |
90 |
}); |
93 |
$template->param( return => $code . ' ' . sprintf( '%010s', ( $valeur + 1 ) ), ); |
91 |
if ( $av ) { |
94 |
my $sth2 = $dbh->prepare("UPDATE authorised_values SET lib=? WHERE category='INVENTORY' AND authorised_value=?"); |
92 |
$av->lib($av->lib + 1); |
95 |
$sth2->execute($valeur+1,$code); |
93 |
$av->store; |
|
|
94 |
$template->param( return => $code . ' ' . sprintf( '%010s', ( $av->lib ) ), ); |
96 |
} else { |
95 |
} else { |
97 |
$template->param( return => "There is no defined value for $code"); |
96 |
$template->param( return => "There is no defined value for $code"); |
98 |
} |
97 |
} |
99 |
# The user entered a custom value, we don't touch it, this could be handled in js |
98 |
# The user entered a custom value, we don't touch it, this could be handled in js |
100 |
} else { |
99 |
} else { |
101 |
- |
|
|