X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=koha-tmpl%2Fintranet-tmpl%2Fprog%2Fen%2Fjs%2Fcheckouts.js;h=4c0ba36eefb2106ae754a7a7f2c4631fd4b0b17a;hb=2e72eb888016f60ce15958ecb37e0ae64f0c8454;hp=eca940a2c02d4bdc2b3e3912f1868f1ae82047a2;hpb=0badd2bcb553c5eff0c3652555f577d44bd4d180;p=koha.git diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index eca940a2c0..4c0ba36eef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -1,4 +1,6 @@ $(document).ready(function() { + $.ajaxSetup ({ cache: false }); + // Handle the select all/none links for checkouts table columns $("#CheckAllRenewals").on("click",function(){ $("#UncheckAllCheckins").click(); @@ -55,7 +57,7 @@ $(document).ready(function() { exempt_fine: $("#exemptfine").is(':checked') }; - $.post( "/cgi-bin/koha/svc/checkin.pl", params, function( data ) { + $.post( "/cgi-bin/koha/svc/checkin", params, function( data ) { id = "#checkin_" + data.itemnumber; content = ""; @@ -84,7 +86,7 @@ $(document).ready(function() { date_due: $("#newduedate").val() }; - $.post( "/cgi-bin/koha/svc/renew.pl", params, function( data ) { + $.post( "/cgi-bin/koha/svc/renew", params, function( data ) { var id = "#renew_" + data.itemnumber; var content = ""; @@ -124,216 +126,270 @@ $(document).ready(function() { var ymd = $.datepicker.formatDate('yy-mm-dd', new Date()); - var issuesTable; - var drawn = 0; - issuesTable = $("#issues-table").dataTable({ - "bAutoWidth": false, - "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t", - "aoColumns": [ - { - "mDataProp": function( oObj ) { - if ( oObj.issued_today ) { - return "" + TODAYS_CHECKOUTS + ""; - } else { - return "" + PREVIOUS_CHECKOUTS + ""; - } - } - }, - { - "mDataProp": "date_due", - "bVisible": false, + $('#issues-table').hide(); + $('#issues-table-actions').hide(); + $('#issues-table-load-immediately').change(function(){ + if ( this.checked && typeof issuesTable === 'undefined') { + $('#issues-table-load-now-button').click(); + } + }); + $('#issues-table-load-now-button').click(function(){ + LoadIssuesTable(); + return false; + }); + + if ( $.cookie("issues-table-load-immediately-" + script) == "true" ) { + LoadIssuesTable(); + $('#issues-table-load-immediately').prop('checked', true); + } + $('#issues-table-load-immediately').on( "change", function(){ + $.cookie("issues-table-load-immediately-" + script, $(this).is(':checked')); + }); + + function LoadIssuesTable() { + $('#issues-table-loading-message').hide(); + $('#issues-table').show(); + $('#issues-table-actions').show(); + + issuesTable = $("#issues-table").dataTable({ + "oLanguage": { + "sEmptyTable" : MSG_DT_LOADING_RECORDS, }, - { - "iDataSort": 1, // Sort on hidden unformatted date due column - "mDataProp": function( oObj ) { - var today = new Date(); - var due = new Date( oObj.date_due ); - if ( today > due ) { - return "" + oObj.date_due_formatted + ""; - } else { - return oObj.date_due_formatted; + "bAutoWidth": false, + "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t", + "aoColumns": [ + { + "mDataProp": function( oObj ) { + if ( oObj.issued_today ) { + return "1" + oObj.timestamp; + } else { + return "0" + oObj.date_due; + } } - } - }, - { - "mDataProp": function ( oObj ) { - title = "" - + oObj.title; - - $.each(oObj.subtitle, function( index, value ) { - title += " " + value.subfield; - }); + }, + { + "mDataProp": function( oObj ) { + if ( oObj.issued_today ) { + return "" + TODAYS_CHECKOUTS + ""; + } else { + return "" + PREVIOUS_CHECKOUTS + ""; + } + } + }, + { + "mDataProp": "date_due", + "bVisible": false, + }, + { + "iDataSort": 1, // Sort on hidden unformatted date due column + "mDataProp": function( oObj ) { + if ( oObj.date_due_overdue ) { + return "" + oObj.date_due_formatted + ""; + } else { + return oObj.date_due_formatted; + } + } + }, + { + "mDataProp": function ( oObj ) { + title = "" + + oObj.title; - title += ""; + $.each(oObj.subtitle, function( index, value ) { + title += " " + value.subfield; + }); - if ( oObj.author ) { - title += " " + BY.replace( "_AUTHOR_", " " + oObj.author ); - } + title += ""; - if ( oObj.itemnotes ) { - var span_class = ""; - if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { - span_class = "circ-hlt"; + if ( oObj.author ) { + title += " " + BY.replace( "_AUTHOR_", " " + oObj.author ); } - title += " - " + oObj.itemnotes + "" - } - title += " " - + "" - + oObj.barcode - + ""; - - return title; - } - }, - { "mDataProp": "itemtype" }, - { "mDataProp": "issuedate_formatted" }, - { "mDataProp": "branchname" }, - { "mDataProp": "itemcallnumber" }, - { - "mDataProp": function ( oObj ) { - if ( ! oObj.charge ) oObj.charge = 0; - return parseFloat(oObj.charge).toFixed(2); - } - }, - { - "mDataProp": function ( oObj ) { - if ( ! oObj.price ) oObj.price = 0; - return parseFloat(oObj.price).toFixed(2); - } - }, - { - "bSortable": false, - "mDataProp": function ( oObj ) { - var content = ""; - var span_style = ""; - var span_class = ""; - - content += ""; - content += "" + oObj.renewals_count + ""; - - if ( oObj.can_renew ) { - // Do nothing - } else if ( oObj.can_renew_error == "on_reserve" ) { - content += "" - + "" + ON_HOLD + "" - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_many" ) { - content += "" - + NOT_RENEWABLE - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_soon" ) { - content += "" - + NOT_RENEWABLE_TOO_SOON - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else { - content += "" - + oObj.can_renew_error - + ""; + if ( oObj.itemnotes ) { + var span_class = ""; + if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { + span_class = "circ-hlt"; + } + title += " - " + oObj.itemnotes + "" + } - span_style = "display: none"; - span_class = "renewals-allowed"; + var inhouse_use = ''; + if ( oObj.inhouse_use == 1 ) { + inhouse_use += " (" + INHOUSE_USE + ")"; + } + + title += " " + + "" + + oObj.barcode + + "" + + inhouse_use; + + return title; + } + }, + { "mDataProp": "itemtype" }, + { "mDataProp": "issuedate_formatted" }, + { "mDataProp": "branchname" }, + { "mDataProp": "itemcallnumber" }, + { + "mDataProp": function ( oObj ) { + if ( ! oObj.charge ) oObj.charge = 0; + return parseFloat(oObj.charge).toFixed(2); + } + }, + { + "mDataProp": function ( oObj ) { + if ( ! oObj.price ) oObj.price = 0; + return parseFloat(oObj.price).toFixed(2); } + }, + { + "bSortable": false, + "mDataProp": function ( oObj ) { + var content = ""; + var span_style = ""; + var span_class = ""; - content += "" - + "" - + ""; + content += ""; + content += "" + oObj.renewals_count + ""; + + if ( oObj.can_renew ) { + // Do nothing + } else if ( oObj.can_renew_error == "on_reserve" ) { + content += "" + + "" + ON_HOLD + "" + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "too_many" ) { + content += "" + + NOT_RENEWABLE + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "too_soon" ) { + content += "" + + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "auto_too_soon" ) { + content += "" + + NOT_RENEWABLE_AUTO_TOO_SOON + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "auto_renew" ) { + content += "" + + NOT_RENEWABLE_AUTO_RENEW + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else { + content += "" + + oObj.can_renew_error + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } - if ( oObj.renewals_remaining ) { - content += "(" - + RENEWALS_REMAINING.replace( "_RENEWALS_REMAINING_", oObj.renewals_remaining ).replace( "_RENEWALS_ALLOWED_", oObj.renewals_allowed ) - + ")"; - } + content += "" + + "" + + ""; - content += ""; + if ( oObj.renewals_remaining && inhouse_use == 0 ) { + content += "(" + + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) + + ")"; + } + content += ""; - return content; + return content; + } + }, + { + "bSortable": false, + "mDataProp": function ( oObj ) { + if ( oObj.can_renew_error == "on_reserve" ) { + return "" + ON_HOLD + ""; + } else { + return ""; + } + } + }, + { + "bVisible": exports_enabled ? true : false, + "bSortable": false, + "mDataProp": function ( oObj ) { + return ""; + } + } + ], + "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { + var total_charge = 0; + var total_price = 0; + for ( var i=0; i < aaData.length; i++ ) { + total_charge += aaData[i]['charge'] * 1; + total_price += aaData[i]['price'] * 1; } + var nCells = nRow.getElementsByTagName('td'); + nCells[1].innerHTML = total_charge.toFixed(2); + nCells[2].innerHTML = total_price.toFixed(2); }, - { - "bSortable": false, - "mDataProp": function ( oObj ) { - if ( oObj.can_renew_error == "on_reserve" ) { - return "" + ON_HOLD + ""; - } else { - return ""; + "bPaginate": false, + "bProcessing": true, + "bServerSide": false, + "sAjaxSource": '/cgi-bin/koha/svc/checkouts', + "fnServerData": function ( sSource, aoData, fnCallback ) { + aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); + + $.getJSON( sSource, aoData, function (json) { + fnCallback(json) + } ); + }, + "fnInitComplete": function(oSettings) { + // Disable rowGrouping plugin after first use + // so any sorting on the table doesn't use it + var oSettings = issuesTable.fnSettings(); + + for (f = 0; f < oSettings.aoDrawCallback.length; f++) { + if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') { + oSettings.aoDrawCallback.splice(f, 1); + break; } } + + oSettings.aaSortingFixed = null; }, + }).rowGrouping( { - "bVisible": exports_enabled ? true : false, - "bSortable": false, - "mDataProp": function ( oObj ) { - return ""; - } - } - ], - "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { - var total_charge = 0; - var total_price = 0; - for ( var i=0; i < aaData.length; i++ ) { - total_charge += aaData[i]['charge'] * 1; - total_price += aaData[i]['price'] * 1; - } - var nCells = nRow.getElementsByTagName('td'); - nCells[1].innerHTML = total_charge.toFixed(2); - nCells[2].innerHTML = total_price.toFixed(2); - }, - "bPaginate": false, - "bProcessing": true, - "bServerSide": false, - "sAjaxSource": '/cgi-bin/koha/svc/checkouts.pl', - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); - - $.getJSON( sSource, aoData, function (json) { - fnCallback(json) - } ); - }, - "fnInitComplete": function(oSettings) { - // Disable rowGrouping plugin after first use - // so any sorting on the table doesn't use it - var oSettings = issuesTable.fnSettings(); - - for (f = 0; f < oSettings.aoDrawCallback.length; f++) { - if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') { - oSettings.aoDrawCallback.splice(f, 1); - break; - } + iGroupingColumnIndex: 1, + iGroupingOrderByColumnIndex: 0, + sGroupingColumnSortDirection: "desc" } + ); - oSettings.aaSortingFixed = null; - }, - }).rowGrouping( - { - iGroupingOrderByColumnIndex: 0, - sGroupingColumnSortDirection: "desc" + if ( $("#issues-table").length ) { + $("#issues-table_processing").position({ + of: $( "#issues-table" ), + collision: "none" + }); } - ); - - if ( $("#issues-table").length ) { - $("#issues-table_processing").position({ - of: $( "#issues-table" ), - collision: "none" - }); } // Don't load relatives' issues table unless it is clicked on @@ -386,6 +442,11 @@ $(document).ready(function() { title += " - " + oObj.itemnotes + "" } + var inhouse_use = ''; + if ( oObj.inhouse_use == 1 ) { + inhouse_use += " ("+INHOUSE_USE+")"; + } + title += " " + "" + oObj.barcode - + ""; + + "" + + inhouse_use; return title; } @@ -426,7 +488,7 @@ $(document).ready(function() { "bPaginate": false, "bProcessing": true, "bServerSide": false, - "sAjaxSource": '/cgi-bin/koha/svc/checkouts.pl', + "sAjaxSource": '/cgi-bin/koha/svc/checkouts', "fnServerData": function ( sSource, aoData, fnCallback ) { $.each(relatives_borrowernumbers, function( index, value ) { aoData.push( { "name": "borrowernumber", "value": value } );