|
Lines 1-4
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Converted to new plugin style (Bug 13437) |
| 4 |
|
| 2 |
# Copyright 2000-2002 Katipo Communications |
5 |
# Copyright 2000-2002 Katipo Communications |
| 3 |
# Parts copyright 2008-2010 Foundations Bible College |
6 |
# Parts copyright 2008-2010 Foundations Bible College |
| 4 |
# |
7 |
# |
|
Lines 17-37
Link Here
|
| 17 |
# You should have received a copy of the GNU General Public License |
20 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
22 |
|
| 20 |
use strict; |
23 |
use Modern::Perl; |
| 21 |
use warnings; |
|
|
| 22 |
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings |
| 23 |
|
24 |
|
| 24 |
use C4::Context; |
25 |
use C4::Context; |
| 25 |
require C4::Barcodes::ValueBuilder; |
26 |
use C4::Barcodes::ValueBuilder; |
| 26 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
| 27 |
|
28 |
|
| 28 |
use Algorithm::CheckDigits; |
29 |
use Algorithm::CheckDigits; |
| 29 |
|
30 |
|
| 30 |
my $DEBUG = 0; |
31 |
my $DEBUG = 0; |
| 31 |
|
32 |
|
| 32 |
sub plugin_javascript { |
33 |
my $builder = sub { |
| 33 |
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; |
34 |
my ( $params ) = @_; |
| 34 |
my $function_name= "barcode".(int(rand(100000))+1); |
35 |
my $function_name = $params->{id}; |
| 35 |
my %args; |
36 |
my %args; |
| 36 |
|
37 |
|
| 37 |
# find today's date |
38 |
# find today's date |
|
Lines 45-57
sub plugin_javascript {
Link Here
|
| 45 |
warn "Barcode type = $autoBarcodeType" if $DEBUG; |
46 |
warn "Barcode type = $autoBarcodeType" if $DEBUG; |
| 46 |
if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') { |
47 |
if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') { |
| 47 |
# don't return a value unless we have the appropriate syspref set |
48 |
# don't return a value unless we have the appropriate syspref set |
| 48 |
return ($function_name, |
49 |
return q|<script type=\"text/javascript\"></script>|; |
| 49 |
"<script type=\"text/javascript\"> |
|
|
| 50 |
// autoBarcodeType OFF (or not defined) |
| 51 |
function Focus$function_name() { return 0;} |
| 52 |
function Clic$function_name() { return 0;} |
| 53 |
function Blur$function_name() { return 0;} |
| 54 |
</script>"); |
| 55 |
} |
50 |
} |
| 56 |
if ($autoBarcodeType eq 'annual') { |
51 |
if ($autoBarcodeType eq 'annual') { |
| 57 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); |
52 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); |
|
Lines 65-70
sub plugin_javascript {
Link Here
|
| 65 |
elsif ($autoBarcodeType eq 'EAN13') { |
60 |
elsif ($autoBarcodeType eq 'EAN13') { |
| 66 |
# not the best, two catalogers could add the same barcode easily this way :/ |
61 |
# not the best, two catalogers could add the same barcode easily this way :/ |
| 67 |
my $query = "select max(abs(barcode)) from items"; |
62 |
my $query = "select max(abs(barcode)) from items"; |
|
|
63 |
my $dbh = $params->{dbh}; |
| 68 |
my $sth = $dbh->prepare($query); |
64 |
my $sth = $dbh->prepare($query); |
| 69 |
$sth->execute(); |
65 |
$sth->execute(); |
| 70 |
while (my ($last)= $sth->fetchrow_array) { |
66 |
while (my ($last)= $sth->fetchrow_array) { |
|
Lines 88-94
sub plugin_javascript {
Link Here
|
| 88 |
$scr or $scr = <<END_OF_JS; |
84 |
$scr or $scr = <<END_OF_JS; |
| 89 |
if (\$('#' + id).val() == '' || force) { |
85 |
if (\$('#' + id).val() == '' || force) { |
| 90 |
\$('#' + id).val('$nextnum'); |
86 |
\$('#' + id).val('$nextnum'); |
| 91 |
} |
87 |
}; |
| 92 |
END_OF_JS |
88 |
END_OF_JS |
| 93 |
|
89 |
|
| 94 |
my $js = <<END_OF_JS; |
90 |
my $js = <<END_OF_JS; |
|
Lines 100-110
$scr
Link Here
|
| 100 |
return 0; |
96 |
return 0; |
| 101 |
} |
97 |
} |
| 102 |
|
98 |
|
| 103 |
function Clic$function_name(id) { |
99 |
function Click$function_name(id) { |
| 104 |
return Focus$function_name('not_relavent', id, 1); |
100 |
return Focus$function_name('not_relevant', id, 1); |
| 105 |
} |
101 |
} |
| 106 |
//]]> |
102 |
//]]> |
| 107 |
</script> |
103 |
</script> |
| 108 |
END_OF_JS |
104 |
END_OF_JS |
| 109 |
return ($function_name, $js); |
105 |
return $js; |
| 110 |
} |
106 |
}; |
|
|
107 |
|
| 108 |
return { builder => $builder }; |