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

(-)a/C4/Circulation.pm (-22 / +20 lines)
Lines 346-364 sub transferbook { Link Here
346
        $messages->{'WasReturned'} = $issue->borrowernumber;
346
        $messages->{'WasReturned'} = $issue->borrowernumber;
347
    }
347
    }
348
348
349
    # find reserves.....
350
    # That'll save a database query.
351
    my ( $resfound, $resrec, undef ) =
352
      CheckReserves( $itemnumber );
353
    if ( $resfound and not $ignoreRs ) {
354
        $resrec->{'ResFound'} = $resfound;
355
356
        #         $messages->{'ResFound'} = $resrec;
357
        $dotransfer = 1;
358
    }
359
360
    # check if item has been recalled. do a transfer if the recall branch is different to the item holding branch, otherwise don't do a transfer
349
    # check if item has been recalled. do a transfer if the recall branch is different to the item holding branch, otherwise don't do a transfer
361
    my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, status => 'R' });
350
    my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, old => undef });
362
    if (defined $recall){
351
    if (defined $recall){
363
        if ($recall->branchcode eq $fbr){
352
        if ($recall->branchcode eq $fbr){
364
            $dotransfer = 0;
353
            $dotransfer = 0;
Lines 366-371 sub transferbook { Link Here
366
        } else {
355
        } else {
367
            $dotransfer = 1;
356
            $dotransfer = 1;
368
        }
357
        }
358
    } else {  #recalls take priority over holds, only check holds if no recalls
359
        # find reserves.....
360
        my ( $resfound, $resrec, undef ) = CheckReserves( $itemnumber );
361
        if ( $resfound and not $ignoreRs ) {
362
            $resrec->{'ResFound'} = $resfound;
363
        #   $messages->{'ResFound'} = $resrec;
364
            $dotransfer = 1;
365
        }
369
    }
366
    }
370
367
371
    #actually do the transfer....
368
    #actually do the transfer....
Lines 1380-1386 sub AddIssue { Link Here
1380
1377
1381
            # Check if a recall
1378
            # Check if a recall
1382
            if ( C4::Context->preference('UseRecalls') ) {
1379
            if ( C4::Context->preference('UseRecalls') ) {
1383
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'} });
1380
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'}, old => undef });
1384
                if (defined $recall) {
1381
                if (defined $recall) {
1385
                    $recall->update({ status => "F", old => 1 });
1382
                    $recall->update({ status => "F", old => 1 });
1386
                }
1383
                }
Lines 2034-2054 sub AddReturn { Link Here
2034
        }
2031
        }
2035
    }
2032
    }
2036
2033
2037
    # find reserves.....
2038
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
2039
    my ($resfound, $resrec);
2034
    my ($resfound, $resrec);
2040
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2041
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2042
    if ($resfound) {
2043
          $resrec->{'ResFound'} = $resfound;
2044
        $messages->{'ResFound'} = $resrec;
2045
    }
2046
2035
2047
    # find recalls.....
2036
    # find recalls.....
2048
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} });
2037
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, old => undef });
2049
    if (defined $recall){
2038
    if (defined $recall){
2050
        $messages->{'RecallFound'} = 1;
2039
        $messages->{'RecallFound'} = 1;
2051
        $messages->{'Recall'} = $recall;
2040
        $messages->{'Recall'} = $recall;
2041
    } else {
2042
        # find reserves.....
2043
        # if we don't have a reserve with the status W, we launch the Checkreserves routine
2044
        my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2045
        ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2046
        if ($resfound) {
2047
            $resrec->{'ResFound'} = $resfound;
2048
            $messages->{'ResFound'} = $resrec;
2049
        }
2052
    }
2050
    }
2053
2051
2054
    # Record the fact that this book was returned.
2052
    # Record the fact that this book was returned.
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 334-340 foreach my $item (@items) { Link Here
334
        }
334
        }
335
    }
335
    }
