Bug 19719: Add new column for collection in the patron checkouts data tables
[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.ccode.escapeHtml();
301                     }
302                 },
303                 {
304                     "mDataProp": function ( oObj ) {
305                         return oObj.location.escapeHtml();
306                     }
307                 },
308                 {
309                     "mDataProp": function ( oObj ) {
310                         return oObj.homebranch.escapeHtml();
311                     }
312                 },
313                 { "mDataProp": "issuedate_formatted" },
314                 {
315                     "mDataProp": function ( oObj ) {
316                         return oObj.branchname.escapeHtml();
317                     }
318                 },
319                 {
320                     "mDataProp": function ( oObj ) {
321                         return oObj.itemcallnumber.escapeHtml();
322                     }
323                 },
324                 {
325                     "mDataProp": function ( oObj ) {
326                         if ( ! oObj.charge ) oObj.charge = 0;
327                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.charge).toFixed(2) + '<span>';
328                     }
329                 },
330                 {
331                     "mDataProp": function ( oObj ) {
332                         if ( ! oObj.fine ) oObj.fine = 0;
333                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.fine).toFixed(2)  + '<span>';
334                     }
335                 },
336                 {
337                     "mDataProp": function ( oObj ) {
338                         if ( ! oObj.price ) oObj.price = 0;
339                         return '<span style="text-align: right; display: block;">' + parseFloat(oObj.price).toFixed(2) + '<span>';
340                     }
341                 },
342                 {
343                     "bSortable": false,
344                     "bVisible": AllowCirculate ? true : false,
345                     "mDataProp": function ( oObj ) {
346                         var content = "";
347                         var span_style = "";
348                         var span_class = "";
349
350                         content += "<span>";
351                         content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>";
352
353                         if ( oObj.can_renew ) {
354                             // Do nothing
355                         } else if ( oObj.can_renew_error == "on_reserve" ) {
356                             content += "<span class='renewals-disabled-no-override'>"
357                                     + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"
358                                     + "</span>";
359
360                             span_style = "display: none";
361                             span_class = "renewals-allowed";
362                         } else if ( oObj.can_renew_error == "too_many" ) {
363                             content += "<span class='renewals-disabled'>"
364                                     + NOT_RENEWABLE
365                                     + "</span>";
366
367                             span_style = "display: none";
368                             span_class = "renewals-allowed";
369                         } else if ( oObj.can_renew_error == "restriction" ) {
370                             content += "<span class='renewals-disabled'>"
371                                     + NOT_RENEWABLE_RESTRICTION
372                                     + "</span>";
373
374                             span_style = "display: none";
375                             span_class = "renewals-allowed";
376                         } else if ( oObj.can_renew_error == "overdue" ) {
377                             content += "<span class='renewals-disabled'>"
378                                     + NOT_RENEWABLE_OVERDUE
379                                     + "</span>";
380
381                             span_style = "display: none";
382                             span_class = "renewals-allowed";
383                         } else if ( oObj.can_renew_error == "too_soon" ) {
384                             content += "<span class='renewals-disabled'>"
385                                     + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date )
386                                     + "</span>";
387
388                             span_style = "display: none";
389                             span_class = "renewals-allowed";
390                         } else if ( oObj.can_renew_error == "auto_too_soon" ) {
391                             content += "<span class='renewals-disabled'>"
392                                     + NOT_RENEWABLE_AUTO_TOO_SOON
393                                     + "</span>";
394
395                             span_style = "display: none";
396                             span_class = "renewals-allowed";
397                         } else if ( oObj.can_renew_error == "auto_too_late" ) {
398                             content += "<span class='renewals-disabled'>"
399                                     + NOT_RENEWABLE_AUTO_TOO_LATE
400                                     + "</span>";
401
402                             span_style = "display: none";
403                             span_class = "renewals-allowed";
404                         } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) {
405                             content += "<span class='renewals-disabled'>"
406                                     + NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING
407                                     + "</span>";
408
409                             span_style = "display: none";
410                             span_class = "renewals-allowed";
411                         } else if ( oObj.can_renew_error == "auto_account_expired" ) {
412                             content += "<span class='renewals-disabled'>"
413                                     + NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED
414                                     + "</span>";
415
416                             span_style = "display: none";
417                             span_class = "renewals-allowed";
418                         } else if ( oObj.can_renew_error == "auto_renew" ) {
419                             content += "<span class='renewals-disabled'>"
420                                     + NOT_RENEWABLE_AUTO_RENEW
421                                     + "</span>";
422
423                             span_style = "display: none";
424                             span_class = "renewals-allowed";
425                         } else if ( oObj.can_renew_error == "onsite_checkout" ) {
426                             // Don't display something if it's an onsite checkout
427                         } else {
428                             content += "<span class='renewals-disabled'>"
429                                     + oObj.can_renew_error
430                                     + "</span>";
431
432                             span_style = "display: none";
433                             span_class = "renewals-allowed";
434                         }
435
436                         var can_force_renew = ( oObj.onsite_checkout == 0 ) && ( oObj.can_renew_error != "on_reserve" );
437                         var can_renew = ( oObj.renewals_remaining > 0  && !oObj.can_renew_error );
438                         if ( can_renew || can_force_renew ) {
439                             content += "<span class='" + span_class + "' style='" + span_style + "'>"
440                                     +  "<input type='checkbox' ";
441                             if ( oObj.date_due_overdue && can_renew ) {
442                                 content += "checked='checked' ";
443                             }
444                             content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>"
445                                     +  "</span>";
446
447                             content += "<span class='renewals'>("
448                                     + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed )
449                                     + ")</span>";
450                         }
451
452                         content += "</span>";
453
454                         return content;
455                     }
456                 },
457                 {
458                     "bSortable": false,
459                     "bVisible": AllowCirculate ? true : false,
460                     "mDataProp": function ( oObj ) {
461                         if ( oObj.can_renew_error == "on_reserve" ) {
462                             return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>";
463                         } else {
464                             return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>";
465                         }
466                     }
467                 },
468                 {
469                     "bVisible": exports_enabled == 1 ? true : false,
470                     "bSortable": false,
471                     "mDataProp": function ( oObj ) {
472                         var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />";
473
474                         s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />";
475                         return s;
476                     }
477                 }
478             ],
479             "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
480                 var total_charge = 0;
481                 var total_fine  = 0;
482                 var total_price = 0;
483                 for ( var i=0; i < aaData.length; i++ ) {
484                     total_charge += aaData[i]['charge'] * 1;
485                     total_fine += aaData[i]['fine'] * 1;
486                     total_price  += aaData[i]['price'] * 1;
487                 }
488                 $("#totaldue").html(total_charge.toFixed(2));
489                 $("#totalfine").html(total_fine.toFixed(2));
490                 $("#totalprice").html(total_price.toFixed(2));
491             },
492             "bPaginate": false,
493             "bProcessing": true,
494             "bServerSide": false,
495             "sAjaxSource": '/cgi-bin/koha/svc/checkouts',
496             "fnServerData": function ( sSource, aoData, fnCallback ) {
497                 aoData.push( { "name": "borrowernumber", "value": borrowernumber } );
498
499                 $.getJSON( sSource, aoData, function (json) {
500                     fnCallback(json)
501                 } );
502             },
503             "fnInitComplete": function(oSettings, json) {
504                 // Disable rowGrouping plugin after first use
505                 // so any sorting on the table doesn't use it
506                 var oSettings = issuesTable.fnSettings();
507
508                 for (f = 0; f < oSettings.aoDrawCallback.length; f++) {
509                     if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') {
510                         oSettings.aoDrawCallback.splice(f, 1);
511                         break;
512                     }
513                 }
514
515                 oSettings.aaSortingFixed = null;
516
517                 // Build a summary of checkouts grouped by itemtype
518                 var checkoutsByItype = json.aaData.reduce(function (obj, row) {
519                     obj[row.itemtype_description] = (obj[row.itemtype_description] || 0) + 1;
520                     return obj;
521                 }, {});
522                 var ul = $('<ul>');
523                 Object.keys(checkoutsByItype).sort().forEach(function (itype) {
524                     var li = $('<li>')
525                         .append($('<strong>').html(itype || MSG_NO_ITEMTYPE))
526                         .append(': ' + checkoutsByItype[itype]);
527                     ul.append(li);
528                 })
529                 $('<details>')
530                     .addClass('checkouts-by-itemtype')
531                     .append($('<summary>').html(MSG_CHECKOUTS_BY_ITEMTYPE))
532                     .append(ul)
533                     .insertBefore(oSettings.nTableWrapper)
534             },
535         }, columns_settings).rowGrouping(
536             {
537                 iGroupingColumnIndex: 1,
538                 iGroupingOrderByColumnIndex: 0,
539                 sGroupingColumnSortDirection: "asc"
540             }
541         );
542
543         if ( $("#issues-table").length ) {
544             $("#issues-table_processing").position({
545                 of: $( "#issues-table" ),
546                 collision: "none"
547             });
548         }
549     }
550
551     // Don't load relatives' issues table unless it is clicked on
552     var relativesIssuesTable;
553     $("#relatives-issues-tab").click( function() {
554         if ( ! relativesIssuesTable ) {
555             relativesIssuesTable = $("#relatives-issues-table").dataTable({
556                 "bAutoWidth": false,
557                 "sDom": "rt",
558                 "aaSorting": [],
559                 "aoColumns": [
560                     {
561                         "mDataProp": "date_due",
562                         "bVisible": false,
563                     },
564                     {
565                         "iDataSort": 1, // Sort on hidden unformatted date due column
566                         "mDataProp": function( oObj ) {
567                             var today = new Date();
568                             var due = new Date( oObj.date_due );
569                             if ( today > due ) {
570                                 return "<span class='overdue'>" + oObj.date_due_formatted + "</span>";
571                             } else {
572                                 return oObj.date_due_formatted;
573                             }
574                         }
575                     },
576                     {
577                         "mDataProp": function ( oObj ) {
578                             title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
579                                   + oObj.biblionumber
580                                   + "'>"
581                                   + oObj.title.escapeHtml();
582
583                             $.each(oObj.subtitle, function( index, value ) {
584                                       title += " " + value.subfield.escapeHtml();
585                             });
586
587                             if ( oObj.enumchron ) {
588                                 title += " (" + oObj.enumchron.escapeHtml() + ")";
589                             }
590
591                             title += "</a></span>";
592
593                             if ( oObj.author ) {
594                                 title += " " + BY.replace( "_AUTHOR_", " " + oObj.author.escapeHtml() );
595                             }
596
597                             if ( oObj.itemnotes ) {
598                                 var span_class = "";
599                                 if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
600                                     span_class = "circ-hlt";
601                                 }
602                                 title += " - <span class='" + span_class + "'>" + oObj.itemnotes.escapeHtml() + "</span>"
603                             }
604
605                             if ( oObj.itemnotes_nonpublic ) {
606                                 var span_class = "";
607                                 if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
608                                     span_class = "circ-hlt";
609                                 }
610                                 title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic.escapeHtml() + "</span>"
611                             }
612
613                             var onsite_checkout = '';
614                             if ( oObj.onsite_checkout == 1 ) {
615                                 onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
616                             }
617
618                             title += " "
619                                   + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
620                                   + oObj.biblionumber
621                                   + "&itemnumber="
622                                   + oObj.itemnumber
623                                   + "#"
624                                   + oObj.itemnumber
625                                   + "'>"
626                                   + oObj.barcode.escapeHtml()
627                                   + "</a>"
628                                   + onsite_checkout;
629
630                             return title;
631                         },
632                         "sType": "anti-the"
633                     },
634                     {
635                         "mDataProp": function ( oObj ) {
636                             return oObj.itemtype_description.escapeHtml();
637                         }
638                     },
639                     {
640                         "mDataProp": function ( oObj ) {
641                             return oObj.ccode.escapeHtml();
642                         }
643                     },
644                     {
645                         "mDataProp": function ( oObj ) {
646                             return oObj.location.escapeHtml();
647                         }
648                     },
649                     { "mDataProp": "issuedate_formatted" },
650                     {
651                         "mDataProp": function ( oObj ) {
652                             return oObj.branchname.escapeHtml();
653                         }
654                     },
655                     {
656                         "mDataProp": function ( oObj ) {
657                             return oObj.itemcallnumber.escapeHtml();
658                         }
659                     },
660                     {
661                         "mDataProp": function ( oObj ) {
662                             if ( ! oObj.charge ) oObj.charge = 0;
663                             return parseFloat(oObj.charge).toFixed(2);
664                         }
665                     },
666                     {
667                         "mDataProp": function ( oObj ) {
668                             if ( ! oObj.fine ) oObj.fine = 0;
669                             return parseFloat(oObj.fine).toFixed(2);
670                         }
671                     },
672                     {
673                         "mDataProp": function ( oObj ) {
674                             if ( ! oObj.price ) oObj.price = 0;
675                             return parseFloat(oObj.price).toFixed(2);
676                         }
677                     },
678                     {
679                         "mDataProp": function( oObj ) {
680                             return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>"
681                                 + oObj.borrower.firstname.escapeHtml()
682                                 + " " +
683                                 oObj.borrower.surname.escapeHtml()
684                                 + " (" + oObj.borrower.cardnumber.escapeHtml() + ")</a>"
685                         }
686                     },
687                 ],
688                 "bPaginate": false,
689                 "bProcessing": true,
690                 "bServerSide": false,
691                 "sAjaxSource": '/cgi-bin/koha/svc/checkouts',
692                 "fnServerData": function ( sSource, aoData, fnCallback ) {
693                     $.each(relatives_borrowernumbers, function( index, value ) {
694                         aoData.push( { "name": "borrowernumber", "value": value } );
695                     });
696
697                     $.getJSON( sSource, aoData, function (json) {
698                         fnCallback(json)
699                     } );
700                 },
701             });
702         }
703     });
704
705     if ( $("#relatives-issues-table").length ) {
706         $("#relatives-issues-table_processing").position({
707             of: $( "#relatives-issues-table" ),
708             collision: "none"
709         });
710     }
711
712     if ( AllowRenewalLimitOverride ) {
713         $( '#override_limit' ).click( function () {
714             if ( this.checked ) {
715                 $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
716             } else {
717                 $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
718             }
719         } ).prop('checked', false);
720     }
721  });