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

(-)a/Koha/Recall.pm (-1 / +40 lines)
Lines 37-46 Koha::Recall - Koha Recall Object class Link Here
37
37
38
=cut
38
=cut
39
39
40
sub type {
40
sub _type {
41
    return 'Recall';
41
    return 'Recall';
42
}
42
}
43
43
44
=head3 is_waiting
45
46
Returns true if recall is awaiting pickup
47
48
=cut
49
50
sub is_waiting {
51
    my ($self) = @_;
52
53
    my $status = $self->status;
54
    return $status && $status eq 'W';
55
}
56
57
=head3 has_expired
58
59
Returns true if recall has expired
60
61
=cut
62
63
sub has_expired {
64
    my ($self) = @_;
65
66
    my $status = $self->status;
67
    return $status && $status eq 'E';
68
}
69
70
=head3 is_requested
71
72
Returns true if recall has been requested
73
74
=cut
75
76
sub is_requested {
77
    my ($self) = @_;
78
79
    my $status = $self->status;
80
    return $status && $status eq 'R';
81
}
82
44
=head1 AUTHOR
83
=head1 AUTHOR
45
84
46
Aleisha Amohia <aleisha@catalyst.net.nz>
85
Aleisha Amohia <aleisha@catalyst.net.nz>
(-)a/Koha/Recalls.pm (-1 / +1 lines)
Lines 38-44 Koha::Recalls - Koha Recalls Object Set class Link Here
38
38
39
=cut
39
=cut
40
40
41
sub type {
41
sub _type {
42
    return 'Recall';
42
    return 'Recall';
43
}
43
}
44
44
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (+1 lines)
Lines 38-43 Link Here
38
            <span class="item-status checkedout">Checked out</span>
38
            <span class="item-status checkedout">Checked out</span>
39
        [% END %]
39
        [% END %]
40
    [% END %]
40
    [% END %]
41
    [% IF loggedinusername %]<a href="/cgi-bin/koha/opac-recall.pl?itemnumber=[% item.itemnumber %]" class="btn btn-default btn-xs">Recall</a>[% END %]
41
[% END %]
42
[% END %]
42
43
43
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
44
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt (+62 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Recall</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% BLOCK cssinclude %][% END %]
6
</head>
7
<body id="opac-recall" class="scrollto">
8
[% INCLUDE 'masthead.inc' %]
9
10
<div class="main">
11
    <ul class="breadcrumb">
12
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
13
        <li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber %]">Details for: [% biblio.title %]</a> <span class="divider">&rsaquo;</span></li>
14
        <li><a href="/cgi-bin/koha/opac-recall.pl?itemnumber=[% itemnumber %]">Recall item</a></li>
15
    </ul>
16
17
    <div class="container-fluid">
18
        <div class="row-fluid">
19
            <div class="span2">
20
                <div id="navigation">
21
                    [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
22
                </div>
23
            </div>
24
            <div class="span10">
25
                <div id="discharge" class="maincontainer">
26
                    <h1>Recall an item</h1>
27
                    [% IF error %]
28
                        <div class="dialog alert">
29
                            [% IF error == 'notloggedin' %]
30
                                Please log in to place a recall.
31
                            [% ELSIF error == 'duplicate' %]
32
                                You have already placed a recall on this item.
33
                            [% ELSE %]
34
                                An error has occurred while attempting to place a recall. Please contact your library.
35
                            [% END %]
36
                        </div>
37
                    [% END %]
38
39
                    [% IF success %]
40
                        <p>Your recall has been placed. The user the item is currently checked out to has been asked to return the item within [% due_interval %] [% due_unit %].</p>
41
                        <p>You will be notified when your item is waiting to be picked up at the library.</p>
42
                    [% ELSIF not error %]
43
                        <p>All borrowable material is subject to recall if checked out and needed by someone else. We will ask the person who has checked out this item to return it so you may use it.</p>
44
                        <p><strong>Warning</strong>: Your library does not allow recalls for x item types.</p>
45
<hr>
46
                        [% IF loggedinusername %]
47
                            <div class="dialog">
48
                            <p>Place a recall on [% biblio.title %] ([% biblio.author %])?</p> <a href="/cgi-bin/koha/opac-recall.pl?op=request&itemnumber=[% itemnumber %]" class="btn btn-default btn-sm">Confirm</a> &nbsp; <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber %]">Cancel</a>
