View | Details | Raw Unified | Return to bug 26351
Collapse All | Expand All

(-)a/C4/Circulation.pm (-35 / +38 lines)
Lines 19-77 package C4::Circulation; Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
23
use Algorithm::CheckDigits;
24
use Carp;
25
use Data::Dumper;
26
use Date::Calc qw(
27
    Today
28
    Today_and_Now
29
    Add_Delta_YM
30
    Add_Delta_DHMS
31
    Date_to_Days
32
    Day_of_Week
33
    Add_Delta_Days
34
);
22
use DateTime;
35
use DateTime;
36
use List::MoreUtils qw( uniq any );
23
use POSIX qw( floor );
37
use POSIX qw( floor );
24
use Koha::DateUtils;
38
use Scalar::Util qw( looks_like_number );
25
use C4::Context;
39
use Try::Tiny;
26
use C4::Stats;
40
27
use C4::Reserves;
41
use C4::Accounts;
28
use C4::Biblio;
42
use C4::Biblio;
43
use C4::Context;
44
use C4::Debug;
45
use C4::ItemCirculationAlertPreference;
29
use C4::Items;
46
use C4::Items;
47
use C4::Log; # logaction
30
use C4::Members;
48
use C4::Members;
31
use C4::Accounts;
32
use C4::ItemCirculationAlertPreference;
33
use C4::Message;
49
use C4::Message;
34
use C4::Debug;
35
use C4::Log; # logaction
36
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
50
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
51
use C4::Reserves;
37
use C4::RotatingCollections qw(GetCollectionItemBranches);
52
use C4::RotatingCollections qw(GetCollectionItemBranches);
38
use Algorithm::CheckDigits;
53
use C4::Stats;
39
54
40
use Data::Dumper;
55
use Koha::Account::Lines;
56
use Koha::Account::Offsets;
41
use Koha::Account;
57
use Koha::Account;
42
use Koha::AuthorisedValues;
58
use Koha::AuthorisedValues;
43
use Koha::Biblioitems;
59
use Koha::Biblioitems;
44
use Koha::DateUtils;
45
use Koha::Calendar;
60
use Koha::Calendar;
61
use Koha::Charges::Fees;
62
use Koha::Checkouts::ReturnClaims;
46
use Koha::Checkouts;
63
use Koha::Checkouts;
64
use Koha::Config::SysPrefs;
65
use Koha::Database;
66
use Koha::DateUtils;
67
use Koha::Holds;
47
use Koha::Illrequests;
68
use Koha::Illrequests;
48
use Koha::Items;
69
use Koha::Items;
49
use Koha::Patrons;
50
use Koha::Patron::Debarments;
51
use Koha::Database;
52
use Koha::Libraries;
70
use Koha::Libraries;
53
use Koha::Account::Lines;
71
use Koha::Patron::Debarments;
54
use Koha::Holds;
72
use Koha::Patrons;
55
use Koha::Account::Lines;
73
use Koha::Plugins;
56
use Koha::Account::Offsets;
57
use Koha::Config::SysPrefs;
58
use Koha::Charges::Fees;
59
use Koha::Util::SystemPreferences;
60
use Koha::Checkouts::ReturnClaims;
61
use Koha::SearchEngine::Indexer;
74
use Koha::SearchEngine::Indexer;
62
use Carp;
75
use Koha::Util::SystemPreferences;
63
use List::MoreUtils qw( uniq any );
76
64
use Scalar::Util qw( looks_like_number );
65
use Try::Tiny;
66
use Date::Calc qw(
67
  Today
68
  Today_and_Now
69
  Add_Delta_YM
70
  Add_Delta_DHMS
71
  Date_to_Days
72
  Day_of_Week
73
  Add_Delta_Days
74
);
75
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
77
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
76
78
77
BEGIN {
79
BEGIN {
Lines 174-179 sub barcodedecode { Link Here
174
    my ($barcode, $filter) = @_;
176
    my ($barcode, $filter) = @_;
175
    my $branch = C4::Context::mybranch();
177
    my $branch = C4::Context::mybranch();
176
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
178
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
179
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
177
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
180
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
178
	if ($filter eq 'whitespace') {
181
	if ($filter eq 'whitespace') {
179
		$barcode =~ s/\s//g;
182
		$barcode =~ s/\s//g;
(-)a/C4/ILSDI/Services.pm (+2 lines)
Lines 34-39 use CGI qw ( -utf8 ); Link Here
34
use DateTime;
34
use DateTime;
35
use C4::Auth;
35
use C4::Auth;
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Plugins;
37
38
38
use Koha::Biblios;
39
use Koha::Biblios;
39
use Koha::Checkouts;
40
use Koha::Checkouts;
Lines 627-632 sub GetServices { Link Here
627
    # Issuing management
628
    # Issuing management
628
    my $barcode = $item->barcode || '';
629
    my $barcode = $item->barcode || '';
629
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
630
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
631
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
630
    if ($barcode) {
632
    if ($barcode) {
631
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
633
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
632
634
(-)a/C4/Items.pm (+1 lines)
Lines 73-78 use Koha::SearchEngine; Link Here
73
use Koha::SearchEngine::Indexer;
73
use Koha::SearchEngine::Indexer;
74
use Koha::SearchEngine::Search;
74
use Koha::SearchEngine::Search;
75
use Koha::Libraries;
75
use Koha::Libraries;
76
use Koha::Plugins;
76
77
77
=head1 NAME
78
=head1 NAME
78
79
(-)a/Koha/Item.pm (+3 lines)
Lines 89-94 sub store { Link Here
89
        $self->itype($self->biblio->biblioitem->itemtype);
89
        $self->itype($self->biblio->biblioitem->itemtype);
90
    }
90
    }
91
91
92
    my ($transformed_barcode) = Koha::Plugins->call( 'barcode_transform', 'item', $self->barcode ) || $self->barcode;
93
    $self->barcode($transformed_barcode);
94
92
    my $today         = dt_from_string;
95
    my $today         = dt_from_string;
93
    my $plugin_action = 'create';
96
    my $plugin_action = 'create';
94
97
(-)a/cataloguing/additem.pl (+4 lines)
Lines 36-41 use Koha::ItemTypes; Link Here
36
use Koha::Libraries;
36
use Koha::Libraries;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
use Koha::SearchEngine::Indexer;
38
use Koha::SearchEngine::Indexer;
39
use Koha::Plugins;
39
use List::MoreUtils qw/any/;
40
use List::MoreUtils qw/any/;
40
use C4::Search;
41
use C4::Search;
41
use Storable qw(thaw freeze);
42
use Storable qw(thaw freeze);
Lines 516-521 if ($op eq "additem") { Link Here
516
517
517
    my $addedolditem = TransformMarcToKoha( $record );
518
    my $addedolditem = TransformMarcToKoha( $record );
518
519
520
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $addedolditem->{'barcode'} ) || $addedolditem->{'barcode'};
521
    $addedolditem->{'barcode'} = $new_barcode;
522
519
    # If we have to add or add & duplicate, we add the item
523
    # If we have to add or add & duplicate, we add the item
520
    if ( $add_submit || $add_duplicate_submit ) {
524
    if ( $add_submit || $add_duplicate_submit ) {
521
525
(-)a/circ/circulation.pl (+2 lines)
Lines 46-51 use Koha::AuthorisedValues; Link Here
46
use Koha::CsvProfiles;
46
use Koha::CsvProfiles;
47
use Koha::Patrons;
47
use Koha::Patrons;
48
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::Patron::Debarments qw(GetDebarments);
49
use Koha::Plugins;
49
use Koha::DateUtils;
50
use Koha::DateUtils;
50
use Koha::Database;
51
use Koha::Database;
51
use Koha::BiblioFrameworks;
52
use Koha::BiblioFrameworks;
Lines 165-170 for my $barcode ( @$barcodes ) { Link Here
165
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
166
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
166
    $barcode = barcodedecode($barcode)
167
    $barcode = barcodedecode($barcode)
167
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
168
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
169
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
168
}
170
}
169
171
170
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
172
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
(-)a/circ/returns.pl (+3 lines)
Lines 56-61 use Koha::DateUtils; Link Here
56
use Koha::Holds;
56
use Koha::Holds;
57
use Koha::Items;
57
use Koha::Items;
58
use Koha::Patrons;
58
use Koha::Patrons;
59
use Koha::Plugins;
59
60
60
my $query = CGI->new;
61
my $query = CGI->new;
61
62
Lines 114-119 foreach ( $query->param ) { Link Here
114
115
115
    # decode barcode    ## Didn't we already decode them before passing them back last time??
116
    # decode barcode    ## Didn't we already decode them before passing them back last time??
116
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
117
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
118
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
117
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
119
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
118
120
119
    ######################
121
    ######################
Lines 243-248 if ($canceltransfer){ Link Here
243
my $returnbranch;
245
my $returnbranch;
244
if ($barcode) {
246
if ($barcode) {
245
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
247
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
248
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
246
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
249
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
247
    my $item = Koha::Items->find({ barcode => $barcode });
250
    my $item = Koha::Items->find({ barcode => $barcode });
248
251
(-)a/offline_circ/process_koc.pl (+9 lines)
Lines 38-43 use Koha::UploadedFiles; Link Here
38
use Koha::Account;
38
use Koha::Account;
39
use Koha::Checkouts;
39
use Koha::Checkouts;
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::Plugins;
41
42
42
use Date::Calc qw( Add_Delta_Days Date_to_Days );
43
use Date::Calc qw( Add_Delta_Days Date_to_Days );
43
44
Lines 246-251 sub kocIssueItem { Link Here
246
    my $circ = shift;
247
    my $circ = shift;
247
248
248
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
249
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
250
251
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} ) || $circ->{barcode};
252
    $circ->{barcode} = $new_barcode;
253
249
    my $branchcode = C4::Context->userenv->{branch};
254
    my $branchcode = C4::Context->userenv->{branch};
250
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
255
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
251
    my $borrower = $patron->unblessed;
256
    my $borrower = $patron->unblessed;
Lines 326-331 sub kocIssueItem { Link Here
326
sub kocReturnItem {
331
sub kocReturnItem {
327
    my ( $circ ) = @_;
332
    my ( $circ ) = @_;
328
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
333
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
334
335
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} ) || $circ->{barcode};
336
    $circ->{barcode} = $new_barcode;
337
329
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
338
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
330
    my $biblio = $item->biblio;
339
    my $biblio = $item->biblio;
331
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
340
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
(-)a/opac/sco/sco-main.pl (+3 lines)
Lines 49-54 use Koha::Items; Link Here
49
use Koha::Patrons;
49
use Koha::Patrons;
50
use Koha::Patron::Images;
50
use Koha::Patron::Images;
51
use Koha::Patron::Messages;
51
use Koha::Patron::Messages;
52
use Koha::Plugins;
52
use Koha::Token;
53
use Koha::Token;
53
54
54
my $query = CGI->new;
55
my $query = CGI->new;
Lines 109-114 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = Link Here
109
    $query->param("newissues")  || '',
110
    $query->param("newissues")  || '',
110
);
111
);
111
112
113
( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
114
112
my @newissueslist = split /,/, $newissues;
115
my @newissueslist = split /,/, $newissues;
113
my $issuenoconfirm = 1; #don't need to confirm on issue.
116
my $issuenoconfirm = 1; #don't need to confirm on issue.
114
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
117
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-1 / +3 lines)
Lines 25-31 use File::Temp qw( tempdir tempfile ); Link Here
25
use FindBin qw($Bin);
25
use FindBin qw($Bin);
26
use Module::Load::Conditional qw(can_load);
26
use Module::Load::Conditional qw(can_load);
27
use Test::MockModule;
27
use Test::MockModule;
28
use Test::More tests => 53;
28
use Test::More tests => 55;
29
29
30
use C4::Context;
30
use C4::Context;
31
use Koha::Database;
31
use Koha::Database;
Lines 181-186 ok( $plugin->can('opac_head'), 'Test plugin can opac_head' ); Link Here
181
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
181
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
182
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
182
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
183
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
183
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
184
ok( $plugin->can('barcode_transform'), 'Test plugin can barcode_transform' );
185
ok( $plugin->can('barcode_generate'), 'Test plugin can barcode_generate' );
184
ok( $plugin->can('configure'), 'Test plugin can configure' );
186
ok( $plugin->can('configure'), 'Test plugin can configure' );
185
ok( $plugin->can('install'), 'Test plugin can install' );
187
ok( $plugin->can('install'), 'Test plugin can install' );
186
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
188
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
(-)a/t/lib/Koha/Plugin/Test.pm (+9 lines)
Lines 93-98 sub intranet_js { Link Here
93
    return "Koha::Plugin::Test::intranet_js";
93
    return "Koha::Plugin::Test::intranet_js";
94
}
94
}
95
95
96
sub barcode_transform {
97
    my ( $self, $type, $barcode ) = @_;
98
    return "Koha::Plugin::Test::barcode_transform";
99
}
100
101
sub barcode_generate {
102
    my ( $self, $type, $object )
103
}
104
96
sub configure {
105
sub configure {
97
    my ( $self, $args ) = @_;
106
    my ( $self, $args ) = @_;
98
    return "Koha::Plugin::Test::configure";;
107
    return "Koha::Plugin::Test::configure";;
(-)a/tools/batchMod.pl (+4 lines)
Lines 45-50 use Koha::Items; Link Here
45
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::Patrons;
46
use Koha::Patrons;
47
use Koha::SearchEngine::Indexer;
47
use Koha::SearchEngine::Indexer;
48
use Koha::Plugins;
48
49
49
my $input = CGI->new;
50
my $input = CGI->new;
50
my $dbh = C4::Context->dbh;
51
my $dbh = C4::Context->dbh;
Lines 402-407 if ($op eq "show"){ Link Here
402
        if ( my $list = $input->param('barcodelist') ) {
403
        if ( my $list = $input->param('barcodelist') ) {
403
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
404
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
404
            @barcodelist = uniq @barcodelist;
405
            @barcodelist = uniq @barcodelist;
406
407
            @barcodelist = map { ( Koha::Plugins->call( 'barcode_transform', 'item', $_ ) )[0] || $_ } @barcodelist;
408
405
            # Note: adding lc for case insensitivity
409
            # Note: adding lc for case insensitivity
406
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
410
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
407
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
411
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
(-)a/tools/inventory.pl (-1 / +5 lines)
Lines 42-47 use Koha::AuthorisedValues; Link Here
42
use Koha::BiblioFrameworks;
42
use Koha::BiblioFrameworks;
43
use Koha::ClassSources;
43
use Koha::ClassSources;
44
use Koha::Items;
44
use Koha::Items;
45
use Koha::Plugins;
46
45
use List::MoreUtils qw( none );
47
use List::MoreUtils qw( none );
46
48
47
my $minlocation=$input->param('minlocation') || '';
49
my $minlocation=$input->param('minlocation') || '';
Lines 180-185 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
180
    }
182
    }
181
    for my $barcode (@uploadedbarcodes) {
183
    for my $barcode (@uploadedbarcodes) {
182
        next unless $barcode;
184
        next unless $barcode;
185
186
        ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
187
183
        ++$lines_read;
188
        ++$lines_read;
184
        if (length($barcode)>$barcode_size) {
189
        if (length($barcode)>$barcode_size) {
185
            $err_length += 1;
190
            $err_length += 1;
186
- 

Return to bug 26351