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.suspend == 1 ) { |
130 |
return "<a class='hold-resume btn btn-link' id='resume" + oObj.reserve_id + "' style='display: inline; white-space: nowrap;'>" |
131 |
+ "<i class='icon-play'></i> Resume</a>"; |
132 |
} else { |
133 |
return "<a class='hold-suspend btn btn-link' id='suspend" + oObj.reserve_id + "' style='display: inline; white-space: nowrap;'>" |
134 |
+ "<i class='icon-pause'></i> Suspend</a>"; |
135 |
} |
136 |
} |
122 |
} |
137 |
} |
123 |
], |
138 |
], |
124 |
"bPaginate": false, |
139 |
"bPaginate": false, |
125 |
"bProcessing": true, |
140 |
"bProcessing": true, |
126 |
"bServerSide": false, |
141 |
"bServerSide": false, |
127 |
"sAjaxSource": '/cgi-bin/koha/svc/holds', |
142 |
"ajax": { |
128 |
"fnServerData": function ( sSource, aoData, fnCallback ) { |
143 |
"url": '/cgi-bin/koha/svc/holds', |
129 |
aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); |
144 |
"data": function ( d ) { |
130 |
|
145 |
d.borrowernumber = borrowernumber; |
131 |
$.getJSON( sSource, aoData, function (json) { |
146 |
} |
132 |
fnCallback(json) |
|
|
133 |
} ); |
134 |
}, |
147 |
}, |
135 |
}); |
148 |
}); |
136 |
|
149 |
|
|
|
150 |
$('#holds-table').on( 'draw.dt', function () { |
151 |
$(".hold-suspend").on( "click", function() { |
152 |
var id = $(this).attr("id").replace("suspend", ""); |
153 |
var hold = holds[id]; |
154 |
$("#suspend-modal-title").html( hold.title ); |
155 |
$("#suspend-modal-reserve_id").val( hold.reserve_id ); |
156 |
$('#suspend-modal').modal('show'); |
157 |
}); |
158 |
|
159 |
$(".hold-resume").on( "click", function() { |
160 |
var id = $(this).attr("id").replace("resume", ""); |
161 |
var hold = holds[id]; |
162 |
$.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){ |
163 |
holdsTable.api().ajax.reload(); |
164 |
}); |
165 |
}); |
166 |
}); |
167 |
|
137 |
if ( $("#holds-table").length ) { |
168 |
if ( $("#holds-table").length ) { |
138 |
$("#holds-table_processing").position({ |
169 |
$("#holds-table_processing").position({ |
139 |
of: $( "#holds-table" ), |
170 |
of: $( "#holds-table" ), |
Lines 142-145
$(document).ready(function() {
Link Here
|
142 |
} |
173 |
} |
143 |
} |
174 |
} |
144 |
} |
175 |
} |
|
|
176 |
|
177 |
$("body").append("\ |
178 |
<div id='suspend-modal' class='modal hide fade' tabindex='-1' role='dialog' aria-hidden='true'>\ |
179 |
<form id='suspend-modal-form' class='form-inline'>\ |
180 |
<div class='modal-header'>\ |
181 |
<button type='button' class='closebtn' data-dismiss='modal' aria-hidden='true'>×</button>\ |
182 |
<h3 id='suspend-modal-label'>" + _("Suspend hold on") + " <i><span id='suspend-modal-title'></span></i></h3>\ |
183 |
</div>\ |
184 |
\ |
185 |
<div class='modal-body'>\ |
186 |
<input type='hidden' id='suspend-modal-reserve_id' name='reserve_id' />\ |
187 |
\ |
188 |
<label for='suspend-modal-until'>Suspend until:</label>\ |
189 |
<input name='suspend_until' id='suspend-modal-until' class='suspend-until' size='10' />\ |
190 |
\ |
191 |
<p/><a class='btn btn-link' id='suspend-modal-clear-date' >" + _("Clear date to suspend indefinitely") + "</a></p>\ |
192 |
\ |
193 |
</div>\ |
194 |
\ |
195 |
<div class='modal-footer'>\ |
196 |
<button id='suspend-modal-submit' class='btn btn-primary' type='submit' name='submit'>" + _("Suspend") + "</button>\ |
197 |
<a href='#' data-dismiss='modal' aria-hidden='true' class='cancel'>" + _("Cancel") + "</a>\ |
198 |
</div>\ |
199 |
</form>\ |
200 |
</div>\ |
201 |
"); |
202 |
|
203 |
$("#suspend-modal-until").datepicker({ minDate: 1 }); // Require that "until date" be in the future |
204 |
$("#suspend-modal-clear-date").on( "click", function() { $("#suspend-modal-until").val(""); } ); |
205 |
|
206 |
$("#suspend-modal-submit").on( "click", function( e ) { |
207 |
e.preventDefault(); |
208 |
$.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){ |
209 |
$('#suspend-modal').modal('hide'); |
210 |
holdsTable.api().ajax.reload(); |
211 |
}); |
212 |
}); |
213 |
|
145 |
}); |
214 |
}); |