Bug 8548: Add datatable to circ overdue report, remove sortby filter

This patch adds a datatable to the circ overdue report. Since the
datatable makes sorting easy, I've also removed the sort by filter on
the side.

To test:
1) Go to Circulation -> Overdues
2) Notice overdues report shows as datatable
3) Confirm sorting on all columns works
4) Test the Filters and confirm they all still work as expected

Sponsored-by: Catalyst IT
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>

Followed test plan, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Aleisha Amohia 2017-02-14 01:36:44 +00:00 committed by Kyle M Hall
parent 72de37e24b
commit b041dfa180
2 changed files with 9 additions and 85 deletions

View file

@ -31,7 +31,6 @@ use DateTime;
use DateTime::Format::MySQL;
my $input = new CGI;
my $order = $input->param('order') || '';
my $showall = $input->param('showall');
my $bornamefilter = $input->param('borname') || '';
my $borcatfilter = $input->param('borcat') || '';
@ -105,20 +104,6 @@ for my $attrcode (grep { /^patron_attr_filter_/ } $input->multi_param) {
my $have_pattr_filter_data = keys(%cgi_attrcode_to_attrvalues) > 0;
my @patron_attr_filter_loop; # array of [ domid cgivalue ismany isclone ordinal code description repeatable authorised_value_category ]
my @patron_attr_order_loop; # array of { label => $patron_attr_label, value => $patron_attr_order }
my @sort_roots = qw(borrower title barcode date_due);
push @sort_roots, map {$_ . " desc"} @sort_roots;
my @order_loop = ({selected => $order ? 0 : 1}); # initial blank row
foreach (@sort_roots) {
my $tmpl_name = $_;
$tmpl_name =~ s/\s/_/g;
push @order_loop, {
selected => $order eq $_ ? 1 : 0,
ordervalue => $_,
'order_' . $tmpl_name => 1,
};
}
my $sth = $dbh->prepare('SELECT code,description,repeatable,authorised_value_category
FROM borrower_attribute_types
@ -139,19 +124,7 @@ while (my $row = $sth->fetchrow_hashref) {
$row->{isclone} = $isclone;
push @patron_attr_filter_loop, { %$row }; # careful: must store a *deep copy* of the modified row
} continue { $isclone = 1, ++$serial }
foreach my $sortorder ('asc', 'desc') {
my $ordervalue = "patron_attr_${sortorder}_${code}";
push @order_loop, {
selected => $order eq $ordervalue ? 1 : 0,
ordervalue => $ordervalue,
label => $row->{description},
$sortorder => 1,
};
}
} continue { ++$ordinal }
for (@patron_attr_order_loop) { $_->{selected} = 1 if $order eq $_->{value} }
$template->param(ORDER_LOOP => \@order_loop);
my %borrowernumber_to_attributes; # hash of { borrowernumber => { attrcode => [ [val,display], [val,display], ... ] } }
# i.e. val differs from display when attr is an authorised value
@ -213,7 +186,6 @@ $template->param(
itemtypeloop => \@itemtypeloop,
patron_attr_filter_loop => \@patron_attr_filter_loop,
borname => $bornamefilter,
order => $order,
showall => $showall,
dateduefrom => $dateduefrom,
datedueto => $datedueto,
@ -300,14 +272,7 @@ if ($noreport) {
my $bnlist = $have_pattr_filter_data ? join(',',keys %borrowernumber_to_attributes) : '';
$strsth =~ s/WHERE 1=1/WHERE 1=1 AND borrowers.borrowernumber IN ($bnlist)/ if $bnlist;
$strsth =~ s/WHERE 1=1/WHERE 0=1/ if $have_pattr_filter_data && !$bnlist; # no match if no borrowers matched patron attrs
$strsth.=" ORDER BY " . (
($order eq "borrower") ? "surname, firstname, date_due" :
($order eq "borrower desc") ? "surname desc, firstname desc, date_due" :
($order eq "title" or $order eq "title desc") ? "$order, date_due, surname, firstname" :
($order eq "barcode" or $order eq "barcode desc") ? "items.$order, date_due, surname, firstname" :
($order eq "date_due desc") ? "date_due DESC, surname, firstname" :
"date_due, surname, firstname" # default sort order
);
$strsth.=" ORDER BY date_due, surname, firstname";
$template->param(sql=>$strsth);
my $sth=$dbh->prepare($strsth);
$sth->execute(
@ -363,29 +328,6 @@ if ($noreport) {
};
}
my ($attrorder) = $order =~ /patron_attr_(.*)$/;
my $patrorder = '';
my $sortorder = 'asc';
if (defined $attrorder) {
($sortorder, $patrorder) = split /_/, $attrorder, 2;
}
print STDERR ">>> order is $order, patrorder is $patrorder, sortorder is $sortorder\n" if $debug;
if (my @attrtype = grep { $_->{'code'} eq $patrorder } @patron_attr_filter_loop) { # sort by patron attrs perhaps?
my $ordinal = $attrtype[0]{ordinal};
print STDERR ">>> sort ordinal is $ordinal\n" if $debug;
sub patronattr_sorter_asc {
lc $a->{patron_attr_value_loop}[$ordinal]{value}
cmp
lc $b->{patron_attr_value_loop}[$ordinal]{value} }
sub patronattr_sorter_des { -patronattr_sorter_asc() }
my $sorter = $sortorder eq 'desc' ? \&patronattr_sorter_des : \&patronattr_sorter_asc;
@overduedata = sort $sorter @overduedata;
}
if ($op eq 'csv') {
binmode(STDOUT, ":encoding(UTF-8)");
my $csv = build_csv(\@overduedata);

View file

@ -3,6 +3,8 @@
<title>Koha &rsaquo; Circulation &rsaquo; Items overdue as of [% todaysdate %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
[%- USE Branches -%]
<script type="text/javascript">
//<![CDATA[
@ -59,6 +61,12 @@
};
});
}
$(document).ready(function(){
$("#overduest").dataTable($.extend(true, {}, dataTablesDefaults, {
"sPaginationType": "four_button"
}));
});
//]]>
</script>
<style type="text/css">
@ -233,32 +241,6 @@
</select>
</li>
<li><label for="order">Sort by:</label> <select name="order" id="order">
[% FOREACH ORDER_LOO IN ORDER_LOOP %]
[% IF ( ORDER_LOO.selected ) %]
<option value="[% ORDER_LOO.ordervalue %]" selected="selected">
[% ELSE %]
<option value="[% ORDER_LOO.ordervalue %]">
[% END %]
[% IF ( ORDER_LOO.order_date_due ) %]Due date
[% ELSIF ( ORDER_LOO.order_borrower ) %]Patron
[% ELSIF ( ORDER_LOO.order_barcode ) %]Barcode
[% ELSIF ( ORDER_LOO.order_title ) %]Title
[% ELSIF ( ORDER_LOO.order_date_due_desc ) %]Due date desc
[% ELSIF ( ORDER_LOO.order_borrower_desc ) %]Patron desc
[% ELSIF ( ORDER_LOO.order_barcode_desc ) %]Barcode desc
[% ELSIF ( ORDER_LOO.order_title_desc ) %]Title desc
[% ELSE %][% ORDER_LOO.label %]
[% IF ( ORDER_LOO.desc ) %]desc[% END %]
[% END %]
</option>
[% END %]
[% FOREACH patron_attr_order_loo IN patron_attr_order_loop %]
[% IF ( patron_attr_order_loo.selected ) %]<option value="[% patron_attr_order_loo.value |html %]" selected="selected">[% patron_attr_order_loo.label %]</option>
[% ELSE %]<option value="[% patron_attr_order_loo.value |html %]">[% patron_attr_order_loo.label %]</option>[% END %]
[% END %]
</select></li>
<li class="radio"><label for="showall">Show any items currently checked out:</label>
[% IF ( showall ) %]
<input type="checkbox" id="showall" name="showall" value="show" checked="checked" />