49
                            </div>
50
                        [% ELSE %]
51
                            <div class="dialog alert">You must be logged in to place a recall.</div>
52
                        [% END %]
53
54
                    [% END %]
55
                </div> <!-- / #discharge -->
56
            </div> <!-- / .span10 -->
57
        </div> <!-- / .row-fluid -->
58
    </div>  <!-- / .container-fluid -->
59
</div> <!-- / .main -->
60
61
[% INCLUDE 'opac-bottom.inc' %]
62
[% BLOCK jsinclude %][% END %]
(-)a/opac/opac-recall.pl (-1 / +96 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use DateTime;
23
use C4::Auth;
24
use C4::Output;
25
use C4::Context;
26
use Koha::Items;
27
use Koha::Recall;
28
use Koha::Recalls;
29
use Koha::DateUtils;
30
use Koha::IssuingRules;
31
use Koha::Patrons;
32
33
my $query = new CGI;
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35
    {
36
        template_name   => "opac-recall.tt",
37
        query           => $query,
38
        type            => "opac",
39
        authnotrequired => 0,
40
    }
41
);
42
43
my $op = $query->param('op') || '';
44
45
my $itemnumber = $query->param('itemnumber');
46
my $item = Koha::Items->find($itemnumber);
47
my $biblio = Koha::Biblios->find($item->biblionumber);
48
my $recalled = Koha::Recalls->find({ itemnumber => $itemnumber });
49
my $error;
50
51
if ($op eq 'request'){
52
    if (!defined($borrowernumber)){
53
    # can't place recall if not logged in
54
        $error = 'notloggedin';
55
        print $query->redirect('/cgi-bin/koha/opac-detail.pl?biblionumber='.$item->biblionumber);
56
    } elsif (defined $recalled && $recalled->borrowernumber == $borrowernumber){
57
    # can't place a recall on an item that this borrower has already recalled
58
        $error = 'duplicate';
59
    } else {
60
    # can recall
61
        my $borrower = Koha::Patrons->find($borrowernumber);
62
        my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch });
63
        my $recall_request = Koha::Recall->new({
64
            borrowernumber => $borrowernumber,
65
            recalldate => dt_from_string(),
66
            biblionumber => $biblio->biblionumber,
67
            branchcode => $item->holdingbranch,
68
            status => 'R',
69
            itemnumber => $itemnumber,
70
            itemtype => $item->itype,
71
        })->store;
72
        if (defined $recall_request->recall_id){ # successful recall
73
            my $recall = Koha::Recalls->find($recall_request->recall_id);
74
            # updating due date on checkout
75
            my $timestamp = dt_from_string($recall->timestamp);
76
            my $due_date = $timestamp->add( $issuing_rule->lengthunit => $issuing_rule->recall_due_date_interval );
77
            Koha::Checkouts->find({ itemnumber => $itemnumber })->update({ date_due => $due_date });
78
79
            $template->param(
80
                success => 1,
81
                due_interval => $issuing_rule->recall_due_date_interval,
82
                due_unit => $issuing_rule->lengthunit
83
            );
84
        } else {
85
            $error = 'failed';
86
        }
87
    }
88
}
89
90
$template->param(
91
    biblio => $biblio,
92
    itemnumber => $itemnumber,
93
    error => $error
94
);
95
96
output_with_http_headers $query, $cookie, $template->output, 'html';

Return to bug 19532