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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+1 lines)
Lines 1172-1177 Link Here
1172
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
1172
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
1173
    [% INCLUDE 'timepicker.inc' %]
1173
    [% INCLUDE 'timepicker.inc' %]
1174
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
1174
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
1175
    [% INCLUDE 'js-date-format.inc' %]
1175
    <script>
1176
    <script>
1176
        /* Set some variable needed in circulation.js */
1177
        /* Set some variable needed in circulation.js */
1177
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1178
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+1 lines)
Lines 933-938 Link Here
933
    [% INCLUDE 'calendar.inc' %]
933
    [% INCLUDE 'calendar.inc' %]
934
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
934
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
935
    [% INCLUDE 'timepicker.inc' %]
935
    [% INCLUDE 'timepicker.inc' %]
936
    [% INCLUDE 'js-date-format.inc' %]
936
    <script>
937
    <script>
937
        /* Set some variable needed in circulation.js */
938
        /* Set some variable needed in circulation.js */
938
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
939
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-28 / +46 lines)
Lines 1-5 Link Here
1
/* global __ dataTablesDefaults borrowernumber SuspendHoldsIntranet */
1
/* global __ dataTablesDefaults borrowernumber SuspendHoldsIntranet */
2
$(document).ready(function() {
2
$(document).ready(function() {
3
4
    function suspend_hold(hold_id, end_date) {
5
        return $.ajax({
6
            method: 'POST',
7
            url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension',
8
            data: function () {
9
                if ( end_date !== null ) return JSON.stringify({ "end_date": end_date })
10
            }
11
        });
12
    }
13
14
    function resume_hold(hold_id) {
15
        return $.ajax({
16
            method: 'DELETE',
17
            url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension'
18
        });
19
    }
20
3
    var holdsTable;
21
    var holdsTable;
4
22
5
    // Don't load holds table unless it is clicked on
23
    // Don't load holds table unless it is clicked on
Lines 131-140 $(document).ready(function() { Link Here
131
                            if ( oObj.found ) {
149
                            if ( oObj.found ) {
132
                                return "";
150
                                return "";
133
                            } else if ( oObj.suspend == 1 ) {
151
                            } else if ( oObj.suspend == 1 ) {
134
                                return "<a class='hold-resume btn btn-default btn-xs' id='resume" + oObj.reserve_id + "'>"
152
                                return "<a class='hold-resume btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "'>"
135
                                     +"<i class='fa fa-play'></i> " + __("Resume") + "</a>";
153
                                     +"<i class='fa fa-play'></i> " + __("Resume") + "</a>";
136
                            } else {
154
                            } else {
137
                                return "<a class='hold-suspend btn btn-default btn-xs' id='suspend" + oObj.reserve_id + "'>"
155
                                return "<a class='hold-suspend btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "' data-hold-title='"+ oObj.title +"'>"
138
                                     +"<i class='fa fa-pause'></i> " + __("Suspend") + "</a>";
156
                                     +"<i class='fa fa-pause'></i> " + __("Suspend") + "</a>";
139
                            }
157
                            }
140
                        }
158
                        }
Lines 197-221 $(document).ready(function() { Link Here
197
215
198
            $('#holds-table').on( 'draw.dt', function () {
216
            $('#holds-table').on( 'draw.dt', function () {
199
                $(".hold-suspend").on( "click", function() {
217
                $(".hold-suspend").on( "click", function() {
200
                    var id = $(this).attr("id").replace("suspend", "");
218
                    var hold_id    = $(this).data('hold-id');
201
                    var hold = holds[id];
219
                    var hold_title = $(this).data('hold-title');
202
                    $("#suspend-modal-title").html( hold.title );
220
                    $("#suspend-modal-title").html( hold_title );
203
                    $("#suspend-modal-reserve_id").val( hold.reserve_id );
221
                    $("#suspend-modal-submit").data( 'hold-id', hold_id );
204
                    $('#suspend-modal').modal('show');
222
                    $('#suspend-modal').modal('show');
205
                });
223
                });
206
224
207
                $(".hold-resume").on( "click", function() {
225
                $(".hold-resume").on("click", function () {
208
                    var id = $(this).attr("id").replace("resume", "");
226
                    var hold_id = $(this).data('hold-id');
209
                    var hold = holds[id];
227
                    resume_hold(
210
                    $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
228
                        hold_id
211
                      if ( data.success ) {
229
                    ).success(function () {
212
                          holdsTable.api().ajax.reload();
230
                        holdsTable.api().ajax.reload();
213
                      } else {
231
                    }).error(function (jqXHR, textStatus, errorThrown) {
214
                        if ( data.error == "HOLD_NOT_FOUND" ) {
232
                        if (jqXHR.status === 404) {
215
                            alert( __("Unable to resume, hold not found") );
233
                            alert(__("Unable to resume, hold not found"));
216
                            holdsTable.api().ajax.reload();
234
                            holdsTable.api().ajax.reload();
217
                        }
235
                        }
218
                      }
219
                    });
236
                    });
220
                });
237
                });
221
238
Lines 286-304 $(document).ready(function() { Link Here
286
303
287
    $("#suspend-modal-submit").on( "click", function( e ) {
304
    $("#suspend-modal-submit").on( "click", function( e ) {
288
        e.preventDefault();
305
        e.preventDefault();
289
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
306
        var suspend_until_date = $("#suspend-modal-until").datepicker("getDate");
290
          $('#suspend-modal').modal('hide');
307
        if ( suspend_until_date !== null ) suspend_until_date = $date(suspend_until_date, {dateformat:"rfc3339"});
291
          if ( data.success ) {
308
        suspend_hold(
292
              holdsTable.api().ajax.reload();
309
            $(this).data('hold-id'),
293
          } else {
310
            suspend_until_date
294
            if ( data.error == "INVALID_DATE" ) {
311
        ).success(function () {
295
                alert( __("Unable to suspend hold, invalid date") );
312
            holdsTable.api().ajax.reload();
296
            }
313
        }).error(function (jqXHR, textStatus, errorThrown) {
297
            else if ( data.error == "HOLD_NOT_FOUND" ) {
314
            if (jqXHR.status === 404) {
298
                alert( __("Unable to suspend hold, hold not found") );
315
                alert(__("Unable to resume, hold not found"));
299
                holdsTable.api().ajax.reload();
316
                holdsTable.api().ajax.reload();
300
            }
317
            }
301
          }
318
        }).done(function() {
319
            $("#suspend-modal-until").val(""); // clean the input
320
            $('#suspend-modal').modal('hide');
302
        });
321
        });
303
    });
322
    });
304
});
323
});
305
- 

Return to bug 28377