336
336
337
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber} });
337
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef });
338
    if (defined $recall){
338
    if (defined $recall){
339
        $item->{recalled} = 1;
339
        $item->{recalled} = 1;
340
        $item->{recall} = $recall;
340
        $item->{recall} = $recall;
(-)a/circ/returns.pl (-26 / +33 lines)
Lines 190-218 if ( $query->param('reserve_id') ) { Link Here
190
}
190
}
191
191
192
if ( $query->param('recall_id') ){
192
if ( $query->param('recall_id') ){
193
    my $recall = Koha::Recalls->find(scalar $query->param('recall_id'));
193
    my $recall = Koha::Recalls->find( $query->param('recall_id') );
194
    my $recall_borrower = $recall->patron;
194
    my $recall_borrower = $recall->patron;
195
    my $item = Koha::Items->find($recall->itemnumber);
195
    my $item = Koha::Items->find($recall->itemnumber);
196
    my $biblio = Koha::Biblios->find($item->biblionumber);
196
    my $biblio = Koha::Biblios->find($item->biblionumber);
197
197
198
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
198
    if( $query->param("transfer_recall") ){
199
    my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
199
        $recall->update({ status => 'T', waitingdate => undef, expirationdate => undef });
200
    my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
200
    } else {
201
    $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
201
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
202
202
        my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
203
    # send notice to user who requested recall to pick up item
203
        my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
204
    my $letter = C4::Letters::GetPreparedLetter (
204
        $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
205
        module => 'circulation',
205
        # send notice to user who requested recall to pick up item
206
        letter_code => 'PICKUP_RECALLED_ITEM',
206
        my $letter = C4::Letters::GetPreparedLetter (
207
        branchcode => $recall->branchcode,
207
                module => 'circulation',
208
        tables => {
208
                letter_code => 'PICKUP_RECALLED_ITEM',
209
            'biblio', $biblio->biblionumber,
209
                branchcode => $recall->branchcode,
210
            'borrowers', $recall_borrower->borrowernumber,
210
                tables => {
211
            'items', $item->itemnumber,
211
                    'biblio',
212
            'recalls', $recall->recall_id,
212
                    $biblio->biblionumber,
213
        },
213
                    'borrowers',
214
    );
214
                    $recall_borrower->borrowernumber,
215
    C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email');
215
                    'items', $item->itemnumber,
216
                    'recalls',
217
                    $recall->recall_id,
218
                },
219
        );
220
        C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email');
221
    }
216
}
222
}
217
223
218
my $borrower;
224
my $borrower;
Lines 513-525 if ( $messages->{'RecallFound'} ){ Link Here
513
        found    => 1,
519
        found    => 1,
514
        recalled => 1,
520
        recalled => 1,
515
        recall   => $recall,
521
        recall   => $recall,
516
        address   => $patron->address,
522
        transfer_recall => ($userenv_branch eq $recall->branchcode ? 1 : 0 )
517
        address2  => $patron->address2,
523
#       address   => $patron->address,
518
        streetnumber => $patron->streetnumber,
524
#       address2  => $patron->address2,
519
        city         => $patron->city,
525
#       streetnumber => $patron->streetnumber,
520
        zipcode      => $patron->zipcode,
526
#       city         => $patron->city,
521
        state        => $patron->state,
527
#       zipcode      => $patron->zipcode,
522
        country      => $patron->country,
528
#       state        => $patron->state,
529
#       country      => $patron->country,
523
    );
530
    );
