Bug 13618: Escape HTML chars in checkouts.js
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / checkouts.js
1 $(document).ready(function() {
2     $.ajaxSetup ({ cache: false });
3
4     var barcodefield = $("#barcode");
5
6     // Handle the select all/none links for checkouts table columns
7     $("#CheckAllRenewals").on("click",function(){
8         $("#UncheckAllCheckins").click();
9         $(".renew:visible").prop("checked", true);
10         return false;
11     });
12     $("#UncheckAllRenewals").on("click",function(){
13         $(".renew:visible").prop("checked", false);
14         return false;
15     });
16
17     $("#CheckAllCheckins").on("click",function(){
18         $("#UncheckAllRenewals").click();
19         $(".checkin:visible").prop("checked", true);
20         return false;
21     });
22     $("#UncheckAllCheckins").on("click",function(){
23         $(".checkin:visible").prop("checked", false);
24         return false;
25     });
26
27     // Don't allow both return and renew checkboxes to be checked
28     $(document).on("change", '.renew', function(){
29         if ( $(this).is(":checked") ) {
30             $( "#checkin_" + $(this).val() ).prop("checked", false);
31         }
32     });
33     $(document).on("change", '.checkin', function(){
34         if ( $(this).is(":checked") ) {
35             $( "#renew_" + $(this).val() ).prop("checked", false);
36         }
37     });
38
39     $("#output_format > option:first-child").attr("selected", "selected");
40     $("select[name='csv_profile_id']").hide();
41     $(document).on("change", '#issues-table-output-format', function(){
42         if ( $(this).val() == 'csv' ) {
43             $("select[name='csv_profile_id']").show();
44         } else {
45             $("select[name='csv_profile_id']").hide();
46         }
47     });
48
49     // Clicking the table cell checks the checkbox inside it
50     $(document).on("click", 'td', function(e){
51         if(e.target.tagName.toLowerCase() == 'td'){
52           $(this).find("input:checkbox:visible").each( function() {
53             $(this).click();
54           });
55         }
56     });
57
58     // Handle renewals and returns
59     $("#RenewCheckinChecked").on("click",function(){
60         $(".checkin:checked:visible").each(function() {
61             itemnumber = $(this).val();
62
63             $(this).replaceWith("<img id='checkin_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
64
65             params = {
66                 itemnumber:     itemnumber,
67                 borrowernumber: borrowernumber,
68                 branchcode:     branchcode,
69                 exempt_fine:    $("#exemptfine").is(':checked')
70             };
71
72             $.post( "/cgi-bin/koha/svc/checkin", params, function( data ) {
73                 id = "#checkin_" + data.itemnumber;
74
75                 content = "";
76                 if ( data.returned ) {
77                     content = CIRCULATION_RETURNED;
78                     $(id).parent().parent().addClass('ok');
79                     $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
80                     if ( data.patronnote != null ) {
81                         $('.patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote);
82                     }
83                 } else {
84                     content = CIRCULATION_NOT_RETURNED;
85                     $(id).parent().parent().addClass('warn');
86                 }
87
88                 $(id).replaceWith( content );
89             }, "json")
90         });
91
92         $(".renew:checked:visible").each(function() {
93             var override_limit = $("#override_limit").is(':checked') ? 1 : 0;
94
95             var itemnumber = $(this).val();
96
97             $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
98
99             var params = {
100                 itemnumber:     itemnumber,
101                 borrowernumber: borrowernumber,
102                 branchcode:     branchcode,
103                 override_limit: override_limit,
104                 date_due:       $("#newduedate").val()
105             };
106
107             $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
108                 var id = "#renew_" + data.itemnumber;
109
110                 var content = "";
111                 if ( data.renew_okay ) {
112                     content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
113                     $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
114                 } else {
115                     content = CIRCULATION_RENEW_FAILED + " ";
116                     if ( data.error == "no_checkout" ) {
117                         content += NOT_CHECKED_OUT;
118                     } else if ( data.error == "too_many" ) {
119                         content += TOO_MANY_RENEWALS;
120                     } else if ( data.error == "on_reserve" ) {
121                         content += ON_RESERVE;
122                     } else if ( data.error == "restriction" ) {
123                         content += NOT_RENEWABLE_RESTRICTION;
124                     } else if ( data.error == "overdue" ) {
125                         content += NOT_RENEWABLE_OVERDUE;
126                     } else if ( data.error ) {
127                         content += data.error;
128                     } else {
129                         content += REASON_UNKNOWN;
130                     }
131                 }
132
133                 $(id).replaceWith( content );
134             }, "json")
135         });
136
137         // Refocus on barcode field if it exists
138         if ( $("#barcode").length ) {
139             $("#barcode").focus();
140         }
141
142         // Prevent form submit
143         return false;
144     });
145
146     $("#RenewAll").on("click",function(){
147         $("#CheckAllRenewals").click();
148         $("#UncheckAllCheckins").click();
149         $("#RenewCheckinChecked").click();
150
151         // Prevent form submit
152         return false;
153     });
154
155     var ymd = $.datepicker.formatDate('yy-mm-dd', new Date());
156
157     $('#issues-table').hide();
158     $('#issues-table-actions').hide();
159     $('#issues-table-load-immediately').change(function(){
160         if ( this.checked && typeof issuesTable === 'undefined') {
161             $('#issues-table-load-now-button').click();
162         }
163         barcodefield.focus();
164     });
165     $('#issues-table-load-now-button').click(function(){
166         LoadIssuesTable();
167         barcodefield.focus();
168         return false;
169     });
170
171     if ( $.cookie("issues-table-load-immediately-" + script) == "true" ) {
172         LoadIssuesTable();
173         $('#issues-table-load-immediately').prop('checked', true);
174     }
175     $('#issues-table-load-immediately').on( "change", function(){
176         $.cookie("issues-table-load-immediately-" + script, $(this).is(':checked'), { expires: 365 });
177     });
178
179     function LoadIssuesTable() {
180         $('#issues-table-loading-message').hide();
181         $('#issues-table').show();
182         $('#issues-table-actions').show();
183
184         issuesTable = KohaTable("issues-table", {
185             "oLanguage": {
186                 "sEmptyTable" : MSG_DT_LOADING_RECORDS,
187                 "sProcessing": MSG_DT_LOADING_RECORDS,
188             },
189             "bAutoWidth": false,
190             "dom": 'B<"clearfix">rt',
191             "aoColumns": [
192                 {
193                     "mDataProp": function( oObj ) {
194                         return oObj.sort_order;
195                     }
196                 },
197                 {
198                     "mDataProp": function( oObj ) {
199                         if ( oObj.issued_today ) {
200                             return "<strong>" + TODAYS_CHECKOUTS + "</strong>";
201                         } else {
202                             return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>";
203                         }
204                     }
205                 },
206                 {
207                     "mDataProp": "date_due",
208                     "bVisible": false,
209                 },
210                 {
211                     "iDataSort": 2, // Sort on hidden unformatted date due column
212                     "mDataProp": function( oObj ) {
213                         var due = oObj.date_due_formatted;
214
215                         if ( oObj.date_due_overdue ) {
216                             due = "<span class='overdue'>" + due + "</span>";
217                         }
218
219                         due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>";
220
221                         if ( oObj.lost ) {
222                             due += "<span class='lost'>" + oObj.lost.escapeHtml() + "</span>";
223                         }
224
225                         if ( oObj.damaged ) {
226                             due += "<span class='dmg'>" + oObj.damaged.escapeHtml() + "</span>";
227                         }
228
229                         var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>";
230                         due +="<br>" + patron_note;
231
232                         return due;
233                     }
234                 },
235                 {
236                     "mDataProp": function ( oObj ) {
237                         title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
238                               + oObj.biblionumber
239                               + "'>"
240                               + oObj.title.escapeHtml();
241
242                         $.each(oObj.subtitle, function( index, value ) {
243                                   title += " " + value.subfield.escapeHtml();
244                         });
245
246                         if ( oObj.enumchron ) {
247                             title += " (" + oObj.enumchron.escapeHtml() + ")";
248                         }
249
250                         title += "</a></span>";
251
252                         if ( oObj.author ) {
253                             title += " " + BY.replace( "_AUTHOR_",  " " + oObj.author.escapeHtml() );
254                         }
255
256                         if ( oObj.itemnotes ) {
257                             var span_class = "text-muted";
258                             if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
259                                 span_class = "circ-hlt";
260                             }
261                             title += " - <span class='" + span_class + " item-note-public'>" + oObj.itemnotes.escapeHtml() + "</span>";
262                         }
263
264                         if ( oObj.itemnotes_nonpublic ) {
265                             var span_class = "text-danger";
266                             if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
267                                 span_class = "circ-hlt";
268                             }
269                             title += " - <span class='" + span_class + " item-note-nonpublic'>" + oObj.itemnotes_nonpublic.escapeHtml() + "</span>";
270                         }
271
272                         var onsite_checkout = '';
273                         if ( oObj.onsite_checkout == 1 ) {
274                             onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
275                         }
276
277                         title += " "
278                               + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
279                               + oObj.biblionumber
280                               + "&itemnumber="
281                               + oObj.itemnumber
282                               + "#"
283                               + oObj.itemnumber
284                               + "'>"
285                               + oObj.barcode.escapeHtml()
286                               + "</a>"
287                               + onsite_checkout
288
289                         return title;
290                     },
291                     "sType": "anti-the"
292                 },
293                 {
294                     "mDataProp": function ( oObj ) {
295                         return oObj.itemtype_description.escapeHtml();
296                     }
297                 },
298                 {
299                     "mDataProp": function ( oObj ) {
300                         return oObj.location.escapeHtml();
301                     }
302                 },
303                 {
304                     "mDataProp": function ( oObj ) {
305                         return oObj.homebranch.escapeHtml();
306                     }
307                 },
308                 { "mDataProp": "issuedate_formatted" },
309                 {
310                     "mDataProp": function ( oObj ) {
311                         return oObj.branchname.escapeHtml();
312                     }
313                 },
314                 {
315                     "mDataProp": function ( oObj ) {
316                         return oObj.itemcallnumber.escapeHtml();
317                     }
318                 },
319                 {
320                     "mDataProp": function ( oObj ) {
321                         if ( ! oObj.charge ) oObj.charge = 0;
322                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.charge).toFixed(2) + '<span>';
323                     }
324                 },
325                 {
326                     "mDataProp": function ( oObj ) {
327                         if ( ! oObj.fine ) oObj.fine = 0;
328                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.fine).toFixed(2)  + '<span>';
329                     }
330                 },
331                 {
332                     "mDataProp": function ( oObj ) {
333                         if ( ! oObj.price ) oObj.price = 0;
334                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.price).toFixed(2) + '<span>';
335                     }
336                 },
337                 {
338                     "bSortable": false,
339                     "bVisible": AllowCirculate ? true : false,
340                     "mDataProp": function ( oObj ) {
341                         var content = "";
342                         var span_style = "";
343                         var span_class = "";
344
345                         content += "<span>";
346                         content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>";
347
348                         if ( oObj.can_renew ) {
349                             // Do nothing
350                         } else if ( oObj.can_renew_error == "on_reserve" ) {
351                             content += "<span class='renewals-disabled-no-override'>"
352                                     + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"
353                                     + "</span>";
354
355                             span_style = "display: none";
356                             span_class = "renewals-allowed";
357                         } else if ( oObj.can_renew_error == "too_many" ) {
358                             content += "<span class='renewals-disabled'>"
359                                     + NOT_RENEWABLE
360                                     + "</span>";
361
362                             span_style = "display: none";
363                             span_class = "renewals-allowed";
364                         } else if ( oObj.can_renew_error == "restriction" ) {
365                             content += "<span class='renewals-disabled'>"
366                                     + NOT_RENEWABLE_RESTRICTION
367                                     + "</span>";
368
369                             span_style = "display: none";
370                             span_class = "renewals-allowed";
371                         } else if ( oObj.can_renew_error == "overdue" ) {
372                             content += "<span class='renewals-disabled'>"
373                                     + NOT_RENEWABLE_OVERDUE
374                                     + "</span>";
375
376                             span_style = "display: none";
377                             span_class = "renewals-allowed";
378                         } else if ( oObj.can_renew_error == "too_soon" ) {
379                             content += "<span class='renewals-disabled'>"
380                                     + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date )
381                                     + "</span>";
382
383                             span_style = "display: none";
384                             span_class = "renewals-allowed";
385                         } else if ( oObj.can_renew_error == "auto_too_soon" ) {
386                             content += "<span class='renewals-disabled'>"
387                                     + NOT_RENEWABLE_AUTO_TOO_SOON
388                                     + "</span>";
389
390                             span_style = "display: none";
391                             span_class = "renewals-allowed";
392                         } else if ( oObj.can_renew_error == "auto_too_late" ) {
393                             content += "<span class='renewals-disabled'>"
394                                     + NOT_RENEWABLE_AUTO_TOO_LATE
395                                     + "</span>";
396
397                             span_style = "display: none";
398                             span_class = "renewals-allowed";
399                         } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) {
400                             content += "<span class='renewals-disabled'>"
401                                     + NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING
402                                     + "</span>";
403
404                             span_style = "display: none";
405                             span_class = "renewals-allowed";
406                         } else if ( oObj.can_renew_error == "auto_account_expired" ) {
407                             content += "<span class='renewals-disabled'>"
408                                     + NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED
409                                     + "</span>";
410
411                             span_style = "display: none";
412                             span_class = "renewals-allowed";
413                         } else if ( oObj.can_renew_error == "auto_renew" ) {
414                             content += "<span class='renewals-disabled'>"
415                                     + NOT_RENEWABLE_AUTO_RENEW
416                                     + "</span>";
417
418                             span_style = "display: none";
419                             span_class = "renewals-allowed";
420                         } else if ( oObj.can_renew_error == "onsite_checkout" ) {
421                             // Don't display something if it's an onsite checkout
422                         } else {
423                             content += "<span class='renewals-disabled'>"
424                                     + oObj.can_renew_error
425                                     + "</span>";
426
427                             span_style = "display: none";
428                             span_class = "renewals-allowed";
429                         }
430
431                         var can_force_renew = ( oObj.onsite_checkout == 0 ) && ( oObj.can_renew_error != "on_reserve" );
432                         var can_renew = ( oObj.renewals_remaining > 0  && !oObj.can_renew_error );
433                         if ( can_renew || can_force_renew ) {
434                             content += "<span class='" + span_class + "' style='" + span_style + "'>"
435                                     +  "<input type='checkbox' ";
436                             if ( oObj.date_due_overdue && can_renew ) {
437                                 content += "checked='checked' ";
438                             }
439                             content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>"
440                                     +  "</span>";
441
442                             content += "<span class='renewals'>("
443                                     + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed )
444                                     + ")</span>";
445                         }
446
447                         content += "</span>";
448
449                         return content;
450                     }
451                 },
452                 {
453                     "bSortable": false,
454                     "bVisible": AllowCirculate ? true : false,
455                     "mDataProp": function ( oObj ) {
456                         if ( oObj.can_renew_error == "on_reserve" ) {
457                             return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>";
458                         } else {
459                             return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>";
460                         }
461                     }
462                 },
463                 {
464                     "bVisible": exports_enabled == 1 ? true : false,
465                     "bSortable": false,
466                     "mDataProp": function ( oObj ) {
467                         var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />";
468
469                         s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />";
470                         return s;
471                     }
472                 }
473             ],
474             "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
475                 var total_charge = 0;
476                 var total_fine  = 0;
477                 var total_price = 0;
478                 for ( var i=0; i < aaData.length; i++ ) {
479                     total_charge += aaData[i]['charge'] * 1;
480                     total_fine += aaData[i]['fine'] * 1;
481                     total_price  += aaData[i]['price'] * 1;
482                 }
483                 $("#totaldue").html(total_charge.toFixed(2));
484                 $("#totalfine").html(total_fine.toFixed(2));
485                 $("#totalprice").html(total_price.toFixed(2));
486             },
487             "bPaginate": false,
488             "bProcessing": true,
489             "bServerSide": false,
490             "sAjaxSource": '/cgi-bin/koha/svc/checkouts',
491             "fnServerData": function ( sSource, aoData, fnCallback ) {
492                 aoData.push( { "name": "borrowernumber", "value": borrowernumber } );
493
494                 $.getJSON( sSource, aoData, function (json) {
495                     fnCallback(json)
496                 } );
497             },
498             "fnInitComplete": function(oSettings, json) {
499                 // Disable rowGrouping plugin after first use
500                 // so any sorting on the table doesn't use it
501                 var oSettings = issuesTable.fnSettings();
502
503                 for (f = 0; f < oSettings.aoDrawCallback.length; f++) {
504                     if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') {
505                         oSettings.aoDrawCallback.splice(f, 1);
506                         break;
507                     }
508                 }
509
510                 oSettings.aaSortingFixed = null;
511
512                 // Build a summary of checkouts grouped by itemtype
513                 var checkoutsByItype = json.aaData.reduce(function (obj, row) {
514                     obj[row.itemtype_description] = (obj[row.itemtype_description] || 0) + 1;
515                     return obj;
516                 }, {});
517                 var ul = $('<ul>');
518                 Object.keys(checkoutsByItype).sort().forEach(function (itype) {
519                     var li = $('<li>')
520                         .append($('<strong>').html(itype || MSG_NO_ITEMTYPE))
521                         .append(': ' + checkoutsByItype[itype]);
522                     ul.append(li);
523                 })
524                 $('<details>')
525                     .addClass('checkouts-by-itemtype')
526                     .append($('<summary>').html(MSG_CHECKOUTS_BY_ITEMTYPE))
527                     .append(ul)
528                     .insertBefore(oSettings.nTableWrapper)
529             },
530         }, columns_settings).rowGrouping(
531             {
532                 iGroupingColumnIndex: 1,
533                 iGroupingOrderByColumnIndex: 0,
534                 sGroupingColumnSortDirection: "asc"
535             }
536         );
537
538         if ( $("#issues-table").length ) {
539             $("#issues-table_processing").position({
540                 of: $( "#issues-table" ),
541                 collision: "none"
542             });
543         }
544     }
545
546     // Don't load relatives' issues table unless it is clicked on
547     var relativesIssuesTable;
548     $("#relatives-issues-tab").click( function() {
549         if ( ! relativesIssuesTable ) {
550             relativesIssuesTable = $("#relatives-issues-table").dataTable({
551                 "bAutoWidth": false,
552                 "sDom": "rt",
553                 "aaSorting": [],
554                 "aoColumns": [
555                     {
556                         "mDataProp": "date_due",
557                         "bVisible": false,
558                     },
559                     {
560                         "iDataSort": 1, // Sort on hidden unformatted date due column
561                         "mDataProp": function( oObj ) {
562                             var today = new Date();
563                             var due = new Date( oObj.date_due );
564                             if ( today > due ) {
565                                 return "<span class='overdue'>" + oObj.date_due_formatted + "</span>";
566                             } else {
567                                 return oObj.date_due_formatted;
568                             }
569                         }
570                     },
571                     {
572                         "mDataProp": function ( oObj ) {
573                             title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
574                                   + oObj.biblionumber
575                                   + "'>"
576                                   + oObj.title.escapeHtml();
577
578                             $.each(oObj.subtitle, function( index, value ) {
579                                       title += " " + value.subfield.escapeHtml();
580                             });
581
582                             if ( oObj.enumchron ) {
583                                 title += " (" + oObj.enumchron.escapeHtml() + ")";
584                             }
585
586                             title += "</a></span>";
587
588                             if ( oObj.author ) {
589                                 title += " " + BY.replace( "_AUTHOR_", " " + oObj.author.escapeHtml() );
590                             }
591
592                             if ( oObj.itemnotes ) {
593                                 var span_class = "";
594                                 if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
595                                     span_class = "circ-hlt";
596                                 }
597                                 title += " - <span class='" + span_class + "'>" + oObj.itemnotes.escapeHtml() + "</span>"
598                             }
599
600                             if ( oObj.itemnotes_nonpublic ) {
601                                 var span_class = "";
602                                 if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
603                                     span_class = "circ-hlt";
604                                 }
605                                 title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic.escapeHtml() + "</span>"
606                             }
607
608                             var onsite_checkout = '';
609                             if ( oObj.onsite_checkout == 1 ) {
610                                 onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
611                             }
612
613                             title += " "
614                                   + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
615                                   + oObj.biblionumber
616                                   + "&itemnumber="
617                                   + oObj.itemnumber
618                                   + "#"
619                                   + oObj.itemnumber
620                                   + "'>"
621                                   + oObj.barcode.escapeHtml()
622                                   + "</a>"
623                                   + onsite_checkout;
624
625                             return title;
626                         },
627                         "sType": "anti-the"
628                     },
629                     {
630                         "mDataProp": function ( oObj ) {
631                             return oObj.itemtype_description.escapeHtml();
632                         }
633                     },
634                     {
635                         "mDataProp": function ( oObj ) {
636                             return oObj.location.escapeHtml();
637                         }
638                     },
639                     { "mDataProp": "issuedate_formatted" },
640                     {
641                         "mDataProp": function ( oObj ) {
642                             return oObj.branchname.escapeHtml();
643                         }
644                     },
645                     {
646                         "mDataProp": function ( oObj ) {
647                             return oObj.itemcallnumber.escapeHtml();
648                         }
649                     },
650                     {
651                         "mDataProp": function ( oObj ) {
652                             if ( ! oObj.charge ) oObj.charge = 0;
653                             return parseFloat(oObj.charge).toFixed(2);
654                         }
655                     },
656                     {
657                         "mDataProp": function ( oObj ) {
658                             if ( ! oObj.fine ) oObj.fine = 0;
659                             return parseFloat(oObj.fine).toFixed(2);
660                         }
661                     },
662                     {
663                         "mDataProp": function ( oObj ) {
664                             if ( ! oObj.price ) oObj.price = 0;
665                             return parseFloat(oObj.price).toFixed(2);
666                         }
667                     },
668                     {
669                         "mDataProp": function( oObj ) {
670                             return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>"
671                                 + oObj.borrower.firstname.escapeHtml()
672                                 + " " +
673                                 oObj.borrower.surname.escapeHtml()
674                                 + " (" + oObj.borrower.cardnumber.escapeHtml() + ")</a>"
675                         }
676                     },
677                 ],
678                 "bPaginate": false,
679                 "bProcessing": true,
680                 "bServerSide": false,
681                 "sAjaxSource": '/cgi-bin/koha/svc/checkouts',
682                 "fnServerData": function ( sSource, aoData, fnCallback ) {
683                     $.each(relatives_borrowernumbers, function( index, value ) {
684                         aoData.push( { "name": "borrowernumber", "value": value } );
685                     });
686
687                     $.getJSON( sSource, aoData, function (json) {
688                         fnCallback(json)
689                     } );
690                 },
691             });
692         }
693     });
694
695     if ( $("#relatives-issues-table").length ) {
696         $("#relatives-issues-table_processing").position({
697             of: $( "#relatives-issues-table" ),
698             collision: "none"
699         });
700     }
701
702     if ( AllowRenewalLimitOverride ) {
703         $( '#override_limit' ).click( function () {
704             if ( this.checked ) {
705                 $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
706             } else {
707                 $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
708             }
709         } ).prop('checked', false);
710     }
711  });