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

(-)a/C4/Circulation.pm (-22 / +24 lines)
Lines 345-363 sub transferbook { Link Here
345
        $messages->{'WasReturned'} = $issue->borrowernumber;
345
        $messages->{'WasReturned'} = $issue->borrowernumber;
346
    }
346
    }
347
347
348
    # find reserves.....
349
    # That'll save a database query.
350
    my ( $resfound, $resrec, undef ) =
351
      CheckReserves( $itemnumber );
352
    if ( $resfound and not $ignoreRs ) {
353
        $resrec->{'ResFound'} = $resfound;
354
355
        #         $messages->{'ResFound'} = $resrec;
356
        $dotransfer = 1;
357
    }
358
348
359
    # 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
360
    my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, status => 'R' });
350
    my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, old => undef });
361
    if (defined $recall){
351
    if (defined $recall){
362
        if ($recall->branchcode eq $fbr){
352
        if ($recall->branchcode eq $fbr){
363
            $dotransfer = 0;
353
            $dotransfer = 0;
Lines 365-370 sub transferbook { Link Here
365
        } else {
355
        } else {
366
            $dotransfer = 1;
356
            $dotransfer = 1;
367
        }
357
        }
358
    } else { #recalls take priority over holds, only check holds if no recalls
359
        # find reserves.....
360
        # That'll save a database query.
361
        my ( $resfound, $resrec, undef ) =
362
          CheckReserves( $itemnumber );
363
        if ( $resfound and not $ignoreRs ) {
364
            $resrec->{'ResFound'} = $resfound;
365
366
            #         $messages->{'ResFound'} = $resrec;
367
            $dotransfer = 1;
368
        }
368
    }
369
    }
369
370
370
    #actually do the transfer....
371
    #actually do the transfer....
Lines 1378-1384 sub AddIssue { Link Here
1378
1379
1379
            # Check if a recall
1380
            # Check if a recall
1380
            if ( C4::Context->preference('UseRecalls') ) {
1381
            if ( C4::Context->preference('UseRecalls') ) {
1381
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'} });
1382
                my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'}, old => undef });
1382
                if (defined $recall) {
1383
                if (defined $recall) {
1383
                    $recall->update({ status => "F", old => 1 });
1384
                    $recall->update({ status => "F", old => 1 });
1384
                }
1385
                }
Lines 2027-2049 sub AddReturn { Link Here
2027
        }
2028
        }
2028
    }
2029
    }
2029
2030
2030
    # find reserves.....
2031
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
2032
    my ($resfound, $resrec);
2031
    my ($resfound, $resrec);
2033
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2034
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2035
    if ($resfound) {
2036
          $resrec->{'ResFound'} = $resfound;
2037
        $messages->{'ResFound'} = $resrec;
2038
    }
2039
2040
    # find recalls.....
2032
    # find recalls.....
2041
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} });
2033
    my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, old => undef });
2042
    if (defined $recall){
2034
    if (defined $recall){
2043
        $messages->{'RecallFound'} = 1;
2035
        $messages->{'RecallFound'} = 1;
2044
        $messages->{'Recall'} = $recall;
2036
        $messages->{'Recall'} = $recall;
2037
    } else {
2038
        # find reserves.....
2039
        # if we don't have a reserve with the status W, we launch the Checkreserves routine
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
        }
2045
    }
2046
    }
2046
2047
2048
2047
    # Record the fact that this book was returned.
2049
    # Record the fact that this book was returned.
2048
    UpdateStats({
2050
    UpdateStats({
2049
        branch         => $branch,
2051
        branch         => $branch,
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 320-326 foreach my $item (@items) { Link Here
320
        }
320
        }
321
    }
321
    }
322
322
323
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber} });
323
    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef });
324
    if (defined $recall){
324
    if (defined $recall){
325
        $item->{recalled} = 1;
325
        $item->{recalled} = 1;
326
        $item->{recall} = $recall;
326
        $item->{recall} = $recall;
(-)a/circ/returns.pl (-26 / +31 lines)
Lines 189-217 if ( $query->param('reserve_id') ) { Link Here
189
}
189
}
190
190
191
if ( $query->param('recall_id') ){
191
if ( $query->param('recall_id') ){
192
    my $recall = Koha::Recalls->find(scalar $query->param('recall_id'));
192
    my $recall = Koha::Recalls->find( $query->param('recall_id') );
193
    my $recall_borrower = $recall->patron;
193
    my $recall_borrower = $recall->patron;
194
    my $item = Koha::Items->find($recall->itemnumber);
194
    my $item = Koha::Items->find($recall->itemnumber);
195
    my $biblio = Koha::Biblios->find($item->biblionumber);
195
    my $biblio = Koha::Biblios->find($item->biblionumber);
196
196
197
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
197
    if( $query->param("transfer_recall") ){
198
    my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
198
        $recall->update({ status => 'T', waitingdate => undef, expirationdate => undef });
199
    my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
199
    } else {
200
    $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
200
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
201
201
        my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay');
202
    # send notice to user who requested recall to pick up item
202
        my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time );
203
    my $letter = C4::Letters::GetPreparedLetter (
203
        $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate });
204
        module => 'circulation',
204
205
        letter_code => 'PICKUP_RECALLED_ITEM',
205
        # send notice to user who requested recall to pick up item
206
        branchcode => $recall->branchcode,
206
        my $letter = C4::Letters::GetPreparedLetter (
207
        tables => {
207
             module => 'circulation',
208
            'biblio', $biblio->biblionumber,
208
             letter_code => 'PICKUP_RECALLED_ITEM',
209
            'borrowers', $recall_borrower->borrowernumber,
209
             branchcode => $recall->branchcode,
210
            'items', $item->itemnumber,
210
             tables => {
211
            'recalls', $recall->recall_id,
211
                 'biblio', $biblio->biblionumber,
212
        },
212
                 'borrowers', $recall_borrower->borrowernumber,
213
    );
213
                 'items', $item->itemnumber,
214
    C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email');
214
                 'recalls', $recall->recall_id,
215
             },
216
         );
217
         C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email');
218
    }
