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

(-)a/C4/Circulation.pm (-39 / +31 lines)
Lines 306-336 sub transferbook { Link Here
306
    my ( $tbr, $barcode, $ignoreRs ) = @_;
306
    my ( $tbr, $barcode, $ignoreRs ) = @_;
307
    my $messages;
307
    my $messages;
308
    my $dotransfer      = 1;
308
    my $dotransfer      = 1;
309
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
309
    my $item = Koha::Items->find( { barcode => $barcode } );
310
    my $issue      = GetItemIssue($itemnumber);
311
    my $biblio = GetBiblioFromItemNumber($itemnumber);
312
310
313
    # bad barcode..
311
    # bad barcode..
314
    if ( not $itemnumber ) {
312
    unless ( $item ) {
315
        $messages->{'BadBarcode'} = $barcode;
313
        $messages->{'BadBarcode'} = $barcode;
316
        $dotransfer = 0;
314
        $dotransfer = 0;
317
    }
315
    }
318
316
317
    my $itemnumber = $item->itemnumber;
318
    my $issue = GetOpenIssue($itemnumber);
319
    # get branches of book...
319
    # get branches of book...
320
    my $hbr = $biblio->{'homebranch'};
320
    my $hbr = $item->homebranch;
321
    my $fbr = $biblio->{'holdingbranch'};
321
    my $fbr = $item->holdingbranch;
322
322
323
    # if using Branch Transfer Limits
323
    # if using Branch Transfer Limits
324
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
324
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
325
        my $code = C4::Context->preference("BranchTransferLimitsType") eq 'ccode' ? $item->ccode : $item->biblio->biblioitem->itemtype; # BranchTransferLimitsType is 'ccode' or 'itemtype'
325
        if ( C4::Context->preference("item-level_itypes") && C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ) {
326
        if ( C4::Context->preference("item-level_itypes") && C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ) {
326
            if ( ! IsBranchTransferAllowed( $tbr, $fbr, $biblio->{'itype'} ) ) {
327
            if ( ! IsBranchTransferAllowed( $tbr, $fbr, $item->itype ) ) {
327
                $messages->{'NotAllowed'} = $tbr . "::" . $biblio->{'itype'};
328
                $messages->{'NotAllowed'} = $tbr . "::" . $item->itype;
328
                $dotransfer = 0;
329
                $dotransfer = 0;
329
            }
330
            }
330
        } elsif ( ! IsBranchTransferAllowed( $tbr, $fbr, $biblio->{ C4::Context->preference("BranchTransferLimitsType") } ) ) {
331
        } elsif ( ! IsBranchTransferAllowed( $tbr, $fbr, $code ) ) {
331
            $messages->{'NotAllowed'} = $tbr . "::" . $biblio->{ C4::Context->preference("BranchTransferLimitsType") };
332
            $messages->{'NotAllowed'} = $tbr . "::" . $code;
332
            $dotransfer = 0;
333
            $dotransfer = 0;
333
    	}
334
        }
334
    }
335
    }
335
336
336
    # if is permanent...
337
    # if is permanent...
Lines 374-380 sub transferbook { Link Here
374
375
375
    }
376
    }
376
    ModDateLastSeen( $itemnumber );
377
    ModDateLastSeen( $itemnumber );
377
    return ( $dotransfer, $messages, $biblio );
378
    return ( $dotransfer, $messages );
