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 |
}); |