Lines 1-478
Link Here
|
1 |
/* global __ */ |
1 |
/* global __ */ |
2 |
|
2 |
|
3 |
$(document).ready(function() { |
|
|
4 |
var loadIssuesTableDelayTimeoutId; |
5 |
|
6 |
var barcodefield = $("#barcode"); |
7 |
|
3 |
|
8 |
var onHoldDueDateSet = false; |
4 |
function RefreshIssuesTable() { |
9 |
|
5 |
var table = $('#issues-table').DataTable(); |
10 |
var onHoldChecked = function() { |
6 |
var renewchecked = $('input[name=renew]:checked').map(function(){ |
11 |
var isChecked = false; |
7 |
return this.value; |
12 |
$('input[data-on-reserve]').each(function() { |
8 |
}).get(); |
13 |
if ($(this).is(':checked')) { |
9 |
var checkinchecked = $('input[name=checkin]:checked').map(function(){ |
14 |
isChecked=true; |
10 |
return this.value; |
|
|
11 |
}).get(); |
12 |
table.ajax.reload( function() { |
13 |
$('#RenewChecked, #CheckinChecked').prop('disabled' , true ); |
14 |
if ( renewchecked.length ) { |
15 |
$('#RenewChecked').prop('disabled' , false ); |
16 |
renewchecked.forEach( function(checked) { |
17 |
$('.renew[value="'+checked+'"]').prop('checked' , true ); |
18 |
}); |
19 |
} |
20 |
if ( checkinchecked.length ) { |
21 |
$('#CheckinChecked').prop('disabled' , false ); |
22 |
checkinchecked.forEach( function(checked) { |
23 |
$('.checkin[value="'+checked+'"]').prop('checked' , true ); |
24 |
}); |
15 |
} |
25 |
} |
|
|
26 |
var checkout_count = table.page.info().recordsTotal; |
27 |
$('.checkout_count').text(checkout_count); |
16 |
}); |
28 |
}); |
17 |
return isChecked; |
29 |
} |
18 |
}; |
|
|
19 |
|
30 |
|
20 |
var showHideOnHoldRenewal = function() { |
31 |
function LoadIssuesTable() { |
21 |
// Display the date input |
32 |
$('#issues-table-loading-message').hide(); |
22 |
if (onHoldChecked()) { |
33 |
$('#issues-table').show(); |
23 |
$('#newonholdduedate').show() |
34 |
$('#issues-table-actions').show(); |
24 |
} else { |
35 |
var msg_loading = __('Loading... you may continue scanning.'); |
25 |
$('#newonholdduedate').hide(); |
36 |
issuesTable = KohaTable("issues-table", { |
26 |
} |
37 |
"oLanguage": { |
27 |
}; |
38 |
"sEmptyTable" : msg_loading, |
|
|
39 |
"sProcessing": msg_loading, |
40 |
}, |
41 |
"bAutoWidth": false, |
42 |
"dom": '<"table_controls"B>rt', |
43 |
"aoColumns": [ |
44 |
{ |
45 |
"mDataProp": function( oObj ) { |
46 |
return oObj.sort_order; |
47 |
} |
48 |
}, |
49 |
{ |
50 |
"mDataProp": function( oObj ) { |
51 |
if ( oObj.issued_today ) { |
52 |
return "<strong>" + __("Today's checkouts") + "</strong>"; |
53 |
} else { |
54 |
return "<strong>" + __("Previous checkouts") + "</strong>"; |
55 |
} |
56 |
} |
57 |
}, |
58 |
{ |
59 |
"mDataProp": "date_due", |
60 |
"bVisible": false, |
61 |
}, |
62 |
{ |
63 |
"iDataSort": 2, // Sort on hidden unformatted date due column |
64 |
"mDataProp": function( oObj ) { |
65 |
let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true }); |
66 |
var due = oObj.date_due_overdue |
67 |
? "<span class='overdue'>" + date_due_formatted + "</span>" |
68 |
: date_due_formatted; |
28 |
|
69 |
|
29 |
// Handle the select all/none links for checkouts table columns |
70 |
due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>"; |
30 |
$("#CheckAllRenewals").on("click",function(){ |
|
|
31 |
$("#UncheckAllCheckins").click(); |
32 |
$(".renew:visible").prop("checked", true); |
33 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
34 |
showHideOnHoldRenewal(); |
35 |
return false; |
36 |
}); |
37 |
$("#UncheckAllRenewals").on("click",function(){ |
38 |
$(".renew:visible").prop("checked", false); |
39 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
40 |
showHideOnHoldRenewal(); |
41 |
return false; |
42 |
}); |
43 |
|
71 |
|
44 |
$("#CheckAllCheckins").on("click",function(){ |
72 |
if ( oObj.lost && oObj.claims_returned ) { |
45 |
$("#UncheckAllRenewals").click(); |
73 |
due += "<span class='lost claims_returned'>" + oObj.lost.escapeHtml() + "</span>"; |
46 |
$(".checkin:visible").prop("checked", true); |
74 |
} else if ( oObj.lost ) { |
47 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
75 |
due += "<span class='lost'>" + oObj.lost.escapeHtml() + "</span>"; |
48 |
return false; |
76 |
} |
49 |
}); |
|
|
50 |
$("#UncheckAllCheckins").on("click",function(){ |
51 |
$(".checkin:visible").prop("checked", false); |
52 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
53 |
return false; |
54 |
}); |
55 |
|
77 |
|
56 |
$("#newduedate").on("change", function() { |
78 |
if ( oObj.damaged ) { |
57 |
if (!onHoldDueDateSet) { |
79 |
due += "<span class='dmg'>" + oObj.damaged.escapeHtml() + "</span>"; |
58 |
$('#newonholdduedate input').val($('#newduedate').val()); |
80 |
} |
59 |
} |
|
|
60 |
}); |
61 |
|
81 |
|
62 |
$("#newonholdduedate").on("change", function() { |
82 |
var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>"; |
63 |
onHoldDueDateSet = true; |
83 |
due +="<br>" + patron_note; |
64 |
}); |
|
|
65 |
|
84 |
|
66 |
// Don't allow both return and renew checkboxes to be checked |
85 |
return due; |
67 |
$(document).on("change", '.renew', function(){ |
86 |
} |
68 |
if ( $(this).is(":checked") ) { |
87 |
}, |
69 |
$( "#checkin_" + $(this).val() ).prop("checked", false); |
88 |
{ |
70 |
} |
89 |
"mDataProp": function ( oObj ) { |
71 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
90 |
let title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" |
72 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
91 |
+ oObj.biblionumber |
73 |
}); |
92 |
+ "'>" |
74 |
$(document).on("change", '.checkin', function(){ |
93 |
+ (oObj.title ? oObj.title.escapeHtml() : '' ); |
75 |
if ( $(this).is(":checked") ) { |
|
|
76 |
$( "#renew_" + $(this).val() ).prop("checked", false); |
77 |
} |
78 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
79 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
80 |
}); |
81 |
|
94 |
|
82 |
// Display on hold due dates input when an on hold item is |
95 |
$.each(oObj.subtitle, function( index, value ) { |
83 |
// selected |
96 |
title += " " + value.escapeHtml(); |
84 |
$(document).on('change', '.renew', function(){ |
97 |
}); |
85 |
showHideOnHoldRenewal(); |
|
|
86 |
}); |
87 |
|
98 |
|
88 |
$("#output_format > option:first-child").attr("selected", "selected"); |
99 |
title += " " + oObj.part_number + " " + oObj.part_name; |
89 |
$("select[name='csv_profile_id']").hide(); |
|
|
90 |
$(document).on("change", '#issues-table-output-format', function(){ |
91 |
if ( $(this).val() == 'csv' ) { |
92 |
$("select[name='csv_profile_id']").show(); |
93 |
} else { |
94 |
$("select[name='csv_profile_id']").hide(); |
95 |
} |
96 |
}); |
97 |
|
100 |
|
98 |
// Clicking the table cell checks the checkbox inside it |
101 |
if ( oObj.enumchron ) { |
99 |
$(document).on("click", 'td', function(e){ |
102 |
title += " <span class='item_enumeration'>(" + oObj.enumchron.escapeHtml() + ")</span>"; |
100 |
if(e.target.tagName.toLowerCase() == 'td'){ |
103 |
} |
101 |
$(this).find("input:checkbox:visible").each( function() { |
|
|
102 |
$(this).click(); |
103 |
}); |
104 |
} |
105 |
}); |
106 |
|
104 |
|
107 |
// Handle renewals and returns |
105 |
title += "</a></span>"; |
108 |
$("#CheckinChecked").on("click",function(){ |
|
|
109 |
|
106 |
|
110 |
let refresh_table = true; |
107 |
if ( oObj.author ) { |
111 |
$(".checkin:checked:visible").each(function() { |
108 |
title += " " + __("by _AUTHOR_").replace( "_AUTHOR_", " " + oObj.author.escapeHtml() ); |
112 |
itemnumber = $(this).val(); |
109 |
} |
113 |
|
110 |
|
114 |
$(this).replaceWith("<img id='checkin_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); |
111 |
if ( oObj.itemnotes ) { |
|
|
112 |
var span_class = "text-muted"; |
113 |
if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ |
114 |
span_class = "circ-hlt"; |
115 |
} |
116 |
title += "<span class='divider-dash'> - </span><span class='" + span_class + " item-note-public'>" + oObj.itemnotes.escapeHtml() + "</span>"; |
117 |
} |
115 |
|
118 |
|
116 |
params = { |
119 |
if ( oObj.itemnotes_nonpublic ) { |
117 |
itemnumber: itemnumber, |
120 |
var span_class = "text-danger"; |
118 |
borrowernumber: borrowernumber, |
121 |
if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ |
119 |
branchcode: branchcode, |
122 |
span_class = "circ-hlt"; |
120 |
exempt_fine: $("#exemptfine").is(':checked') |
123 |
} |
121 |
}; |
124 |
title += "<span class='divider-dash'> - </span><span class='" + span_class + " item-note-nonpublic'>" + oObj.itemnotes_nonpublic.escapeHtml() + "</span>"; |
|
|
125 |
} |
122 |
|
126 |
|
123 |
$.post({ |
127 |
var onsite_checkout = ''; |
124 |
url: "/cgi-bin/koha/svc/checkin", |
128 |
if ( oObj.onsite_checkout == 1 ) { |
125 |
data: params, |
129 |
onsite_checkout += " <span class='onsite_checkout'>(" + __("On-site checkout") + ")</span>"; |
126 |
success: function( data ) { |
130 |
} |
127 |
id = "#checkin_" + data.itemnumber; |
|
|
128 |
|
131 |
|
129 |
content = ""; |
132 |
if ( oObj.recalled == 1 ) { |
130 |
if ( data.returned ) { |
133 |
title += "<span class='divider-dash'> - </span><span class='circ-hlt item-recalled'>" + __("This item has been recalled and the due date updated") + ".</span>"; |
131 |
content = __("Checked in"); |
|
|
132 |
$(id).parent().parent().addClass('ok'); |
133 |
$('#date_due_' + data.itemnumber).html( __("Checked in") ); |
134 |
if ( data.patronnote != null ) { |
135 |
$('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote); |
136 |
} |
134 |
} |
137 |
} else { |
|
|
138 |
content = __("Unable to check in"); |
139 |
$(id).parent().parent().addClass('warn'); |
140 |
refresh_table = false; |
141 |
} |
142 |
|
135 |
|
143 |
$(id).replaceWith( content ); |
136 |
title += " " |
144 |
}, |
137 |
+ "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" |
145 |
dataType: "json", |
138 |
+ oObj.biblionumber |
146 |
async: false, |
139 |
+ "&itemnumber=" |
147 |
}); |
140 |
+ oObj.itemnumber |
148 |
}); |
141 |
+ "#" |
149 |
// Refocus on barcode field if it exists |
142 |
+ oObj.itemnumber |
150 |
if ( $("#barcode").length ) { |
143 |
+ "'>" |
151 |
$("#barcode").focus(); |
144 |
+ (oObj.barcode ? oObj.barcode.escapeHtml() : "") |
152 |
} |
145 |
+ "</a>" |
|
|
146 |
+ onsite_checkout |
153 |
|
147 |
|
154 |
if ( refresh_table ) { |
148 |
return title; |
155 |
RefreshIssuesTable(); |
149 |
}, |
156 |
} |
150 |
"sType": "anti-the" |
157 |
$('#RenewChecked, #CheckinChecked').prop('disabled' , true ); |
151 |
}, |
158 |
// Prevent form submit |
152 |
{ |
159 |
return false; |
153 |
"mDataProp": function ( oObj ) { |
160 |
}); |
154 |
return oObj.recordtype_description.escapeHtml(); |
161 |
$("#RenewChecked").on("click",function(){ |
|
|
162 |
let refresh_table = true; |
163 |
$(".confirm:checked:visible").each(function() { |
164 |
itemnumber = $(this).val(); |
165 |
id = "#checkin_" + itemnumber; |
166 |
materials = $(this).data('materials'); |
167 |
|
168 |
$(this).replaceWith("<span class='confirm' id='checkin_" + itemnumber + "'>" + __("Confirm") + " (<span>" + materials + "</span>): <input type='checkbox' class='checkin' name='checkin' value='" + itemnumber +"'></input></span>"); |
169 |
$(id).parent().parent().addClass('warn'); |
170 |
}); |
171 |
|
172 |
$(".renew:checked:visible").each(function() { |
173 |
var override_limit = $("#override_limit").is(':checked') ? 1 : 0; |
174 |
|
175 |
var isOnReserve = $(this).data().hasOwnProperty('onReserve'); |
176 |
|
177 |
var itemnumber = $(this).val(); |
178 |
|
179 |
$(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); |
180 |
|
181 |
var params = { |
182 |
itemnumber: itemnumber, |
183 |
borrowernumber: borrowernumber, |
184 |
branchcode: branchcode, |
185 |
override_limit: override_limit |
186 |
}; |
187 |
|
188 |
if (UnseenRenewals) { |
189 |
var ren = $("#renew_as_unseen_checkbox"); |
190 |
var renew_unseen = ren.length > 0 && ren.is(':checked') ? 1 : 0; |
191 |
params.seen = renew_unseen === 1 ? 0 : 1; |
192 |
} |
193 |
|
194 |
// Determine which due date we need to use |
195 |
var dueDate = isOnReserve ? |
196 |
$("#newonholdduedate input").val() : |
197 |
$("#newduedate").val(); |
198 |
|
199 |
if (dueDate && dueDate.length > 0) { |
200 |
params.date_due = dueDate |
201 |
} |
202 |
|
203 |
$.post({ |
204 |
url: "/cgi-bin/koha/svc/renew", |
205 |
data: params, |
206 |
success: function( data ) { |
207 |
var id = "#renew_" + data.itemnumber; |
208 |
|
209 |
var content = ""; |
210 |
if ( data.renew_okay ) { |
211 |
content = __("Renewed, due:") + " " + data.date_due; |
212 |
$('#date_due_' + data.itemnumber).replaceWith( data.date_due ); |
213 |
} else { |
214 |
content = __("Renew failed:") + " "; |
215 |
if ( data.error == "no_checkout" ) { |
216 |
content += __("not checked out"); |
217 |
} else if ( data.error == "too_many" ) { |
218 |
content += __("too many renewals"); |
219 |
} else if ( data.error == "too_unseen" ) { |
220 |
content += __("too many consecutive renewals without being seen by the library"); |
221 |
} else if ( data.error == "on_reserve" ) { |
222 |
content += __("on hold"); |
223 |
} else if ( data.error == "restriction" ) { |
224 |
content += __("Not allowed: patron restricted"); |
225 |
} else if ( data.error == "overdue" ) { |
226 |
content += __("Not allowed: overdue"); |
227 |
} else if ( data.error == 'no_open_days' ) { |
228 |
content += __('Unable to find an open day'); |
229 |
} else if ( data.error ) { |
230 |
content += data.error; |
231 |
} else { |
232 |
content += __("reason unknown"); |
233 |
} |
234 |
refresh_table = false; |
235 |
} |
155 |
} |
236 |
|
156 |
}, |
237 |
$(id).replaceWith( content ); |
|
|
238 |
}, |
239 |
dataType: "json", |
240 |
async: false, |
241 |
}); |
242 |
}); |
243 |
|
244 |
// Refocus on barcode field if it exists |
245 |
if ( $("#barcode").length ) { |
246 |
$("#barcode").focus(); |
247 |
} |
248 |
|
249 |
if ( refresh_table ) { |
250 |
RefreshIssuesTable(); |
251 |
} |
252 |
// Prevent form submit |
253 |
return false; |
254 |
}); |
255 |
|
256 |
$("#RenewAll").on("click",function(){ |
257 |
$("#CheckAllRenewals").click(); |
258 |
$("#UncheckAllCheckins").click(); |
259 |
showHideOnHoldRenewal(); |
260 |
$("#RenewChecked").click(); |
261 |
$('#RenewChecked').prop('disabled' , true ); |
262 |
// Prevent form submit |
263 |
return false; |
264 |
}); |
265 |
|
266 |
var ymd = flatpickr.formatDate(new Date(), "Y-m-d"); |
267 |
|
268 |
$('#issues-table-load-immediately').change(function(){ |
269 |
if ( this.checked && typeof issuesTable === 'undefined') { |
270 |
$('#issues-table-load-now-button').click(); |
271 |
} |
272 |
barcodefield.focus(); |
273 |
}); |
274 |
$('#issues-table-load-now-button').click(function(){ |
275 |
if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); |
276 |
LoadIssuesTable(); |
277 |
barcodefield.focus(); |
278 |
return false; |
279 |
}); |
280 |
|
281 |
if ( Cookies.get("issues-table-load-immediately-" + script) == "true" ) { |
282 |
if ( LoadCheckoutsTableDelay ) { |
283 |
loadIssuesTableDelayTimeoutId = setTimeout( function(){ LoadIssuesTable() }, LoadCheckoutsTableDelay * 1000); |
284 |
} else { |
285 |
LoadIssuesTable(); |
286 |
} |
287 |
$('#issues-table-load-immediately').prop('checked', true); |
288 |
} else { |
289 |
$('#issues-table-load-delay').hide(); |
290 |
} |
291 |
$('#issues-table-load-immediately').on( "change", function(){ |
292 |
Cookies.set("issues-table-load-immediately-" + script, $(this).is(':checked'), { expires: 365, sameSite: 'Lax' }); |
293 |
}); |
294 |
|
295 |
function RefreshIssuesTable() { |
296 |
var table = $('#issues-table').DataTable(); |
297 |
var renewchecked = $('input[name=renew]:checked').map(function(){ |
298 |
return this.value; |
299 |
}).get(); |
300 |
var checkinchecked = $('input[name=checkin]:checked').map(function(){ |
301 |
return this.value; |
302 |
}).get(); |
303 |
table.ajax.reload( function() { |
304 |
$('#RenewChecked, #CheckinChecked').prop('disabled' , true ); |
305 |
if ( renewchecked.length ) { |
306 |
$('#RenewChecked').prop('disabled' , false ); |
307 |
renewchecked.forEach( function(checked) { |
308 |
$('.renew[value="'+checked+'"]').prop('checked' , true ); |
309 |
}); |
310 |
} |
311 |
if ( checkinchecked.length ) { |
312 |
$('#CheckinChecked').prop('disabled' , false ); |
313 |
checkinchecked.forEach( function(checked) { |
314 |
$('.checkin[value="'+checked+'"]').prop('checked' , true ); |
315 |
}); |
316 |
} |
317 |
var checkout_count = table.page.info().recordsTotal; |
318 |
$('.checkout_count').text(checkout_count); |
319 |
}); |
320 |
} |
321 |
|
322 |
function LoadIssuesTable() { |
323 |
$('#issues-table-loading-message').hide(); |
324 |
$('#issues-table').show(); |
325 |
$('#issues-table-actions').show(); |
326 |
var msg_loading = __('Loading... you may continue scanning.'); |
327 |
issuesTable = KohaTable("issues-table", { |
328 |
"oLanguage": { |
329 |
"sEmptyTable" : msg_loading, |
330 |
"sProcessing": msg_loading, |
331 |
}, |
332 |
"bAutoWidth": false, |
333 |
"dom": '<"table_controls"B>rt', |
334 |
"aoColumns": [ |
335 |
{ |
157 |
{ |
336 |
"mDataProp": function( oObj ) { |
158 |
"mDataProp": function ( oObj ) { |
337 |
return oObj.sort_order; |
159 |
return oObj.itemtype_description.escapeHtml(); |
338 |
} |
160 |
} |
339 |
}, |
161 |
}, |
340 |
{ |
162 |
{ |
341 |
"mDataProp": function( oObj ) { |
163 |
"mDataProp": function ( oObj ) { |
342 |
if ( oObj.issued_today ) { |
164 |
return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); |
343 |
return "<strong>" + __("Today's checkouts") + "</strong>"; |
|
|
344 |
} else { |
345 |
return "<strong>" + __("Previous checkouts") + "</strong>"; |
346 |
} |
347 |
} |
165 |
} |
348 |
}, |
166 |
}, |
349 |
{ |
167 |
{ |
350 |
"mDataProp": "date_due", |
168 |
"mDataProp": function ( oObj ) { |
|
|
169 |
return ( oObj.location ? oObj.location.escapeHtml() : '' ); |
170 |
} |
171 |
}, |
172 |
{ |
173 |
"mDataProp": function ( oObj ) { |
174 |
return (oObj.homebranch ? oObj.homebranch.escapeHtml() : '' ); |
175 |
} |
176 |
}, |
177 |
{ |
178 |
"mDataProp": "issuedate", |
351 |
"bVisible": false, |
179 |
"bVisible": false, |
352 |
}, |
180 |
}, |
353 |
{ |
181 |
{ |
354 |
"iDataSort": 2, // Sort on hidden unformatted date due column |
182 |
"iDataSort": 10, // Sort on hidden unformatted issuedate column |
355 |
"mDataProp": function( oObj ) { |
183 |
"mDataProp": function( oObj ) { |
356 |
let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true }); |
184 |
return $datetime(oObj.issuedate, { no_tz_adjust: true }); |
357 |
var due = oObj.date_due_overdue |
|
|
358 |
? "<span class='overdue'>" + date_due_formatted + "</span>" |
359 |
: date_due_formatted; |
360 |
|
361 |
due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>"; |
362 |
|
363 |
if ( oObj.lost && oObj.claims_returned ) { |
364 |
due += "<span class='lost claims_returned'>" + oObj.lost.escapeHtml() + "</span>"; |
365 |
} else if ( oObj.lost ) { |
366 |
due += "<span class='lost'>" + oObj.lost.escapeHtml() + "</span>"; |
367 |
} |
368 |
|
369 |
if ( oObj.damaged ) { |
370 |
due += "<span class='dmg'>" + oObj.damaged.escapeHtml() + "</span>"; |
371 |
} |
372 |
|
373 |
var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>"; |
374 |
due +="<br>" + patron_note; |
375 |
|
376 |
return due; |
377 |
} |
378 |
}, |
379 |
{ |
380 |
"mDataProp": function ( oObj ) { |
381 |
let title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" |
382 |
+ oObj.biblionumber |
383 |
+ "'>" |
384 |
+ (oObj.title ? oObj.title.escapeHtml() : '' ); |
385 |
|
386 |
$.each(oObj.subtitle, function( index, value ) { |
387 |
title += " " + value.escapeHtml(); |
388 |
}); |
389 |
|
390 |
title += " " + oObj.part_number + " " + oObj.part_name; |
391 |
|
392 |
if ( oObj.enumchron ) { |
393 |
title += " <span class='item_enumeration'>(" + oObj.enumchron.escapeHtml() + ")</span>"; |
394 |
} |
395 |
|
396 |
title += "</a></span>"; |
397 |
|
398 |
if ( oObj.author ) { |
399 |
title += " " + __("by _AUTHOR_").replace( "_AUTHOR_", " " + oObj.author.escapeHtml() ); |
400 |
} |
401 |
|
402 |
if ( oObj.itemnotes ) { |
403 |
var span_class = "text-muted"; |
404 |
if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ |
405 |
span_class = "circ-hlt"; |
406 |
} |
407 |
title += "<span class='divider-dash'> - </span><span class='" + span_class + " item-note-public'>" + oObj.itemnotes.escapeHtml() + "</span>"; |
408 |
} |
409 |
|
410 |
if ( oObj.itemnotes_nonpublic ) { |
411 |
var span_class = "text-danger"; |
412 |
if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ |
413 |
span_class = "circ-hlt"; |
414 |
} |
415 |
title += "<span class='divider-dash'> - </span><span class='" + span_class + " item-note-nonpublic'>" + oObj.itemnotes_nonpublic.escapeHtml() + "</span>"; |
416 |
} |
417 |
|
418 |
var onsite_checkout = ''; |
419 |
if ( oObj.onsite_checkout == 1 ) { |
420 |
onsite_checkout += " <span class='onsite_checkout'>(" + __("On-site checkout") + ")</span>"; |
421 |
} |
422 |
|
423 |
if ( oObj.recalled == 1 ) { |
424 |
title += "<span class='divider-dash'> - </span><span class='circ-hlt item-recalled'>" + __("This item has been recalled and the due date updated") + ".</span>"; |
425 |
} |
426 |
|
427 |
title += " " |
428 |
+ "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" |
429 |
+ oObj.biblionumber |
430 |
+ "&itemnumber=" |
431 |
+ oObj.itemnumber |
432 |
+ "#" |
433 |
+ oObj.itemnumber |
434 |
+ "'>" |
435 |
+ (oObj.barcode ? oObj.barcode.escapeHtml() : "") |
436 |
+ "</a>" |
437 |
+ onsite_checkout |
438 |
|
439 |
return title; |
440 |
}, |
441 |
"sType": "anti-the" |
442 |
}, |
443 |
{ |
444 |
"mDataProp": function ( oObj ) { |
445 |
return oObj.recordtype_description.escapeHtml(); |
446 |
} |
447 |
}, |
448 |
{ |
449 |
"mDataProp": function ( oObj ) { |
450 |
return oObj.itemtype_description.escapeHtml(); |
451 |
} |
452 |
}, |
453 |
{ |
454 |
"mDataProp": function ( oObj ) { |
455 |
return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); |
456 |
} |
457 |
}, |
458 |
{ |
459 |
"mDataProp": function ( oObj ) { |
460 |
return ( oObj.location ? oObj.location.escapeHtml() : '' ); |
461 |
} |
462 |
}, |
463 |
{ |
464 |
"mDataProp": function ( oObj ) { |
465 |
return (oObj.homebranch ? oObj.homebranch.escapeHtml() : '' ); |
466 |
} |
467 |
}, |
468 |
{ |
469 |
"mDataProp": "issuedate", |
470 |
"bVisible": false, |
471 |
}, |
472 |
{ |
473 |
"iDataSort": 10, // Sort on hidden unformatted issuedate column |
474 |
"mDataProp": function( oObj ) { |
475 |
return $datetime(oObj.issuedate, { no_tz_adjust: true }); |
476 |
} |
185 |
} |
477 |
}, |
186 |
}, |
478 |
{ |
187 |
{ |
Lines 574-753
$(document).ready(function() {
Link Here
|
574 |
+ __("Can no longer be auto-renewed - number of checkout days exceeded") |
283 |
+ __("Can no longer be auto-renewed - number of checkout days exceeded") |
575 |
+ "</span>"; |
284 |
+ "</span>"; |
576 |
|
285 |
|
577 |
span_style = "display: none"; |
286 |
span_style = "display: none"; |
578 |
span_class = "renewals-allowed"; |
287 |
span_class = "renewals-allowed"; |
579 |
} else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { |
288 |
} else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { |
580 |
msg += "<span class='renewals-disabled'>" |
289 |
msg += "<span class='renewals-disabled'>" |
581 |
+ __("Automatic renewal failed, patron has unpaid fines") |
290 |
+ __("Automatic renewal failed, patron has unpaid fines") |
582 |
+ "</span>"; |
291 |
+ "</span>"; |
|
|
292 |
|
293 |
span_style = "display: none"; |
294 |
span_class = "renewals-allowed"; |
295 |
} else if ( oObj.can_renew_error == "auto_account_expired" ) { |
296 |
msg += "<span class='renewals-disabled'>" |
297 |
+ __("Automatic renewal failed, account expired") |
298 |
+ "</span>"; |
299 |
|
300 |
span_style = "display: none"; |
301 |
span_class = "renewals-allowed"; |
302 |
} else if ( oObj.can_renew_error == "onsite_checkout" ) { |
303 |
// Don't display something if it's an onsite checkout |
304 |
} else if ( oObj.can_renew_error == "item_denied_renewal" ) { |
305 |
content += "<span class='renewals-disabled'>" |
306 |
+ __("Renewal denied by syspref") |
307 |
+ "</span>"; |
308 |
|
309 |
span_style = "display: none"; |
310 |
span_class = "renewals-allowed"; |
311 |
} else { |
312 |
msg += "<span class='renewals-disabled'>" |
313 |
+ oObj.can_renew_error |
314 |
+ "</span>"; |
315 |
|
316 |
span_style = "display: none"; |
317 |
span_class = "renewals-allowed"; |
318 |
} |
319 |
|
320 |
var can_force_renew = ( oObj.onsite_checkout == 0 ) && |
321 |
( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride)) |
322 |
? true : false; |
323 |
var can_renew = ( oObj.renewals_remaining > 0 && ( !oObj.can_renew_error || oObj.can_renew_error == "too_unseen" )); |
324 |
content += "<span>"; |
325 |
if ( can_renew || can_force_renew ) { |
326 |
content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>"; |
327 |
content += "<span class='" + span_class + "' style='" + span_style + "'>" |
328 |
+ "<input type='checkbox' "; |
329 |
if ( oObj.date_due_overdue && can_renew ) { |
330 |
content += "checked='checked' "; |
331 |
} |
332 |
if (oObj.can_renew_error == "on_reserve") { |
333 |
content += "data-on-reserve "; |
334 |
} |
335 |
content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>" |
336 |
+ "</span>"; |
337 |
} |
338 |
content += msg; |
339 |
if ( can_renew || can_force_renew ) { |
340 |
content += "<span class='renewals-info'>("; |
341 |
content += __("%s of %s renewals remaining").format(oObj.renewals_remaining, oObj.renewals_allowed); |
342 |
if (UnseenRenewals && oObj.unseen_allowed) { |
343 |
content += __(" and %s of %s unseen renewals remaining").format(oObj.unseen_remaining, oObj.unseen_allowed); |
344 |
} |
345 |
content += ")</span>"; |
346 |
} |
347 |
if(oObj.auto_renew){ |
348 |
content += "<span class='renewals-info'>("; |
349 |
content += __("Scheduled for automatic renewal"); |
350 |
content += ")</span>"; |
351 |
} |
352 |
|
353 |
return content; |
354 |
} |
355 |
}, |
356 |
{ |
357 |
"bSortable": false, |
358 |
"bVisible": AllowCirculate ? true : false, |
359 |
"mDataProp": function ( oObj ) { |
360 |
if ( oObj.can_renew_error == "recalled" ) { |
361 |
return "<a href='/cgi-bin/koha/recalls/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("Recalled") + "</a>"; |
362 |
} else if ( oObj.can_renew_error == "on_reserve" ) { |
363 |
return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("On hold") + "</a>"; |
364 |
} else if ( oObj.materials ) { |
365 |
return "<input type='checkbox' class='confirm' id='confirm_" + oObj.itemnumber + "' name='confirm' value='" + oObj.itemnumber + "' data-materials='" + oObj.materials.escapeHtml() + "'></input>"; |
366 |
} else { |
367 |
return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; |
368 |
} |
369 |
} |
370 |
}, |
371 |
{ |
372 |
"bVisible": ClaimReturnedLostValue ? true : false, |
373 |
"bSortable": false, |
374 |
"mDataProp": function ( oObj ) { |
375 |
let content = ""; |
376 |
|
377 |
if ( oObj.return_claim_id ) { |
378 |
content = '<span class="badge">' + oObj.return_claim_created_on_formatted + '</span>'; |
379 |
} else if ( ClaimReturnedLostValue ) { |
380 |
content = '<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="' + oObj.itemnumber + '"><i class="fa fa-exclamation-circle"></i> ' + __("Claim returned") + '</a>'; |
381 |
} else { |
382 |
content = '<a class="btn btn-default btn-xs" disabled="disabled" title="ClaimReturnedLostValue is not set, this feature is disabled"><i class="fa fa-exclamation-circle"></i> ' + __("Claim returned") + '</a>'; |
383 |
} |
384 |
return content; |
385 |
} |
386 |
}, |
387 |
{ |
388 |
"bVisible": exports_enabled == 1 ? true : false, |
389 |
"bSortable": false, |
390 |
"mDataProp": function ( oObj ) { |
391 |
var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />"; |
392 |
|
393 |
s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />"; |
394 |
return s; |
395 |
} |
396 |
} |
397 |
], |
398 |
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { |
399 |
var total_charge = 0; |
400 |
var total_fine = 0; |
401 |
var total_price = 0; |
402 |
for ( var i=0; i < aaData.length; i++ ) { |
403 |
total_charge += aaData[i]['charge'] * 1; |
404 |
total_fine += aaData[i]['fine'] * 1; |
405 |
total_price += aaData[i]['price'] * 1; |
406 |
} |
407 |
$("#totaldue").html(total_charge.format_price() ); |
408 |
$("#totalfine").html(total_fine.format_price() ); |
409 |
$("#totalprice").html(total_price.format_price() ); |
410 |
}, |
411 |
"bPaginate": false, |
412 |
"bProcessing": true, |
413 |
"bServerSide": false, |
414 |
"sAjaxSource": '/cgi-bin/koha/svc/checkouts', |
415 |
"fnServerData": function ( sSource, aoData, fnCallback ) { |
416 |
aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); |
417 |
|
418 |
$.getJSON( sSource, aoData, function (json) { |
419 |
fnCallback(json) |
420 |
} ); |
421 |
}, |
422 |
"rowGroup":{ |
423 |
"dataSrc": "issued_today", |
424 |
"startRender": function ( rows, group ) { |
425 |
if ( group ) { |
426 |
return __("Today's checkouts"); |
427 |
} else { |
428 |
return __("Previous checkouts"); |
429 |
} |
430 |
} |
431 |
}, |
432 |
"fnInitComplete": function(oSettings, json) { |
433 |
// Build a summary of checkouts grouped by itemtype |
434 |
var checkoutsByItype = json.aaData.reduce(function (obj, row) { |
435 |
obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1; |
436 |
return obj; |
437 |
}, {}); |
438 |
var ul = $('<ul>'); |
439 |
Object.keys(checkoutsByItype).sort().forEach(function (itype) { |
440 |
var li = $('<li>') |
441 |
.append($('<strong>').html(itype || __("No itemtype"))) |
442 |
.append(': ' + checkoutsByItype[itype]); |
443 |
ul.append(li); |
444 |
}) |
445 |
$('<details>') |
446 |
.addClass('checkouts-by-itemtype') |
447 |
.append($('<summary>').html( __("Number of checkouts by item type") )) |
448 |
.append(ul) |
449 |
.insertBefore(oSettings.nTableWrapper) |
450 |
}, |
451 |
}, table_settings_issues_table); |
452 |
|
453 |
if ( $("#issues-table").length ) { |
454 |
$("#issues-table_processing").position({ |
455 |
of: $( "#issues-table" ), |
456 |
collision: "none" |
457 |
}); |
458 |
} |
459 |
} |
460 |
|
461 |
|
462 |
var loadIssuesTableDelayTimeoutId; |
463 |
var barcodefield = $("#barcode"); |
464 |
|
465 |
$('#issues-table-load-now-button').click(function(){ |
466 |
if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); |
467 |
LoadIssuesTable(); |
468 |
barcodefield.focus(); |
469 |
return false; |
470 |
}); |
471 |
$(document).ready(function() { |
472 |
|
473 |
var onHoldDueDateSet = false; |
474 |
|
475 |
var onHoldChecked = function() { |
476 |
var isChecked = false; |
477 |
$('input[data-on-reserve]').each(function() { |
478 |
if ($(this).is(':checked')) { |
479 |
isChecked=true; |
480 |
} |
481 |
}); |
482 |
return isChecked; |
483 |
}; |
484 |
|
485 |
var showHideOnHoldRenewal = function() { |
486 |
// Display the date input |
487 |
if (onHoldChecked()) { |
488 |
$('#newonholdduedate').show() |
489 |
} else { |
490 |
$('#newonholdduedate').hide(); |
491 |
} |
492 |
}; |
493 |
|
494 |
// Handle the select all/none links for checkouts table columns |
495 |
$("#CheckAllRenewals").on("click",function(){ |
496 |
$("#UncheckAllCheckins").click(); |
497 |
$(".renew:visible").prop("checked", true); |
498 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
499 |
showHideOnHoldRenewal(); |
500 |
return false; |
501 |
}); |
502 |
$("#UncheckAllRenewals").on("click",function(){ |
503 |
$(".renew:visible").prop("checked", false); |
504 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
505 |
showHideOnHoldRenewal(); |
506 |
return false; |
507 |
}); |
508 |
|
509 |
$("#CheckAllCheckins").on("click",function(){ |
510 |
$("#UncheckAllRenewals").click(); |
511 |
$(".checkin:visible").prop("checked", true); |
512 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
513 |
return false; |
514 |
}); |
515 |
$("#UncheckAllCheckins").on("click",function(){ |
516 |
$(".checkin:visible").prop("checked", false); |
517 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
518 |
return false; |
519 |
}); |
520 |
|
521 |
$("#newduedate").on("change", function() { |
522 |
if (!onHoldDueDateSet) { |
523 |
$('#newonholdduedate input').val($('#newduedate').val()); |
524 |
} |
525 |
}); |
526 |
|
527 |
$("#newonholdduedate").on("change", function() { |
528 |
onHoldDueDateSet = true; |
529 |
}); |
530 |
|
531 |
// Don't allow both return and renew checkboxes to be checked |
532 |
$(document).on("change", '.renew', function(){ |
533 |
if ( $(this).is(":checked") ) { |
534 |
$( "#checkin_" + $(this).val() ).prop("checked", false); |
535 |
} |
536 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
537 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
538 |
}); |
539 |
$(document).on("change", '.checkin', function(){ |
540 |
if ( $(this).is(":checked") ) { |
541 |
$( "#renew_" + $(this).val() ).prop("checked", false); |
542 |
} |
543 |
$('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); |
544 |
$('#RenewChecked').prop('disabled', !$('.renew:checked').length ); |
545 |
}); |
546 |
|
547 |
// Display on hold due dates input when an on hold item is |
548 |
// selected |
549 |
$(document).on('change', '.renew', function(){ |
550 |
showHideOnHoldRenewal(); |
551 |
}); |
552 |
|
553 |
$("#output_format > option:first-child").attr("selected", "selected"); |
554 |
$("select[name='csv_profile_id']").hide(); |
555 |
$(document).on("change", '#issues-table-output-format', function(){ |
556 |
if ( $(this).val() == 'csv' ) { |
557 |
$("select[name='csv_profile_id']").show(); |
558 |
} else { |
559 |
$("select[name='csv_profile_id']").hide(); |
560 |
} |
561 |
}); |
562 |
|
563 |
// Clicking the table cell checks the checkbox inside it |
564 |
$(document).on("click", 'td', function(e){ |
565 |
if(e.target.tagName.toLowerCase() == 'td'){ |
566 |
$(this).find("input:checkbox:visible").each( function() { |
567 |
$(this).click(); |
568 |
}); |
569 |
} |
570 |
}); |
571 |
|
572 |
// Handle renewals and returns |
573 |
$("#CheckinChecked").on("click",function(){ |
574 |
|
575 |
let refresh_table = true; |
576 |
$(".checkin:checked:visible").each(function() { |
577 |
itemnumber = $(this).val(); |
578 |
|
579 |
$(this).replaceWith("<img id='checkin_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); |
580 |
|
581 |
params = { |
582 |
itemnumber: itemnumber, |
583 |
borrowernumber: borrowernumber, |
584 |
branchcode: branchcode, |
585 |
exempt_fine: $("#exemptfine").is(':checked') |
586 |
}; |
587 |
|
588 |
$.post({ |
589 |
url: "/cgi-bin/koha/svc/checkin", |
590 |
data: params, |
591 |
success: function( data ) { |
592 |
id = "#checkin_" + data.itemnumber; |
593 |
|
594 |
content = ""; |
595 |
if ( data.returned ) { |
596 |
content = __("Checked in"); |
597 |
$(id).parent().parent().addClass('ok'); |
598 |
$('#date_due_' + data.itemnumber).html( __("Checked in") ); |
599 |
if ( data.patronnote != null ) { |
600 |
$('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote); |
601 |
} |
602 |
} else { |
603 |
content = __("Unable to check in"); |
604 |
$(id).parent().parent().addClass('warn'); |
605 |
refresh_table = false; |
606 |
} |
607 |
|
608 |
$(id).replaceWith( content ); |
609 |
}, |
610 |
dataType: "json", |
611 |
async: false, |
612 |
}); |
613 |
}); |
614 |
// Refocus on barcode field if it exists |
615 |
if ( $("#barcode").length ) { |
616 |
$("#barcode").focus(); |
617 |
} |
618 |
|
619 |
if ( refresh_table ) { |
620 |
RefreshIssuesTable(); |
621 |
} |
622 |
$('#RenewChecked, #CheckinChecked').prop('disabled' , true ); |
623 |
// Prevent form submit |
624 |
return false; |
625 |
}); |
626 |
$("#RenewChecked").on("click",function(){ |
627 |
let refresh_table = true; |
628 |
$(".confirm:checked:visible").each(function() { |
629 |
itemnumber = $(this).val(); |
630 |
id = "#checkin_" + itemnumber; |
631 |
materials = $(this).data('materials'); |
632 |
|
633 |
$(this).replaceWith("<span class='confirm' id='checkin_" + itemnumber + "'>" + __("Confirm") + " (<span>" + materials + "</span>): <input type='checkbox' class='checkin' name='checkin' value='" + itemnumber +"'></input></span>"); |
634 |
$(id).parent().parent().addClass('warn'); |
635 |
}); |
636 |
|
637 |
$(".renew:checked:visible").each(function() { |
638 |
var override_limit = $("#override_limit").is(':checked') ? 1 : 0; |
639 |
|
640 |
var isOnReserve = $(this).data().hasOwnProperty('onReserve'); |
583 |
|
641 |
|
584 |
span_style = "display: none"; |
642 |
var itemnumber = $(this).val(); |
585 |
span_class = "renewals-allowed"; |
|
|
586 |
} else if ( oObj.can_renew_error == "auto_account_expired" ) { |
587 |
msg += "<span class='renewals-disabled'>" |
588 |
+ __("Automatic renewal failed, account expired") |
589 |
+ "</span>"; |
590 |
|
643 |
|
591 |
span_style = "display: none"; |
644 |
$(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); |
592 |
span_class = "renewals-allowed"; |
|
|
593 |
} else if ( oObj.can_renew_error == "onsite_checkout" ) { |
594 |
// Don't display something if it's an onsite checkout |
595 |
} else if ( oObj.can_renew_error == "item_denied_renewal" ) { |
596 |
content += "<span class='renewals-disabled'>" |
597 |
+ __("Renewal denied by syspref") |
598 |
+ "</span>"; |
599 |
|
645 |
|
600 |
span_style = "display: none"; |
646 |
var params = { |
601 |
span_class = "renewals-allowed"; |
647 |
itemnumber: itemnumber, |
602 |
} else { |
648 |
borrowernumber: borrowernumber, |
603 |
msg += "<span class='renewals-disabled'>" |
649 |
branchcode: branchcode, |
604 |
+ oObj.can_renew_error |
650 |
override_limit: override_limit |
605 |
+ "</span>"; |
651 |
}; |
606 |
|
652 |
|
607 |
span_style = "display: none"; |
653 |
if (UnseenRenewals) { |
608 |
span_class = "renewals-allowed"; |
654 |
var ren = $("#renew_as_unseen_checkbox"); |
609 |
} |
655 |
var renew_unseen = ren.length > 0 && ren.is(':checked') ? 1 : 0; |
|
|
656 |
params.seen = renew_unseen === 1 ? 0 : 1; |
657 |
} |
610 |
|
658 |
|
611 |
var can_force_renew = ( oObj.onsite_checkout == 0 ) && |
659 |
// Determine which due date we need to use |
612 |
( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride)) |
660 |
var dueDate = isOnReserve ? |
613 |
? true : false; |
661 |
$("#newonholdduedate input").val() : |
614 |
var can_renew = ( oObj.renewals_remaining > 0 && ( !oObj.can_renew_error || oObj.can_renew_error == "too_unseen" )); |
662 |
$("#newduedate").val(); |
615 |
content += "<span>"; |
|
|
616 |
if ( can_renew || can_force_renew ) { |
617 |
content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>"; |
618 |
content += "<span class='" + span_class + "' style='" + span_style + "'>" |
619 |
+ "<input type='checkbox' "; |
620 |
if ( oObj.date_due_overdue && can_renew ) { |
621 |
content += "checked='checked' "; |
622 |
} |
623 |
if (oObj.can_renew_error == "on_reserve") { |
624 |
content += "data-on-reserve "; |
625 |
} |
626 |
content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>" |
627 |
+ "</span>"; |
628 |
} |
629 |
content += msg; |
630 |
if ( can_renew || can_force_renew ) { |
631 |
content += "<span class='renewals-info'>("; |
632 |
content += __("%s of %s renewals remaining").format(oObj.renewals_remaining, oObj.renewals_allowed); |
633 |
if (UnseenRenewals && oObj.unseen_allowed) { |
634 |
content += __(" and %s of %s unseen renewals remaining").format(oObj.unseen_remaining, oObj.unseen_allowed); |
635 |
} |
636 |
content += ")</span>"; |
637 |
} |
638 |
if(oObj.auto_renew){ |
639 |
content += "<span class='renewals-info'>("; |
640 |
content += __("Scheduled for automatic renewal"); |
641 |
content += ")</span>"; |
642 |
} |
643 |
|
663 |
|
644 |
return content; |
664 |
if (dueDate && dueDate.length > 0) { |
645 |
} |
665 |
params.date_due = dueDate |
646 |
}, |
666 |
} |
647 |
{ |
|
|
648 |
"bSortable": false, |
649 |
"bVisible": AllowCirculate ? true : false, |
650 |
"mDataProp": function ( oObj ) { |
651 |
if ( oObj.can_renew_error == "recalled" ) { |
652 |
return "<a href='/cgi-bin/koha/recalls/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("Recalled") + "</a>"; |
653 |
} else if ( oObj.can_renew_error == "on_reserve" ) { |
654 |
return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("On hold") + "</a>"; |
655 |
} else if ( oObj.materials ) { |
656 |
return "<input type='checkbox' class='confirm' id='confirm_" + oObj.itemnumber + "' name='confirm' value='" + oObj.itemnumber + "' data-materials='" + oObj.materials.escapeHtml() + "'></input>"; |
657 |
} else { |
658 |
return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; |
659 |
} |
660 |
} |
661 |
}, |
662 |
{ |
663 |
"bVisible": ClaimReturnedLostValue ? true : false, |
664 |
"bSortable": false, |
665 |
"mDataProp": function ( oObj ) { |
666 |
let content = ""; |
667 |
|
667 |
|
668 |
if ( oObj.return_claim_id ) { |
668 |
$.post({ |
669 |
content = '<span class="badge">' + oObj.return_claim_created_on_formatted + '</span>'; |
669 |
url: "/cgi-bin/koha/svc/renew", |
670 |
} else if ( ClaimReturnedLostValue ) { |
670 |
data: params, |
671 |
content = '<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="' + oObj.itemnumber + '"><i class="fa fa-exclamation-circle"></i> ' + __("Claim returned") + '</a>'; |
671 |
success: function( data ) { |
|
|
672 |
var id = "#renew_" + data.itemnumber; |
673 |
|
674 |
var content = ""; |
675 |
if ( data.renew_okay ) { |
676 |
content = __("Renewed, due:") + " " + data.date_due; |
677 |
$('#date_due_' + data.itemnumber).replaceWith( data.date_due ); |
678 |
} else { |
679 |
content = __("Renew failed:") + " "; |
680 |
if ( data.error == "no_checkout" ) { |
681 |
content += __("not checked out"); |
682 |
} else if ( data.error == "too_many" ) { |
683 |
content += __("too many renewals"); |
684 |
} else if ( data.error == "too_unseen" ) { |
685 |
content += __("too many consecutive renewals without being seen by the library"); |
686 |
} else if ( data.error == "on_reserve" ) { |
687 |
content += __("on hold"); |
688 |
} else if ( data.error == "restriction" ) { |
689 |
content += __("Not allowed: patron restricted"); |
690 |
} else if ( data.error == "overdue" ) { |
691 |
content += __("Not allowed: overdue"); |
692 |
} else if ( data.error == 'no_open_days' ) { |
693 |
content += __('Unable to find an open day'); |
694 |
} else if ( data.error ) { |
695 |
content += data.error; |
672 |
} else { |
696 |
} else { |
673 |
content = '<a class="btn btn-default btn-xs" disabled="disabled" title="ClaimReturnedLostValue is not set, this feature is disabled"><i class="fa fa-exclamation-circle"></i> ' + __("Claim returned") + '</a>'; |
697 |
content += __("reason unknown"); |
674 |
} |
698 |
} |
675 |
return content; |
699 |
refresh_table = false; |
676 |
} |
700 |
} |
677 |
}, |
|
|
678 |
{ |
679 |
"bVisible": exports_enabled == 1 ? true : false, |
680 |
"bSortable": false, |
681 |
"mDataProp": function ( oObj ) { |
682 |
var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />"; |
683 |
|
701 |
|
684 |
s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />"; |
702 |
$(id).replaceWith( content ); |
685 |
return s; |
|
|
686 |
} |
687 |
} |
688 |
], |
689 |
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { |
690 |
var total_charge = 0; |
691 |
var total_fine = 0; |
692 |
var total_price = 0; |
693 |
for ( var i=0; i < aaData.length; i++ ) { |
694 |
total_charge += aaData[i]['charge'] * 1; |
695 |
total_fine += aaData[i]['fine'] * 1; |
696 |
total_price += aaData[i]['price'] * 1; |
697 |
} |
698 |
$("#totaldue").html(total_charge.format_price() ); |
699 |
$("#totalfine").html(total_fine.format_price() ); |
700 |
$("#totalprice").html(total_price.format_price() ); |
701 |
}, |
703 |
}, |
702 |
"bPaginate": false, |
704 |
dataType: "json", |
703 |
"bProcessing": true, |
705 |
async: false, |
704 |
"bServerSide": false, |
706 |
}); |
705 |
"sAjaxSource": '/cgi-bin/koha/svc/checkouts', |
707 |
}); |
706 |
"fnServerData": function ( sSource, aoData, fnCallback ) { |
|
|
707 |
aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); |
708 |
|
708 |
|
709 |
$.getJSON( sSource, aoData, function (json) { |
709 |
// Refocus on barcode field if it exists |
710 |
fnCallback(json) |
710 |
if ( $("#barcode").length ) { |
711 |
} ); |
711 |
$("#barcode").focus(); |
712 |
}, |
712 |
} |
713 |
"rowGroup":{ |
|
|
714 |
"dataSrc": "issued_today", |
715 |
"startRender": function ( rows, group ) { |
716 |
if ( group ) { |
717 |
return __("Today's checkouts"); |
718 |
} else { |
719 |
return __("Previous checkouts"); |
720 |
} |
721 |
} |
722 |
}, |
723 |
"fnInitComplete": function(oSettings, json) { |
724 |
// Build a summary of checkouts grouped by itemtype |
725 |
var checkoutsByItype = json.aaData.reduce(function (obj, row) { |
726 |
obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1; |
727 |
return obj; |
728 |
}, {}); |
729 |
var ul = $('<ul>'); |
730 |
Object.keys(checkoutsByItype).sort().forEach(function (itype) { |
731 |
var li = $('<li>') |
732 |
.append($('<strong>').html(itype || __("No itemtype"))) |
733 |
.append(': ' + checkoutsByItype[itype]); |
734 |
ul.append(li); |
735 |
}) |
736 |
$('<details>') |
737 |
.addClass('checkouts-by-itemtype') |
738 |
.append($('<summary>').html( __("Number of checkouts by item type") )) |
739 |
.append(ul) |
740 |
.insertBefore(oSettings.nTableWrapper) |
741 |
}, |
742 |
}, table_settings_issues_table); |
743 |
|
713 |
|
744 |
if ( $("#issues-table").length ) { |
714 |
if ( refresh_table ) { |
745 |
$("#issues-table_processing").position({ |
715 |
RefreshIssuesTable(); |
746 |
of: $( "#issues-table" ), |
716 |
} |
747 |
collision: "none" |
717 |
// Prevent form submit |
748 |
}); |
718 |
return false; |
|
|
719 |
}); |
720 |
|
721 |
$("#RenewAll").on("click",function(){ |
722 |
$("#CheckAllRenewals").click(); |
723 |
$("#UncheckAllCheckins").click(); |
724 |
showHideOnHoldRenewal(); |
725 |
$("#RenewChecked").click(); |
726 |
$('#RenewChecked').prop('disabled' , true ); |
727 |
// Prevent form submit |
728 |
return false; |
729 |
}); |
730 |
|
731 |
var ymd = flatpickr.formatDate(new Date(), "Y-m-d"); |
732 |
|
733 |
$('#issues-table-load-immediately').change(function(){ |
734 |
if ( this.checked && typeof issuesTable === 'undefined') { |
735 |
$('#issues-table-load-now-button').click(); |
736 |
} |
737 |
barcodefield.focus(); |
738 |
}); |
739 |
|
740 |
if ( Cookies.get("issues-table-load-immediately-" + script) == "true" ) { |
741 |
if ( LoadCheckoutsTableDelay ) { |
742 |
loadIssuesTableDelayTimeoutId = setTimeout( function(){ LoadIssuesTable() }, LoadCheckoutsTableDelay * 1000); |
743 |
} else { |
744 |
LoadIssuesTable(); |
749 |
} |
745 |
} |
|
|
746 |
$('#issues-table-load-immediately').prop('checked', true); |
747 |
} else { |
748 |
$('#issues-table-load-delay').hide(); |
750 |
} |
749 |
} |
|
|
750 |
$('#issues-table-load-immediately').on( "change", function(){ |
751 |
Cookies.set("issues-table-load-immediately-" + script, $(this).is(':checked'), { expires: 365, sameSite: 'Lax' }); |
752 |
}); |
751 |
|
753 |
|
752 |
// Don't load relatives' issues table unless it is clicked on |
754 |
// Don't load relatives' issues table unless it is clicked on |
753 |
var relativesIssuesTable; |
755 |
var relativesIssuesTable; |
754 |
- |
|
|