#
# 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 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 3 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.
+# 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.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use C4::Context;
use C4::Output;
-use CGI qw(-oldstyle_urls);
+use CGI qw(-oldstyle_urls -utf8);
use C4::Auth;
use C4::Branch;
use C4::Debug;
use C4::Dates qw/format_date format_date_in_iso/;
-use Date::Calc qw/Today/;
use Text::CSV_XS;
+use Koha::DateUtils;
+use DateTime;
my $input = new CGI;
my $order = $input->param('order') || '';
my $itemtypefilter = $input->param('itemtype') || '';
my $borflagsfilter = $input->param('borflag') || '';
my $branchfilter = $input->param('branch') || '';
+my $homebranchfilter = $input->param('homebranch') || '';
+my $holdingbranchfilter = $input->param('holdingbranch') || '';
my $op = $input->param('op') || '';
my $dateduefrom = format_date_in_iso($input->param( 'dateduefrom' )) || '';
my $datedueto = format_date_in_iso($input->param( 'datedueto' )) || '';
+# FIXME This is a kludge to include times
+if ($datedueto) {
+ $datedueto .= ' 23:59';
+}
+if ($dateduefrom) {
+ $dateduefrom .= ' 00:00';
+}
+# kludge end
my $isfiltered = $op =~ /apply/i && $op =~ /filter/i;
my $noreport = C4::Context->preference('FilterBeforeOverdueReport') && ! $isfiltered && $op ne "csv";
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
- template_name => "circ/overdue.tmpl",
+ template_name => "circ/overdue.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { reports => 1, circulate => "circulate_remaining_permissions" },
+ flagsrequired => { circulate => "overdues_report" },
debug => 1,
}
);
itemtypename => $description,
};
}
-my $onlymine=C4::Context->preference('IndependantBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags} % 2 !=1 &&
- C4::Context->userenv->{branch};
+my $onlymine =
+ C4::Context->preference('IndependentBranches')
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{branch};
$branchfilter = C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
$template->param(
patron_attr_header_loop => [ map { { header => $_->{description} } } grep { ! $_->{isclone} } @patron_attr_filter_loop ],
branchloop => GetBranchesLoop($branchfilter, $onlymine),
+ homebranchloop => GetBranchesLoop( $homebranchfilter, $onlymine ),
+ holdingbranchloop => GetBranchesLoop( $holdingbranchfilter, $onlymine ),
branchfilter => $branchfilter,
+ homebranchfilter => $homebranchfilter,
+ holdingbranchfilter => $homebranchfilter,
borcatloop=> \@borcatloop,
itemtypeloop => \@itemtypeloop,
patron_attr_filter_loop => \@patron_attr_filter_loop,
borname => $bornamefilter,
order => $order,
showall => $showall,
- DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
dateduefrom => $input->param( 'dateduefrom' ) || '',
datedueto => $input->param( 'datedueto' ) || '',
);
# FIX 2: ensure there are indexes for columns participating in the WHERE clauses, where feasible/reasonable
- my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Today());
+ my $today_dt = DateTime->now(time_zone => C4::Context->tz);
+ $today_dt->truncate(to => 'minute');
+ my $todaysdate = $today_dt->strftime('%Y-%m-%d %H:%M');
$bornamefilter =~s/\*/\%/g;
$bornamefilter =~s/\?/\_/g;
borrowers.country,
borrowers.phone,
borrowers.email,
+ borrowers.cardnumber,
issues.itemnumber,
issues.issuedate,
items.barcode,
+ items.homebranch,
+ items.holdingbranch,
biblio.title,
biblio.author,
borrowers.borrowernumber,
biblio.biblionumber,
borrowers.branchcode,
items.itemcallnumber,
- items.replacementprice
+ items.replacementprice,
+ items.enumchron
FROM issues
LEFT JOIN borrowers ON (issues.borrowernumber=borrowers.borrowernumber )
LEFT JOIN items ON (issues.itemnumber=items.itemnumber)
$strsth.=" AND biblioitems.itemtype = '" . $itemtypefilter . "' ";
}
}
- $strsth.=" AND borrowers.flags = '" . $borflagsfilter . "' " if $borflagsfilter;
+ if ( $borflagsfilter eq 'gonenoaddress' ) {
+ $strsth .= " AND borrowers.gonenoaddress <> 0";
+ }
+ elsif ( $borflagsfilter eq 'debarred' ) {
+ $strsth .= " AND borrowers.debarred >= CURDATE()" ;
+ }
+ elsif ( $borflagsfilter eq 'lost') {
+ $strsth .= " AND borrowers.lost <> 0";
+ }
$strsth.=" AND borrowers.branchcode = '" . $branchfilter . "' " if $branchfilter;
+ $strsth.=" AND items.homebranch = '" . $homebranchfilter . "' " if $homebranchfilter;
+ $strsth.=" AND items.holdingbranch = '" . $holdingbranchfilter . "' " if $holdingbranchfilter;
$strsth.=" AND date_due < '" . $datedueto . "' " if $datedueto;
$strsth.=" AND date_due > '" . $dateduefrom . "' " if $dateduefrom;
# restrict patrons (borrowers) to those matching the patron attribute filter(s), if any
my @displayvalues = map { $_->[1] } @{ $pattrs->{$pattr_filter->{code}} }; # grab second value from each subarray
push @patron_attr_value_loop, { value => join(', ', sort { lc $a cmp lc $b } @displayvalues) };
}
+ my $dt = dt_from_string($data->{date_due}, 'sql');
push @overduedata, {
- duedate => format_date($data->{date_due}),
+ duedate => output_pref($dt),
borrowernumber => $data->{borrowernumber},
barcode => $data->{barcode},
+ cardnumber => $data->{cardnumber},
itemnum => $data->{itemnumber},
issuedate => format_date($data->{issuedate}),
borrowertitle => $data->{borrowertitle},
title => $data->{title},
author => $data->{author},
branchcode => $data->{branchcode},
+ homebranchcode => $data->{homebranchcode},
+ holdingbranchcode => $data->{holdingbranchcode},
itemcallnumber => $data->{itemcallnumber},
replacementprice => $data->{replacementprice},
+ enumchron => $data->{enumchron},
patron_attr_value_loop => \@patron_attr_value_loop,
};
}
$template->param(
csv_param_string => $csv_param_string,
- todaysdate => format_date($todaysdate),
+ todaysdate => output_pref($today_dt),
overdueloop => \@overduedata,
nnoverdue => scalar(@overduedata),
noverdue_is_plural => scalar(@overduedata) != 1,
my @lines = ();
# build header ...
- my @keys = qw /duedate title author borrowertitle name phone barcode email address address2 zipcode city country
+ my @keys = qw /duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype/;
my $csv = Text::CSV_XS->new();
$csv->combine(@keys);