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

(-)a/C4/Circulation.pm (+2 lines)
Lines 154-159 Will do some manipulation of the barcode for systems that deliver a barcode Link Here
154
to circulation.pl that differs from the barcode stored for the item.
154
to circulation.pl that differs from the barcode stored for the item.
155
For proper functioning of this filter, calling the function on the 
155
For proper functioning of this filter, calling the function on the 
156
correct barcode string (items.barcode) should return an unaltered barcode.
156
correct barcode string (items.barcode) should return an unaltered barcode.
157
Barcode is going to be automatically trimmed of leading/trailing whitespaces.
157
158
158
The optional $filter argument is to allow for testing or explicit 
159
The optional $filter argument is to allow for testing or explicit 
159
behavior that ignores the System Pref.  Valid values are the same as the 
160
behavior that ignores the System Pref.  Valid values are the same as the 
Lines 167-172 System Pref options. Link Here
167
sub barcodedecode {
168
sub barcodedecode {
168
    my ($barcode, $filter) = @_;
169
    my ($barcode, $filter) = @_;
169
    my $branch = C4::Context::mybranch();
170
    my $branch = C4::Context::mybranch();
171
    $barcode =~ s/^\s+|\s+$//g;
170
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
172
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
171
    Koha::Plugins->call('item_barcode_transform',  \$barcode );
173
    Koha::Plugins->call('item_barcode_transform',  \$barcode );
172
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
174
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
(-)a/circ/branchtransfers.pl (-2 / +2 lines)
Lines 22-28 Link Here
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Circulation qw( transferbook );
25
use C4::Circulation qw( transferbook barcodedecode );
26
use C4::Output qw( output_html_with_http_headers );
26
use C4::Output qw( output_html_with_http_headers );
27
use C4::Reserves qw( ModReserve ModReserveAffect );
27
use C4::Reserves qw( ModReserve ModReserveAffect );
28
use C4::Auth qw( get_session get_template_and_user );
28
use C4::Auth qw( get_session get_template_and_user );
Lines 121-127 my @trsfitemloop; Link Here
121
my $transferred;
121
my $transferred;
122
my $barcode = $query->param('barcode');
122
my $barcode = $query->param('barcode');
123
# remove leading/trailing whitespace
123
# remove leading/trailing whitespace
124
defined $barcode and $barcode =~ s/^\s*|\s*$//g;  # FIXME: barcodeInputFilter
124
$barcode = barcodedecode($barcode) if $barcode;
125
# warn "barcode : $barcode";
125
# warn "barcode : $barcode";
126
if ($barcode) {
126
if ($barcode) {
127
127
(-)a/circ/circulation.pl (-1 lines)
Lines 158-164 if (C4::Context->preference("DisplayClearScreenButton")) { Link Here
158
}
158
}
159
159
160
for my $barcode ( @$barcodes ) {
160
for my $barcode ( @$barcodes ) {
161
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
162
    $barcode = barcodedecode( $barcode ) if $barcode;
161
    $barcode = barcodedecode( $barcode ) if $barcode;
163
}
162
}
164
163
(-)a/circ/renew.pl (-2 / +1 lines)
Lines 43-49 my $schema = Koha::Database->new()->schema(); Link Here
43
43
44
my $barcode        = $cgi->param('barcode') // '';
44
my $barcode        = $cgi->param('barcode') // '';
45
my $unseen         = $cgi->param('unseen') || 0;
45
my $unseen         = $cgi->param('unseen') || 0;
46
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
47
$barcode = barcodedecode($barcode) if $barcode;
46
$barcode = barcodedecode($barcode) if $barcode;
48
my $override_limit = $cgi->param('override_limit');
47
my $override_limit = $cgi->param('override_limit');
49
my $override_holds = $cgi->param('override_holds');
48
my $override_holds = $cgi->param('override_holds');
Lines 54-60 my $error = q{}; Link Here
54
my ( $soonest_renew_date, $latest_auto_renew_date );
53
my ( $soonest_renew_date, $latest_auto_renew_date );
55
54
56
if ($barcode) {
55
if ($barcode) {
57
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
56
    $barcode = barcodedecode($barcode) if $barcode;
58
    $item = $schema->resultset("Item")->single( { barcode => $barcode } );
57
    $item = $schema->resultset("Item")->single( { barcode => $barcode } );
59
58
60
    if ($item) {
59
    if ($item) {
(-)a/circ/returns.pl (-2 lines)
Lines 119-125 foreach ( $query->param ) { Link Here
119
    $counter++;
119
    $counter++;
120
120
121
    # decode barcode    ## Didn't we already decode them before passing them back last time??
121
    # decode barcode    ## Didn't we already decode them before passing them back last time??
122
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
123
    $barcode = barcodedecode($barcode) if $barcode;
122
    $barcode = barcodedecode($barcode) if $barcode;
124
123
125
    ######################
124
    ######################
Lines 285-291 if ($transit) { Link Here
285
# actually return book and prepare item table.....
284
# actually return book and prepare item table.....
286
my $returnbranch;
285
my $returnbranch;
287
if ($barcode) {
286
if ($barcode) {
288
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
289
    $barcode = barcodedecode($barcode) if $barcode;
287
    $barcode = barcodedecode($barcode) if $barcode;
290
    my $item = Koha::Items->find({ barcode => $barcode });
288
    my $item = Koha::Items->find({ barcode => $barcode });
291
289
(-)a/course_reserves/add_items.pl (-1 / +2 lines)
Lines 27-32 use C4::Output qw( output_html_with_http_headers ); Link Here
27
use C4::Koha qw( GetAuthorisedValues );
27
use C4::Koha qw( GetAuthorisedValues );
28
use Koha::Items;
28
use Koha::Items;
29
29
30
use C4::Circulation qw( barcodedecode );
30
use C4::CourseReserves qw( GetCourse GetCourseReserve ModCourse ModCourseItem ModCourseReserve );
31
use C4::CourseReserves qw( GetCourse GetCourseReserve ModCourse ModCourseItem ModCourseReserve );
31
32
32
use Koha::Items;
33
use Koha::Items;
Lines 42-48 my $itemnumber = $cgi->param('itemnumber') || ''; Link Here
42
my $is_edit      = $cgi->param('is_edit')      || '';
43
my $is_edit      = $cgi->param('is_edit')      || '';
43
my $biblionumber = $cgi->param('biblionumber') || '';
44
my $biblionumber = $cgi->param('biblionumber') || '';
44
45
45
$barcode =~ s/^\s*|\s*$//g; #remove leading/trailing whitespace
46
$barcode = barcodedecode($barcode) if $barcode;
46
$biblionumber =~ s/^\s*|\s*$//g; #remove leading/trailing whitespace
47
$biblionumber =~ s/^\s*|\s*$//g; #remove leading/trailing whitespace
47
48
48
my ( $item, $biblio );
49
my ( $item, $biblio );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +1 lines)
Lines 35-41 Circulation: Link Here
35
                  T-prefix: Remove the first number from T-prefix style
35
                  T-prefix: Remove the first number from T-prefix style
36
                  libsuite8: Convert from Libsuite8 form
36
                  libsuite8: Convert from Libsuite8 form
37
                  EAN13: EAN-13 or zero-padded UPC-A form
37
                  EAN13: EAN-13 or zero-padded UPC-A form
38
            - scanned item barcodes.
38
            - scanned item barcodes. Mind that barcode whitespaces always trimmed from both ends before this filter.
39
        -
39
        -
40
            - pref: itemBarcodeFallbackSearch
40
            - pref: itemBarcodeFallbackSearch
41
              choices:
41
              choices:
(-)a/t/Circulation_barcodedecode.t (-6 / +5 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 26;
20
use Test::More tests => 28;
21
21
22
use C4::Context;
22
use C4::Context;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 29-47 t::lib::Mocks::mock_userenv({ branchcode => 'IMS' }); Link Here
29
our %inputs = (
29
our %inputs = (
30
    cuecat     => ["26002315", '.C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.', ".C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.\r\n",
30
    cuecat     => ["26002315", '.C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.', ".C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.\r\n",
31
                    'q.C3nZC3nZC3nWDNzYDxf2CNnY.fHmc.C3DWC3nZCNjXD3nW.', '.C3nZC3nZC3nWCxjWE3D1C3nX.cGf2.ENr7C3v7D3T3ENj3C3zYDNnZ.' ],
31
                    'q.C3nZC3nZC3nWDNzYDxf2CNnY.fHmc.C3DWC3nZCNjXD3nW.', '.C3nZC3nZC3nWCxjWE3D1C3nX.cGf2.ENr7C3v7D3T3ENj3C3zYDNnZ.' ],
32
    whitespace => [" 26002315", "26002315 ", "\n\t26002315\n"],
32
    whitespace => [" 26002315", "26002315 ", "\n\t26002315\n", "whitespace removed"],
33
    'T-prefix' => [qw(T0031472 T32)],
33
    'T-prefix' => [qw(T0031472 T32)],
34
    'libsuite8' => ['b000126', 'b12', 'B0126', 'IMS-B-126', 'ims-b-126','CD0000024','00123','11998'],
34
    'libsuite8' => ['b000126', 'b12', 'B0126', 'IMS-B-126', 'ims-b-126','CD0000024','00123','11998'],
35
    EAN13      => [qw(892685001928 695152)],
35
    EAN13      => [qw(892685001928 695152)],
36
    other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
36
    other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345", " side spaces removed \n"],
37
);
37
);
38
our %outputs = (
38
our %outputs = (
39
    cuecat     => ["26002315", "046675000808", "046675000808", "043000112403", "978068484914051500"],
39
    cuecat     => ["26002315", "046675000808", "046675000808", "043000112403", "978068484914051500"],
40
    whitespace => [qw(26002315 26002315 26002315)],
40
    whitespace => [qw(26002315 26002315 26002315 whitespaceremoved)],
41
    'T-prefix' => [qw(T0031472 T0000002         )],
41
    'T-prefix' => [qw(T0031472 T0000002         )],
42
    'libsuite8' => ['IMS-b-126', 'IMS-b-12', 'IMS-B-126', 'IMS-B-126', 'ims-b-126','IMS-CD-24','IMS-b-123','IMS-b-11998'],
42
    'libsuite8' => ['IMS-b-126', 'IMS-b-12', 'IMS-B-126', 'IMS-B-126', 'ims-b-126','IMS-CD-24','IMS-b-123','IMS-b-11998'],
43
    EAN13      => [qw(0892685001928 0000000695152)],
43
    EAN13      => [qw(0892685001928 0000000695152)],
44
    other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
44
    other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345", "side spaces removed"],
45
);
45
);
46
46
47
my @filters = sort keys %inputs;
47
my @filters = sort keys %inputs;
48
- 

Return to bug 30409