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

(-)a/Koha/Biblio.pm (+18 lines)
Lines 318-323 sub subscriptions { Link Here
318
    return $self->{_subscriptions};
318
    return $self->{_subscriptions};
319
}
319
}
320
320
321
=head3 hasItemswaitingOrInTransit
322
323
=cut
324
325
sub hasItemswaitingOrInTransit {
326
    my ( $self ) = @_;
327
328
    if ( Koha::Holds->search({ biblionumber => $self->id,
329
                               found => ['W', 'T'] })->count ) {
330
        return 1;
331
    }
332
333
    foreach my $item ( $self->items ) {
334
        return 1 if $item->get_transfer;
335
    }
336
337
    return 0;
338
}
321
339
322
=head3 type
340
=head3 type
323
341
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +1 lines)
Lines 3-9 Link Here
3
    [% UNLESS ( norequests ) %]
3
    [% UNLESS ( norequests ) %]
4
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
4
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
5
            [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
5
            [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
6
                [% IF ( AllowOnShelfHolds OR ItemsIssued OR ItemsWaitingOrInTransit ) %]
6
                [% IF ( ReservableItems ) %]
7
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber | html %]">Place hold</a></li>
7
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber | html %]">Place hold</a></li>
8
                [% END %]
8
                [% END %]
9
            [% END %]
9
            [% END %]
(-)a/opac/opac-detail.pl (-15 / +5 lines)
Lines 458-477 if ($session->param('busc')) { Link Here
458
}
458
}
459
}
459
}
460
460
461
my $itemsWaitingOrInTransit = Koha::Holds->search(
462
    {
463
        biblionumber => $biblionumber,
464
        found => ['W', 'T']
465
    })->count();
466
unless ($itemsWaitingOrInTransit) {
467
    foreach my $item ( Koha::Items->search(biblionumber => $biblionumber) ) {
468
        $itemsWaitingOrInTransit = 1 if $item->get_transfer;
469
    }
470
}
471
472
$template->param(
461
$template->param(
473
    ItemsIssued => CountItemsIssued( $biblionumber ),
474
    ItemsWaitingOrInTransit => $itemsWaitingOrInTransit,
475
    OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
462
    OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
476
);
463
);
477
464
Lines 664-676 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { Link Here
664
    };
651
    };
665
}
652
}
666
653
654
my $allow_onshelf_holds;
667
if ( not $viewallitems and @items > $max_items_to_display ) {
655
if ( not $viewallitems and @items > $max_items_to_display ) {
668
    $template->param(
656
    $template->param(
669
        too_many_items => 1,
657
        too_many_items => 1,
670
        items_count => scalar( @items ),
658
        items_count => scalar( @items ),
671
    );
659
    );
672
} else {
660
} else {
673
  my $allow_onshelf_holds;
674
  my $patron = Koha::Patrons->find( $borrowernumber );
661
  my $patron = Koha::Patrons->find( $borrowernumber );
675
  for my $itm (@items) {
662
  for my $itm (@items) {
676
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
663
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
Lines 729-737 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
729
        push @itemloop, $itm;
716
        push @itemloop, $itm;
730
    }
717
    }
731
  }
718
  }
732
  $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
733
}
719
}
734
720
721
my $itemsWaitingOrInTransit = Koha::Biblios->find($biblionumber)->hasItemswaitingOrInTransit || 0;
722
my $itemsIssued = CountItemsIssued( $biblionumber );
723
$template->param( 'ReservableItems' => $itemsWaitingOrInTransit || $itemsIssued || $allow_onshelf_holds );
724
735
# Display only one tab if one items list is empty
725
# Display only one tab if one items list is empty
736
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
726
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
737
    $template->param(SeparateHoldings => 0);
727
    $template->param(SeparateHoldings => 0);
(-)a/t/db_dependent/Koha/Biblios.t (-2 / +41 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
23
24
use C4::Reserves;
24
use C4::Reserves;
25
25
Lines 80-84 subtest 'subscriptions' => sub { Link Here
80
    is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
80
    is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
81
};
81
};
82
82
83
subtest 'waiting_or_in_transit' => sub {
84
    plan tests => 4;
85
    my $biblio = $builder->build( { source => 'Biblio' } );
86
    my $item = $builder->build({
87
        source => 'Item',
88
        value => {
89
            biblionumber => $biblio->{biblionumber}
90
        }
91
    });
92
    my $reserve = $builder->build({
93
        source => 'Reserve',
94
        value => {
95
            biblionumber => $biblio->{biblionumber},
96
            found => undef
97
        }
98
    });
99
100
    $reserve = Koha::Holds->find($reserve->{reserve_id});
101
    $biblio = Koha::Biblios->find($biblio->{biblionumber});
102
103
    is($biblio->hasItemswaitingOrInTransit, 0, 'Item is neither waiting nor in transit');
104
105
    $reserve->found('W')->store;
106
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item is waiting');
107
108
    $reserve->found('T')->store;
109
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item is in transit');
110
111
    my $transfer = $builder->build({
112
        source => 'Branchtransfer',
113
        value => {
114
            itemnumber => $item->{itemnumber},
115
            datearrived => undef
116
        }
117
    });
118
    my $t = Koha::Database->new()->schema()->resultset( 'Branchtransfer' )->find($transfer->{branchtransfer_id});
119
    $reserve->found(undef)->store;
120
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item has transfer');
121
};
122
83
$schema->storage->txn_rollback;
123
$schema->storage->txn_rollback;
84
124
85
- 

Return to bug 4319