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

(-)a/Koha/Hold.pm (-1 / +42 lines)
Lines 41-46 Koha::Hold - Koha Hold object class Link Here
41
41
42
=cut
42
=cut
43
43
44
=head3 suspend_hold
45
46
my $hold = $hold->suspend_hold( $suspend_until_dt );
47
48
=cut
49
50
sub suspend_hold {
51
    my ( $self, $dt ) = @_;
52
53
    if ( $self->is_waiting ) {    # We can't suspend waiting holds
54
        carp "Unable to suspend waiting hold!";
55
        return $self;
56
    }
57
58
    $dt ||= undef;
59
60
    $self->suspend(1);
61
    $self->suspend_until( $dt );
62
63
    $self->store();
64
65
    return $self;
66
}
67
68
=head3 resume
69
70
my $hold = $hold->resume();
71
72
=cut
73
74
sub resume {
75
    my ( $self ) = @_;
76
77
    $self->suspend(0);
78
    $self->suspend_until( undef );
79
80
    $self->store();
81
82
    return $self;
83
}
84
44
=head3 waiting_expires_on
85
=head3 waiting_expires_on
45
86
46
Returns a DateTime for the date a waiting holds expires on.
87
Returns a DateTime for the date a waiting holds expires on.
Lines 52-58 Returns undef if the hold is not waiting ( found = 'W' ). Link Here
52
sub waiting_expires_on {
93
sub waiting_expires_on {
53
    my ($self) = @_;
94
    my ($self) = @_;
54
95
55
    return unless $self->found() eq 'W';
96
    return unless $self->found() && $self->found() eq 'W';
56
97
57
    my $ReservesMaxPickUpDelay = C4::Context->preference('ReservesMaxPickUpDelay');
98
    my $ReservesMaxPickUpDelay = C4::Context->preference('ReservesMaxPickUpDelay');
58
    return unless $ReservesMaxPickUpDelay;
99
    return unless $ReservesMaxPickUpDelay;
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js (-8 / +79 lines)
Lines 8-18 $(document).ready(function() { Link Here
8
    if ( $("#holds-tab").parent().hasClass('ui-state-active') ) { load_holds_table() }
8
    if ( $("#holds-tab").parent().hasClass('ui-state-active') ) { load_holds_table() }
9
9
10
    function load_holds_table() {
10
    function load_holds_table() {
11
        var holds = new Array();
11
        if ( ! holdsTable ) {
12
        if ( ! holdsTable ) {
12
            holdsTable = $("#holds-table").dataTable({
13
            holdsTable = $("#holds-table").dataTable({
13
                "bAutoWidth": false,
14
                "bAutoWidth": false,
14
                "sDom": "rt",
15
                "sDom": "rt",
15
                "aoColumns": [
16
                "columns": [
16
                    {
17
                    {
17
                        "mDataProp": "reservedate_formatted"
18
                        "mDataProp": "reservedate_formatted"
18
                    },
19
                    },
Lines 119-139 $(document).ready(function() { Link Here
119
                                 + "<input type='hidden' name='borrowernumber' value='" + borrowernumber + "'>"
120
                                 + "<input type='hidden' name='borrowernumber' value='" + borrowernumber + "'>"
120
                                 + "<input type='hidden' name='reserve_id' value='" + oObj.reserve_id + "'>";
121
                                 + "<input type='hidden' name='reserve_id' value='" + oObj.reserve_id + "'>";
121
                        }
122
                        }
123
                    },
124
                    {
125
                        "bSortable": false,
126
                        "mDataProp": function( oObj ) {
127
                            holds[oObj.reserve_id] = oObj; //Store holds for later use
128
129
                            if ( oObj.found ) {
130
                                return "";
131
                            } else if ( oObj.suspend == 1 ) {
132
                                return "<a class='hold-resume btn btn-link' id='resume" + oObj.reserve_id + "' style='display: inline; white-space: nowrap;'>"
133
                                     + "<i class='icon-play'></i> " + _("Resume") + "</a>";
134
                            } else {
135
                                return "<a class='hold-suspend btn btn-link' id='suspend" + oObj.reserve_id + "' style='display: inline; white-space: nowrap;'>"
136
                                     + "<i class='icon-pause'></i> " + _("Suspend") + "</a>";
137
                            }
138
                        }
122
                    }
139
                    }
123
                ],
140
                ],
124
                "bPaginate": false,
141
                "bPaginate": false,
125
                "bProcessing": true,
142
                "bProcessing": true,
126
                "bServerSide": false,
143
                "bServerSide": false,
127
                "sAjaxSource": '/cgi-bin/koha/svc/holds',
144
                "ajax": {
128
                "fnServerData": function ( sSource, aoData, fnCallback ) {
145
                    "url": '/cgi-bin/koha/svc/holds',
129
                    aoData.push( { "name": "borrowernumber", "value": borrowernumber } );
146
                    "data": function ( d ) {
130
147
                        d.borrowernumber = borrowernumber;
131
                    $.getJSON( sSource, aoData, function (json) {
148
                    }
132
                        fnCallback(json)
133
                    } );
134
                },
149
                },
135
            });
150
            });
136
151
152
            $('#holds-table').on( 'draw.dt', function () {
153
                $(".hold-suspend").on( "click", function() {
154
                    var id = $(this).attr("id").replace("suspend", "");
155
                    var hold = holds[id];
156
                    $("#suspend-modal-title").html( hold.title );
157
                    $("#suspend-modal-reserve_id").val( hold.reserve_id );
158
                    $('#suspend-modal').modal('show');
159
                });
160
161
                $(".hold-resume").on( "click", function() {
162
                    var id = $(this).attr("id").replace("resume", "");
163
                    var hold = holds[id];
164
                    $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
165
                      holdsTable.api().ajax.reload();
166
                    });
167
                });
168
            });
169
137
            if ( $("#holds-table").length ) {
170
            if ( $("#holds-table").length ) {
138
                $("#holds-table_processing").position({
171
                $("#holds-table_processing").position({
139
                    of: $( "#holds-table" ),
172
                    of: $( "#holds-table" ),
Lines 142-145 $(document).ready(function() { Link Here
142
            }
175
            }
143
        }
176
        }
144
    }
177
    }
178
179
    $("body").append("\
180
        <div id='suspend-modal' class='modal hide fade' tabindex='-1' role='dialog' aria-hidden='true'>\
181
            <form id='suspend-modal-form' class='form-inline'>\
182
                <div class='modal-header'>\
183
                    <button type='button' class='closebtn' data-dismiss='modal' aria-hidden='true'>×</button>\
184
                    <h3 id='suspend-modal-label'>" + _("Suspend hold on") + " <i><span id='suspend-modal-title'></span></i></h3>\
185
                </div>\
186
\
187
                <div class='modal-body'>\
188
                    <input type='hidden' id='suspend-modal-reserve_id' name='reserve_id' />\
189
\
190
                    <label for='suspend-modal-until'>Suspend until:</label>\
191
                    <input name='suspend_until' id='suspend-modal-until' class='suspend-until' size='10' />\
192
\
193
                    <p/><a class='btn btn-link' id='suspend-modal-clear-date' >" + _("Clear date to suspend indefinitely") + "</a></p>\
194
\
195
                </div>\
196
\
197
                <div class='modal-footer'>\
198
                    <button id='suspend-modal-submit' class='btn btn-primary' type='submit' name='submit'>" + _("Suspend") + "</button>\
199
                    <a href='#' data-dismiss='modal' aria-hidden='true' class='cancel'>" + _("Cancel") + "</a>\
200
                </div>\
201
            </form>\
202
        </div>\
203
    ");
204
205
    $("#suspend-modal-until").datepicker({ minDate: 1 }); // Require that "until date" be in the future
206
    $("#suspend-modal-clear-date").on( "click", function() { $("#suspend-modal-until").val(""); } );
207
208
    $("#suspend-modal-submit").on( "click", function( e ) {
209
        e.preventDefault();
210
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
211
          $('#suspend-modal').modal('hide');
212
          holdsTable.api().ajax.reload();
213
        });
214
    });
215
145
});
216
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+1 lines)
Lines 895-900 No patron matched <span class="ex">[% message %]</span> Link Here
895
                    <th>Expiration</th>
895
                    <th>Expiration</th>
896
                    <th>Priority</th>
896
                    <th>Priority</th>
897
                    <th>Delete?</th>
897
                    <th>Delete?</th>
898
                    <th>Suspend?</th>
898
                </tr>
899
                </tr>
899
            </thead>
900
            </thead>
900
        </table>
901
        </table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+1 lines)
Lines 484-489 function validate1(date) { Link Here
484
                    <th>Expiration</th>
484
                    <th>Expiration</th>
485
                    <th>Priority</th>
485
                    <th>Priority</th>
486
                    <th>Delete?</th>
486
                    <th>Delete?</th>
487
                    <th>Suspend?</th>
487
                </tr>
488
                </tr>
488
            </thead>
489
            </thead>
489
        </table>
490
        </table>
(-)a/svc/hold/resume (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2015 ByWater Solutions
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(to_json);
24
25
use C4::Context;
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::DateUtils qw(dt_from_string);
28
use Koha::Holds;
29
30
my $input = new CGI;
31
32
my ( $auth_status, $sessionID ) =
33
  check_cookie_auth( $input->cookie('CGISESSID'),
34
    { circulate => 'circulate_remaining_permissions' } );
35
36
if ( $auth_status ne "ok" ) {
37
    exit 0;
38
}
39
40
binmode STDOUT, ":encoding(UTF-8)";
41
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
42
43
my $reserve_id = $input->param('reserve_id');
44
45
my $hold = Koha::Holds->find( $reserve_id );
46
$hold->resume();
47
48
print to_json( { success => !$hold->suspend() } );
(-)a/svc/hold/suspend (-1 / +51 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2015 ByWater Solutions
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(to_json);
24
25
use C4::Context;
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::DateUtils qw(dt_from_string);
28
use Koha::Holds;
29
30
my $input = new CGI;
31
32
my ( $auth_status, $sessionID ) =
33
  check_cookie_auth( $input->cookie('CGISESSID'),
34
    { circulate => 'circulate_remaining_permissions' } );
35
36
if ( $auth_status ne "ok" ) {
37
    exit 0;
38
}
39
40
binmode STDOUT, ":encoding(UTF-8)";
41
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
42
43
my $reserve_id = $input->param('reserve_id');
44
45
my $suspend_until = $input->param('suspend_until') || undef;
46
$suspend_until = dt_from_string( $suspend_until ) if $suspend_until;
47
48
my $hold = Koha::Holds->find( $reserve_id );
49
$hold->suspend_hold( $suspend_until );
50
51
print to_json( { success => $hold->suspend() } );

Return to bug 14310