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

(-)a/Koha/Recall.pm (+26 lines)
Lines 123-128 sub is_requested { Link Here
123
    return $status && $status eq 'R';
123
    return $status && $status eq 'R';
124
}
124
}
125
125
126
=head3 is_overdue
127
128
Returns true if recall is overdue
129
130
=cut
131
132
sub is_overdue {
133
    my ($self) = @_;
134
135
    my $status = $self->status;
136
    return $status && $status eq 'O';
137
}
138
139
=head3 is_cancelled
140
141
Returns true if recall is cancelled
142
143
=cut
144
145
sub is_cancelled {
146
    my ($self) = @_;
147
148
    my $status = $self->status;
149
    return $status && $status eq 'C';
150
}
151
126
=head1 AUTHOR
152
=head1 AUTHOR
127
153
128
Aleisha Amohia <aleisha@catalyst.net.nz>
154
Aleisha Amohia <aleisha@catalyst.net.nz>
(-)a/circ/circulation.pl (-1 / +6 lines)
Lines 56-61 use Koha::Patron::Messages; Link Here
56
use Koha::SearchEngine;
56
use Koha::SearchEngine;
57
use Koha::SearchEngine::Search;
57
use Koha::SearchEngine::Search;
58
use Koha::Patron::Modifications;
58
use Koha::Patron::Modifications;
59
use Koha::Recalls;
59
60
60
use Date::Calc qw(
61
use Date::Calc qw(
61
  Today
62
  Today
Lines 460-472 if (@$barcodes) { Link Here
460
461
461
##################################################################################
462
##################################################################################
462
# BUILD HTML
463
# BUILD HTML
463
# show all reserves of this borrower, and the position of the reservation ....
464
# show all recalls and reserves of this borrower, and the position of the reservation ....
464
if ($patron) {
465
if ($patron) {
465
    my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds
466
    my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds
466
    my $waiting_holds = $holds->waiting;
467
    my $waiting_holds = $holds->waiting;
468
469
    my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber });
470
467
    $template->param(
471
    $template->param(
468
        holds_count  => $holds->count(),
472
        holds_count  => $holds->count(),
469
        WaitingHolds => $waiting_holds,
473
        WaitingHolds => $waiting_holds,
474
        recalls => $recalls
470
    );
475
    );
471
}
476
}
472
477
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc (+76 lines)
Line 0 Link Here
1
<div id="recalls">
2
[% IF recalls.count %]
3
    <table id="recalls-table" class="table table-bordered table-striped">
4
        <thead>
5
            <tr>
6
                <th class="recall-title anti-the">Title</th>
7
                <th class="recall-date psort title-string">Placed on</th>
8
                <th class="recall-expiry title-string">Expires on</th>
9
                <th class="recall-branch">Pickup location</th>
10
                <th class="recall-status">Status</th>
11
                <th class="recall-cancel">Cancel</th>
12
            </tr>
13
        </thead>
14
15
        <tbody>
16
            [% FOREACH recall IN recalls %]
17
                <tr>
18
                    <td class="recall-title">
19
                        <a class="recall-title" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% recall.biblionumber %]">
20
                            [% recall.biblio.title %]
21
                            [% FOREACH s IN recall.biblio.subtitles %]
22
                                [% s %]
23
                            [% END %]
24
                            [% recall.item.enumchron %]
25
                        </a>
26
                        [% recall.biblio.author %]
27
                    </td>
28
29
                    <td class="recall-date">
30
                        [% recall.recalldate | $KohaDates %]
31
                    </td>
32
33
                    <td class="recall-expiry">
34
                        [% IF ( recall.is_waiting ) %]
35
                            [% IF ( recall.expirationdate ) %]
36
                                [% recall.expirationdate | $KohaDates %]
37
                            [% ELSE %]
38
                                Never expires
39
                            [% END %]
40
                        [% ELSIF ( recall.has_expired && recall.expirationdate ) %]
41
                            [% recall.expirationdate | $KohaDates %]
42
                        [% ELSE %]
43
                            -
44
                        [% END %]
45
                    </td>
46
47
                    <td class="recall-branch">
48
                        [% recall.branch.branchname %]
49
                    </td>
50
51
                    <td class="recall-status">
52
                        [% IF ( recall.is_requested ) %]
53
                            Requested
54
                        [% ELSIF ( recall.is_waiting ) %]
55
                            Ready for pickup
56
                        [% ELSIF ( recall.has_expired ) %]
57
                            Expired
58
                        [% END %]
59
                    </td>
60
61
                    <td class="recall-cancel">
62
                        [% IF ( !recall.cancellationdate ) %]