378
}
379
}
379
380
380
381
Lines 673-679 sub CanBookBeIssued { Link Here
673
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
674
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
674
    my $override_high_holds = $params->{override_high_holds} || 0;
675
    my $override_high_holds = $params->{override_high_holds} || 0;
675
676
676
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
677
    my $item = GetItem(undef, $barcode );
677
    my $issue = GetItemIssue($item->{itemnumber});
678
    my $issue = GetItemIssue($item->{itemnumber});
678
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
679
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
679
	$item->{'itemtype'}=$item->{'itype'}; 
680
	$item->{'itemtype'}=$item->{'itype'}; 
Lines 1147-1154 sub CanBookBeReturned { Link Here
1147
1148
1148
sub checkHighHolds {
1149
sub checkHighHolds {
1149
    my ( $item, $borrower ) = @_;
1150
    my ( $item, $borrower ) = @_;
1150
    my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1151
    my $branch = _GetCircControlBranch( $item, $borrower );
1151
    my $branch = _GetCircControlBranch( $item, $borrower );
1152
    my $item_object = Koha::Items->find( $item->{itemnumber} );
1152
1153
1153
    my $return_data = {
1154
    my $return_data = {
1154
        exceeded    => 0,
1155
        exceeded    => 0,
Lines 1207-1217 sub checkHighHolds { Link Here
1207
1208
1208
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1209
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1209
1210
1210
        my $itype =
1211
        my $itype = $item_object->effective_itemtype;
1211
          ( C4::Context->preference('item-level_itypes') )
1212
          ? $biblio->{'itype'}
1213
          : $biblio->{'itemtype'};
1214
1215
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1212
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1216
1213
1217
        my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration');
1214
        my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration');
Lines 1300-1314 sub AddIssue { Link Here
1300
        # find which item we issue
1297
        # find which item we issue
1301
        my $item = GetItem( '', $barcode )
1298
        my $item = GetItem( '', $barcode )
1302
          or return;    # if we don't get an Item, abort.
1299
          or return;    # if we don't get an Item, abort.
1300
        my $item_object = Koha::Items->find( { barcode => $barcode } );
1303
1301
1304
        my $branch = _GetCircControlBranch( $item, $borrower );
1302
        my $branch = _GetCircControlBranch( $item, $borrower );
1305
1303
1306
        # get actual issuing if there is one
1304
        # get actual issuing if there is one
1307
        my $actualissue = GetItemIssue( $item->{itemnumber} );
1305
        my $actualissue = GetItemIssue( $item->{itemnumber} );
1308
1306
1309
        # get biblioinformation for this item
1310
        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1311
1312
        # check if we just renew the issue.
1307
        # check if we just renew the issue.
1313
        if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}
1308
        if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}
1314
                and not $switch_onsite_checkout ) {
1309
                and not $switch_onsite_checkout ) {
Lines 1362-1371 sub AddIssue { Link Here
1362
1357
1363
            # Record in the database the fact that the book was issued.
1358
            # Record in the database the fact that the book was issued.
1364
            unless ($datedue) {
1359
            unless ($datedue) {
1365
                my $itype =
1360
                my $itype = $item_object->effective_itemtype;
1366
                  ( C4::Context->preference('item-level_itypes') )
1367
                  ? $biblio->{'itype'}
1368
                  : $biblio->{'itemtype'};
1369
                $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower );
1361
                $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower );
1370
1362
1371
            }
1363
            }
Lines 1466-1472 sub AddIssue { Link Here
1466
        logaction(
1458
        logaction(
1467
            "CIRCULATION", "ISSUE",
1459
            "CIRCULATION", "ISSUE",
1468
            $borrower->{'borrowernumber'},
1460
            $borrower->{'borrowernumber'},
1469
            $biblio->{'itemnumber'}
1461
            $item->{'itemnumber'}
1470
        ) if C4::Context->preference("IssueLog");
1462
        ) if C4::Context->preference("IssueLog");
1471
    }
1463
    }
1472
    return $issue;
1464
    return $issue;
Lines 1864-1870 sub AddReturn { Link Here
1864
    }
1856
    }
1865
1857
1866
        # full item data, but no borrowernumber or checkout info (no issue)
1858
        # full item data, but no borrowernumber or checkout info (no issue)
1867
        # we know GetItem should work because GetItemnumberFromBarcode worked
1868
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1859
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1869
        # get the proper branch to which to return the item
1860
        # get the proper branch to which to return the item
1870
    my $returnbranch = $item->{$hbr} || $branch ;
1861
    my $returnbranch = $item->{$hbr} || $branch ;
Lines 2863-2869 sub AddRenewal { Link Here
2863
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd();
2854
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd();
2864
2855
2865
    my $item   = GetItem($itemnumber) or return;
2856
    my $item   = GetItem($itemnumber) or return;
2866
    my $biblio = GetBiblioFromItemNumber($itemnumber) or return;
2857
    my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item
2858
    my $biblio = $item_object->biblio;
2867
2859
2868
    my $dbh = C4::Context->dbh;
2860
    my $dbh = C4::Context->dbh;
2869
2861
Lines 2891-2898 sub AddRenewal { Link Here
2891
    # based on the value of the RenewalPeriodBase syspref.
2883
    # based on the value of the RenewalPeriodBase syspref.
2892
    unless ($datedue) {
2884
    unless ($datedue) {
2893
2885
2894
        my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'};
2886
        my $itemtype = $item_object->effective_itemtype;
2895
2896
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2887
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2897
                                        dt_from_string( $issuedata->{date_due} ) :
2888
                                        dt_from_string( $issuedata->{date_due} ) :
2898
                                        DateTime->now( time_zone => C4::Context->tz());
2889
                                        DateTime->now( time_zone => C4::Context->tz());
Lines 2910-2923 sub AddRenewal { Link Here
2910
    $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
2901
    $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
2911
2902
2912
    # Update the renewal count on the item, and tell zebra to reindex
2903
    # Update the renewal count on the item, and tell zebra to reindex
2913
    $renews = $biblio->{'renewals'} + 1;
2904
    $renews = $item->{renewals} + 1;
2914
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber);
2905
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber);
2915
2906
2916
    # Charge a new rental fee, if applicable?
2907
    # Charge a new rental fee, if applicable?
2917
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2908
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2918
    if ( $charge > 0 ) {
2909
    if ( $charge > 0 ) {
2919
        my $accountno = getnextacctno( $borrowernumber );
2910
        my $accountno = getnextacctno( $borrowernumber );
2920
        my $item = GetBiblioFromItemNumber($itemnumber);
2921
        my $manager_id = 0;
2911
        my $manager_id = 0;
2922
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
2912
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
2923
        $sth = $dbh->prepare(
2913
        $sth = $dbh->prepare(
Lines 2927-2933 sub AddRenewal { Link Here
2927
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2917
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2928
        );
2918
        );
2929
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2919
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2930
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2920
            "Renewal of Rental Item " . $item_object->title . " $item->{'barcode'}",
2931
            'Rent', $charge, $itemnumber );
2921
            'Rent', $charge, $itemnumber );
2932
    }
2922
    }
2933
2923
Lines 3749-3757 sub ProcessOfflineOperation { Link Here
3749
sub ProcessOfflineReturn {
3739
sub ProcessOfflineReturn {
3750
    my $operation = shift;
3740
    my $operation = shift;
3751
3741
3752
    my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} );
3742
    my $item = Koha::Items->find({barcode => $operation->{barcode}});
3753
3743
3754
    if ( $itemnumber ) {
3744
    if ( $item ) {
3745
        my $itemnumber = $item->itemnumber;
3755
        my $issue = GetOpenIssue( $itemnumber );
3746
        my $issue = GetOpenIssue( $itemnumber );
3756
        if ( $issue ) {
3747
        if ( $issue ) {
3757
            MarkIssueReturned(
3748
            MarkIssueReturned(
Lines 3780-3789 sub ProcessOfflineIssue { Link Here
3780
    my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} );
3771
    my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} );
3781
3772
3782
    if ( $borrower->{borrowernumber} ) {
3773
    if ( $borrower->{borrowernumber} ) {
3783
        my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} );
3774
        my $item = Koha::Items->find({ barcode => $operation->{barcode} });
3784
        unless ($itemnumber) {
3775
        unless ($item) {
3785
            return "Barcode not found.";
3776
            return "Barcode not found.";
3786
        }
3777
        }
3778
        my $itemnumber = $item->itemnumber;
3787
        my $issue = GetOpenIssue( $itemnumber );
3779
        my $issue = GetOpenIssue( $itemnumber );
3788
3780
3789
        if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned
3781
        if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned
(-)a/C4/Members.pm (-6 / +8 lines)
Lines 827-835 sub GetMemberAccountRecords { Link Here
827
    my $total = 0;
827
    my $total = 0;
828
    while ( my $data = $sth->fetchrow_hashref ) {
828
    while ( my $data = $sth->fetchrow_hashref ) {
829
        if ( $data->{itemnumber} ) {
829
        if ( $data->{itemnumber} ) {
830
            my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} );
830
            my $item = Koha::Items->find( $data->{itemnumber} );
831
            $data->{biblionumber} = $biblio->{biblionumber};
831
            my $biblio = $item->biblio;
832
            $data->{title}        = $biblio->{title};
832
            $data->{biblionumber} = $biblio->biblionumber;
833
            $data->{title}        = $biblio->title;
833
        }
834
        }
834
        $acctlines[$numlines] = $data;
835
        $acctlines[$numlines] = $data;
835
        $numlines++;
836
        $numlines++;
Lines 908-916 sub GetBorNotifyAcctRecord { Link Here
908
    my $total = 0;
909
    my $total = 0;
909
    while ( my $data = $sth->fetchrow_hashref ) {
910
    while ( my $data = $sth->fetchrow_hashref ) {
910
        if ( $data->{itemnumber} ) {
911
        if ( $data->{itemnumber} ) {
911
            my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} );
912
            my $item = Koha::Items->find( $data->{itemnumber} );
912
            $data->{biblionumber} = $biblio->{biblionumber};
913
            my $biblio = $item->biblio;
913
            $data->{title}        = $biblio->{title};
914
            $data->{biblionumber} = $biblio->biblionumber;
915
            $data->{title}        = $biblio->title;
914
        }
916
        }
915
        $acctlines[$numlines] = $data;
917
        $acctlines[$numlines] = $data;
916
        $numlines++;
918
        $numlines++;
(-)a/C4/SIP/ILS/Item.pm (-19 / +17 lines)
Lines 23-28 use C4::Members; Link Here
23
use C4::Reserves;
23
use C4::Reserves;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Biblios;
25
use Koha::Biblios;
26
use Koha::Items;
26
27
27
28
28
=encoding UTF-8
29
=encoding UTF-8
Lines 69-105 use Koha::Biblios; Link Here
69
sub new {
70
sub new {
70
	my ($class, $item_id) = @_;
71
	my ($class, $item_id) = @_;
71
	my $type = ref($class) || $class;
72
	my $type = ref($class) || $class;
72
	my $self;
73
    my $item = Koha::Items->find( { barcode => $item_id } );
73
    my $itemnumber = GetItemnumberFromBarcode($item_id);
74
    unless ( $item ) {
74
	my $item = GetBiblioFromItemNumber($itemnumber);    # actually biblio.*, biblioitems.* AND items.*  (overkill)
75
	if (! $item) {
76
		syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
75
		syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
77
		warn "new ILS::Item($item_id) : No item '$item_id'.";
76
		warn "new ILS::Item($item_id) : No item '$item_id'.";
78
        return;
77
        return;
79
	}
78
	}
80
    $item->{  'itemnumber'   } = $itemnumber;
79
    my $self = $item->unblessed;
81
    $item->{      'id'       } = $item->{barcode};     # to SIP, the barcode IS the id.
80
    $self->{      'id'       } = $item->barcode;     # to SIP, the barcode IS the id.
82
    $item->{permanent_location}= $item->{homebranch};
81
    $self->{permanent_location}= $item->homebranch;
83
    $item->{'collection_code'} = $item->{ccode};
82
    $self->{'collection_code'} = $item->ccode;
84
    $item->{  'call_number'  } = $item->{itemcallnumber};
83
    $self->{  'call_number'  } = $item->itemcallnumber;
85
84
86
    my $it = C4::Context->preference('item-level_itypes') ? $item->{itype} : $item->{itemtype};
85
    my $it = $item->effective_itemtype;
87
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
86
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
88
    $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
87
    $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
89
88
90
	# check if its on issue and if so get the borrower
89
	# check if its on issue and if so get the borrower
91
	my $issue = GetItemIssue($item->{'itemnumber'});
90
    my $issue = GetItemIssue($item->itemnumber);
92
    if ($issue) {
91
    if ($issue) {
93
        $item->{due_date} = $issue->{date_due};
92
        $self->{due_date} = $issue->{date_due};
94
    }
93
    }
95
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
94
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
96
	$item->{patron} = $borrower->{'cardnumber'};
95
    $self->{patron} = $borrower->{'cardnumber'};
97
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
96
    my $biblio = Koha::Biblios->find( $self->{biblionumber } );
98
    my $holds = $biblio->current_holds->unblessed;
97
    my $holds = $biblio->current_holds->unblessed;
99
    $item->{hold_queue} = $holds;
98
    $self->{hold_queue} = $holds;
100
	$item->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$item->{hold_queue}} )];
99
    $self->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$self->{hold_queue}} )];
101
	$item->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$item->{hold_queue}} )];
100
    $self->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$self->{hold_queue}} )];
102
	$self = $item;
103
	bless $self, $type;
101
	bless $self, $type;
104
102
105
    syslog("LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'",
103
    syslog("LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'",
(-)a/C4/SIP/ILS/Transaction/Hold.pm (-14 / +10 lines)
Lines 3-19 Link Here
3
3
4
package C4::SIP::ILS::Transaction::Hold;
4
package C4::SIP::ILS::Transaction::Hold;
5
5
6
use warnings;
6
use Modern::Perl;
7
use strict;
8
7
9
use C4::SIP::ILS::Transaction;
8
use C4::SIP::ILS::Transaction;
10
9
11
use C4::Reserves;	# AddReserve
10
use C4::Reserves;	# AddReserve
12
use C4::Members;	# GetMember
11
use C4::Members;	# GetMember
13
use C4::Biblio;		# GetBiblioFromItemNumber GetBiblioItemByBiblioNumber
14
use parent qw(C4::SIP::ILS::Transaction);
12
use parent qw(C4::SIP::ILS::Transaction);
15
13
16
14
use Koha::Items;
17
15
18
my %fields = (
16
my %fields = (
19
	expiration_date => 0,
17
	expiration_date => 0,
Lines 49-56 sub do_hold { Link Here
49
        $self->ok(0);
47
        $self->ok(0);
50
        return $self;
48
        return $self;
51
    }
49
    }
52
    my $bib = GetBiblioFromItemNumber( undef, $self->{item}->id );
50
    my $item = Koha::Items->find({ barcode => $self->{item}->id });
53
    unless ($bib) {
51
    unless ($item) {
54
        $self->screen_msg( 'No biblio record matches barcode "' . $self->{item}->id . '".' );
52
        $self->screen_msg( 'No biblio record matches barcode "' . $self->{item}->id . '".' );
55
        $self->ok(0);
53
        $self->ok(0);
56
        return $self;
54
        return $self;
Lines 61-68 sub do_hold { Link Here
61
        $self->ok(0);
59
        $self->ok(0);
62
        return $self;
60
        return $self;
63
    }
61
    }
64
    my $bibno = $bib->{biblionumber};
62
    AddReserve( $branch, $borrower->{borrowernumber}, $item->biblionumber );
65
    AddReserve( $branch, $borrower->{borrowernumber}, $bibno, GetBiblioItemByBiblioNumber($bibno) );
66
63
67
    # unfortunately no meaningful return value
64
    # unfortunately no meaningful return value
68
    $self->ok(1);
65
    $self->ok(1);
Lines 82-91 sub drop_hold { Link Here
82
		$self->ok(0);
79
		$self->ok(0);
83
		return $self;
80
		return $self;
84
	}
81
	}
85
	my $bib = GetBiblioFromItemNumber(undef, $self->{item}->id);
82
    my $item = Koha::Items->find({ barcode => $self->{item}->id });
86
83
87
      CancelReserve({
84
      CancelReserve({
88
            biblionumber   => $bib->{biblionumber},
85
            biblionumber   => $item->biblionumber,
89
        itemnumber     => $self->{item}->id,
86
        itemnumber     => $self->{item}->id,
90
           borrowernumber => $borrower->{borrowernumber}
87
           borrowernumber => $borrower->{borrowernumber}
91
      });
88
      });
Lines 107-114 sub change_hold { Link Here
107
		$self->ok(0);
104
		$self->ok(0);
108
		return $self;
105
		return $self;
109
	}
106
	}
110
	my $bib = GetBiblioFromItemNumber(undef, $self->{item}->id);
107
    my $item = Koha::Items->find({ barcode => $self->{item}->id });
111
	unless ($bib) {
108
    unless ($item) {
112
		$self->screen_msg('No biblio record matches barcode "' . $self->{item}->id . '".');
109
		$self->screen_msg('No biblio record matches barcode "' . $self->{item}->id . '".');
113
		$self->ok(0);
110
		$self->ok(0);
114
		return $self;
111
		return $self;
Lines 119-126 sub change_hold { Link Here
119
		$self->ok(0);
116
		$self->ok(0);
120
		return $self;
117
		return $self;
121
	}
118
	}
122
	my $bibno = $bib->{biblionumber};
119
    ModReserve({ biblionumber => $item->biblionumber, borrowernumber => $borrower->{borrowernumber}, branchcode => $branch });
123
	ModReserve({ biblionumber => $bibno, borrowernumber => $borrower->{borrowernumber}, branchcode => $branch });
124
120
125
	$self->ok(1);
121
	$self->ok(1);
126
	return $self;
122
	return $self;
(-)a/catalogue/issuehistory.pl (-1 / +1 lines)
Lines 24-30 use C4::Auth; Link Here
24
use C4::Output;
24
use C4::Output;
25
25
26
use C4::Circulation;    # GetBiblioIssues
26
use C4::Circulation;    # GetBiblioIssues
27
use C4::Biblio;    # GetBiblio GetBiblioFromItemNumber
27
use C4::Biblio;    # GetBiblio
28
use C4::Search;		# enabled_staff_search_views
28
use C4::Search;		# enabled_staff_search_views
29
29
30
my $query = new CGI;
30
my $query = new CGI;
(-)a/cataloguing/moveitem.pl (-15 / +9 lines)
Lines 34-39 use C4::Acquisition qw/GetOrderFromItemnumber ModOrder GetOrder/; Link Here
34
use Date::Calc qw(Today);
34
use Date::Calc qw(Today);
35
35
36
use MARC::File::XML;
36
use MARC::File::XML;
37
38
use Koha::Items;
39
37
my $query = CGI->new;
40
my $query = CGI->new;
38
41
39
# The biblio to move the item to
42
# The biblio to move the item to
Lines 61-79 $template->param(biblionumber => $biblionumber); Link Here
61
64
62
# If we already have the barcode of the item to move and the biblionumber to move the item to
65
# If we already have the barcode of the item to move and the biblionumber to move the item to
63
if ($barcode && $biblionumber) { 
66
if ($barcode && $biblionumber) { 
64
    
65
    # We get his itemnumber
66
    my $itemnumber = GetItemnumberFromBarcode($barcode);
67
67
68
    if ($itemnumber) {
68
    my $itemnumber;
69
    	# And then, we get the item
69
    my $item = Koha::Items->find({ barcode => $barcode });
70
	my $item = GetItem($itemnumber);
70
71
    if ($item) {
71
72
72
	if ($item) {
73
        $itemnumber = $item->itemnumber;
74
        my $frombiblionumber = $item->biblionumber;
73
75
74
	    my $results = GetBiblioFromItemNumber($itemnumber, $barcode);
75
	    my $frombiblionumber = $results->{'biblionumber'};
76
	   
77
	    my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber); 
76
	    my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber); 
78
	    if ($moveresult) { 
77
	    if ($moveresult) { 
79
		$template->param(success => 1);
78
		$template->param(success => 1);
Lines 87-97 if ($barcode && $biblionumber) { Link Here
87
	    $template->param(error => 1,
86
	    $template->param(error => 1,
88
	                     errornoitem => 1);
87
	                     errornoitem => 1);
89
	}
88
	}
90
    } else {
91
	    $template->param(error => 1,
92
			     errornoitemnumber => 1);
93
94
    }
95
    $template->param(
89
    $template->param(
96
			barcode => $barcode,  
90
			barcode => $barcode,  
97
			itemnumber => $itemnumber,
91
			itemnumber => $itemnumber,
(-)a/circ/branchtransfers.pl (-24 / +22 lines)
Lines 33-38 use C4::Koha; Link Here
33
use C4::Members;
33
use C4::Members;
34
use Koha::BiblioFrameworks;
34
use Koha::BiblioFrameworks;
35
use Koha::AuthorisedValues;
35
use Koha::AuthorisedValues;
36
use Koha::Items;
36
37
37
###############################################
38
###############################################
38
#  Getting state
39
#  Getting state
Lines 112-143 defined $barcode and $barcode =~ s/^\s*|\s*$//g; # FIXME: barcodeInputFilter Link Here
112
# warn "barcode : $barcode";
113
# warn "barcode : $barcode";
113
if ($barcode) {
114
if ($barcode) {
114
115
115
    my $iteminformation;
116
    ( $transfered, $messages ) =
116
    ( $transfered, $messages, $iteminformation ) =
117
      transferbook( $tobranchcd, $barcode, $ignoreRs );
117
      transferbook( $tobranchcd, $barcode, $ignoreRs );
118
#       use Data::Dumper;
118
    my $item = Koha::Items->find({ barcode => $barcode });
119
#       warn "Transfered : $transfered / ".Dumper($messages);
120
    $found = $messages->{'ResFound'};
119
    $found = $messages->{'ResFound'};
121
    if ($transfered) {
120
    if ($transfered) {
122
        my %item;
121
        my %item;
122
        my $biblio = $item->biblio;
123
        my $frbranchcd =  C4::Context->userenv->{'branch'};
123
        my $frbranchcd =  C4::Context->userenv->{'branch'};
124
#         if ( not($found) ) {
124
        $item{'biblionumber'}          = $item->biblionumber;
125
        $item{'biblionumber'}          = $iteminformation->{'biblionumber'};
125
        $item{'itemnumber'}            = $item->itemnumber;
126
        $item{'itemnumber'}            = $iteminformation->{'itemnumber'};
126
        $item{'title'}                 = $biblio->title;
127
        $item{'title'}                 = $iteminformation->{'title'};
127
        $item{'author'}                = $biblio->author;
128
        $item{'author'}                = $iteminformation->{'author'};
128
        $item{'itemtype'}              = $biblio->biblioitem->itemtype;
129
        $item{'itemtype'}              = $iteminformation->{'itemtype'};
129
        $item{'ccode'}                 = $item->ccode;
130
        $item{'ccode'}                 = $iteminformation->{'ccode'};
130
        $item{'itemcallnumber'}        = $item->itemcallnumber;
131
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
131
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $item->location });
132
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
133
        $item{'location'}              = $av->count ? $av->next->lib : '';
132
        $item{'location'}              = $av->count ? $av->next->lib : '';
134
#         }
135
        $item{counter}  = 0;
133
        $item{counter}  = 0;
136
        $item{barcode}  = $barcode;
134
        $item{barcode}  = $barcode;
137
        $item{frombrcd} = $frbranchcd;
135
        $item{frombrcd} = $frbranchcd;
138
        $item{tobrcd}   = $tobranchcd;
136
        $item{tobrcd}   = $tobranchcd;
139
        push( @trsfitemloop, \%item );
137
        push( @trsfitemloop, \%item );
140
#         warn Dumper(@trsfitemloop);
141
    }
138
    }
142
}
139
}
143
140
Lines 153-167 foreach ( $query->param ) { Link Here
153
    $item{barcode}  = $bc;
150
    $item{barcode}  = $bc;
154
    $item{frombrcd} = $frbcd;
151
    $item{frombrcd} = $frbcd;
155
    $item{tobrcd}   = $tobcd;
152
    $item{tobrcd}   = $tobcd;
156
    my ($iteminformation) = GetBiblioFromItemNumber( GetItemnumberFromBarcode($bc) );
153
    my $item = Koha::Items->find({ barcode => $bc });
157
    $item{'biblionumber'}          = $iteminformation->{'biblionumber'};
154
    my $biblio = $item->biblio;
158
    $item{'itemnumber'}            = $iteminformation->{'itemnumber'};
155
    $item{'biblionumber'}          = $item->biblionumber;
159
    $item{'title'}                 = $iteminformation->{'title'};
156
    $item{'itemnumber'}            = $item->itemnumber;
160
    $item{'author'}                = $iteminformation->{'author'};
157
    $item{'title'}                 = $biblio->title;
161
    $item{'itemtype'}              = $iteminformation->{'itemtype'};
158
    $item{'author'}                = $biblio->author;
162
    $item{'ccode'}                 = $iteminformation->{'ccode'};
159
    $item{'itemtype'}              = $biblio->biblioitem->itemtype;
163
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
160
    $item{'ccode'}                 = $item->ccode;
164
    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
161
    $item{'itemcallnumber'}        = $item->itemcallnumber;
162
    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $item->location });
165
    $item{'location'}              = $av->count ? $av->next->lib : '';
163
    $item{'location'}              = $av->count ? $av->next->lib : '';
166
    push( @trsfitemloop, \%item );
164
    push( @trsfitemloop, \%item );
167
}
165
}
(-)a/circ/returns.pl (-50 / +41 lines)
Lines 52-57 use Koha::DateUtils; Link Here
52
use Koha::Calendar;
52
use Koha::Calendar;
53
use Koha::BiblioFrameworks;
53
use Koha::BiblioFrameworks;
54
use Koha::Checkouts;
54
use Koha::Checkouts;
55
use Koha::Items;
55
use Koha::Patrons;
56
use Koha::Patrons;
56
57
57
my $query = new CGI;
58
my $query = new CGI;
Lines 146-159 if ($query->param('WT-itemNumber')){ Link Here
146
}
147
}
147
148
148
if ( $query->param('reserve_id') ) {
149
if ( $query->param('reserve_id') ) {
149
    my $item           = $query->param('itemnumber');
150
    my $itemnumber     = $query->param('itemnumber');
150
    my $borrowernumber = $query->param('borrowernumber');
151
    my $borrowernumber = $query->param('borrowernumber');
151
    my $reserve_id     = $query->param('reserve_id');
152
    my $reserve_id     = $query->param('reserve_id');
152
    my $diffBranchReturned = $query->param('diffBranch');
153
    my $diffBranchReturned = $query->param('diffBranch');
153
    my $iteminfo   = GetBiblioFromItemNumber($item);
154
    my $cancel_reserve = $query->param('cancel_reserve');
154
    my $cancel_reserve = $query->param('cancel_reserve');
155
    # fix up item type for display
155
    # fix up item type for display
156
    $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'};
156
    my $item = Koha::Items->find( $itemnumber );
157
    my $biblio = $item->biblio;
157
158
158
    if ( $cancel_reserve ) {
159
    if ( $cancel_reserve ) {
159
        CancelReserve({ reserve_id => $reserve_id, charge_cancel_fee => !$forgivemanualholdsexpire });
160
        CancelReserve({ reserve_id => $reserve_id, charge_cancel_fee => !$forgivemanualholdsexpire });
Lines 161-179 if ( $query->param('reserve_id') ) { Link Here
161
        my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
162
        my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
162
        # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
163
        # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
163
        # i.e., whether to apply waiting status
164
        # i.e., whether to apply waiting status
164
        ModReserveAffect( $item, $borrowernumber, $diffBranchSend, $reserve_id );
165
        ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id );
165
    }
166
    }
166
#   check if we have other reserves for this document, if we have a return send the message of transfer
167
#   check if we have other reserves for this document, if we have a return send the message of transfer
167
    my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
168
    my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
168
169
169
    my $borr = GetMember( borrowernumber => $nextreservinfo );
170
    my $borr = GetMember( borrowernumber => $nextreservinfo );
170
    my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
171
    my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
171
    if ( $messages->{'transfert'} ) {
172
    if ( $messages->{'transfert'} ) {
172
        $template->param(
173
        $template->param(
173
            itemtitle      => $iteminfo->{'title'},
174
            itemtitle      => $biblio->title,
174
            itemnumber     => $iteminfo->{'itemnumber'},
175
            itemnumber     => $item->itemnumber,
175
            itembiblionumber => $iteminfo->{'biblionumber'},
176
            itembiblionumber => $biblio->biblionumber,
176
            iteminfo       => $iteminfo->{'author'},
177
            iteminfo       => $biblio->author,
177
            name           => $name,
178
            name           => $name,
178
            borrowernumber => $borrowernumber,
179
            borrowernumber => $borrowernumber,
179
            borcnum        => $borr->{'cardnumber'},
180
            borcnum        => $borr->{'cardnumber'},
Lines 256-275 my $returnbranch; Link Here
256
if ($barcode) {
257
if ($barcode) {
257
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
258
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
258
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
259
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
259
    $itemnumber = GetItemnumberFromBarcode($barcode);
260
    my $item = Koha::Items->find({ barcode => $barcode });
260
261
#
262
# save the return
263
#
264
265
    # get biblio description
266
    my $biblio = GetBiblioFromItemNumber($itemnumber);
267
    # fix up item type for display
268
    $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
269
261
270
    # Check if we should display a checkin message, based on the the item
262
    # Check if we should display a checkin message, based on the the item
271
    # type of the checked in item
263
    # type of the checked in item
272
    my $itemtype = Koha::ItemTypes->find( $biblio->{'itemtype'} );
264
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
273
    if ( $itemtype && $itemtype->checkinmsg ) {
265
    if ( $itemtype && $itemtype->checkinmsg ) {
274
        $template->param(
266
        $template->param(
275
            checkinmsg     => $itemtype->checkinmsg,
267
            checkinmsg     => $itemtype->checkinmsg,
Lines 278-303 if ($barcode) { Link Here
278
    }
270
    }
279
271
280
    # make sure return branch respects home branch circulation rules, default to homebranch
272
    # make sure return branch respects home branch circulation rules, default to homebranch
281
    my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
273
    my $hbr = GetBranchItemRule($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
282
    $returnbranch = $biblio->{$hbr};
274
    $returnbranch = $item->$hbr;
283
275
284
    my $materials = $biblio->{'materials'};
276
    my $materials = $item->materials;
285
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
277
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
286
    $materials = $descriptions->{lib} // $materials;
278
    $materials = $descriptions->{lib} // $materials;
287
279
288
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
280
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
289
281
282
    my $biblio = $item->biblio;
290
    $template->param(
283
    $template->param(
291
        title            => $biblio->{'title'},
284
        title            => $biblio->title,
292
        homebranch       => $biblio->{'homebranch'},
285
        homebranch       => $item->homebranch,
293
        holdingbranch    => $biblio->{'holdingbranch'},
286
        holdingbranch    => $item->holdingbranch,
294
        returnbranch     => $returnbranch,
287
        returnbranch     => $returnbranch,
295
        author           => $biblio->{'author'},
288
        author           => $biblio->author,
296
        itembarcode      => $biblio->{'barcode'},
289
        itembarcode      => $item->barcode,
297
        itemtype         => $biblio->{'itemtype'},
290
        itemtype         => $item->effective_itemtype,
298
        ccode            => $biblio->{'ccode'},
291
        ccode            => $item->ccode,
299
        itembiblionumber => $biblio->{'biblionumber'},
292
        itembiblionumber => $biblio->biblionumber,
300
        biblionumber     => $biblio->{'biblionumber'},
293
        biblionumber     => $biblio->biblionumber,
301
        borrower         => $borrower,
294
        borrower         => $borrower,
302
        additional_materials => $materials,
295
        additional_materials => $materials,
303
        issue            => $issue,
296
        issue            => $issue,
Lines 594-618 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
594
            $ri{borrowernumber} = $riborrowernumber{$_};
587
            $ri{borrowernumber} = $riborrowernumber{$_};
595
        }
588
        }
596
589
597
        #        my %ri;
590
        my $item = Koha::Items->find({ barcode => $bar_code });
598
        my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
591
        my $biblio = $item->biblio;
599
        my $item   = GetItem( GetItemnumberFromBarcode($bar_code) );
592
        # FIXME pass $item to the template and we are done here...
600
        # fix up item type for display
593
        $ri{itembiblionumber}    = $biblio->biblionumber;
601
        $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
594
        $ri{itemtitle}           = $biblio->title;
602
        $ri{itembiblionumber}    = $biblio->{'biblionumber'};
595
        $ri{itemauthor}          = $biblio->author;
603
        $ri{itemtitle}           = $biblio->{'title'};
596
        $ri{itemcallnumber}      = $item->itemcallnumber;
604
        $ri{itemauthor}          = $biblio->{'author'};
597
        $ri{dateaccessioned}     = $item->dateaccessioned;
605
        $ri{itemcallnumber}      = $biblio->{'itemcallnumber'};
598
        $ri{itemtype}            = $item->effective_itemtype;
606
        $ri{dateaccessioned}     = $item->{dateaccessioned};
599
        $ri{itemnote}            = $item->itemnotes;
607
        $ri{itemtype}            = $biblio->{'itemtype'};
600
        $ri{itemnotes_nonpublic} = $item->itemnotes_nonpublic;
608
        $ri{itemnote}            = $biblio->{'itemnotes'};
601
        $ri{ccode}               = $item->ccode;
609
        $ri{itemnotes_nonpublic} = $item->{'itemnotes_nonpublic'};
602
        $ri{enumchron}           = $item->enumchron;
610
        $ri{ccode}               = $biblio->{'ccode'};
603
        $ri{itemnumber}          = $item->itemnumber;
611
        $ri{enumchron}           = $biblio->{'enumchron'};
612
        $ri{itemnumber}          = $biblio->{'itemnumber'};
613
        $ri{barcode}             = $bar_code;
604
        $ri{barcode}             = $bar_code;
614
        $ri{homebranch}          = $item->{'homebranch'};
605
        $ri{homebranch}          = $item->homebranch;
615
        $ri{holdingbranch}       = $item->{'holdingbranch'};
606
        $ri{holdingbranch}       = $item->holdingbranch;
616
607
617
        $ri{location}         = $biblio->{'location'};
608
        $ri{location}         = $biblio->{'location'};
618
        my $shelfcode = $ri{'location'};
609
        my $shelfcode = $ri{'location'};
(-)a/circ/transferstoreceive.pl (-9 / +18 lines)
Lines 89-108 while ( my $library = $libraries->next ) { Link Here
89
                $getransf{'messcompa'} = 1;
89
                $getransf{'messcompa'} = 1;
90
				$getransf{'diff'} = $diff;
90
				$getransf{'diff'} = $diff;
91
            }
91
            }
92
            my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
92
93
            my $itemtype = Koha::ItemTypes->find( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} );
93
            my $item = Koha::Items->find( $num->{itemnumber} );
94
            my $biblio = $item->biblio;
95
            my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
94
96
95
            $getransf{'datetransfer'} = $num->{'datesent'};
97
            $getransf{'datetransfer'} = $num->{'datesent'};
96
            $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
98
            $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
97
			foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
99
            %getransf = (
98
            	$getransf{$_} = $gettitle->{$_};
100
                %getransf,
99
			}
101
                title          => $biblio->title,
100
102
                author         => $biblio->author,
101
            my $record = GetMarcBiblio($gettitle->{'biblionumber'});
103
                biblionumber   => $biblio->biblionumber,
102
            $getransf{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($gettitle->{'biblionumber'}));
104
                itemnumber     => $item->itemnumber,
105
                barcode        => $item->barcode,
106
                homebranch     => $item->homebranch,
107
                holdingbranch  => $item->holdingbranch,
108
                itemcallnumber => $item->itemcallnumber,
109
            );
110
111
            my $record = GetMarcBiblio($biblio->biblionumber);
112
            $getransf{'subtitle'} = GetRecordValue('subtitle', $record, $biblio->frameworkcode);
103
113
104
            # we check if we have a reserv for this transfer
114
            # we check if we have a reserv for this transfer
105
            my $item = Koha::Items->find( $num->{itemnumber} );
106
            my $holds = $item->current_holds;
115
            my $holds = $item->current_holds;
107
            if ( my $first_hold = $holds->next ) {
116
            if ( my $first_hold = $holds->next ) {
108
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
117
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
(-)a/circ/waitingreserves.pl (-17 / +17 lines)
Lines 37-42 use C4::Reserves; Link Here
37
use C4::Koha;
37
use C4::Koha;
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::BiblioFrameworks;
39
use Koha::BiblioFrameworks;
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 92-125 foreach my $num (@getreserves) { Link Here
92
    next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
93
    next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
93
94
94
    my $itemnumber = $num->{'itemnumber'};
95
    my $itemnumber = $num->{'itemnumber'};
95
    my $gettitle     = GetBiblioFromItemNumber( $itemnumber );
96
    my $item = Koha::Items->find( $itemnumber );
97
    my $biblio = $item->biblio;
96
    my $borrowernum = $num->{'borrowernumber'};
98
    my $borrowernum = $num->{'borrowernumber'};
97
    my $holdingbranch = $gettitle->{'holdingbranch'};
99
    my $holdingbranch = $item->holdingbranch;
98
    my $homebranch = $gettitle->{'homebranch'};
100
    my $homebranch = $item->homebranch;
99
101
100
    my %getreserv = (
102
    my %getreserv = (
101
        itemnumber => $itemnumber,
103
        itemnumber => $itemnumber,
102
        borrowernum => $borrowernum,
104
        borrowernum => $borrowernum,
103
    );
105
    );
104
106
105
    # fix up item type for display
106
    $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
107
    my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
107
    my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
108
    my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
108
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
109
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
109
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
110
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
110
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
111
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
111
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
112
112
113
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
113
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
114
    $getreserv{'title'}          = $gettitle->{'title'};
114
    $getreserv{'title'}          = $biblio->title;
115
    $getreserv{'subtitle'}       = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'}));
115
    $getreserv{'subtitle'}       = GetRecordValue('subtitle', GetMarcBiblio($biblio->biblionumber), $biblio->frameworkcode);
116
    $getreserv{'biblionumber'}   = $gettitle->{'biblionumber'};
116
    $getreserv{'biblionumber'}   = $biblio->biblionumber;
117
    $getreserv{'barcode'}        = $gettitle->{'barcode'};
117
    $getreserv{'barcode'}        = $item->barcode;
118
    $getreserv{'homebranch'}     = $gettitle->{'homebranch'};
118
    $getreserv{'homebranch'}     = $homebranch;
119
    $getreserv{'holdingbranch'}  = $gettitle->{'holdingbranch'};
119
    $getreserv{'holdingbranch'}  = $item->holdingbranch;
120
    $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
120
    $getreserv{'itemcallnumber'} = $item->itemcallnumber;
121
    $getreserv{'enumchron'}      = $gettitle->{'enumchron'};
121
    $getreserv{'enumchron'}      = $item->enumchron;
122
    $getreserv{'copynumber'}     = $gettitle->{'copynumber'};
122
    $getreserv{'copynumber'}     = $item->copynumber;
123
    if ( $homebranch ne $holdingbranch ) {
123
    if ( $homebranch ne $holdingbranch ) {
124
        $getreserv{'dotransfer'} = 1;
124
        $getreserv{'dotransfer'} = 1;
125
    }
125
    }
Lines 190-196 sub cancel { Link Here
190
    if ($nextreservinfo) {
190
    if ($nextreservinfo) {
191
        my %res;
191
        my %res;
192
        my $borrowerinfo = C4::Members::GetMember( borrowernumber => $nextreservinfo );
192
        my $borrowerinfo = C4::Members::GetMember( borrowernumber => $nextreservinfo );
193
        my $iteminfo = GetBiblioFromItemNumber($item);
193
        my $title = Koha::Items->find( $item )->biblio->title;
194
        if ( $messages->{'transfert'} ) {
194
        if ( $messages->{'transfert'} ) {
195
            $res{messagetransfert} = $messages->{'transfert'};
195
            $res{messagetransfert} = $messages->{'transfert'};
196
            $res{branchcode}       = $messages->{'transfert'};
196
            $res{branchcode}       = $messages->{'transfert'};
Lines 201-207 sub cancel { Link Here
201
        $res{nextreservsurname}   = $borrowerinfo->{'surname'};
201
        $res{nextreservsurname}   = $borrowerinfo->{'surname'};
202
        $res{nextreservfirstname} = $borrowerinfo->{'firstname'};
202
        $res{nextreservfirstname} = $borrowerinfo->{'firstname'};
203
        $res{nextreservitem}      = $item;
203
        $res{nextreservitem}      = $item;
204
        $res{nextreservtitle}     = $iteminfo->{'title'};
204
        $res{nextreservtitle}     = $title;
205
        $res{waiting}             = $messages->{'waiting'} ? 1 : 0;
205
        $res{waiting}             = $messages->{'waiting'} ? 1 : 0;
206
206
207
        return \%res;
207
        return \%res;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/moveitem.tt (-6 / +2 lines)
Lines 36-53 Link Here
36
		[% IF ( errornonewitem ) %]ERROR: Unable to create the new item.<p>
36
		[% IF ( errornonewitem ) %]ERROR: Unable to create the new item.<p>
37
			[% INCLUDE actions %]
37
			[% INCLUDE actions %]
38
			[% INCLUDE fail %]
38
			[% INCLUDE fail %]
39
		</p>
39
		[% END %]
40
		[% END %]
40
41
41
		[% IF ( errornoitem ) %]ERROR: Unable to get the item.<p>
42
		[% IF ( errornoitem ) %]ERROR: Unable to get the item.<p>
42
			[% INCLUDE actions %]
43
			[% INCLUDE actions %]
43
			[% INCLUDE fail %]
44
			[% INCLUDE fail %]
44
		[% END %]
45
46
		[% IF ( errornoitemnumber ) %]ERROR: Unable to get the item number from this barcode.<p>
47
			[% INCLUDE actions %]
48
			[% INCLUDE fail %]
49
		[% END %]
50
		</p>
45
		</p>
46
		[% END %]
51
    </div>
47
    </div>
52
48
53
	[% ELSE %]
49
	[% ELSE %]
(-)a/misc/cronjobs/advance_notices.pl (-4 / +5 lines)
Lines 57-62 use C4::Members::Messaging; Link Here
57
use C4::Overdues;
57
use C4::Overdues;
58
use Koha::DateUtils;
58
use Koha::DateUtils;
59
use C4::Log;
59
use C4::Log;
60
use Koha::Items;
60
use Koha::Libraries;
61
use Koha::Libraries;
61
use Koha::Patrons;
62
use Koha::Patrons;
62
63
Lines 251-257 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
251
            $due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
252
            $due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
252
            $due_digest->{ $upcoming->{borrowernumber} }->{count}++;
253
            $due_digest->{ $upcoming->{borrowernumber} }->{count}++;
253
        } else {
254
        } else {
254
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
255
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
255
            my $letter_type = 'DUE';
256
            my $letter_type = 'DUE';
256
            $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0');
257
            $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0');
257
            my $titles = "";
258
            my $titles = "";
Lines 265-271 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
265
                my $letter = parse_letter( { letter_code    => $letter_type,
266
                my $letter = parse_letter( { letter_code    => $letter_type,
266
                                      borrowernumber => $upcoming->{'borrowernumber'},
267
                                      borrowernumber => $upcoming->{'borrowernumber'},
267
                                      branchcode     => $upcoming->{'branchcode'},
268
                                      branchcode     => $upcoming->{'branchcode'},
268
                                      biblionumber   => $biblio->{'biblionumber'},
269
                                      biblionumber   => $item->biblionumber,
269
                                      itemnumber     => $upcoming->{'itemnumber'},
270
                                      itemnumber     => $upcoming->{'itemnumber'},
270
                                      substitute     => { 'items.content' => $titles },
271
                                      substitute     => { 'items.content' => $titles },
271
                                      message_transport_type => $transport,
272
                                      message_transport_type => $transport,
Lines 285-291 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
285
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
286
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
286
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
287
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
287
        } else {
288
        } else {
288
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
289
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
289
            my $letter_type = 'PREDUE';
290
            my $letter_type = 'PREDUE';
290
            $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'});
291
            $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'});
291
            my $titles = "";
292
            my $titles = "";
Lines 299-305 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
299
                my $letter = parse_letter( { letter_code    => $letter_type,
300
                my $letter = parse_letter( { letter_code    => $letter_type,
300
                                      borrowernumber => $upcoming->{'borrowernumber'},
301
                                      borrowernumber => $upcoming->{'borrowernumber'},
301
                                      branchcode     => $upcoming->{'branchcode'},
302
                                      branchcode     => $upcoming->{'branchcode'},
302
                                      biblionumber   => $biblio->{'biblionumber'},
303
                                      biblionumber   => $item->biblionumber,
303
                                      itemnumber     => $upcoming->{'itemnumber'},
304
                                      itemnumber     => $upcoming->{'itemnumber'},
304
                                      substitute     => { 'items.content' => $titles },
305
                                      substitute     => { 'items.content' => $titles },
305
                                      message_transport_type => $transport,
306
                                      message_transport_type => $transport,
(-)a/offline_circ/enqueue_koc.pl (-3 / +4 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Members;
33
use C4::Members;
34
use C4::Stats;
34
use C4::Stats;
35
use Koha::UploadedFiles;
35
use Koha::UploadedFiles;
36
use Koha::Items;
36
37
37
use Date::Calc qw( Add_Delta_Days Date_to_Days );
38
use Date::Calc qw( Add_Delta_Days Date_to_Days );
38
39
Lines 189-198 sub _get_borrowernumber_from_barcode { Link Here
189
190
190
    return unless $barcode;
191
    return unless $barcode;
191
192
192
    my $item = GetBiblioFromItemNumber( undef, $barcode );
193
    my $item = Koha::Items->find({ barcode => $barcode });
193
    return unless $item->{'itemnumber'};
194
    return unless $item;
194
195
195
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
196
    my $issue = C4::Circulation::GetItemIssue( $item->itemnumber );
196
    return unless $issue->{'borrowernumber'};
197
    return unless $issue->{'borrowernumber'};
197
    return $issue->{'borrowernumber'};
198
    return $issue->{'borrowernumber'};
198
}
199
}
(-)a/offline_circ/list.pl (-3 / +6 lines)
Lines 30-35 use C4::Circulation; Link Here
30
use C4::Members;
30
use C4::Members;
31
use C4::Biblio;
31
use C4::Biblio;
32
32
33
use Koha::Items;
34
33
my $query = CGI->new;
35
my $query = CGI->new;
34
36
35
my ($template, $loggedinuser, $cookie) = get_template_and_user({
37
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 43-51 my ($template, $loggedinuser, $cookie) = get_template_and_user({ Link Here
43
my $operations = GetOfflineOperations;
45
my $operations = GetOfflineOperations;
44
46
45
for (@$operations) {
47
for (@$operations) {
46
    my $biblio             = GetBiblioFromItemNumber(undef, $_->{'barcode'});
48
    my $item = Koha::Items->find({ barcode => $_->{barcode} });
47
    $_->{'bibliotitle'}    = $biblio->{'title'};
49
    my $biblio = $item->biblio;
48
    $_->{'biblionumber'}   = $biblio->{'biblionumber'};
50
    $_->{'bibliotitle'}    = $biblio->title;
51
    $_->{'biblionumber'}   = $biblio->biblionumber;
49
    my $borrower           = C4::Members::GetMember( cardnumber => $_->{'cardnumber'} );
52
    my $borrower           = C4::Members::GetMember( cardnumber => $_->{'cardnumber'} );
50
    if ($borrower) {
53
    if ($borrower) {
51
        $_->{'borrowernumber'} = $borrower->{'borrowernumber'};
54
        $_->{'borrowernumber'} = $borrower->{'borrowernumber'};
(-)a/offline_circ/process_koc.pl (-24 / +25 lines)
Lines 249-267 sub kocIssueItem { Link Here
249
    $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
    my $branchcode = C4::Context->userenv->{branch};
250
    my $branchcode = C4::Context->userenv->{branch};
251
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
251
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
252
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
252
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
253
    my $issue = GetItemIssue( $item->{'itemnumber'} );
253
    my $issue = GetItemIssue( $item->itemnumber );
254
    my $biblio = $item->biblio;
254
255
255
    if ( $issue->{ 'date_due' } ) { ## Item is currently checked out to another person.
256
    if ( $issue->{ 'date_due' } ) { ## Item is currently checked out to another person.
256
        #warn "Item Currently Issued.";
257
        #warn "Item Currently Issued.";
257
        my $issue = GetOpenIssue( $item->{'itemnumber'} );
258
        my $issue = GetOpenIssue( $item->itemnumber );
258
259
259
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
260
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
260
            #warn "Item issued to this member already, renewing.";
261
            #warn "Item issued to this member already, renewing.";
261
262
262
            C4::Circulation::AddRenewal(
263
            C4::Circulation::AddRenewal(
263
                $issue->{'borrowernumber'},    # borrowernumber
264
                $issue->{'borrowernumber'},    # borrowernumber
264
                $item->{'itemnumber'},         # itemnumber
265
                $item->itemnumber,             # itemnumber
265
                undef,                         # branch
266
                undef,                         # branch
266
                undef,                         # datedue - let AddRenewal calculate it automatically
267
                undef,                         # datedue - let AddRenewal calculate it automatically
267
                $circ->{'date'},               # issuedate
268
                $circ->{'date'},               # issuedate
Lines 269-277 sub kocIssueItem { Link Here
269
270
270
            push @output, {
271
            push @output, {
271
                renew => 1,
272
                renew => 1,
272
                title => $item->{ 'title' },
273
                title => $biblio->title,
273
                biblionumber => $item->{'biblionumber'},
274
                biblionumber => $biblio->biblionumber,
274
                barcode => $item->{ 'barcode' },
275
                barcode => $item->barcode,
275
                firstname => $borrower->{ 'firstname' },
276
                firstname => $borrower->{ 'firstname' },
276
                surname => $borrower->{ 'surname' },
277
                surname => $borrower->{ 'surname' },
277
                borrowernumber => $borrower->{'borrowernumber'},
278
                borrowernumber => $borrower->{'borrowernumber'},
Lines 290-298 sub kocIssueItem { Link Here
290
                C4::Circulation::AddIssue( $borrower, $circ->{'barcode'}, undef, undef, $circ->{'date'} ) unless ( DEBUG );
291
                C4::Circulation::AddIssue( $borrower, $circ->{'barcode'}, undef, undef, $circ->{'date'} ) unless ( DEBUG );
291
                push @output, {
292
                push @output, {
292
                    issue => 1,
293
                    issue => 1,
293
                    title => $item->{ 'title' },
294
                    title => $biblio->title,
294
                    biblionumber => $item->{'biblionumber'},
295
                    biblionumber => $biblio->biblionumber,
295
                    barcode => $item->{ 'barcode' },
296
                    barcode => $item->barcode,
296
                    firstname => $borrower->{ 'firstname' },
297
                    firstname => $borrower->{ 'firstname' },
297
                    surname => $borrower->{ 'surname' },
298
                    surname => $borrower->{ 'surname' },
298
                    borrowernumber => $borrower->{'borrowernumber'},
299
                    borrowernumber => $borrower->{'borrowernumber'},
Lines 310-318 sub kocIssueItem { Link Here
310
        C4::Circulation::AddIssue( $borrower, $circ->{'barcode'}, undef, undef, $circ->{'date'} ) unless ( DEBUG );
311
        C4::Circulation::AddIssue( $borrower, $circ->{'barcode'}, undef, undef, $circ->{'date'} ) unless ( DEBUG );
311
        push @output, {
312
        push @output, {
312
            issue => 1,
313
            issue => 1,
313
            title => $item->{ 'title' },
314
            title => $biblio->title,
314
            biblionumber => $item->{'biblionumber'},
315
            biblionumber => $biblio->biblionumber,
315
            barcode => $item->{ 'barcode' },
316
            barcode => $item->barcode,
316
            firstname => $borrower->{ 'firstname' },
317
            firstname => $borrower->{ 'firstname' },
317
            surname => $borrower->{ 'surname' },
318
            surname => $borrower->{ 'surname' },
318
            borrowernumber => $borrower->{'borrowernumber'},
319
            borrowernumber => $borrower->{'borrowernumber'},
Lines 325-351 sub kocIssueItem { Link Here
325
sub kocReturnItem {
326
sub kocReturnItem {
326
    my ( $circ ) = @_;
327
    my ( $circ ) = @_;
327
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
328
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
328
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
329
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
329
    #warn( Data::Dumper->Dump( [ $circ, $item ], [ qw( circ item ) ] ) );
330
    my $biblio = $item->biblio;
330
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
331
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
331
    if ( $borrowernumber ) {
332
    if ( $borrowernumber ) {
332
        my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
333
        my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
333
        C4::Circulation::MarkIssueReturned(
334
        C4::Circulation::MarkIssueReturned(
334
            $borrowernumber,
335
            $borrowernumber,
335
            $item->{'itemnumber'},
336
            $item->itemnumber,
336
            undef,
337
            undef,
337
            $circ->{'date'},
338
            $circ->{'date'},
338
            $borrower->{'privacy'}
339
            $borrower->{'privacy'}
339
        );
340
        );
340
341
341
        ModItem({ onloan => undef }, $item->{'biblionumber'}, $item->{'itemnumber'});
342
        ModItem({ onloan => undef }, $biblio->biblionumber, $item->itemnumber);
342
        ModDateLastSeen( $item->{'itemnumber'} );
343
        ModDateLastSeen( $item->itemnumber );
343
344
344
        push @output, {
345
        push @output, {
345
            return => 1,
346
            return => 1,
346
            title => $item->{ 'title' },
347
            title => $biblio->title,
347
            biblionumber => $item->{'biblionumber'},
348
            biblionumber => $biblio->biblionumber,
348
            barcode => $item->{ 'barcode' },
349
            barcode => $item->barcode,
349
            borrowernumber => $borrower->{'borrowernumber'},
350
            borrowernumber => $borrower->{'borrowernumber'},
350
            firstname => $borrower->{'firstname'},
351
            firstname => $borrower->{'firstname'},
351
            surname => $borrower->{'surname'},
352
            surname => $borrower->{'surname'},
Lines 395-404 sub _get_borrowernumber_from_barcode { Link Here
395
396
396
    return unless $barcode;
397
    return unless $barcode;
397
398
398
    my $item = GetBiblioFromItemNumber( undef, $barcode );
399
    my $item = Koha::Items->find({ barcode => $barcode });
399
    return unless $item->{'itemnumber'};
400
    return unless $item;
400
401
401
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
402
    my $issue = C4::Circulation::GetItemIssue( $item->itemnumber );
402
    return unless $issue->{'borrowernumber'};
403
    return unless $issue->{'borrowernumber'};
403
    return $issue->{'borrowernumber'};
404
    return $issue->{'borrowernumber'};
404
}
405
}
(-)a/opac/opac-shelves.pl (-2 / +2 lines)
Lines 30-35 use C4::Tags qw( get_tags ); Link Here
30
use C4::XSLT;
30
use C4::XSLT;
31
31
32
use Koha::Biblioitems;
32
use Koha::Biblioitems;
33
use Koha::Items;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
use Koha::Virtualshelves;
35
use Koha::Virtualshelves;
35
use Koha::RecordProcessor;
36
use Koha::RecordProcessor;
Lines 174-182 if ( $op eq 'add_form' ) { Link Here
174
        if( my $barcode = $query->param('barcode') ) {
175
        if( my $barcode = $query->param('barcode') ) {
175
            my $item = GetItem( 0, $barcode);
176
            my $item = GetItem( 0, $barcode);
176
            if (defined $item && $item->{itemnumber}) {
177
            if (defined $item && $item->{itemnumber}) {
177
                my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
178
                if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
178
                if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
179
                    my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
179
                    my $added = eval { $shelf->add_biblio( $item->{biblionumber}, $loggedinuser ); };
180
                    if ($@) {
180
                    if ($@) {
181
                        push @messages, { type => 'error', code => ref($@), msg => $@ };
181
                        push @messages, { type => 'error', code => ref($@), msg => $@ };
182
                    } elsif ( $added ) {
182
                    } elsif ( $added ) {
(-)a/virtualshelves/shelves.pl (-3 / +1 lines)
Lines 152-159 if ( $op eq 'add_form' ) { Link Here
152
                    next if $barcode eq '';
152
                    next if $barcode eq '';
153
                    my $item = GetItem( 0, $barcode);
153
                    my $item = GetItem( 0, $barcode);
154
                    if (defined $item && $item->{itemnumber}) {
154
                    if (defined $item && $item->{itemnumber}) {
155
                        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
155
                        my $added = eval { $shelf->add_biblio( $item->{biblionumber}, $loggedinuser ); };
156
                        my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
157
                        if ($@) {
156
                        if ($@) {
158
                            push @messages, { item_barcode => $barcode, type => 'alert', code => ref($@), msg => $@ };
157
                            push @messages, { item_barcode => $barcode, type => 'alert', code => ref($@), msg => $@ };
159
                        } elsif ( $added ) {
158
                        } elsif ( $added ) {
160
- 

Return to bug 18276