Bug 25858: Use bitwise OR for setting a bit in borrowers.flag
[koha.git] / cataloguing / value_builder / barcode_manual.pl
blob1167c7fbc8580a4275e52bf77852828faac607d3
1 #!/usr/bin/perl
3 # Converted to new plugin style (Bug 13437)
5 # Copyright 2000-2002 Katipo Communications
6 # Parts copyright 2008-2010 Foundations Bible College
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Modern::Perl;
25 use C4::Context;
26 use C4::Barcodes::ValueBuilder;
27 use C4::Biblio qw/GetMarcFromKohaField/;
28 use Koha::DateUtils;
30 my $DEBUG = 0;
32 my $builder = sub {
33 my ( $params ) = @_;
34 my $function_name = $params->{id};
35 my %args;
37 my $dbh = $params->{dbh};
38 $args{dbh} = $dbh;
40 # find today's date
41 ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }));
42 ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" );
43 ($args{loctag},$args{locsubfield}) = GetMarcFromKohaField( "items.homebranch" );
45 my $nextnum;
46 my $scr;
47 my $autoBarcodeType = C4::Context->preference("autoBarcode");
48 warn "Barcode type = $autoBarcodeType" if $DEBUG;
49 if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') {
50 # don't return a value unless we have the appropriate syspref set
51 return q|<script type=\"text/javascript\"></script>|;
53 if ($autoBarcodeType eq 'annual') {
54 ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
56 elsif ($autoBarcodeType eq 'incremental') {
57 ($nextnum, $scr) = C4::Barcodes::ValueBuilder::incremental::get_barcode(\%args);
59 elsif ($autoBarcodeType eq 'hbyymmincr') { # Generates a barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, reset yearly -fbcit
60 ($nextnum, $scr) = C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode(\%args);
63 # default js body (if not filled by hbyymmincr)
64 $scr or $scr = <<END_OF_JS;
65 if (\$('#' + id).val() == '') {
66 \$('#' + id).val('$nextnum');
68 END_OF_JS
70 my $js = <<END_OF_JS;
71 <script type="text/javascript">
72 //<![CDATA[
74 function Click$function_name(id) {
75 $scr
76 return false;
78 //]]>
79 </script>
80 END_OF_JS
81 return $js;
84 return { builder => $builder };