63
                            <a class="btn btn-sm btn-danger" id="cancel_recall" data-id="[% recall.recall_id %]"><i class="fa fa-times"></i> Cancel</a>
64
                        [% ELSE %]
65
                            Cancelled
66
                        [% END %]
67
                    </td>
68
69
                </tr>
70
            [% END %]
71
        </tbody>
72
    </table>
73
    [% ELSE %]
74
        Patron has no current recalls.
75
    [% END %]
76
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +10 lines)
Lines 818-823 No patron matched <span class="ex">[% message | html %]</span> Link Here
818
        [% END %]
818
        [% END %]
819
    </li>
819
    </li>
820
820
821
    [% IF recalls.count %]
822
        <li><a href="#recalls" id+"recalls-tab">[% recalls.count %] Recall(s)</a></li>
823
    [% END %]
824
821
    [% IF Koha.Preference('ArticleRequests') %]
825
    [% IF Koha.Preference('ArticleRequests') %]
822
        <li>
826
        <li>
823
            <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count %] Article requests</a>
827
            <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count %] Article requests</a>
Lines 928-933 No patron matched <span class="ex">[% message | html %]</span> Link Here
928
[% END %]
932
[% END %]
929
</div> <!-- reservesloop -->
933
</div> <!-- reservesloop -->
930
934
935
[% IF recalls.count %]
936
    [% INCLUDE 'recalls.inc' %]
937
[% END %]
938
931
[% IF Koha.Preference('ArticleRequests') %]
939
[% IF Koha.Preference('ArticleRequests') %]
932
    [% INCLUDE 'patron-article-requests.inc' %]
940
    [% INCLUDE 'patron-article-requests.inc' %]
933
[% END %]
941
[% END %]
Lines 983-989 No patron matched <span class="ex">[% message | html %]</span> Link Here
983
    [% Asset.js("js/pages/circulation.js") %]
991
    [% Asset.js("js/pages/circulation.js") %]
984
    [% Asset.js("js/checkouts.js") %]
992
    [% Asset.js("js/checkouts.js") %]
985
    [% Asset.js("js/holds.js") %]
993
    [% Asset.js("js/holds.js") %]
986
    [% Asset.js("js/circ-patron-search-results.js") %]
994
    [% Asset.js("js/recalls.js") %]
995
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/circ-patron-search-results_[% KOHA_VERSION %].js"></script>
987
    <script type="text/javascript">
996
    <script type="text/javascript">
988
        /* Set some variable needed in circulation.js */
997
        /* Set some variable needed in circulation.js */
989
        var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
998
        var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+4 lines)
Lines 742-747 Link Here
742
                                [% END %]
742
                                [% END %]