215
}
219
}
216
220
217
my $borrower;
221
my $borrower;
Lines 485-497 if ( $messages->{'RecallFound'} ){ Link Here
485
        found    => 1,
489
        found    => 1,
486
        recalled => 1,
490
        recalled => 1,
487
        recall   => $recall,
491
        recall   => $recall,
488
        address   => $patron->address,
492
        transfer_recall => ($userenv_branch eq $recall->branchcode ? 1 : 0 )
489
        address2  => $patron->address2,
493
#        address   => $patron->address,
490
        streetnumber => $patron->streetnumber,
494
#        address2  => $patron->address2,
491
        city         => $patron->city,
495
#        streetnumber => $patron->streetnumber,
492
        zipcode      => $patron->zipcode,
496
#        city         => $patron->city,
493
        state        => $patron->state,
497
#        zipcode      => $patron->zipcode,
494
        country      => $patron->country,
498
#        state        => $patron->state,
499
#        country      => $patron->country,
495
    );
500
    );
496
}
501
}
497
502
(-)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 1860-1866 CREATE TABLE `recalls` ( -- information related to recalls in Koha Link Here
1860
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1860
    `cancellationdate` date default NULL, -- the date this recall was cancelled
1861
    `recallnotes` mediumtext, -- notes related to this recall
1861
    `recallnotes` mediumtext, -- notes related to this recall
1862
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1862
    `priority` smallint(6) default NULL, -- where in the queue the patron sits
1863
    `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
1863
    `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
1864
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1864
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated
1865
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1865
    `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on
1866
    `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1866
    `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 47-54 Link Here
47
                <div id="results" class="toptabs">
47
                <div id="results" class="toptabs">
48
48
49
                    <ul>
49
                    <ul>
50
                        <li><a href="#recallswaiting">Recalls waiting: [% recalls.count %]</a></li>
50
                        <li><a href="#recallswaiting">Recalls waiting: [% recalls.size %]</a></li>
51
                        <li><a href="#recallsover">Recalls waiting over [% Koha.Preference('RecallsMaxPickUpDelay') %] days: [% over.count %]</a></li>
51
                        <li><a href="#recallsover">Recalls waiting over [% Koha.Preference('RecallsMaxPickUpDelay') %] days: [% over.size %]</a></li>
52
                    </ul>
52
                    </ul>
53
53
54
                    <div id="recallswaiting">
54
                    <div id="recallswaiting">
Lines 99-105 Link Here
99
                    </div>
99
                    </div>
100
100
101
                    <div id="recallsover">
101
                    <div id="recallsover">
102
                        [% IF ( over.count ) %]
102
                        [% IF ( over.size > 0) %]
103
                            [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]<p>Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.</p>[% END %]
103
                            [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]<p>Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.</p>[% END %]
104
                            <table id="recallsover-table">
104
                            <table id="recallsover-table">
105
                                <thead><tr>
105
                                <thead><tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-4 / +8 lines)
Lines 465-471 Link Here
465
            <div class="modal-content">
465
            <div class="modal-content">
466
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
466
            <form method="post" action="/cgi-bin/koha/circ/returns.pl" class="confirm">
467
                <div class="modal-header">
467
                <div class="modal-header">
468
                    <h3>Recall found: <br/>
468
                    <h3>Recall found  [% IF transfer_recall %] needing transfer to [% Branches.GetName( recall.branchcode ) %][% END %]: <br/>
469
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
469
                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %] </a>
470
                    </h3>
470
                    </h3>
471
                </div>
471
                </div>
Lines 499-516 Link Here
499
                        <li class="error">Patron's address is in doubt</li>
499
                        <li class="error">Patron's address is in doubt</li>
500
                    [% END %]
500
                    [% END %]
501
501
502
                    <h4><strong>Wait for pickup at</strong> [% recall.library.branchname %]</h4>
502
                    <h4>
503
                    [% IF transfer_recall %]Transfer to [% Branches.GetName( recall.branchcode ) %]
504
                    [% ELSIF recall.status == 'W' %]Hold for pickup (already waiting) at [% recall.library.branchname %]
505
                    [% ELSE %]Hold for pickup at [% recall.library.branchname %][% END %]
506
                    </h4>
503
507
504
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
508
                    <input type="hidden" name="itemnumber" value="[% recall.itemnumber %]" />
505
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
509
                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
506
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
510
                    <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
507
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
511
                    <input type="hidden" name="recall_id" value="[% recall.recall_id %]" />
508
                    <input type="hidden" name="diffBranch" value="[% recall.branchcode %]" />
512
                    <input type="hidden" name="transfer_recall" value="[% recall.branchcode %]" />
509
                </div>
513
                </div>
510
514
511
                <div class="modal-footer">
515
                <div class="modal-footer">
512
                    <button type="submit" class="btn btn-default approve">
516
                    <button type="submit" class="btn btn-default approve">
513
                        <i class="fa fa-check"></i> Confirm recall waiting
517
                        <i class="fa fa-check"></i> Confirm recall [% IF transfer_recall %]and transfer[% END %]
514
                    </button>
518
                    </button>
515
519
516
                    <button data-dismiss="modal" aria-hidden="true" type="submit" class="btn btn-danger deny" onclick="$('#barcode').focus(); return false;">
520
                    <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 33-39 Link Here
33
                            [% IF error == 'notloggedin' %]
33
                            [% IF error == 'notloggedin' %]
34
                                Please log in to place a recall.
34
                                Please log in to place a recall.
35
                            [% ELSIF error == 'duplicate' %]
35
                            [% ELSIF error == 'duplicate' %]
36
                                You have already placed a recall on this item.
36
                                A recall has already been placed on this item.
37
                            [% ELSIF error == 'not_issued' %]
38
                                Cannot recall an item that is not issued.
39
                            [% ELSIF error == 'not_allowed' %]
40
                                You may not place a recall on this item according to circulation rules.
37
                            [% ELSE %]
41
                            [% ELSE %]
38
                                An error has occurred while attempting to place a recall. Please contact your library.
42
                                An error has occurred while attempting to place a recall. Please contact your library.
39
                            [% END %]
43
                            [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt (-1 / +3 lines)
Lines 98-103 Link Here
98
                                                    Expired
98
                                                    Expired
99
                                                [% ELSIF ( RECALL.is_cancelled ) %]
99
                                                [% ELSIF ( RECALL.is_cancelled ) %]
100
                                                    Cancelled
100
                                                    Cancelled
101
                                                [% ELSIF ( RECALL.is_finished ) %]
102
                                                    Finished
101
                                                [% END %]
103
                                                [% END %]
102
                                            </td>
104
                                            </td>
103
                                            <td class="due_date">
105
                                            <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 843-852 Using this account is not recommended because some parts of Koha will not functi Link Here
843
                                                        Requested
843
                                                        Requested
844
                                                    [% ELSIF ( RECALL.is_waiting ) %]
844
                                                    [% ELSIF ( RECALL.is_waiting ) %]
845
                                                        Ready for pickup
845
                                                        Ready for pickup
846
                                                    [% ELSIF ( RECALL.status == 'T' ) %]
847
                                                        In-transit to pickup library
846
                                                    [% END %]
848
                                                    [% END %]
847
                                                </td>
849
                                                </td>
848
                                                <td class="cancelrecall">
850
                                                <td class="cancelrecall">
849
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue ) ) %]
851
                                                    [% IF ( !RECALL.cancellationdate && ( RECALL.is_requested || RECALL.is_overdue || RECALL.status == 'T' ) ) %]
850
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
852
                                                        <form action="/cgi-bin/koha/opac-recall.pl" method="post">
851
                                                            <input type="hidden" name="op" value="cancel">
853
                                                            <input type="hidden" name="op" value="cancel">
852
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
854
                                                            <input type="hidden" name="recall_id" value="[% RECALL.recall_id %]">
(-)a/opac/opac-detail.pl (-2 / +4 lines)
Lines 708-715 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
708
        $itm->{on_order} = 1
708
        $itm->{on_order} = 1
709
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
709
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
710
    }
710
    }
711
711
    my $recall = Koha::Recalls->find({ itemnumber => $itm->{itemnumber}, old => undef });
712
    if ( $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber && C4::Context->preference('UseRecalls') ) {
712
    if ( !$recall && $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber
713
            && C4::Context->preference('UseRecalls')
714
            && Koha::IssuingRules->get_opacitemholds_policy({ item => $item, patron => $patron }) ne 'N' ) {
713
        $itm->{avail_for_recall} = 1;
715
        $itm->{avail_for_recall} = 1;
714
    }
716
    }
715
717
(-)a/opac/opac-recall.pl (-6 / +16 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-69 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 });
67
        my $recall_request = Koha::Recall->new({
77
        my $recall_request = Koha::Recall->new({
68
            borrowernumber => $borrowernumber,
78
            borrowernumber => $borrowernumber,
69
            recalldate => dt_from_string(),
79
            recalldate => dt_from_string(),
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