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

(-)a/C4/Circulation.pm (-20 / +20 lines)
Lines 383-392 sub transferbook { Link Here
383
383
384
    # find recall
384
    # find recall
385
    if ( C4::Context->preference('UseRecalls') ) {
385
    if ( C4::Context->preference('UseRecalls') ) {
386
        my $recall = Koha::Recalls->find({ itemnumber => $itemnumber, status => 'in_transit' });
386
        my $recall = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' });
387
        if ( defined $recall ) {
387
        if ( defined $recall ) {
388
            # do a transfer if the recall branch is different to the item holding branch
388
            # do a transfer if the recall branch is different to the item holding branch
389
            if ( $recall->branchcode eq $fbr ) {
389
            if ( $recall->pickup_library_id eq $fbr ) {
390
                $dotransfer = 0;
390
                $dotransfer = 0;
391
                $messages->{'RecallPlacedAtHoldingBranch'} = 1;
391
                $messages->{'RecallPlacedAtHoldingBranch'} = 1;
392
            } else {
392
            } else {
Lines 1136-1170 sub CanBookBeIssued { Link Here
1136
    # Only bother doing this if UseRecalls is enabled and the item is recallable
1136
    # Only bother doing this if UseRecalls is enabled and the item is recallable
1137
    # Don't look at recalls that are in transit
1137
    # Don't look at recalls that are in transit
1138
    if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) {
1138
    if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) {
1139
        my @recalls = $biblio->recalls({},{ order_by => { -asc => 'recalldate' } })->filter_by_current->as_list;
1139
        my @recalls = $biblio->recalls({},{ order_by => { -asc => 'created_date' } })->filter_by_current->as_list;
1140
1140
1141
        foreach my $r ( @recalls ) {
1141
        foreach my $r ( @recalls ) {
1142
            if ( $r->itemnumber and
1142
            if ( $r->item_id and
1143
                $r->itemnumber == $item_object->itemnumber and
1143
                $r->item_id == $item_object->itemnumber and
1144
                $r->borrowernumber == $patron->borrowernumber and
1144
                $r->patron_id == $patron->borrowernumber and
1145
                ( $r->waiting or $r->requested ) ) {
1145
                ( $r->waiting or $r->requested ) ) {
1146
                $messages{RECALLED} = $r->recall_id;
1146
                $messages{RECALLED} = $r->id;
1147
                $recall = $r;
1147
                $recall = $r;
1148
                # this item is recalled by or already waiting for this borrower and the recall can be fulfilled
1148
                # this item is recalled by or already waiting for this borrower and the recall can be fulfilled
1149
                last;
1149
                last;
1150
            }
1150
            }
1151
            elsif ( $r->itemnumber and
1151
            elsif ( $r->item_id and
1152
                $r->itemnumber == $item_object->itemnumber and
1152
                $r->item_id == $item_object->itemnumber and
1153
                $r->in_transit ) {
1153
                $r->in_transit ) {
1154
                # recalled item is in transit
1154
                # recalled item is in transit
1155
                $issuingimpossible{RECALLED_INTRANSIT} = $r->branchcode;
1155
                $issuingimpossible{RECALLED_INTRANSIT} = $r->pickup_library_id;
1156
            }
1156
            }
1157
            elsif ( $r->item_level_recall and
1157
            elsif ( $r->item_level and
1158
                $r->itemnumber == $item_object->itemnumber and
1158
                $r->item_id == $item_object->itemnumber and
1159
                $r->borrowernumber != $patron->borrowernumber and
1159
                $r->patron_id != $patron->borrowernumber and
1160
                !$r->in_transit ) {
1160
                !$r->in_transit ) {
1161
                # this specific item has been recalled by a different patron
1161
                # this specific item has been recalled by a different patron
1162
                $needsconfirmation{RECALLED} = $r;
1162
                $needsconfirmation{RECALLED} = $r;
1163
                $recall = $r;
1163
                $recall = $r;
1164
                last;
1164
                last;
1165
            }
1165
            }
1166
            elsif ( !$r->item_level_recall and
1166
            elsif ( !$r->item_level and
1167
                $r->borrowernumber != $patron->borrowernumber and
1167
                $r->patron_id != $patron->borrowernumber and
1168
                !$r->in_transit ) {
1168
                !$r->in_transit ) {
1169
                # a different patron has placed a biblio-level recall and this item is eligible to fill it
1169
                # a different patron has placed a biblio-level recall and this item is eligible to fill it
1170
                $needsconfirmation{RECALLED} = $r;
1170
                $needsconfirmation{RECALLED} = $r;
Lines 2311-2317 sub AddReturn { Link Here
2311
        $recall = $item->check_recalls if $item->can_be_waiting_recall;
2311
        $recall = $item->check_recalls if $item->can_be_waiting_recall;
2312
        if ( defined $recall ) {
2312
        if ( defined $recall ) {
2313
            $messages->{RecallFound} = $recall;
2313
            $messages->{RecallFound} = $recall;
2314
            if ( $recall->branchcode ne $branch ) {
2314
            if ( $recall->pickup_library_id ne $branch ) {
2315
                $messages->{RecallNeedsTransfer} = $branch;
2315
                $messages->{RecallNeedsTransfer} = $branch;
2316
            }
2316
            }
2317
        }
2317
        }
Lines 2378-2385 sub AddReturn { Link Here
2378
2378
2379
    if ( C4::Context->preference('UseRecalls') ) {
2379
    if ( C4::Context->preference('UseRecalls') ) {
2380
        # all recalls that have triggered a transfer will have an allocated itemnumber
2380
        # all recalls that have triggered a transfer will have an allocated itemnumber
2381
        my $transfer_recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, status => 'in_transit' });
2381
        my $transfer_recall = Koha::Recalls->find({ item_id => $item->itemnumber, status => 'in_transit' });
2382
        if ( $transfer_recall and $transfer_recall->branchcode eq $branch ) {
2382
        if ( $transfer_recall and $transfer_recall->pickup_library_id eq $branch ) {
2383
            $messages->{TransferredRecall} = $transfer_recall;
2383
            $messages->{TransferredRecall} = $transfer_recall;
2384
        }
2384
        }
2385
    }
2385
    }
Lines 2906-2914 sub CanBookBeRenewed { Link Here
2906
        my $recall = undef;
2906
        my $recall = undef;
2907
        $recall = $item->check_recalls if $item->can_be_waiting_recall;
2907
        $recall = $item->check_recalls if $item->can_be_waiting_recall;
2908
        if ( defined $recall ) {
2908
        if ( defined $recall ) {
2909
            if ( $recall->item_level_recall ) {
2909
            if ( $recall->item_level ) {
2910
                # item-level recall. check if this item is the recalled item, otherwise renewal will be allowed
2910
                # item-level recall. check if this item is the recalled item, otherwise renewal will be allowed
2911
                return ( 0, 'recalled' ) if ( $recall->itemnumber == $item->itemnumber );
2911
                return ( 0, 'recalled' ) if ( $recall->item_id == $item->itemnumber );
2912
            } else {
2912
            } else {
2913
                # biblio-level recall, so only disallow renewal if the biblio-level recall has been fulfilled by a different item
2913
                # biblio-level recall, so only disallow renewal if the biblio-level recall has been fulfilled by a different item
2914
                return ( 0, 'recalled' ) unless ( $recall->waiting );
2914
                return ( 0, 'recalled' ) unless ( $recall->waiting );
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 751-757 sub _parseletter_sth { Link Here
751
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
751
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
752
    ($table eq 'problem_reports') ? "SELECT * FROM $table WHERE reportid = ?" :
752
    ($table eq 'problem_reports') ? "SELECT * FROM $table WHERE reportid = ?" :
753
    ($table eq 'additional_contents' || $table eq 'opac_news') ? "SELECT * FROM additional_contents WHERE idnew = ?" :
753
    ($table eq 'additional_contents' || $table eq 'opac_news') ? "SELECT * FROM additional_contents WHERE idnew = ?" :
754
    ($table eq 'recalls') ? "SELECT * FROM $table WHERE recall_id = ?" :
754
    ($table eq 'recalls') ? "SELECT * FROM $table WHERE id = ?" :
755
    undef ;
755
    undef ;
756
    unless ($query) {
756
    unless ($query) {
757
        warn "ERROR: No _parseletter_sth query for table '$table'";
757
        warn "ERROR: No _parseletter_sth query for table '$table'";
(-)a/C4/Overdues.pm (-2 / +2 lines)
Lines 260-270 sub CalcFine { Link Here
260
260
261
        # check if item has been recalled. recall should have been marked Overdue by cronjob, so only look at overdue recalls
261
        # check if item has been recalled. recall should have been marked Overdue by cronjob, so only look at overdue recalls
262
        # only charge using recall_overdue_fine if there is an item-level recall for this particular item, OR a biblio-level recall
262
        # only charge using recall_overdue_fine if there is an item-level recall for this particular item, OR a biblio-level recall
263
        my @recalls = Koha::Recalls->search({ biblionumber => $item->{biblionumber}, status => 'overdue' })->as_list;
263
        my @recalls = Koha::Recalls->search({ biblio_id => $item->{biblionumber}, status => 'overdue' })->as_list;
264
        my $bib_level_recall = 0;
264
        my $bib_level_recall = 0;
265
        $bib_level_recall = 1 if scalar @recalls > 0;
265
        $bib_level_recall = 1 if scalar @recalls > 0;
266
        foreach my $recall ( @recalls ) {
266
        foreach my $recall ( @recalls ) {
267
            if ( $recall->item_level_recall and $recall->itemnumber == $item->{itemnumber} and $issuing_rule->{recall_overdue_fine} ) {
267
            if ( $recall->item_level and $recall->item_id == $item->{itemnumber} and $issuing_rule->{recall_overdue_fine} ) {
268
                $bib_level_recall = 0;
268
                $bib_level_recall = 0;
269
                $amount = $charge_periods * $issuing_rule->{recall_overdue_fine};
269
                $amount = $charge_periods * $issuing_rule->{recall_overdue_fine};
270
                last;
270
                last;
(-)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 $patron->recalls->filter_by_current->search({ itemnumber => $item->itemnumber })->count;
426
      if $patron->recalls->filter_by_current->search({ item_id => $item->itemnumber })->count;
427
427
428
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
428
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
429
429
(-)a/C4/Search.pm (-1 / +1 lines)
Lines 1904-1910 sub searchResults { Link Here
1904
                    ($transfertwhen, $transfertfrom, $transfertto) = C4::Circulation::GetTransfers($item->{itemnumber});
1904
                    ($transfertwhen, $transfertfrom, $transfertto) = C4::Circulation::GetTransfers($item->{itemnumber});
1905
                    $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
1905
                    $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
1906
                    if ( C4::Context->preference('UseRecalls') ) {
1906
                    if ( C4::Context->preference('UseRecalls') ) {
1907
                        if ( Koha::Recalls->search({ itemnumber => $item->{itemnumber}, status => 'waiting' })->count ) {
1907
                        if ( Koha::Recalls->search({ item_id => $item->{itemnumber}, status => 'waiting' })->count ) {
1908
                            $recallstatus = 'Waiting';
1908
                            $recallstatus = 'Waiting';
1909
                        }
1909
                        }
1910
                    }
1910
                    }
(-)a/C4/XSLT.pm (-1 / +1 lines)
Lines 357-363 sub buildKohaItemsNamespace { Link Here
357
        my $recalls_count;
357
        my $recalls_count;
358
358
359
        if ( C4::Context->preference('UseRecalls') ) {
359
        if ( C4::Context->preference('UseRecalls') ) {
360
            $recalls_count = Koha::Recalls->search({ itemnumber => $item->itemnumber, status => 'waiting' })->count;
360
            $recalls_count = Koha::Recalls->search({ item_id => $item->itemnumber, status => 'waiting' })->count;
361
        }
361
        }
362
362
363
        if ($recalls_count) {
363
        if ($recalls_count) {
(-)a/Koha/Biblio.pm (-1 / +1 lines)
Lines 1250-1256 sub can_be_recalled { Link Here
1250
        return 0 if ( $patron->recalls->filter_by_current->count >= $recalls_allowed );
1250
        return 0 if ( $patron->recalls->filter_by_current->count >= $recalls_allowed );
1251
1251
1252
        # check borrower has not reached open recalls allowed per record limit
1252
        # check borrower has not reached open recalls allowed per record limit
1253
        return 0 if ( $patron->recalls->filter_by_current->search({ biblionumber => $self->biblionumber })->count >= $recalls_per_record );
1253
        return 0 if ( $patron->recalls->filter_by_current->search({ biblio_id => $self->biblionumber })->count >= $recalls_per_record );
1254
1254
1255
        # check if any of the items under this biblio are already checked out by this borrower
1255
        # check if any of the items under this biblio are already checked out by this borrower
1256
        return 0 if ( Koha::Checkouts->search({ itemnumber => [ @all_itemnumbers ], borrowernumber => $patron->borrowernumber })->count > 0 );
1256
        return 0 if ( Koha::Checkouts->search({ itemnumber => [ @all_itemnumbers ], borrowernumber => $patron->borrowernumber })->count > 0 );
(-)a/Koha/Item.pm (-9 / +9 lines)
Lines 1463-1475 sub recall { Link Here
1463
    my ( $self ) = @_;
1463
    my ( $self ) = @_;
1464
    my @recalls = Koha::Recalls->search(
1464
    my @recalls = Koha::Recalls->search(
1465
        {
1465
        {
1466
            biblionumber => $self->biblionumber,
1466
            biblio_id => $self->biblionumber,
1467
            old          => 0,
1467
            completed => 0,
1468
        },
1468
        },
1469
        { order_by => { -asc => 'recalldate' } }
1469
        { order_by => { -asc => 'created_date' } }
1470
    )->as_list;
1470
    )->as_list;
1471
    foreach my $recall (@recalls) {
1471
    foreach my $recall (@recalls) {
1472
        if ( $recall->item_level_recall and $recall->itemnumber == $self->itemnumber ){
1472
        if ( $recall->item_level and $recall->item_id == $self->itemnumber ){
1473
            return $recall;
1473
            return $recall;
1474
        }
1474
        }
1475
    }
1475
    }
Lines 1526-1535 sub can_be_recalled { Link Here
1526
        return 0 if ( $patron->recalls->filter_by_current->count >= $rule->{recalls_allowed} );
1526
        return 0 if ( $patron->recalls->filter_by_current->count >= $rule->{recalls_allowed} );
1527
1527
1528
        # check borrower has not reach open recalls allowed per record limit
1528
        # check borrower has not reach open recalls allowed per record limit
1529
        return 0 if ( $patron->recalls->filter_by_current->search({ biblionumber => $self->biblionumber })->count >= $rule->{recalls_per_record} );
1529
        return 0 if ( $patron->recalls->filter_by_current->search({ biblio_id => $self->biblionumber })->count >= $rule->{recalls_per_record} );
1530
1530
1531
        # check if this patron has already recalled this item
1531
        # check if this patron has already recalled this item
1532
        return 0 if ( Koha::Recalls->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->filter_by_current->count > 0 );
1532
        return 0 if ( Koha::Recalls->search({ item_id => $self->itemnumber, patron_id => $patron->borrowernumber })->filter_by_current->count > 0 );
1533
1533
1534
        # check if this patron has already checked out this item
1534
        # check if this patron has already checked out this item
1535
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
1535
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
Lines 1615-1624 sub check_recalls { Link Here
1615
    my ( $self ) = @_;
1615
    my ( $self ) = @_;
1616
1616
1617
    my @recalls = Koha::Recalls->search(
1617
    my @recalls = Koha::Recalls->search(
1618
        {   biblionumber => $self->biblionumber,
1618
        {   biblio_id => $self->biblionumber,
1619
            itemnumber   => [ $self->itemnumber, undef ]
1619
            item_id   => [ $self->itemnumber, undef ]
1620
        },
1620
        },
1621
        { order_by => { -asc => 'recalldate' } }
1621
        { order_by => { -asc => 'created_date' } }
1622
    )->filter_by_current->as_list;
1622
    )->filter_by_current->as_list;
1623
1623
1624
    my $recall;
1624
    my $recall;
(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 2060-2066 Return the patron's recalls. Link Here
2060
sub recalls {
2060
sub recalls {
2061
    my ( $self ) = @_;
2061
    my ( $self ) = @_;
2062
2062
2063
    return Koha::Recalls->search({ borrowernumber => $self->borrowernumber });
2063
    return Koha::Recalls->search({ patron_id => $self->borrowernumber });
2064
}
2064
}
2065
2065
2066
=head2 Internal methods
2066
=head2 Internal methods
(-)a/Koha/Recall.pm (-27 / +27 lines)
Lines 108-118 Returns the related Koha::Checkout object for this recall. Link Here
108
108
109
sub checkout {
109
sub checkout {
110
    my ( $self ) = @_;
110
    my ( $self ) = @_;
111
    $self->{_checkout} ||= Koha::Checkouts->find({ itemnumber => $self->itemnumber });
111
    $self->{_checkout} ||= Koha::Checkouts->find({ itemnumber => $self->item_id });
112
112
113
    unless ( $self->item_level_recall ) {
113
    unless ( $self->item_level ) {
114
        # Only look at checkouts of items that are allowed to be recalled, and get the oldest one
114
        # Only look at checkouts of items that are allowed to be recalled, and get the oldest one
115
        my @items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list;
115
        my @items = Koha::Items->search({ biblionumber => $self->biblio_id })->as_list;
116
        my @itemnumbers;
116
        my @itemnumbers;
117
        foreach (@items) {
117
        foreach (@items) {
118
            my $recalls_allowed = Koha::CirculationRules->get_effective_rule({
118
            my $recalls_allowed = Koha::CirculationRules->get_effective_rule({
Lines 250-256 sub calc_expirationdate { Link Here
250
    my ( $self ) = @_;
250
    my ( $self ) = @_;
251
251
252
    my $item;
252
    my $item;
253
    if ( $self->item_level_recall ) {
253
    if ( $self->item_level ) {
254
        $item = $self->item;
254
        $item = $self->item;
255
    } elsif ( $self->checkout ) {
255
    } elsif ( $self->checkout ) {
256
        $item = $self->checkout->item;
256
        $item = $self->checkout->item;
Lines 285-299 Set the recall as in transit. Link Here
285
sub start_transfer {
285
sub start_transfer {
286
    my ( $self, $params ) = @_;
286
    my ( $self, $params ) = @_;
287
287
288
    if ( $self->item_level_recall ) {
288
    if ( $self->item_level ) {
289
        # already has an itemnumber
289
        # already has an itemnumber
290
        $self->update({ status => 'in_transit' });
290
        $self->update({ status => 'in_transit' });
291
    } else {
291
    } else {
292
        my $itemnumber = $params->{item}->itemnumber;
292
        my $itemnumber = $params->{item}->itemnumber;
293
        $self->update({ status => 'in_transit', itemnumber => $itemnumber });
293
        $self->update({ status => 'in_transit', item_id => $itemnumber });
294
    }
294
    }
295
295
296
    my ( $dotransfer, $messages ) = C4::Circulation::transferbook({ to_branch => $self->branchcode, from_branch => $self->item->holdingbranch, barcode => $self->item->barcode, trigger => 'Recall' });
296
    my ( $dotransfer, $messages ) = C4::Circulation::transferbook({ to_branch => $self->pickup_library_id, from_branch => $self->item->holdingbranch, barcode => $self->item->barcode, trigger => 'Recall' });
297
297
298
    return ( $self, $dotransfer, $messages );
298
    return ( $self, $dotransfer, $messages );
299
}
299
}
Lines 309-318 If a transfer is cancelled, revert the recall to requested. Link Here
309
sub revert_transfer {
309
sub revert_transfer {
310
    my ( $self ) = @_;
310
    my ( $self ) = @_;
311
311
312
    if ( $self->item_level_recall ) {
312
    if ( $self->item_level ) {
313
        $self->update({ status => 'requested' });
313
        $self->update({ status => 'requested' });
314
    } else {
314
    } else {
315
        $self->update({ status => 'requested', itemnumber => undef });
315
        $self->update({ status => 'requested', item_id => undef });
316
    }
316
    }
317
317
318
    return $self;
318
    return $self;
Lines 335-360 sub set_waiting { Link Here
335
    my ( $self, $params ) = @_;
335
    my ( $self, $params ) = @_;
336
336
337
    my $itemnumber;
337
    my $itemnumber;
338
    if ( $self->item_level_recall ) {
338
    if ( $self->item_level ) {
339
        $itemnumber = $self->itemnumber;
339
        $itemnumber = $self->item_id;
340
        $self->update({ status => 'waiting', waitingdate => dt_from_string, expirationdate => $params->{expirationdate} });
340
        $self->update({ status => 'waiting', waiting_date => dt_from_string, expiration_date => $params->{expirationdate} });
341
    } else {
341
    } else {
342
        # biblio-level recall with no itemnumber. need to set itemnumber
342
        # biblio-level recall with no itemnumber. need to set itemnumber
343
        $itemnumber = $params->{item}->itemnumber;
343
        $itemnumber = $params->{item}->itemnumber;
344
        $self->update({ status => 'waiting', waitingdate => dt_from_string, expirationdate => $params->{expirationdate}, itemnumber => $itemnumber });
344
        $self->update({ status => 'waiting', waiting_date => dt_from_string, expiration_date => $params->{expirationdate}, item_id => $itemnumber });
345
    }
345
    }
346
346
347
    # send notice to recaller to pick up item
347
    # send notice to recaller to pick up item
348
    my $letter = C4::Letters::GetPreparedLetter(
348
    my $letter = C4::Letters::GetPreparedLetter(
349
        module => 'circulation',
349
        module => 'circulation',
350
        letter_code => 'PICKUP_RECALLED_ITEM',
350
        letter_code => 'PICKUP_RECALLED_ITEM',
351
        branchcode => $self->branchcode,
351
        branchcode => $self->pickup_library_id,
352
        want_librarian => 0,
352
        want_librarian => 0,
353
        tables => {
353
        tables => {
354
            biblio => $self->biblionumber,
354
            biblio => $self->biblio_id,
355
            borrowers => $self->borrowernumber,
355
            borrowers => $self->patron_id,
356
            items => $itemnumber,
356
            items => $itemnumber,
357
            recalls => $self->recall_id,
357
            recalls => $self->id,
358
        },
358
        },
359
    );
359
    );
360
360
Lines 373-382 Revert recall waiting status. Link Here
373
373
374
sub revert_waiting {
374
sub revert_waiting {
375
    my ( $self ) = @_;
375
    my ( $self ) = @_;
376
    if ( $self->item_level_recall ){
376
    if ( $self->item_level ){
377
        $self->update({ status => 'requested', waitingdate => undef });
377
        $self->update({ status => 'requested', waiting_date => undef });
378
    } else {
378
    } else {
379
        $self->update({ status => 'requested', waitingdate => undef, itemnumber => undef });
379
        $self->update({ status => 'requested', waiting_date => undef, item_id => undef });
380
    }
380
    }
381
    return $self;
381
    return $self;
382
}
382
}
Lines 411-417 sub set_overdue { Link Here
411
    my ( $self, $params ) = @_;
411
    my ( $self, $params ) = @_;
412
    my $interface = $params->{interface} || 'COMMANDLINE';
412
    my $interface = $params->{interface} || 'COMMANDLINE';
413
    $self->update({ status => 'overdue' });
413
    $self->update({ status => 'overdue' });
414
    C4::Log::logaction( 'RECALLS', 'OVERDUE', $self->recall_id, "Recall status set to overdue", $interface ) if ( C4::Context->preference('RecallsLog') );
414
    C4::Log::logaction( 'RECALLS', 'OVERDUE', $self->id, "Recall status set to overdue", $interface ) if ( C4::Context->preference('RecallsLog') );
415
    return $self;
415
    return $self;
416
}
416
}
417
417
Lines 426-433 Set a recall as expired. This may be done manually or by a cronjob, either when Link Here
426
sub set_expired {
426
sub set_expired {
427
    my ( $self, $params ) = @_;
427
    my ( $self, $params ) = @_;
428
    my $interface = $params->{interface} || 'COMMANDLINE';
428
    my $interface = $params->{interface} || 'COMMANDLINE';
429
    $self->update({ status => 'expired', old => 1, expirationdate => dt_from_string });
429
    $self->update({ status => 'expired', completed => 1, completed_date => dt_from_string });
430
    C4::Log::logaction( 'RECALLS', 'EXPIRE', $self->recall_id, "Recall expired", $interface ) if ( C4::Context->preference('RecallsLog') );
430
    C4::Log::logaction( 'RECALLS', 'EXPIRE', $self->id, "Recall expired", $interface ) if ( C4::Context->preference('RecallsLog') );
431
    return $self;
431
    return $self;
432
}
432
}
433
433
Lines 441-448 Set a recall as cancelled. This may be done manually, either by the borrower tha Link Here
441
441
442
sub set_cancelled {
442
sub set_cancelled {
443
    my ( $self ) = @_;
443
    my ( $self ) = @_;
444
    $self->update({ status => 'cancelled', old => 1, cancellationdate => dt_from_string });
444
    $self->update({ status => 'cancelled', completed => 1, completed_date => dt_from_string });
445
    C4::Log::logaction( 'RECALLS', 'CANCEL', $self->recall_id, "Recall cancelled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') );
445
    C4::Log::logaction( 'RECALLS', 'CANCEL', $self->id, "Recall cancelled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') );
446
    return $self;
446
    return $self;
447
}
447
}
448
448
Lines 456-463 Set a recall as finished. This should only be called when the item allocated to Link Here
456
456
457
sub set_fulfilled {
457
sub set_fulfilled {
458
    my ( $self ) = @_;
458
    my ( $self ) = @_;
459
    $self->update({ status => 'fulfilled', old => 1 });
459
    $self->update({ status => 'fulfilled', completed => 1, completed_date => dt_from_string });
460
    C4::Log::logaction( 'RECALLS', 'FULFILL', $self->recall_id, "Recall fulfilled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') );
460
    C4::Log::logaction( 'RECALLS', 'FULFILL', $self->id, "Recall fulfilled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') );
461
    return $self;
461
    return $self;
462
}
462
}
463
463
(-)a/Koha/Recalls.pm (-18 / +18 lines)
Lines 118-135 sub add_recall { Link Here
118
    }
118
    }
119
119
120
    my $recall_request = Koha::Recall->new({
120
    my $recall_request = Koha::Recall->new({
121
        borrowernumber => $patron->borrowernumber,
121
        patron_id => $patron->borrowernumber,
122
        recalldate => dt_from_string(),
122
        created_date => dt_from_string(),
123
        biblionumber => $biblio->biblionumber,
123
        biblio_id => $biblio->biblionumber,
124
        branchcode => $branchcode,
124
        pickup_library_id => $branchcode,
125
        status => 'requested',
125
        status => 'requested',
126
        itemnumber => defined $itemnumber ? $itemnumber : undef,
126
        item_id => defined $itemnumber ? $itemnumber : undef,
127
        expirationdate => $expirationdate,
127
        expiration_date => $expirationdate,
128
        item_level_recall => defined $itemnumber ? 1 : 0,
128
        item_level => defined $itemnumber ? 1 : 0,
129
    })->store;
129
    })->store;
130
130
131
    if (defined $recall_request->recall_id){ # successful recall
131
    if (defined $recall_request->id){ # successful recall
132
        my $recall = Koha::Recalls->find( $recall_request->recall_id );
132
        my $recall = Koha::Recalls->find( $recall_request->id );
133
133
134
        # get checkout and adjust due date based on circulation rules
134
        # get checkout and adjust due date based on circulation rules
135
        my $checkout = $recall->checkout;
135
        my $checkout = $recall->checkout;
Lines 145-157 sub add_recall { Link Here
145
        $checkout->update({ date_due => $due_date });
145
        $checkout->update({ date_due => $due_date });
146
146
147
        # get itemnumber of most relevant checkout if a biblio-level recall
147
        # get itemnumber of most relevant checkout if a biblio-level recall
148
        unless ( $recall->item_level_recall ) { $itemnumber = $checkout->itemnumber; }
148
        unless ( $recall->item_level ) { $itemnumber = $checkout->itemnumber; }
149
149
150
        # send notice to user with recalled item checked out
150
        # send notice to user with recalled item checked out
151
        my $letter = C4::Letters::GetPreparedLetter (
151
        my $letter = C4::Letters::GetPreparedLetter (
152
            module => 'circulation',
152
            module => 'circulation',
153
            letter_code => 'RETURN_RECALLED_ITEM',
153
            letter_code => 'RETURN_RECALLED_ITEM',
154
            branchcode => $recall->branchcode,
154
            branchcode => $recall->pickup_library_id,
155
            tables => {
155
            tables => {
156
                biblio => $biblio->biblionumber,
156
                biblio => $biblio->biblionumber,
157
                borrowers => $checkout->borrowernumber,
157
                borrowers => $checkout->borrowernumber,
Lines 168-180 sub add_recall { Link Here
168
            branch => C4::Context->userenv->{'branch'},
168
            branch => C4::Context->userenv->{'branch'},
169
            type => 'recall',
169
            type => 'recall',
170
            itemnumber => $itemnumber,
170
            itemnumber => $itemnumber,
171
            borrowernumber => $recall->borrowernumber,
171
            borrowernumber => $recall->patron_id,
172
            itemtype => $item->effective_itemtype,
172
            itemtype => $item->effective_itemtype,
173
            ccode => $item->ccode,
173
            ccode => $item->ccode,
174
        });
174
        });
175
175
176
        # add action log
176
        # add action log
177
        C4::Log::logaction( 'RECALLS', 'CREATE', $recall->recall_id, "Recall requested by borrower #" . $recall->borrowernumber, $interface ) if ( C4::Context->preference('RecallsLog') );
177
        C4::Log::logaction( 'RECALLS', 'CREATE', $recall->id, "Recall requested by borrower #" . $recall->patron_id, $interface ) if ( C4::Context->preference('RecallsLog') );
178
178
179
        return ( $recall, $due_interval, $due_date );
179
        return ( $recall, $due_interval, $due_date );
180
    }
180
    }
Lines 230-241 sub move_recall { Link Here
230
        # move_recall was not called to revert or cancel, but was called to fulfill
230
        # move_recall was not called to revert or cancel, but was called to fulfill
231
        my $recall = Koha::Recalls->search(
231
        my $recall = Koha::Recalls->search(
232
            {
232
            {
233
                borrowernumber => $borrowernumber,
233
                patron_id => $borrowernumber,
234
                biblionumber   => $item->biblionumber,
234
                biblio_id => $item->biblionumber,
235
                itemnumber     => [ $item->itemnumber, undef ],
235
                item_id   => [ $item->itemnumber, undef ],
236
                old            => 0,
236
                completed => 0,
237
            },
237
            },
238
            { order_by => { -asc => 'recalldate' } }
238
            { order_by => { -asc => 'created_date' } }
239
        )->next;
239
        )->next;
240
        if ( $recall ) {
240
        if ( $recall ) {
241
            $recall->set_fulfilled;
241
            $recall->set_fulfilled;
(-)a/Koha/Template/Plugin/Biblio.pm (-2 / +1 lines)
Lines 60-66 sub CanArticleRequest { Link Here
60
sub RecallsCount {
60
sub RecallsCount {
61
    my ( $self, $biblionumber ) = @_;
61
    my ( $self, $biblionumber ) = @_;
62
62
63
    my $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => 0 });
63
    my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
64
64
65
    return $recalls->count;
65
    return $recalls->count;
66
}
66
}
67
- 

Return to bug 30291