743
                            </div> [% # /div#reserves %]
743
                            </div> [% # /div#reserves %]
744
                        [% END %]
744
                        [% END %]
745
                        [% IF recalls %]
746
                            [% INCLUDE 'recalls.inc' %]
747
                        [% END %]
745
748
746
                        [% IF Koha.Preference('ArticleRequests') %]
749
                        [% IF Koha.Preference('ArticleRequests') %]
747
                            [% INCLUDE 'patron-article-requests.inc' %]
750
                            [% INCLUDE 'patron-article-requests.inc' %]
Lines 770-775 Link Here
770
    [% Asset.js("js/holds.js") %]
773
    [% Asset.js("js/holds.js") %]
771
    [% Asset.js("js/members-menu.js") %]
774
    [% Asset.js("js/members-menu.js") %]
772
    [% Asset.js("js/messaging-preference-form.js") %]
775
    [% Asset.js("js/messaging-preference-form.js") %]
776
    [% Asset.js("js/recalls.js") %]
773
    <script>
777
    <script>
774
        /* Set some variable needed in circulation.js */
778
        /* Set some variable needed in circulation.js */
775
        var interface = "[% interface %]";
779
        var interface = "[% interface %]";
(-)a/koha-tmpl/intranet-tmpl/prog/js/recalls.js (+29 lines)
Line 0 Link Here
1
$(document).ready(function() {
2
3
        $("#cancel_recall").click(function(e){
4
            if (confirmDelete(_("Are you sure you want to remove this recall?"))){
5
                var $self = $(this);
6
                var $recall_id = $(this).data('id');
7
                var ajaxData = {
8
                    'recall_id': $recall_id,
9
                };
10
11
                $.ajax({
12
                    url: '/cgi-bin/koha/svc/recall',
13
                    type: 'POST',
14
                    dataType: 'json',
15
                    data: ajaxData,
16
                })
17
                .done(function(data) {
18
                    var message = "";
19
                    if(data.success == 0) {
20
                        message = "The recall may have already been cancelled. Please refresh the page.";
21
                    } else {
22
                        message = "Cancelled"
23
                    }
24
                    $self.parent().html(message);
25
                });
26
            }
27
        });
28
29
});
(-)a/members/moremember.pl (-2 / +6 lines)
Lines 55-60 use Koha::AuthorisedValues; Link Here
55
use Koha::CsvProfiles;
55
use Koha::CsvProfiles;
56
use Koha::Patron::Debarments qw(GetDebarments);
56
use Koha::Patron::Debarments qw(GetDebarments);
57
use Koha::Patron::Messages;
57
use Koha::Patron::Messages;
58
use Koha::Recalls;
58
use Module::Load;
59
use Module::Load;
59
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
60
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
60
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
61
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
Lines 240-250 if ( $data->{dateofbirth} ) { Link Here
240
241
241
### ###############################################################################
242
### ###############################################################################
242
# BUILD HTML
243
# BUILD HTML
243
# show all reserves of this borrower, and the position of the reservation ....
244
# show all recalls and reserves of this borrower, and the position of the reservation ....
244
if ($borrowernumber) {
245
if ($borrowernumber) {
246
    my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber });
245
    $template->param(
247
    $template->param(
246
        holds_count => Koha::Database->new()->schema()->resultset('Reserve')
248
        holds_count => Koha::Database->new()->schema()->resultset('Reserve')
247
          ->count( { borrowernumber => $borrowernumber } ) );
249
          ->count( { borrowernumber => $borrowernumber } ),
250
        recalls => $recalls
251
    );
248
}
252
}
249
253
250
# Add sync data to the user data
254
# Add sync data to the user data
(-)a/opac/opac-recall.pl (-2 / +3 lines)
Lines 53-60 if ($op eq 'request'){ Link Here
53
    # can't place recall if not logged in
53
    # can't place recall if not logged in
54
        $error = 'notloggedin';
54
        $error = 'notloggedin';
55
        print $query->redirect('/cgi-bin/koha/opac-detail.pl?biblionumber='.$item->biblionumber);
55
        print $query->redirect('/cgi-bin/koha/opac-detail.pl?biblionumber='.$item->biblionumber);
56
    } elsif (defined $recalled && $recalled->borrowernumber == $borrowernumber){
56
    } elsif ( defined $recalled && $recalled->borrowernumber == $borrowernumber && ($recalled->is_requested || $recalled->is_waiting || $recalled->is_overdue) ){
57
    # can't place a recall on an item that this borrower has already recalled
57
    # can't place a recall on an item that this borrower has already recalled
58
    # if recall is expired or cancelled, user may recall again
58
        $error = 'duplicate';
59
        $error = 'duplicate';
59
    } else {
60
    } else {
60
    # can recall
61
    # can recall
Lines 87-93 if ($op eq 'request'){ Link Here
87
    }
88
    }
88
} elsif ($op eq 'cancel'){
89
} elsif ($op eq 'cancel'){
89
    my $recall_id = $query->param('recall_id');
90
    my $recall_id = $query->param('recall_id');
90
    Koha::Recalls->find($recall_id)->delete;
91
    Koha::Recalls->find($recall_id)->update({ cancellationdate => dt_from_string(), status => 'C' });
91
    print $query->redirect('/cgi-bin/koha/opac-user.pl');
92
    print $query->redirect('/cgi-bin/koha/opac-user.pl');
92
}
93
}
93
94
(-)a/svc/recall (-1 / +51 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
use JSON qw(encode_json);
24
25
use C4::Context;
26
use C4::Auth qw(check_cookie_auth);
27
use C4::Output qw(output_with_http_headers);
28
use Koha::Recalls;
29
use Koha::DateUtils;
30
31
my $input = new CGI;
32
33
my ( $auth_status, $sessionID ) =
34
  check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } );
35
36
if ( $auth_status ne "ok" ) {
37
    print $input->header(-type => 'text/plain', -status => '403 Forbidden');
38
    exit 0;
39
}
40
41
my $recall_id = $input->param('recall_id');
42
my $recall = Koha::Recalls->find($recall_id);
43
unless ($recall) {
44
    my $json = encode_json( { success => 0 } );
45
    output_with_http_headers( $input, undef, $json, "json" );
46
    exit;
47
}
48
49
$recall->update({ cancellationdate => dt_from_string(), status => 'C' });
50
my $json = encode_json( { success => 1 } );
51
output_with_http_headers( $input, undef, $json, "json" );

Return to bug 19532