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

(-)a/C4/Circulation.pm (-22 / +21 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 ) =
361
            CheckReserves( $itemnumber );
362
        if ( $resfound and not $ignoreRs ) {
363
            $resrec->{'ResFound'} = $resfound;
364
#         $messages->{'ResFound'} = $resrec;
365
            $dotransfer = 1;
366
        }
369
    }
367
    }
370
368
371
    #actually do the transfer....
369
    #actually do the transfer....
Lines 1380-1386 sub AddIssue { Link Here
1380
1378
1381
            # Check if a recall
1379
            # Check if a recall
1382
            if ( C4::Context->preference('UseRecalls') ) {
1380
            if ( C4::Context->preference('UseRecalls') ) {
1383
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'} });
1381
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'}, old => undef });
1384
                if (defined $recall) {
1382
                if (defined $recall) {
1385
                    $recall->update({ status => "F", old => 1 });
1383
                    $recall->update({ status => "F", old => 1 });
1386
                }
1384
                }
Lines 2034-2054 sub AddReturn { Link Here
2034
        }
2032
        }
2035
    }
2033
    }
2036
2034
2037
    # find reserves.....
2038
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
2039
    my ($resfound, $resrec);
2035
    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
2036
2047
    # find recalls.....
2037
    # find recalls.....
2048
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} });
2038
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, old => undef });
2049
    if (defined $recall){
2039
    if (defined $recall){
2050
        $messages->{'RecallFound'} = 1;
2040
        $messages->{'RecallFound'} = 1;
2051
        $messages->{'Recall'} = $recall;
2041
        $messages->{'Recall'} = $recall;
2042
    } else {
2043
        # find reserves.....
2044
        # if we don't have a reserve with the status W, we launch the Checkreserves routine
2045
        my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2046
        ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2047
        if ($resfound) {
2048
            $resrec->{'ResFound'} = $resfound;
2049
            $messages->{'ResFound'} = $resrec;
2050
        }
2052
    }
2051
    }
2053
2052
2054
    # Record the fact that this book was returned.
2053
    # 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 (-27 / +34 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
    if( $query->param("transfer_recall") ){
198
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
198
        $recall->update({ status => 'T', waitingdate => undef, expirationdate => undef });
199
    my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
199
    } else {
200
    my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
200
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
201
    $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
201
        my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
202
202
        my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
203
    # send notice to user who requested recall to pick up item
203
        $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
204
    my $letter = C4::Letters::GetPreparedLetter (
204
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 1871-1877 CREATE TABLE `recalls` ( -- information related to recalls in Koha Link Here
1871
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1871
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1872
    `recallnotes` mediumtext, -- notes related to this recall
1872
    `recallnotes` mediumtext, -- notes related to this recall
1873
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1873
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1874
    `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
1874
    `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
1875
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1875
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1876
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1876
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1877
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1877
    `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 (-5 / +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
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>
554
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
557
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
555
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
558
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
556
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
559
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
557
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
560
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
558
                    <input type="hidden" name="diffBranch" value="[% recall.branchcode %]" />
561
                    <input type="hidden" name="transfer_recall" value="[% recall.branchcode %]" />
559
                </div>
562
                </div>
560
563
561
                <div class="modal-footer">
564
                <div class="modal-footer">
562
                    <button type="submit" class="btn btn-default approve">
565
                    <button type="submit" class="btn btn-default approve">
563
                        <i class="fa fa-check"></i> Confirm recall waiting
566
                        <i class="fa fa-check"></i> Confirm recall [% IF transfer_recall %]and transfer[% END %]
564
                    </button>
567
                    </button>
565
568
566
                    <button data-dismiss="modal" aria-hidden="true" type="submit" class="btn btn-danger deny" onclick="$('#barcode').focus(); return false;">
569
                    <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 96-101 Link Here
96
                                                    Expired
96
                                                    Expired
97
                                                [% ELSIF ( RECALL.is_cancelled ) %]
97
                                                [% ELSIF ( RECALL.is_cancelled ) %]
98
                                                    Cancelled
98
                                                    Cancelled
99
                                                [% ELSIF ( RECALL.is_finished ) %]
100
                                                    Finished
99
                                                [% END %]
101
                                                [% END %]
100
                                            </td>
102
                                            </td>
101
                                            <td class="due_date">
103
                                            <td class="due_date">
Lines 115-121 Link Here
115
                                                        <input type="hidden" name="op" value="cancel">
117
                                                        <input type="hidden" name="op" value="cancel">
116
                                                        <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
118
                                                        <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
117
                                                        <input type="hidden" name="itemnumber" value="[% RECALL.itemnumber %]">
119
                                                        <input type="hidden" name="itemnumber" value="[% RECALL.itemnumber %]">
118
                                                        <button type="submit" name="submit" class="btn btn-mini btn-danger" id="cancel_recall"><i class="icon-remove icon-white"></i> Cancel</button>
120
                                                        <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>
119
                                                    </form>
121
                                                    </form>
120
                                                [% END %]
122
                                                [% END %]
121
                                            </td>
123
                                            </td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-1 / +3 lines)
Lines 848-857 Link Here
848
                                                        Requested
848
                                                        Requested
849
                                                    [% ELSIF ( RECALL.is_waiting ) %]
849
                                                    [% ELSIF ( RECALL.is_waiting ) %]
850
                                                        Ready for pickup
850
                                                        Ready for pickup
851
                                                    [% ELSIF ( RECALL.status == 'T' ) %]
852
                                                        In-transit to pickup library
851
                                                    [% END %]
853
                                                    [% END %]
852
                                                </td>
854
                                                </td>
853
                                                <td class="cancelrecall">
855
                                                <td class="cancelrecall">
854
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue ) ) %]
856
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue || RECALL.status == 'T' ) ) %]
855
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
857
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
856
                                                            <input type="hidden" name="op" value="cancel">
858
                                                            <input type="hidden" name="op" value="cancel">
857
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
859
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
(-)a/opac/opac-detail.pl (-1 / +5 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 && C4::Context->preference('UseRecalls') ) {
712
    my $recall = Koha::Recalls->find({ itemnumber => $itm->{itemnumber}, old => undef });
713
    if ( !$recall && $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber
714
            && C4::Context->preference('UseRecalls')
715
            && Koha::IssuingRules->get_opacitemholds_policy({ item => $item, patron => $patron }) ne 'N' )
716
    {
713
        $itm->{avail_for_recall} = 1;
717
        $itm->{avail_for_recall} = 1;
714
    }
718
    }
715
719
(-)a/opac/opac-recall.pl (-7 / +18 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
82
            my $checkout_borrower = Koha::Patrons->find($checkout->borrowernumber->borrowernumber);
92
            $checkout->update({ date_due => $due_date });
93
            my $checkout_borrower = $checkout->patron;
83
94
84
            # send notice to user with recalled item checked out
95
            # send notice to user with recalled item checked out
85
            my $letter = C4::Letters::GetPreparedLetter (
96
            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