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

(-)a/C4/Acquisition.pm (-6 / +7 lines)
Lines 31-36 use Koha::DateUtils qw( dt_from_string output_pref ); Link Here
31
use Koha::Acquisition::Order;
31
use Koha::Acquisition::Order;
32
use Koha::Acquisition::Booksellers;
32
use Koha::Acquisition::Booksellers;
33
use Koha::Biblios;
33
use Koha::Biblios;
34
use Koha::Items;
34
use Koha::Number::Price;
35
use Koha::Number::Price;
35
use Koha::Libraries;
36
use Koha::Libraries;
36
37
Lines 1606-1622 sub CancelReceipt { Link Here
1606
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1607
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1607
        if ( @affects ) {
1608
        if ( @affects ) {
1608
            for my $in ( @itemnumbers ) {
1609
            for my $in ( @itemnumbers ) {
1609
                my $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber( $in );
1610
                my $item = Koha::Items->find( $in );
1610
                my $frameworkcode = GetFrameworkCode($biblionumber);
1611
                my $biblio = $item->biblio;
1611
                my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode );
1612
                my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $biblio->frameworkcode );
1612
                my $item = C4::Items::GetMarcItem( $biblionumber, $in );
1613
                my $item_marc = C4::Items::GetMarcItem( $biblio->biblionumber, $in );
1613
                for my $affect ( @affects ) {
1614
                for my $affect ( @affects ) {
1614
                    my ( $sf, $v ) = split q{=}, $affect, 2;
1615
                    my ( $sf, $v ) = split q{=}, $affect, 2;
1615
                    foreach ( $item->field($itemfield) ) {
1616
                    foreach ( $item_marc->field($itemfield) ) {
1616
                        $_->update( $sf => $v );
1617
                        $_->update( $sf => $v );
1617
                    }
1618
                    }
1618
                }
1619
                }
1619
                C4::Items::ModItemFromMarc( $item, $biblionumber, $in );
1620
                C4::Items::ModItemFromMarc( $item_marc, $biblio->biblionumber, $in );
1620
            }
1621
            }
1621
        }
1622
        }
1622
    }
1623
    }
(-)a/C4/Items.pm (-1 / +2 lines)
Lines 669-675 sub DelItem { Link Here
669
    my $biblionumber = $params->{biblionumber};
669
    my $biblionumber = $params->{biblionumber};
670
670
671
    unless ($biblionumber) {
671
    unless ($biblionumber) {
672
        $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber);
672
        my $item = Koha::Items->find( $itemnumber );
673
        $biblionumber = $item->biblio->biblionumber;
673
    }
674
    }
674
675
675
    # If there is no biblionumber for the given itemnumber, there is nothing to delete
676
    # If there is no biblionumber for the given itemnumber, there is nothing to delete
(-)a/C4/Record.pm (-1 / +3 lines)
Lines 34-39 use C4::XSLT (); Link Here
34
use YAML; #marcrecords2csv
34
use YAML; #marcrecords2csv
35
use Template;
35
use Template;
36
use Text::CSV::Encoded; #marc2csv
36
use Text::CSV::Encoded; #marc2csv
37
use Koha::Items;
37
use Koha::SimpleMARC qw(read_field);
38
use Koha::SimpleMARC qw(read_field);
38
use Koha::XSLT_Handler;
39
use Koha::XSLT_Handler;
39
use Koha::CsvProfiles;
40
use Koha::CsvProfiles;
Lines 427-433 sub marc2csv { Link Here
427
    my $firstpass = 1;
428
    my $firstpass = 1;
428
    if ( @$itemnumbers ) {
429
    if ( @$itemnumbers ) {
429
        for my $itemnumber ( @$itemnumbers) {
430
        for my $itemnumber ( @$itemnumbers) {
430
            my $biblionumber = GetBiblionumberFromItemnumber $itemnumber;
431
            my $item = Koha::Items->find( $itemnumber );
432
            my $biblionumber = $item->biblio->biblionumber;
431
            $output .= marcrecord2csv( $biblionumber, $id, $firstpass, $csv, $fieldprocessing, [$itemnumber] );
433
            $output .= marcrecord2csv( $biblionumber, $id, $firstpass, $csv, $fieldprocessing, [$itemnumber] );
432
            $firstpass = 0;
434
            $firstpass = 0;
433
        }
435
        }
(-)a/Koha/REST/V1/Hold.pm (-6 / +7 lines)
Lines 22-27 use Mojo::Base 'Mojolicious::Controller'; Link Here
22
use C4::Biblio;
22
use C4::Biblio;
23
use C4::Reserves;
23
use C4::Reserves;
24
24
25
use Koha::Items;
25
use Koha::Patrons;
26
use Koha::Patrons;
26
use Koha::Holds;
27
use Koha::Holds;
27
use Koha::DateUtils;
28
use Koha::DateUtils;
Lines 65-82 sub add { Link Here
65
        }, 400);
66
        }, 400);
66
    }
67
    }
67
68
69
    my $biblio;
