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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1125-1131 sub CanBookBeIssued { Link Here
1125
    # Only bother doing this if UseRecalls is enabled and the item is recallable
1125
    # Only bother doing this if UseRecalls is enabled and the item is recallable
1126
    # Don't look at recalls that are in transit
1126
    # Don't look at recalls that are in transit
1127
    if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) {
1127
    if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) {
1128
        my @recalls = $biblio->recalls;
1128
        my @recalls = $biblio->recalls->as_list;
1129
1129
1130
        foreach my $r ( @recalls ) {
1130
        foreach my $r ( @recalls ) {
1131
            if ( $r->itemnumber and
1131
            if ( $r->itemnumber and
(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 423-429 sub CanItemBeReserved { Link Here
423
423
424
    # check if a recall exists on this item from this borrower
424
    # check if a recall exists on this item from this borrower
425
    return { status => 'recall' }
425
    return { status => 'recall' }
426
      if Koha::Recalls->search({ borrowernumber => $borrowernumber, itemnumber => $itemnumber, old => undef })->count;
426
      if Koha::Recalls->search({ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, old => undef })->count;
427
427
428
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
428
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
429
429
(-)a/Koha/Biblio.pm (-7 / +10 lines)
Lines 1172-1183 Return all active recalls attached to this biblio, sorted by oldest first Link Here
1172
1172
1173
sub recalls {
1173
sub recalls {
1174
    my ( $self, $params ) = @_;
1174
    my ( $self, $params ) = @_;
1175
    if ( $params->{borrowernumber} ) {
1175
1176
        my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef, borrowernumber => $params->{borrowernumber} }, { order_by => { -asc => 'recalldate' } });
1176
    my $args = {
1177
        return @recalls_rs;
1177
        biblionumber => $self->biblionumber,
1178
    }
1178
        old => undef,
1179
    my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } });
1179
    };
1180
    return @recalls_rs;
1180
    $args->{ borrowernumber } = $params->{ borrowernumber } if $params->{ borrowernumber };
1181
1182
    my $recalls_rs = $self->_result->recalls->search( $args, { order_by => { -asc => 'recalldate' } });
1183
    return Koha::Recalls->_new_from_dbic( $recalls_rs );
1181
}
1184
}
1182
1185
1183
=head3 can_be_recalled
1186
=head3 can_be_recalled
Lines 1200-1206 sub can_be_recalled { Link Here
1200
        $branchcode = $patron->branchcode;
1203
        $branchcode = $patron->branchcode;
1201
    }
1204
    }
1202
1205
1203
    my @all_items = Koha::Items->search({ biblionumber => $self->biblionumber });
1206
    my @all_items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list;
1204
1207
1205
    # if there are no available items at all, no recall can be placed
1208
    # if there are no available items at all, no recall can be placed
1206
    return 0 if ( scalar @all_items == 0 );
1209
    return 0 if ( scalar @all_items == 0 );
(-)a/Koha/Item.pm (-3 / +3 lines)
Lines 1461-1467 Return the relevant recall for this item Link Here
1461
1461
1462
sub recall {
1462
sub recall {
1463
    my ( $self ) = @_;
1463
    my ( $self ) = @_;
1464
    my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } });
1464
    my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } })->as_list;
