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

(-)a/C4/ImportBatch.pm (-2 / +3 lines)
Lines 27-32 use C4::Items; Link Here
27
use C4::Charset;
27
use C4::Charset;
28
use C4::AuthoritiesMarc;
28
use C4::AuthoritiesMarc;
29
use C4::MarcModificationTemplates;
29
use C4::MarcModificationTemplates;
30
use Koha::Items;
30
use Koha::Plugins::Handler;
31
use Koha::Plugins::Handler;
31
use Koha::Logger;
32
use Koha::Logger;
32
33
Lines 747-753 sub BatchCommitItems { Link Here
747
748
748
        my $item = TransformMarcToKoha( $item_marc );
749
        my $item = TransformMarcToKoha( $item_marc );
749
750
750
        my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} );
751
        my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} });
751
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
752
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
752
753
753
        my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?");
754
        my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?");
Lines 761-767 sub BatchCommitItems { Link Here
761
            $updsth->finish();
762
            $updsth->finish();
762
            $num_items_replaced++;
763
            $num_items_replaced++;
763
        } elsif ( $action eq "replace" && $duplicate_barcode ) {
764
        } elsif ( $action eq "replace" && $duplicate_barcode ) {
764
            my $itemnumber = GetItemnumberFromBarcode( $item->{'barcode'} );
765
            my $itemnumber = $duplicate_barcode->itemnumber;
765
            ModItemFromMarc( $item_marc, $biblionumber, $itemnumber );
766
            ModItemFromMarc( $item_marc, $biblionumber, $itemnumber );
766
            $updsth->bind_param( 1, 'imported' );
767
            $updsth->bind_param( 1, 'imported' );
767
            $updsth->bind_param( 2, $item->{itemnumber} );
768
            $updsth->bind_param( 2, $item->{itemnumber} );
(-)a/C4/Items.pm (-3 / +3 lines)
Lines 740-749 sub CheckItemPreSave { Link Here
740
740
741
    # check for duplicate barcode
741
    # check for duplicate barcode
742
    if (exists $item_ref->{'barcode'} and defined $item_ref->{'barcode'}) {
742
    if (exists $item_ref->{'barcode'} and defined $item_ref->{'barcode'}) {
743
        my $existing_itemnumber = GetItemnumberFromBarcode($item_ref->{'barcode'});
743
        my $existing_item= Koha::Items->find({barcode => $item_ref->{'barcode'}});
744
        if ($existing_itemnumber) {
744
        if ($existing_item) {
745
            if (!exists $item_ref->{'itemnumber'}                       # new item
745
            if (!exists $item_ref->{'itemnumber'}                       # new item
746
                or $item_ref->{'itemnumber'} != $existing_itemnumber) { # existing item
746
                or $item_ref->{'itemnumber'} != $existing_item->itemnumber) { # existing item
747
                $errors{'duplicate_barcode'} = $item_ref->{'barcode'};
747
                $errors{'duplicate_barcode'} = $item_ref->{'barcode'};
748
            }
748
            }
749
        }
749
        }
(-)a/circ/returns.pl (-2 / +3 lines)
Lines 591-598 $template->param( Link Here
591
    AudioAlerts        => C4::Context->preference("AudioAlerts"),
591
    AudioAlerts        => C4::Context->preference("AudioAlerts"),
592
);
592
);
593
593
594
$itemnumber = GetItemnumberFromBarcode( $barcode );
594
my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!?
595
if ( $itemnumber ) {
595
if ( $item_from_barcode ) {
596
    $itemnumber = $item_from_barcode->itemnumber;
596
    my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
597
    my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
597
    if ( $holdingBranch and $collectionBranch ) {
598
    if ( $holdingBranch and $collectionBranch ) {
598
        $holdingBranch //= '';
599
        $holdingBranch //= '';
(-)a/labels/label-edit-batch.pl (-4 / +5 lines)
Lines 25-34 use CGI qw ( -utf8 ); Link Here
25
25
26
use C4::Auth qw(get_template_and_user);
26
use C4::Auth qw(get_template_and_user);
27
use C4::Output qw(output_html_with_http_headers);
27
use C4::Output qw(output_html_with_http_headers);
28
use C4::Items qw(GetItem GetItemnumberFromBarcode);
28
use C4::Items qw(GetItem);
29
use C4::Creators;
29
use C4::Creators;
30
use C4::Labels;
30
use C4::Labels;
31
31
32
use Koha::Items;
33
32
my $cgi = new CGI;
34
my $cgi = new CGI;
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {
36
    {
Lines 90-98 elsif ($op eq 'add') { Link Here
90
                push @item_numbers, $number;
92
                push @item_numbers, $number;
91
            }
93
            }
92
            elsif ($number_type eq "barcode" ) {  # we must test in case an invalid barcode is passed in; we effectively disgard them atm
94
            elsif ($number_type eq "barcode" ) {  # we must test in case an invalid barcode is passed in; we effectively disgard them atm
93
                if( my $item_number = GetItemnumberFromBarcode($number) ){
95
                my $item = Koha::Items->find({barcode => $number});
94
                    push @item_numbers, $item_number;
96
                push @item_numbers, $item->itemnumber if $item;
95
                }
96
            }
97
            }
97
        }
98
        }
98
    }
99
    }
(-)a/members/mancredit.pl (-1 / +3 lines)
Lines 34-39 use C4::Items; Link Here
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
35
36
use Koha::Account;
36
use Koha::Account;
37
use Koha::Items;
37
use Koha::Patrons;
38
use Koha::Patrons;
38
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
39
use Koha::Token;
40
use Koha::Token;
Lines 67-73 if ($add){ Link Here
67
        my $barcode = $input->param('barcode');
68
        my $barcode = $input->param('barcode');
68
        my $item_id;
69
        my $item_id;
69
        if ($barcode) {
70
        if ($barcode) {
70
            $item_id = GetItemnumberFromBarcode($barcode);
71
            my $item = Koha::Items->find({barcode => $barcode});
72
            $item_id = $item->itemnumber if $item;
71
        }
73
        }
72
        my $description = $input->param('desc');
74
        my $description = $input->param('desc');
73
        my $note        = $input->param('note');
75
        my $note        = $input->param('note');
(-)a/members/maninvoice.pl (-1 / +3 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use Koha::Token;
34
use Koha::Token;
35
35
36
use Koha::Items;
36
use Koha::Patrons;
37
use Koha::Patrons;
37
38
38
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
Lines 61-67 if ($add){ Link Here
61
        my $barcode=$input->param('barcode');
62
        my $barcode=$input->param('barcode');
62
        my $itemnum;
63
        my $itemnum;
63
        if ($barcode) {
64
        if ($barcode) {
64
            $itemnum = GetItemnumberFromBarcode($barcode);
65
            my $item = Koha::Items->find({barcode => $barcode});
66
            $itemnum = $item->itemnumber if $item;
65
        }
67
        }
66
        my $desc=$input->param('desc');
68
        my $desc=$input->param('desc');
67
        my $amount=$input->param('amount');
69
        my $amount=$input->param('amount');
(-)a/rotating_collections/addItems.pl (-1 / +4 lines)
Lines 24-29 use C4::Context; Link Here
24
use C4::RotatingCollections;
24
use C4::RotatingCollections;
25
use C4::Items;
25
use C4::Items;
26
26
27
use Koha::Items;
28
27
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
28
30
29
my $query = new CGI;
31
my $query = new CGI;
Lines 44-50 if ( $query->param('action') eq 'addItem' ) { Link Here
44
    my $colId      = $query->param('colId');
46
    my $colId      = $query->param('colId');
45
    my $barcode    = $query->param('barcode');
47
    my $barcode    = $query->param('barcode');
46
    my $removeItem = $query->param('removeItem');
48
    my $removeItem = $query->param('removeItem');
47
    my $itemnumber = GetItemnumberFromBarcode($barcode);
49
    my $item       = Koha::Items->find({barcode => $barcode});
50
    my $itemnumber = $item ? $item->itemnumber : undef;
48
51
49
    my ( $success, $errorCode, $errorMessage );
52
    my ( $success, $errorCode, $errorMessage );
50
53
(-)a/serials/serials-edit.pl (-5 / +4 lines)
Lines 72-78 use C4::Output; Link Here
72
use C4::Context;
72
use C4::Context;
73
use C4::Serials;
73
use C4::Serials;
74
use C4::Search qw/enabled_staff_search_views/;
74
use C4::Search qw/enabled_staff_search_views/;
75
75
use Koha::DateUtils;
76
use Koha::DateUtils;
77
use Koha::Items;
76
use Koha::Serial::Items;
78
use Koha::Serial::Items;
77
79
78
use List::MoreUtils qw/uniq/;
80
use List::MoreUtils qw/uniq/;
Lines 372-382 if ( $op and $op eq 'serialchangestatus' ) { Link Here
372
                        )
374
                        )
373
                      )
375
                      )
374
                    {
376
                    {
375
                        $exists = GetItemnumberFromBarcode(
377
                        my $barcode = $bib_record->subfield( $barcodetagfield, $barcodetagsubfield );
376
                            $bib_record->subfield(
378
                        $exists = Koha::Items->find({barcode => $barcode});
377
                                $barcodetagfield, $barcodetagsubfield
378
                            )
379
                        );
380
                    }
379
                    }
381
380
382
                    #           push @errors,"barcode_not_unique" if($exists);
381
                    #           push @errors,"barcode_not_unique" if($exists);
(-)a/tools/batchMod.pl (-20 / +8 lines)
Lines 244-258 if ($op eq "show"){ Link Here
244
244
245
        @contentlist = uniq @contentlist;
245
        @contentlist = uniq @contentlist;
246
        if ($filecontent eq 'barcode_file') {
246
        if ($filecontent eq 'barcode_file') {
247
            foreach my $barcode (@contentlist) {
247
            my $existing_items = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
248
248
            @itemnumbers = $existing_items->get_column('itemnumber');
249
                my $itemnumber = GetItemnumberFromBarcode($barcode);
249
            my %exists = map {$_=>1} @{$existing_items->get_column('barcode')};
250
                if ($itemnumber) {
250
            @notfoundbarcodes = grep { !$exists{$_} } @contentlist;
251
                    push @itemnumbers,$itemnumber;
252
                } else {
253
                    push @notfoundbarcodes, $barcode;
254
                }
255
            }
256
        }
251
        }
257
        elsif ( $filecontent eq 'itemid_file') {
252
        elsif ( $filecontent eq 'itemid_file') {
258
            @itemnumbers = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
253
            @itemnumbers = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
Lines 269-284 if ($op eq "show"){ Link Here
269
        if ( my $list=$input->param('barcodelist')){
264
        if ( my $list=$input->param('barcodelist')){
270
            push my @barcodelist, uniq( split(/\s\n/, $list) );
265
            push my @barcodelist, uniq( split(/\s\n/, $list) );
271
266
272
            foreach my $barcode (@barcodelist) {
267
            my $existing_items = Koha::Items->search({ itemnumber => \@barcodelist })->get_column('itemnumber');
273
268
            @itemnumbers = $existing_items->get_column('itemnumber');
274
                my $itemnumber = GetItemnumberFromBarcode($barcode);
269
            my %exists = map {$_=>1} @{$existing_items->get_column('barcode')};
275
                if ($itemnumber) {
270
            @notfoundbarcodes = grep { !$exists{$_} } @barcodelist;
276
                    push @itemnumbers,$itemnumber;
277
                } else {
278
                    push @notfoundbarcodes, $barcode;
279
                }
280
            }
281
282
        }
271
        }
283
    }
272
    }
284
273
285
- 

Return to bug 21183