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 954-959 Link Here
954
    [% INCLUDE 'timepicker.inc' %]
954
    [% INCLUDE 'timepicker.inc' %]
955
    [% INCLUDE 'select2.inc' %]
955
    [% INCLUDE 'select2.inc' %]
956
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
956
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
957
    [% INCLUDE 'js-date-format.inc' %]
957
    <script>
958
    <script>
958
        /* Set some variable needed in circulation.js */
959
        /* Set some variable needed in circulation.js */
959
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
960
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+1 lines)
Lines 861-866 Link Here
861
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
861
    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
862
    [% INCLUDE 'timepicker.inc' %]
862
    [% INCLUDE 'timepicker.inc' %]
863
    [% INCLUDE 'select2.inc' %]
863
    [% INCLUDE 'select2.inc' %]
864
    [% INCLUDE 'js-date-format.inc' %]
864
    <script>
865
    <script>
865
        /* Set some variable needed in circulation.js */
866
        /* Set some variable needed in circulation.js */
866
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
867
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-28 / +46 lines)
Lines 94-99 function display_pickup_location (state) { Link Here
94
94
95
/* global __ dataTablesDefaults borrowernumber SuspendHoldsIntranet */
95
/* global __ dataTablesDefaults borrowernumber SuspendHoldsIntranet */
96
$(document).ready(function() {
96
$(document).ready(function() {
97
98
    function suspend_hold(hold_id, end_date) {
99
        return $.ajax({
100
            method: 'POST',
101
            url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension',
102
            data: function () {
103
                if ( end_date !== null ) return JSON.stringify({ "end_date": end_date })
104
            }
105
        });
106
    }
107
108
    function resume_hold(hold_id) {
109
        return $.ajax({
110
            method: 'DELETE',
111
            url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension'
112
        });
113
    }
114
97
    var holdsTable;
115
    var holdsTable;
98
116
99
    // Don't load holds table unless it is clicked on
117
    // Don't load holds table unless it is clicked on
Lines 225-234 $(document).ready(function() { Link Here
225
                            if ( oObj.found ) {
243
                            if ( oObj.found ) {
226
                                return "";
244
                                return "";
227
                            } else if ( oObj.suspend == 1 ) {
245
                            } else if ( oObj.suspend == 1 ) {
228
                                return "<a class='hold-resume btn btn-default btn-xs' id='resume" + oObj.reserve_id + "'>"
246
                                return "<a class='hold-resume btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "'>"
229
                                     +"<i class='fa fa-play'></i> " + __("Resume") + "</a>";
247
                                     +"<i class='fa fa-play'></i> " + __("Resume") + "</a>";
230
                            } else {
248
                            } else {
231
                                return "<a class='hold-suspend btn btn-default btn-xs' id='suspend" + oObj.reserve_id + "'>"
249
                                return "<a class='hold-suspend btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "' data-hold-title='"+ oObj.title +"'>"
232
                                     +"<i class='fa fa-pause'></i> " + __("Suspend") + "</a>";
250
                                     +"<i class='fa fa-pause'></i> " + __("Suspend") + "</a>";
233
                            }
251
                            }
234
                        }
252
                        }
Lines 291-315 $(document).ready(function() { Link Here
291
309
292
            $('#holds-table').on( 'draw.dt', function () {
310
            $('#holds-table').on( 'draw.dt', function () {
293
                $(".hold-suspend").on( "click", function() {
311
                $(".hold-suspend").on( "click", function() {
294
                    var id = $(this).attr("id").replace("suspend", "");
312
                    var hold_id    = $(this).data('hold-id');
295
                    var hold = holds[id];
313
                    var hold_title = $(this).data('hold-title');
296
                    $("#suspend-modal-title").html( hold.title );
314
                    $("#suspend-modal-title").html( hold_title );
297
                    $("#suspend-modal-reserve_id").val( hold.reserve_id );
315
                    $("#suspend-modal-submit").data( 'hold-id', hold_id );
298
                    $('#suspend-modal').modal('show');
316
                    $('#suspend-modal').modal('show');
299
                });
317
                });
300
318
301
                $(".hold-resume").on( "click", function() {
319
                $(".hold-resume").on("click", function () {
302
                    var id = $(this).attr("id").replace("resume", "");
320
                    var hold_id = $(this).data('hold-id');
303
                    var hold = holds[id];
321
                    resume_hold(
304
                    $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
322
                        hold_id
305
                      if ( data.success ) {
323
                    ).success(function () {
306
                          holdsTable.api().ajax.reload();
324
                        holdsTable.api().ajax.reload();
307
                      } else {
325
                    }).error(function (jqXHR, textStatus, errorThrown) {
308
                        if ( data.error == "HOLD_NOT_FOUND" ) {
326
                        if (jqXHR.status === 404) {
309
                            alert( __("Unable to resume, hold not found") );
327
                            alert(__("Unable to resume, hold not found"));
310
                            holdsTable.api().ajax.reload();
328
                            holdsTable.api().ajax.reload();
311
                        }
329
                        }
312
                      }
313
                    });
330
                    });
314
                });
331
                });
315
332
Lines 384-402 $(document).ready(function() { Link Here
384
401
385
    $("#suspend-modal-submit").on( "click", function( e ) {
402
    $("#suspend-modal-submit").on( "click", function( e ) {
386
        e.preventDefault();
403
        e.preventDefault();
387
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
404
        var suspend_until_date = $("#suspend-modal-until").datepicker("getDate");
388
          $('#suspend-modal').modal('hide');
405
        if ( suspend_until_date !== null ) suspend_until_date = $date(suspend_until_date, {dateformat:"rfc3339"});
389
          if ( data.success ) {
406
        suspend_hold(
390
              holdsTable.api().ajax.reload();
407
            $(this).data('hold-id'),
391
          } else {
408
            suspend_until_date
392
            if ( data.error == "INVALID_DATE" ) {
409
        ).success(function () {
393
                alert( __("Unable to suspend hold, invalid date") );
410
            holdsTable.api().ajax.reload();
394
            }
411
        }).error(function (jqXHR, textStatus, errorThrown) {
395
            else if ( data.error == "HOLD_NOT_FOUND" ) {
412
            if (jqXHR.status === 404) {
396
                alert( __("Unable to suspend hold, hold not found") );
413
                alert(__("Unable to resume, hold not found"));
397
                holdsTable.api().ajax.reload();
414
                holdsTable.api().ajax.reload();
398
            }
415
            }
399
          }
416
        }).done(function() {
417
            $("#suspend-modal-until").val(""); // clean the input
418
            $('#suspend-modal').modal('hide');
400
        });
419
        });
401
    });
420
    });
402
});
421
});
403
- 

Return to bug 28377