1465
    foreach my $recall (@recalls) {
1465
    foreach my $recall (@recalls) {
1466
        if ( $recall->item_level_recall and $recall->itemnumber == $self->itemnumber ){
1466
        if ( $recall->item_level_recall and $recall->itemnumber == $self->itemnumber ){
1467
            return $recall;
1467
            return $recall;
Lines 1534-1540 sub can_be_recalled { Link Here
1534
1534
1535
    # check item availability
1535
    # check item availability
1536
    # items are unavailable for recall if they are lost, withdrawn or notforloan
1536
    # items are unavailable for recall if they are lost, withdrawn or notforloan
1537
    my @items = Koha::Items->search({ biblionumber => $self->biblionumber, itemlost => 0, withdrawn => 0, notforloan => 0 });
1537
    my @items = Koha::Items->search({ biblionumber => $self->biblionumber, itemlost => 0, withdrawn => 0, notforloan => 0 })->as_list;
1538
1538
1539
    # if there are no available items at all, no recall can be placed
1539
    # if there are no available items at all, no recall can be placed
1540
    return 0 if ( scalar @items == 0 );
1540
    return 0 if ( scalar @items == 0 );
Lines 1608-1614 Get the most relevant recall for this item. Link Here
1608
sub check_recalls {
1608
sub check_recalls {
1609
    my ( $self ) = @_;
1609
    my ( $self ) = @_;
1610
1610
1611
    my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, itemnumber => [ $self->itemnumber, undef ], status => [ 'R','O','W','T' ] }, { order_by => { -asc => 'recalldate' } });
1611
    my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, itemnumber => [ $self->itemnumber, undef ], status => [ 'R','O','W','T' ] }, { order_by => { -asc => 'recalldate' } })->as_list;
1612
1612
1613
    my $recall;
1613
    my $recall;
1614
    # iterate through relevant recalls to find the best one.
1614
    # iterate through relevant recalls to find the best one.
(-)a/Koha/Recall.pm (-1 / +1 lines)
Lines 110-116 sub checkout { Link Here
110
110
111
    unless ( $self->item_level_recall ) {
111
    unless ( $self->item_level_recall ) {
112
        # Only look at checkouts of items that are allowed to be recalled, and get the oldest one
112
        # Only look at checkouts of items that are allowed to be recalled, and get the oldest one
113
        my @items = Koha::Items->search({ biblionumber => $self->biblionumber });
113
        my @items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list;
114
        my @itemnumbers;
114
        my @itemnumbers;
115
        foreach (@items) {
115
        foreach (@items) {
116
            my $recalls_allowed = Koha::CirculationRules->get_effective_rule({
116
            my $recalls_allowed = Koha::CirculationRules->get_effective_rule({
(-)a/circ/returns.pl (-2 / +2 lines)
Lines 178-184 if ( $query->param('recall_id') ) { Link Here
178
    my $itemnumber = $query->param('itemnumber');
178
    my $itemnumber = $query->param('itemnumber');
179
    my $return_branch = $query->param('returnbranch');
179
    my $return_branch = $query->param('returnbranch');
180
180
181
    my $expirationdate = $recall->calc_expirationdate;
182
    my $item;
181
    my $item;
183
    if ( !$recall->item_level_recall ) {
182
    if ( !$recall->item_level_recall ) {
184
        $item = Koha::Items->find( $itemnumber );
183
        $item = Koha::Items->find( $itemnumber );
Lines 187-193 if ( $query->param('recall_id') ) { Link Here
187
    if ( $recall->branchcode ne $return_branch ) {
186
    if ( $recall->branchcode ne $return_branch ) {
188
        $recall->start_transfer({ item => $item }) if !$recall->in_transit;
187
        $recall->start_transfer({ item => $item }) if !$recall->in_transit;
189
    } else {
188
    } else {
190
        $recall->set_waiting({ item => $item }) if !$recall->waiting;
189
        my $expirationdate = $recall->calc_expirationdate;
190
        $recall->set_waiting({ item => $item, expirationdate => $expirationdate }) if !$recall->waiting;
191
    }
191
    }
192
}
192
}
193
193
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc (-1 / +1 lines)
Lines 18-24 Link Here
18
    [% END # / OPACHoldRequests %]
18
    [% END # / OPACHoldRequests %]
19
19
20
    [% IF Koha.Preference('UseRecalls') %]
20
    [% IF Koha.Preference('UseRecalls') %]
21
        <span class="actions"><a class="btn btn-link recall" href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark-o" aria-hidden="true"></i> Place recall</a></span>
21
        <span class="actions"><a class="btn btn-link btn-sm recall" href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark-o" aria-hidden="true"></i> Place recall</a></span>
22
    [% END %]
22
    [% END %]
23
23
24
    [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
24
    [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-7 / +1 lines)
Lines 767-779 Link Here
767
                                        [% FOREACH RECALL IN RECALLS %]
767
                                        [% FOREACH RECALL IN RECALLS %]
768
                                        <tr>
768
                                        <tr>
769
                                            <td class="title">
769
                                            <td class="title">
770
                                                <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% RECALL.biblionumber | html %]">
770
                                                <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% RECALL.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=RECALL.biblio %]</a> [% IF RECALL.item_level_recall %]<p class="hint">Item recalled: [% RECALL.item.barcode | html %]</p>[% END %]
771
                                                    [% RECALL.biblio.title | html %]
772
                                                    [% FOREACH s IN RECALL.biblio.subtitle %]
773
                                                        [% s | html %]
774
                                                    [% END %]
775
                                                </a>
776
                                                [% RECALL.biblio.author | html %]
777
                                            </td>
771
                                            </td>
778
                                            <td class="recalldate">
772
                                            <td class="recalldate">
779
                                                <span title="[% RECALL.recalldate | html %]">
773
                                                <span title="[% RECALL.recalldate | html %]">
(-)a/misc/cronjobs/recalls/expire_recalls.pl (-1 / +1 lines)
Lines 37-43 use C4::Log; Link Here
37
37
38
cronlogaction();
38
cronlogaction();
39
39
40
my @recalls = Koha::Recalls->search({ old => undef });
40
my @recalls = Koha::Recalls->search({ old => undef })->as_list;
41
foreach my $recall (@recalls) {
41
foreach my $recall (@recalls) {
42
    if ( ( $recall->requested or $recall->overdue ) and $recall->expirationdate and dt_from_string( $recall->expirationdate ) < dt_from_string() ){
42
    if ( ( $recall->requested or $recall->overdue ) and $recall->expirationdate and dt_from_string( $recall->expirationdate ) < dt_from_string() ){
43
        # recall is requested or overdue and has surpassed the specified expiration date
43
        # recall is requested or overdue and has surpassed the specified expiration date
(-)a/misc/cronjobs/recalls/overdue_recalls.pl (-1 / +1 lines)
Lines 36-42 use C4::Log; Link Here
36
36
37
cronlogaction();
37
cronlogaction();
38
38
39
my @recalls = Koha::Recalls->search({ status => 'R' });
39
my @recalls = Koha::Recalls->search({ status => 'R' })->as_list;
40
foreach my $recall (@recalls){
40
foreach my $recall (@recalls){
41
    if ( $recall->should_be_overdue ){
41
    if ( $recall->should_be_overdue ){
42
        $recall->set_overdue({ interface => 'COMMANDLINE' });
42
        $recall->set_overdue({ interface => 'COMMANDLINE' });
(-)a/opac/opac-recall.pl (-3 / +2 lines)
Lines 43-52 if ( C4::Context->preference('UseRecalls') ) { Link Here
43
43
44
    unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; }
44
    unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; }
45
45
46
    my $items = Koha::Items->search({ biblionumber => $biblionumber });
46
    my $items = Koha::Items->search({ biblionumber => $biblionumber })->as_list;
47
47
48
    # check if already recalled
48
    # check if already recalled
49
    my $recalled = scalar $biblio->recalls({ borrowernumber => $borrowernumber });
49
    my $recalled = $biblio->recalls({ borrowernumber => $borrowernumber })->count;
50
    if ( defined $recalled and $recalled > 0 ) {
50
    if ( defined $recalled and $recalled > 0 ) {
51
        my $recalls_per_record = Koha::CirculationRules->get_effective_rule({
51
        my $recalls_per_record = Koha::CirculationRules->get_effective_rule({
52
            categorycode => $patron->categorycode,
52
            categorycode => $patron->categorycode,
53
- 

Return to bug 19532