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
use Koha::CsvProfiles;
37
use Koha::CsvProfiles;
Lines 1660-1676 sub CancelReceipt { Link Here
1660
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1661
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1661
        if ( @affects ) {
1662
        if ( @affects ) {
1662
            for my $in ( @itemnumbers ) {
1663
            for my $in ( @itemnumbers ) {
1663
                my $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber( $in );
1664
                my $item = Koha::Items->find( $in );
1664
                my $frameworkcode = GetFrameworkCode($biblionumber);
1665
                my $biblio = $item->biblio;
1665
                my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode );
1666
                my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $biblio->frameworkcode );
1666
                my $item = C4::Items::GetMarcItem( $biblionumber, $in );
1667
                my $item_marc = C4::Items::GetMarcItem( $biblio->biblionumber, $in );
1667
                for my $affect ( @affects ) {
1668
                for my $affect ( @affects ) {
1668
                    my ( $sf, $v ) = split q{=}, $affect, 2;
1669
                    my ( $sf, $v ) = split q{=}, $affect, 2;
1669
                    foreach ( $item->field($itemfield) ) {
1670
                    foreach ( $item_marc->field($itemfield) ) {
1670
                        $_->update( $sf => $v );
1671
                        $_->update( $sf => $v );
1671
                    }
1672
                    }
1672
                }
1673
                }
1673
                C4::Items::ModItemFromMarc( $item, $biblionumber, $in );
1674
                C4::Items::ModItemFromMarc( $item_marc, $biblio->biblionumber, $in );
1674
            }
1675
            }
1675
        }
1676
        }
1676
    }
1677
    }
(-)a/C4/Items.pm (-1 / +2 lines)
Lines 665-671 sub DelItem { Link Here
665
    my $biblionumber = $params->{biblionumber};
665
    my $biblionumber = $params->{biblionumber};
666
666
667
    unless ($biblionumber) {
667
    unless ($biblionumber) {
668
        $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber);
668
        my $item = Koha::Items->find( $itemnumber );
669
        $biblionumber = $item->biblio->biblionumber;
669
    }
670
    }
670
671
671
    # If there is no biblionumber for the given itemnumber, there is nothing to delete
672
    # 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 (-5 / +9 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;
79
        $biblio->unblessed; # FIXME remove later
80
    } else {
81
        $biblio = C4::Biblio::GetBiblio($biblionumber);
76
    }
82
    }
77
83
78
    my $biblio = C4::Biblio::GetBiblio($biblionumber);
79
80
    my $can_reserve =
84
    my $can_reserve =
81
      $itemnumber
85
      $itemnumber
82
      ? CanItemBeReserved( $borrowernumber, $itemnumber )
86
      ? CanItemBeReserved( $borrowernumber, $itemnumber )
(-)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 794-802 foreach my $field (@fields) { Link Here
794
795
795
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
796
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
796
	    foreach my $hostitemnumber (@hostitemnumbers){
797
	    foreach my $hostitemnumber (@hostitemnumbers){
798
            my $item = Koha::Items->find( $hostitemnumber );
797
		if ($this_row{itemnumber} eq $hostitemnumber){
799
		if ($this_row{itemnumber} eq $hostitemnumber){
798
			$this_row{hostitemflag} = 1;
800
			$this_row{hostitemflag} = 1;
799
			$this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
801
            $this_row{hostbiblionumber}= $item->biblio->biblionumber;
800
			last;
802
			last;
801
		}
803
		}
802
	    }
804
	    }
(-)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