From 93af9b8cf6c1127e71bc881cb231198fed313880 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 21 Apr 2014 07:33:33 -0400 Subject: [PATCH] Bug 11703 [QA Followup] - Retain functionality of IssuesDefaultSortOrder system preferences --- koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 1 - svc/checkouts.pl | 102 +++++++++++++---------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index 01098c9..9ac9c3d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -129,7 +129,6 @@ $(document).ready(function() { issuesTable = $("#issues-table").dataTable({ "bAutoWidth": false, "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t", - "aaSorting": [[ 0, "desc" ]], "aoColumns": [ { "mDataProp": function( oObj ) { diff --git a/svc/checkouts.pl b/svc/checkouts.pl index ed4d0ff..dedec01 100755 --- a/svc/checkouts.pl +++ b/svc/checkouts.pl @@ -81,7 +81,9 @@ my $sql = ' borrowernumber, surname, firstname, - cardnumber + cardnumber, + + DATEDIFF( issuedate, CURRENT_DATE() ) AS not_issued_today FROM issues LEFT JOIN items USING ( itemnumber ) LEFT JOIN biblio USING ( biblionumber ) @@ -107,7 +109,8 @@ $sth->execute(@parameters); my $item_level_itypes = C4::Context->preference('item-level_itypes'); -my @checkouts; +my @checkouts_today; +my @checkouts_previous; while ( my $c = $sth->fetchrow_hashref() ) { my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} ); @@ -116,52 +119,63 @@ while ( my $c = $sth->fetchrow_hashref() ) { my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); - push( - @checkouts, - { - DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, - title => $c->{title}, - author => $c->{author}, - barcode => $c->{barcode}, - itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, - itemnotes => $c->{itemnotes}, - branchcode => $c->{branchcode}, - branchname => $c->{branchname}, - itemcallnumber => $c->{itemcallnumber} || q{}, - charge => $charge, - price => $c->{replacementprice} || q{}, - can_renew => $can_renew, - can_renew_error => $can_renew_error, - itemnumber => $c->{itemnumber}, - borrowernumber => $c->{borrowernumber}, - biblionumber => $c->{biblionumber}, - issuedate => $c->{issuedate}, - date_due => $c->{date_due}, - renewals_count => $renewals_count, - renewals_allowed => $renewals_allowed, - renewals_remaining => $renewals_remaining, - issuedate_formatted => - output_pref( dt_from_string( $c->{issuedate} ) ), - date_due_formatted => output_pref( - { - dt => dt_from_string( $c->{date_due} ), - as_due_date => 1 - } - ), - subtitle => GetRecordValue( - 'subtitle', - GetMarcBiblio( $c->{biblionumber} ), - GetFrameworkCode( $c->{biblionumber} ) - ), - borrower => { - surname => $c->{surname}, - firstname => $c->{firstname}, - cardnumber => $c->{cardnumber}, + + my $checkout = { + DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, + title => $c->{title}, + author => $c->{author}, + barcode => $c->{barcode}, + itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, + itemnotes => $c->{itemnotes}, + branchcode => $c->{branchcode}, + branchname => $c->{branchname}, + itemcallnumber => $c->{itemcallnumber} || q{}, + charge => $charge, + price => $c->{replacementprice} || q{}, + can_renew => $can_renew, + can_renew_error => $can_renew_error, + itemnumber => $c->{itemnumber}, + borrowernumber => $c->{borrowernumber}, + biblionumber => $c->{biblionumber}, + issuedate => $c->{issuedate}, + date_due => $c->{date_due}, + renewals_count => $renewals_count, + renewals_allowed => $renewals_allowed, + renewals_remaining => $renewals_remaining, + issuedate_formatted => output_pref( dt_from_string( $c->{issuedate} ) ), + date_due_formatted => output_pref( + { + dt => dt_from_string( $c->{date_due} ), + as_due_date => 1 } + ), + subtitle => GetRecordValue( + 'subtitle', + GetMarcBiblio( $c->{biblionumber} ), + GetFrameworkCode( $c->{biblionumber} ) + ), + borrower => { + surname => $c->{surname}, + firstname => $c->{firstname}, + cardnumber => $c->{cardnumber}, } - ); + }; + + if ( $c->{not_issued_today} ) { + push( @checkouts_previous, $checkout ); + } + else { + push( @checkouts_today, $checkout ); + } } +@checkouts_today = reverse(@checkouts_today) + if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' ); +@checkouts_previous = reverse(@checkouts_previous) + if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' ); + +my @checkouts = ( @checkouts_today, @checkouts_previous ); + my $data; $data->{'iTotalRecords'} = scalar @checkouts; #FIXME $data->{'iTotalDisplayRecords'} = scalar @checkouts; -- 1.7.2.5