524
}
531
}
525
532
(-)a/installer/data/mysql/atomicupdate/bug_19532_-_add_recalls_table.sql (-1 / +1 lines)
Lines 9-15 CREATE TABLE `recalls` ( -- information related to recalls in Koha Link Here
9
    `cancellationdate` date default NULL, -- the date this recall was cancelled
9
    `cancellationdate` date default NULL, -- the date this recall was cancelled
10
    `recallnotes` mediumtext, -- notes related to this recall
10
    `recallnotes` mediumtext, -- notes related to this recall
11
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
11
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
12
    `status` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, C=cancelled, F=finished/completed
12
    `status` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, C=cancelled, F=finished/completed, T=transferring
13
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
13
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
14
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
14
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
15
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
15
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 1883-1889 CREATE TABLE `recalls` ( -- information related to recalls in Koha Link Here
1883
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1883
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1884
    `recallnotes` mediumtext, -- notes related to this recall
1884
    `recallnotes` mediumtext, -- notes related to this recall
1885
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1885
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1886
    `found` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, F=finished/completed
1886
    `found` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, T=transferring, E=expired, F=finished/completed
1887
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1887
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1888
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1888
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1889
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1889
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt (-3 / +3 lines)
Lines 45-52 Link Here
45
                <div id="results" class="toptabs">
45
                <div id="results" class="toptabs">
46
46
47
                    <ul>
47
                    <ul>
48
                        <li><a href="#recallswaiting">Recalls waiting: [% recalls.count %]</a></li>
48
                        <li><a href="#recallswaiting">Recalls waiting: [% recalls.size %]</a></li>
49
                        <li><a href="#recallsover">Recalls waiting over [% Koha.Preference('RecallsMaxPickUpDelay') %] days: [% over.count %]</a></li>
49
                        <li><a href="#recallsover">Recalls waiting over [% Koha.Preference('RecallsMaxPickUpDelay') %] days: [% over.size %]</a></li>
50
                    </ul>
50
                    </ul>
51
51
52
                    <div id="recallswaiting">
52
                    <div id="recallswaiting">
Lines 97-103 Link Here
97
                    </div>
97
                    </div>
98
98
99
                    <div id="recallsover">
99
                    <div id="recallsover">
100
                        [% IF ( over.count ) %]
100
                        [% IF ( over.size > 0 ) %]
101
                            [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]<p>Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.</p>[% END %]
101
                            [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]<p>Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.</p>[% END %]
102
                            <table id="recallsover-table">
102
                            <table id="recallsover-table">
103
                                <thead><tr>
103
                                <thead><tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-4 / +8 lines)
Lines 515-521 Link Here
515
            <div class="modal-content">
515
            <div class="modal-content">
516
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
516
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
517
                <div class="modal-header">
517
                <div class="modal-header">
518
                    <h3>Recall found: <br/>
518
                    <h3>Recall found  [% IF transfer_recall %] needing transfer to [% Branches.GetName( recall.branchcode ) %][% END %]: <br/>
519
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
519
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
520
                    </h3>
520
                    </h3>
521
                </div>
521
                </div>
Lines 549-566 Link Here
549
                        <li class="error">Patron's address is in doubt</li>
549
                        <li class="error">Patron's address is in doubt</li>
550
                    [% END %]
550
                    [% END %]
551
551
552
                    <h4><strong>Wait for pickup at</strong> [% recall.library.branchname %]</h4>
552
                    <h4>
553
                    [% IF transfer_recall %]Transfer to [% Branches.GetName( recall.branchcode ) %]
554
                    [% ELSIF recall.status == 'W' %]Hold for pickup (already waiting) at [% recall.library.branchname %]
555
                    [% ELSE %]Hold for pickup at [% recall.library.branchname %][% END %]
556
                    </h4>
553
557
554
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
558
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
555
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
559
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
556
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
560
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
557
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
561
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
558
                    <input type="hidden" name="diffBranch" value="[% recall.branchcode %]" />
562
                    <input type="hidden" name="transfer_recall" value="[% recall.branchcode %]" />
559
                </div>
563
                </div>
560
564
561
                <div class="modal-footer">
565
                <div class="modal-footer">
562
                    <button type="submit" class="btn btn-default approve">
566
                    <button type="submit" class="btn btn-default approve">
563
                        <i class="fa fa-check"></i> Confirm recall waiting
567
                        <i class="fa fa-check"></i> Confirm recall [% IF transfer_recall %]and transfer[% END %]
564
                    </button>
568
                    </button>
565
569
566
                    <button data-dismiss="modal" aria-hidden="true" type="submit" class="btn btn-danger deny" onclick="$('#barcode').focus(); return false;">
570
                    <button data-dismiss="modal" aria-hidden="true" type="submit" class="btn btn-danger deny" onclick="$('#barcode').focus(); return false;">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt (-1 / +5 lines)
Lines 31-37 Link Here
31
                            [% IF error == 'notloggedin' %]
31
                            [% IF error == 'notloggedin' %]
32
                                Please log in to place a recall.
32
                                Please log in to place a recall.
33
                            [% ELSIF error == 'duplicate' %]
33
                            [% ELSIF error == 'duplicate' %]
34
                                You have already placed a recall on this item.
34
                                A recall has already been placed on this item.
35
                            [% ELSIF error == 'not_issued' %]
36
                                Cannot recall an item that is not issued.
37
                            [% ELSIF error == 'not_allowed' %]
38
                                You may not place a recall on this item according to circulation rules.
35
                            [% ELSE %]
39
                            [% ELSE %]
36
                                An error has occurred while attempting to place a recall. Please contact your library.
40
                                An error has occurred while attempting to place a recall. Please contact your library.
37
                            [% END %]
41
                            [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt (-1 / +3 lines)
Lines 97-102 Link Here
97
                                                    Expired
97
                                                    Expired
98
                                                [% ELSIF ( RECALL.is_cancelled ) %]
98
                                                [% ELSIF ( RECALL.is_cancelled ) %]
99
                                                    Cancelled
99
                                                    Cancelled
100
                                                [% ELSIF ( RECALL.is_finished ) %]
101
                                                    Finished
100
                                                [% END %]
102
                                                [% END %]
101
                                            </td>
103
                                            </td>
102
                                            <td class="due_date">
104
                                            <td class="due_date">
Lines 116-122 Link Here
116
                                                        <input type="hidden" name="op" value="cancel">
118
                                                        <input type="hidden" name="op" value="cancel">
117
                                                        <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
119
                                                        <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
118
                                                        <input type="hidden" name="itemnumber" value="[% RECALL.itemnumber %]">
120
                                                        <input type="hidden" name="itemnumber" value="[% RECALL.itemnumber %]">
119
                                                        <button type="submit" name="submit" class="btn btn-mini btn-danger" id="cancel_recall"><i class="icon-remove icon-white"></i> Cancel</button>
121
                                                        <button type="submit" name="submit" class="btn btn-xs btn-danger" id="cancel_recall_[% RECALL.recall_id %]"><i class="icon-remove icon-white"></i> Cancel</button>
120
                                                    </form>
122
                                                    </form>
121
                                                [% END %]
123
                                                [% END %]
122
                                            </td>
124
                                            </td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-1 / +3 lines)
Lines 853-862 Link Here
853
                                                        Requested
853
                                                        Requested
854
                                                    [% ELSIF ( RECALL.is_waiting ) %]
854
                                                    [% ELSIF ( RECALL.is_waiting ) %]
855
                                                        Ready for pickup
855
                                                        Ready for pickup
856
                                                    [% ELSIF ( RECALL.status == 'T' ) %]
857
                                                        In-transit to pickup library
856
                                                    [% END %]
858
                                                    [% END %]
857
                                                </td>
859
                                                </td>
858
                                                <td class="cancelrecall">
860
                                                <td class="cancelrecall">
859
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue ) ) %]
861
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue || RECALL.status == 'T' ) ) %]
860
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
862
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
861
                                                            <input type="hidden" name="op" value="cancel">
