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 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 343-361 $(document).ready(function() { Link Here
343
360
344
    $("#suspend-modal-submit").on( "click", function( e ) {
361
    $("#suspend-modal-submit").on( "click", function( e ) {
345
        e.preventDefault();
362
        e.preventDefault();
346
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
363
        var suspend_until_date = $("#suspend-modal-until").datepicker("getDate");
347
          $('#suspend-modal').modal('hide');
364
        if ( suspend_until_date !== null ) suspend_until_date = $date(suspend_until_date, {dateformat:"rfc3339"});
348
          if ( data.success ) {
365
        suspend_hold(
349
              holdsTable.api().ajax.reload();
366
            $(this).data('hold-id'),
350
          } else {
367
            suspend_until_date
351
            if ( data.error == "INVALID_DATE" ) {
368
        ).success(function () {
352
                alert( __("Unable to suspend hold, invalid date") );
369
            holdsTable.api().ajax.reload();
353
            }
370
        }).error(function (jqXHR, textStatus, errorThrown) {
354
            else if ( data.error == "HOLD_NOT_FOUND" ) {
371
            if (jqXHR.status === 404) {
355
                alert( __("Unable to suspend hold, hold not found") );
372
                alert(__("Unable to resume, hold not found"));
356
                holdsTable.api().ajax.reload();
373
                holdsTable.api().ajax.reload();
357
            }
374
            }
358
          }
375
        }).done(function() {
376
            $("#suspend-modal-until").val(""); // clean the input
377
            $('#suspend-modal').modal('hide');
359
        });
378
        });
360
    });
379
    });
361
});
380
});
362
- 

Return to bug 28377