X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=koha-tmpl%2Fintranet-tmpl%2Fprog%2Fen%2Fjs%2Fholds.js;h=bf7ea44da891f04df1a2e7d15120d4662793fbb4;hb=c60c8f0821a89b2914124b77ef6ae80421940009;hp=077b3b605c781c1ff81858a270a0d5bd712dd35a;hpb=cc878aee77d8ed24d14217009a504bdbcf4de2f7;p=koha-ffzg.git diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js index 077b3b605c..bf7ea44da8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js @@ -8,11 +8,12 @@ $(document).ready(function() { if ( $("#holds-tab").parent().hasClass('ui-state-active') ) { load_holds_table() } function load_holds_table() { + var holds = new Array(); if ( ! holdsTable ) { holdsTable = $("#holds-table").dataTable({ "bAutoWidth": false, "sDom": "rt", - "aoColumns": [ + "columns": [ { "mDataProp": "reservedate_formatted" }, @@ -119,21 +120,53 @@ $(document).ready(function() { + "" + ""; } + }, + { + "bSortable": false, + "mDataProp": function( oObj ) { + holds[oObj.reserve_id] = oObj; //Store holds for later use + + if ( oObj.found ) { + return ""; + } else if ( oObj.suspend == 1 ) { + return "" + + " " + _("Resume") + ""; + } else { + return "" + + " " + _("Suspend") + ""; + } + } } ], "bPaginate": false, "bProcessing": true, "bServerSide": false, - "sAjaxSource": '/cgi-bin/koha/svc/holds', - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); - - $.getJSON( sSource, aoData, function (json) { - fnCallback(json) - } ); + "ajax": { + "url": '/cgi-bin/koha/svc/holds', + "data": function ( d ) { + d.borrowernumber = borrowernumber; + } }, }); + $('#holds-table').on( 'draw.dt', function () { + $(".hold-suspend").on( "click", function() { + var id = $(this).attr("id").replace("suspend", ""); + var hold = holds[id]; + $("#suspend-modal-title").html( hold.title ); + $("#suspend-modal-reserve_id").val( hold.reserve_id ); + $('#suspend-modal').modal('show'); + }); + + $(".hold-resume").on( "click", function() { + var id = $(this).attr("id").replace("resume", ""); + var hold = holds[id]; + $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){ + holdsTable.api().ajax.reload(); + }); + }); + }); + if ( $("#holds-table").length ) { $("#holds-table_processing").position({ of: $( "#holds-table" ), @@ -142,4 +175,42 @@ $(document).ready(function() { } } } + + $("body").append("\ + \ + "); + + $("#suspend-modal-until").datepicker({ minDate: 1 }); // Require that "until date" be in the future + $("#suspend-modal-clear-date").on( "click", function() { $("#suspend-modal-until").val(""); } ); + + $("#suspend-modal-submit").on( "click", function( e ) { + e.preventDefault(); + $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){ + $('#suspend-modal').modal('hide'); + holdsTable.api().ajax.reload(); + }); + }); + });