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 2030-2050 sub AddReturn { Link Here
2030
        }
2028
        }
2031
    }
2029
    }
2032
2030
2033
    # find reserves.....
2034
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
2035
    my ($resfound, $resrec);
2031
    my ($resfound, $resrec);
2036
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2037
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2038
    if ($resfound) {
2039
          $resrec->{'ResFound'} = $resfound;
2040
        $messages->{'ResFound'} = $resrec;
2041
    }
2042
2032
2043
    # find recalls.....
2033
    # find recalls.....
2044
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} });
2034
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, old => undef });
2045
    if (defined $recall){
2035
    if (defined $recall){
2046
        $messages->{'RecallFound'} = 1;
2036
        $messages->{'RecallFound'} = 1;
2047
        $messages->{'Recall'} = $recall;
2037
        $messages->{'Recall'} = $recall;
2038
    } else {
2039
        # find reserves.....
2040
        # if we don't have a reserve with the status W, we launch the Checkreserves routine
2041
        my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2042
        ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2043
        if ($resfound) {
2044
            $resrec->{'ResFound'} = $resfound;
2045
            $messages->{'ResFound'} = $resrec;
2046
        }
2048
    }
2047
    }
2049
2048
2050
    # Record the fact that this book was returned.
2049
    # Record the fact that this book was returned.
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 324-330 foreach my $item (@items) { Link Here
324
        }
324
        }
325
    }
325
    }
326
326
327
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber} });
327
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef });
328
    if (defined $recall){
328
    if (defined $recall){
329
        $item->{recalled} = 1;
329
        $item->{recalled} = 1;
330
        $item->{recall} = $recall;
330
        $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 484-496 if ( $messages->{'RecallFound'} ){ Link Here
484
        found    => 1,
490
        found    => 1,
485
        recalled => 1,
491
        recalled => 1,
486
        recall   => $recall,
492
        recall   => $recall,
487
        address   => $patron->address,
493
        transfer_recall => ($userenv_branch eq $recall->branchcode ? 1 : 0 )
488
        address2  => $patron->address2,
494
#        address   => $patron->address,
489
        streetnumber => $patron->streetnumber,
495
#        address2  => $patron->address2,
490
        city         => $patron->city,
496
#        streetnumber => $patron->streetnumber,
491
        zipcode      => $patron->zipcode,
497
#        city         => $patron->city,
492
        state        => $patron->state,
498
#        zipcode      => $patron->zipcode,
493
        country      => $patron->country,
499
#        state        => $patron->state,
500
#        country      => $patron->country,
494
    );
501
    );
495
}
502
}
496
503
(-)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 1884-1890 CREATE TABLE `recalls` ( -- information related to recalls in Koha Link Here
1884
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1884
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1885
    `recallnotes` mediumtext, -- notes related to this recall
1885
    `recallnotes` mediumtext, -- notes related to this recall
1886
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1886
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1887
    `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
1887
    `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
1888
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1888
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1889
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1889
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1890
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1890
    `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 463-469 Link Here
463
            <div class="modal-content">
463
            <div class="modal-content">
464
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
464
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
465
                <div class="modal-header">
465
                <div class="modal-header">
466
                    <h3>Recall found: <br/>
466
                    <h3>Recall found  [% IF transfer_recall %] needing transfer to [% Branches.GetName( recall.branchcode ) %][% END %]: <br/>
467
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
467
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
468
                    </h3>
468
                    </h3>
469
                </div>
469
                </div>
Lines 497-514 Link Here
497
                        <li class="error">Patron's address is in doubt</li>
497
                        <li class="error">Patron's address is in doubt</li>
498
                    [% END %]
498
                    [% END %]
499
499
500
                    <h4><strong>Wait for pickup at</strong> [% recall.library.branchname %]</h4>
500
                    <h4>
501
501
                    [% IF transfer_recall %]Transfer to [% Branches.GetName( recall.branchcode ) %]
502
                    [% ELSIF recall.status == 'W' %]Hold for pickup (already waiting) at [% recall.library.branchname %]
503
                    [% ELSE %]Hold for pickup at [% recall.library.branchname %][% END %]
504
                    </h4>
502
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
505
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
503
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
506
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
504
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
507
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
505
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
508
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
506
                    <input type="hidden" name="diffBranch" value="[% recall.branchcode %]" />
509
                    <input type="hidden" name="transfer_recall" value="[% recall.branchcode %]" />
507
                </div>
510
                </div>
508
511
509
                <div class="modal-footer">
512
                <div class="modal-footer">
510
                    <button type="submit" class="btn btn-default approve">
513
                    <button type="submit" class="btn btn-default approve">
511
                        <i class="fa fa-check"></i> Confirm recall waiting
514
                        <i class="fa fa-check"></i> Confirm recall [% IF transfer_recall %]and transfer[% END %]
512
                    </button>
515
                    </button>
513
516
514
                    <button data-dismiss="modal" aria-hidden="true" type="submit" class="btn btn-danger deny" onclick="$('#barcode').focus(); return false;">
517
                    <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 856-865 Link Here
856
                                                        Requested
856
                                                        Requested
857
                                                    [% ELSIF ( RECALL.is_waiting ) %]
857
                                                    [% ELSIF ( RECALL.is_waiting ) %]
858
                                                        Ready for pickup
858
                                                        Ready for pickup
859
                                                    [% ELSIF ( RECALL.status == 'T' ) %]
860
                                                        In-transit to pickup library
859
                                                    [% END %]
861
                                                    [% END %]
860
                                                </td>
862
                                                </td>
861
                                                <td class="cancelrecall">
863
                                                <td class="cancelrecall">
862
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue ) ) %]
864
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue || RECALL.status == 'T' ) ) %]
863
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
865
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
864
                                                            <input type="hidden" name="op" value="cancel">
866
                                                            <input type="hidden" name="op" value="cancel">
865
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
867
                                                            <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 306-312 $template->param( show_barcode => 1 ) if $show_barcode; Link Here
306
306
307
# now the reserved items....
307
# now the reserved items....
308
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
308
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
309
my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber, status => { '=', ['R', 'W'] } } );
309
my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber, old => undef } );
310
310
311
$template->param(
311
$template->param(
312
    RESERVES       => $reserves,
312
    RESERVES       => $reserves,
313
- 

Return to bug 19532