Koha/circ/ypattrodue-attr-search-authvalue.pl
Galen Charlton ab44e2986a bug 2866: Overdues Reports - Upgrading to filter by patron extended attributes
Patch by Rick Welykochy <rick@praxis.com.au> with some squashing
by me.

Bug Report: 2866 Filtering and sorting the overdue report using patron attributes

1. Create a new system preference ?FilterBeforeOverdueReport?
2. Option to filter *before* the overdue report runs, avoiding report slowness
3. Add searchable patron attributes to the list of overdue report filters
4. Add searchable patron attributes to the sort fields on the overdue report
5. add item call number and replacement price
6. the CSV download link now returns the same
   data as the web report, rather than (inconsistently)
   trying to run the overdue_notices.pl batch job
7. always run report if requesting CSV
8. barcodes are now links
9. use item-level item type for overdue itemtype filter

Included is a new callback for searching patron attributes, similar
to circ/ysearch.pl.

The following additional bugs are fixed:

2748: Nothing is output to the .csv file for the "Overdues" circulation report

This is fixed by having circ/overdues.pl produce the CSV output directly instead
of trying to call the overdues cronjob.  The CSV output includes all of the fields
that are displayed on the web table plus the item replacement price and any extended
patron attributes.

2836: overdues.csv may contain HTML
2837: Descending sort doesn't descend on the overdues report plus other probs with report

This enhancement was sponsored by the Plano Independent School District.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
2009-05-28 19:20:36 -05:00

52 lines
1.8 KiB
Perl
Executable file

#!/usr/bin/perl
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use warnings;
use CGI;
use C4::Context;
use C4::Auth qw/check_cookie_auth/;
use C4::Debug;
my $input = new CGI;
my $query = $input->param('query');
my $attrcode = $input->path_info || '';
$attrcode =~ s|^/||;
my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } );
exit 0 if $auth_status ne "ok";
binmode STDOUT, ":utf8";
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
print STDERR ">> CALLING $0 (attrcode=$attrcode, query=$query)\n" if $debug;
my $dbh = C4::Context->dbh;
my $sql = qq(SELECT authorised_value, lib description
FROM borrower_attribute_types b, authorised_values v
WHERE b.code=?
AND b.authorised_value_category = v.category
AND v.lib like ?);
my $sth = $dbh->prepare($sql);
$sth->execute( $attrcode, "$query%" );
while ( my $rec = $sth->fetchrow_hashref ) {
print STDERR ">> attrcode=$attrcode match '$query' ==> $rec->{description} ($rec->{authorised_value})\n" if $debug;
print "$rec->{description}\t$rec->{authorised_value}\n";
}