863
                                                            <input type="hidden" name="op" value="cancel">
862
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
864
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
(-)a/opac/opac-detail.pl (-1 / +4 lines)
Lines 709-715 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
709
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
709
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
710
    }
710
    }
711
711
712
    if ( $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber ) {
712
    my $recall = Koha::Recalls->find({ itemnumber => $itm->{itemnumber}, old => undef });
713
    if ( !$recall && $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber        && C4::Context->preference('UseRecalls')
714
        && Koha::IssuingRules->get_opacitemholds_policy({ item => $item, patron => $patron }) ne 'N' )
715
    {
713
        $itm->{avail_for_recall} = 1;
716
        $itm->{avail_for_recall} = 1;
714
    }
717
    }
715
718
(-)a/opac/opac-recall.pl (-7 / +17 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#pinio
2
3
3
# This file is part of Koha.
4
# This file is part of Koha.
4
#
5
#
Lines 46-60 my $op = $query->param('op') || ''; Link Here
46
my $itemnumber = $query->param('itemnumber');
47
my $itemnumber = $query->param('itemnumber');
47
my $item = Koha::Items->find($itemnumber);
48
my $item = Koha::Items->find($itemnumber);
48
my $biblio = Koha::Biblios->find($item->biblionumber);
49
my $biblio = Koha::Biblios->find($item->biblionumber);
49
my $recalled = Koha::Recalls->find({ itemnumber => $itemnumber });
50
my $patron = Koha::Patrons->find($borrowernumber);
51
my $recalled = Koha::Recalls->find({ itemnumber => $itemnumber, old => undef, borrowernumber => $borrowernumber });
50
my $error;
52
my $error;
51
53
52
if ( defined $recalled && $recalled->borrowernumber == $borrowernumber && ($recalled->is_requested || $recalled->is_waiting || $recalled->is_overdue) ){
54
if ( defined $recalled ){
53
    # can't place a recall on an item that this borrower has already recalled
55
    # can't place a recall on an item that this borrower has already recalled
54
    # if recall is expired or cancelled, user may recall again
56
    # if recall is expired or cancelled, user may recall again
55
    $error = 'duplicate';
57
    $error = 'duplicate';
56
}
58
}
57
59
60
my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
61
unless ( defined $checkout ){
62
    # can't recall an item not checked out
63
    # checking in case they force the itemnumber
64
    $error = 'not_issued';
65
}
66
67
$error = 'not_allowed' unless Koha::IssuingRules->get_opacitemholds_policy({ item => $item, patron => $patron }) ne 'N';
68
58
if ($op eq 'request'){
69
if ($op eq 'request'){
59
    if (!defined $borrowernumber){
70
    if (!defined $borrowernumber){
60
    # can't place recall if not logged in
71
    # can't place recall if not logged in
Lines 62-70 if ($op eq 'request'){ Link Here
62
        print $query->redirect('/cgi-bin/koha/opac-detail.pl?biblionumber='.$item->biblionumber);
73
        print $query->redirect('/cgi-bin/koha/opac-detail.pl?biblionumber='.$item->biblionumber);
63
     } elsif ( !defined $error ){
74
     } elsif ( !defined $error ){
64
        # can recall
75
        # can recall
65
        my $borrower = Koha::Patrons->find($borrowernumber);
76
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $patron->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
66
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
77
         my $recall_request = Koha::Recall->new({
67
        my $recall_request = Koha::Recall->new({
68
            borrowernumber => $borrowernumber,
78
            borrowernumber => $borrowernumber,
69
            recalldate => dt_from_string(),
79
            recalldate => dt_from_string(),
70
            biblionumber => $biblio->biblionumber,
80
            biblionumber => $biblio->biblionumber,
Lines 78-85 if ($op eq 'request'){ Link Here
78
            # updating due date on checkout
88
            # updating due date on checkout
79
            my $timestamp = dt_from_string($recall->timestamp);
89
            my $timestamp = dt_from_string($recall->timestamp);
80
            my $due_date = $timestamp->add( $issuing_rule->lengthunit => $issuing_rule->recall_due_date_interval );
90
            my $due_date = $timestamp->add( $issuing_rule->lengthunit => $issuing_rule->recall_due_date_interval );
81
            my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber })->update({ date_due => $due_date });
91
            $checkout->update({ date_due => $due_date });
82
            my $checkout_borrower = Koha::Patrons->find($checkout->borrowernumber->borrowernumber);
92
            my $checkout_borrower = $checkout->patron;
83
93
84
            # send notice to user with recalled item checked out
94
            # send notice to user with recalled item checked out
85
            my $letter = C4::Letters::GetPreparedLetter (
95
            my $letter = C4::Letters::GetPreparedLetter (
(-)a/opac/opac-user.pl (-2 / +1 lines)
Lines 305-311 $template->param( show_barcode => 1 ) if $show_barcode; Link Here
305
305
306
# now the reserved items....
306
# now the reserved items....
307
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
307
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
308
my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber, status => { '=', ['R', 'W'] } } );
308
my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber, old => undef } );
309
309
310
$template->param(
310
$template->param(
311
    RESERVES       => $reserves,
311
    RESERVES       => $reserves,
312
- 

Return to bug 19532