X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Foverdue.pl;h=cef345cbffb5207f7844e883b304f9b5b914b9d9;hb=a469663d7b0993894582759235c2475f662c8da4;hp=e59961a3027d85a0938a072cfedaa7e8be4b5473;hpb=e12fca0eb8330adbe230c435a55e88696409bfbd;p=koha_fer diff --git a/circ/overdue.pl b/circ/overdue.pl index e59961a302..cef345cbff 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -28,8 +28,9 @@ 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') || ''; @@ -42,6 +43,14 @@ my $branchfilter = $input->param('branch') || ''; 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"; @@ -212,7 +221,6 @@ $template->param( borname => $bornamefilter, order => $order, showall => $showall, - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), dateduefrom => $input->param( 'dateduefrom' ) || '', datedueto => $input->param( 'datedueto' ) || '', ); @@ -229,7 +237,9 @@ if ($noreport) { # 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; @@ -256,7 +266,8 @@ if ($noreport) { 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) @@ -274,7 +285,15 @@ if ($noreport) { $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 date_due < '" . $datedueto . "' " if $datedueto; $strsth.=" AND date_due > '" . $dateduefrom . "' " if $dateduefrom; @@ -309,9 +328,10 @@ if ($noreport) { 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}, itemnum => $data->{itemnumber}, @@ -334,6 +354,7 @@ if ($noreport) { branchcode => $data->{branchcode}, itemcallnumber => $data->{itemcallnumber}, replacementprice => $data->{replacementprice}, + enumchron => $data->{enumchron}, patron_attr_value_loop => \@patron_attr_value_loop, }; } @@ -379,7 +400,7 @@ if ($noreport) { $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, @@ -403,7 +424,7 @@ sub build_csv { 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);