68
    if ($itemnumber) {
70
    if ($itemnumber) {
69
        my $item_biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber);
71
        my $item = Koha::Items->find( $itemnumber );
70
        if ($biblionumber and $biblionumber != $item_biblionumber) {
72
        $biblio = $item->biblio;
73
        if ($biblionumber and $biblionumber != $biblio->biblionumber) {
71
            return $c->$cb({
74
            return $c->$cb({
72
                error => "Item $itemnumber doesn't belong to biblio $biblionumber"
75
                error => "Item $itemnumber doesn't belong to biblio $biblionumber"
73
            }, 400);
76
            }, 400);
74
        }
77
        }
75
        $biblionumber ||= $item_biblionumber;
78
        $biblionumber ||= $biblio->biblionumber;
76
    }
79
    }
77
80
78
    my $biblio = C4::Biblio::GetBiblio($biblionumber);
79
80
    my $can_reserve =
81
    my $can_reserve =
81
      $itemnumber
82
      $itemnumber
82
      ? CanItemBeReserved( $borrowernumber, $itemnumber )
83
      ? CanItemBeReserved( $borrowernumber, $itemnumber )
Lines 98-104 sub add { Link Here
98
99
99
    my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber,
100
    my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber,
100
        $biblionumber, undef, $priority, undef, $expirationdate, undef,
101
        $biblionumber, undef, $priority, undef, $expirationdate, undef,
101
        $biblio->{title}, $itemnumber);
102
        $biblio->title, $itemnumber);
102
103
103
    unless ($reserve_id) {
104
    unless ($reserve_id) {
104
        return $c->$cb({
105
        return $c->$cb({
(-)a/cataloguing/additem.pl (-1 / +3 lines)
Lines 31-36 use C4::Circulation; Link Here
31
use C4::Koha;
31
use C4::Koha;
32
use C4::ClassSource;
32
use C4::ClassSource;
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use Koha::Items;
34
use Koha::ItemTypes;
35
use Koha::ItemTypes;
35
use Koha::Libraries;
36
use Koha::Libraries;
36
use List::MoreUtils qw/any/;
37
use List::MoreUtils qw/any/;
Lines 807-815 foreach my $field (@fields) { Link Here
807
808
808
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
809
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
809
	    foreach my $hostitemnumber (@hostitemnumbers){
810
	    foreach my $hostitemnumber (@hostitemnumbers){
811
            my $item = Koha::Items->find( $hostitemnumber );
810
		if ($this_row{itemnumber} eq $hostitemnumber){
812
		if ($this_row{itemnumber} eq $hostitemnumber){
811
			$this_row{hostitemflag} = 1;
813
			$this_row{hostitemflag} = 1;
812
			$this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
814
            $this_row{hostbiblionumber}= $item->biblio->biblionumber;
813
			last;
815
			last;
814
		}
816
		}
815
	    }
817
	    }
(-)a/opac/opac-reserve.pl (-1 / +2 lines)
Lines 244-250 if ( $query->param('place_reserve') ) { Link Here
244
244
245
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
245
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
246
        if ( $itemNum ne '' ) {
246
        if ( $itemNum ne '' ) {
247
            my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum);
247
            my $item = Koha::Items->find( $itemNum );
248
            my $hostbiblioNum = $item->biblio->biblionumber;
248
            if ( $hostbiblioNum ne $biblioNum ) {
249
            if ( $hostbiblioNum ne $biblioNum ) {
249
                $biblioNum = $hostbiblioNum;
250
                $biblioNum = $hostbiblioNum;
250
            }
251
            }
(-)a/tools/batchMod.pl (-2 / +5 lines)
Lines 37-42 use List::MoreUtils qw/uniq/; Link Here
37
37
38
use Koha::Biblios;
38
use Koha::Biblios;
39
use Koha::DateUtils;
39
use Koha::DateUtils;
40
use Koha::Items;
40
use Koha::ItemTypes;
41
use Koha::ItemTypes;
41
42
42
my $input = new CGI;
43
my $input = new CGI;
Lines 121-127 if ($op eq "action") { Link Here
121
	    $items_display_hashref=BuildItemsData(@itemnumbers);
122
	    $items_display_hashref=BuildItemsData(@itemnumbers);
122
	} else {
123
	} else {
123
	    # Else, we only display the barcode
124
	    # Else, we only display the barcode
124
	    my @simple_items_display = map {{ itemnumber => $_, barcode => (GetBarcodeFromItemnumber($_) or ""), biblionumber => (GetBiblionumberFromItemnumber($_) or "") }} @itemnumbers;
125
        my @simple_items_display = map {
126
            my $itemnumber = $_;
127
            my $item = Koha::Items->find($itemnumber);
128
            { itemnumber => $itemnumber, barcode => ($item->barcode || q||), biblionumber => $item->biblio->biblionumber }} @itemnumbers;
125
	    $template->param("simple_items_display" => \@simple_items_display);
129
	    $template->param("simple_items_display" => \@simple_items_display);
126
	}
130
	}
127
131
128
- 

Return to bug 18277