$(document).ready(function() { // Don't load holds table unless it is clicked on var holdsTable; $("#holds-tab").click( function() { if ( ! holdsTable ) { holdsTable = $("#holds-table").dataTable({ "bAutoWidth": false, "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t", "aoColumns": [ { "mDataProp": "reservedate_formatted" }, { "mDataProp": function ( oObj ) { title = "" + oObj.title; $.each(oObj.subtitle, function( index, value ) { title += " " + value.subfield; }); title += ""; if ( oObj.author ) { title += " " + BY.replace( "_AUTHOR_", oObj.author ); } if ( oObj.itemnotes ) { var span_class = ""; if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { span_class = "circ-hlt"; } title += " - " + oObj.itemnotes + "" } return title; } }, { "mDataProp": function( oObj ) { return oObj.itemcallnumber || ""; } }, { "mDataProp": function( oObj ) { var data = ""; if ( oObj.suspend == 1 ) { data += "

" + HOLD_IS_SUSPENDED; if ( oObj.suspend_until ) { data += " " + UNTIL.format( oObj.suspend_until_formatted ); } data += "

"; } if ( oObj.barcode ) { data += ""; if ( oObj.found == "W" ) { data += ITEM_IS_WAITING; if ( ! oObj.waiting_here ) { data += " " + AT.format( oObj.waiting_at ); } } else if ( oObj.transferred ) { data += ITEM_IS_IN_TRANSIT.format( oObj.from_branch ); } else if ( oObj.not_transferred ) { data += NOT_TRANSFERRED_YET.format( oObj.not_transferred_by ); } data += ""; data += " " + oObj.barcode + ""; } return data; } }, { "mDataProp": "expirationdate_formatted" }, { "mDataProp": function( oObj ) { if ( oObj.priority && parseInt( oObj.priority ) && parseInt( oObj.priority ) > 0 ) { return oObj.priority; } else { return ""; } } }, { "bSortable": false, "mDataProp": function( oObj ) { return "" + "" + "" + ""; } } ], "bPaginate": false, "bProcessing": true, "bServerSide": false, "sAjaxSource": '/cgi-bin/koha/svc/holds', "fnServerData": function ( sSource, aoData, fnCallback ) { aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); $.getJSON( sSource, aoData, function (json) { fnCallback(json) } ); }, }); if ( $("#holds-table").length ) { $("#holds-table_processing").position({ of: $( "#holds-table" ), collision: "none" }); } } }); });