#!/usr/bin/perl
-
# Copyright 2000-2002 Katipo Communications
#
# 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; FIXME - Bug 2505
-use CGI;
+use CGI qw ( -utf8 );
use Date::Manip;
use C4::Auth;
use C4::Output;
use C4::Circulation;
use C4::Reports;
-use C4::Dates qw/format_date format_date_in_iso/;
use C4::Members;
+use Koha::DateUtils;
=head1 NAME
-plugin that shows circulation stats
+reports/issues_stats.pl
=head1 DESCRIPTION
-=over 2
+Plugin that shows circulation stats
=cut
# my $debug = 1; # override for now.
my $input = new CGI;
-my $fullreportname = "reports/issues_stats.tmpl";
+my $fullreportname = "reports/issues_stats.tt";
my $do_it = $input->param('do_it');
my $line = $input->param("Line");
my $column = $input->param("Column");
-my @filters = $input->param("Filter");
-$filters[0]=format_date_in_iso($filters[0]);
-$filters[1]=format_date_in_iso($filters[1]);
+my @filters = $input->multi_param("Filter");
+$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); }
+ if ( $filters[0] );
+$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); }
+ if ( $filters[1] );
my $podsp = $input->param("DisplayBy");
my $type = $input->param("PeriodTypeSel");
my $daysel = $input->param("PeriodDaySel");
our $sep = $input->param("sep");
$sep = "\t" if ($sep eq 'tabulation');
$template->param(do_it => $do_it,
- DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
);
my $itemtypes = GetItemTypes();
print map {$sep.$_->{totalcol}} @$cols;
print $sep.@$results[0]->{total};
}
- exit(1); # exit either way after $do_it
+ exit; # exit either way after $do_it
}
my $dbh = C4::Context->dbh;
# create itemtype arrayref for <select>.
my @itemtypeloop;
-for my $itype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys(%$itemtypes)) {
- push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{description} } ;
+for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
+ push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
}
# location list
push @ccodes, { code => $_, description => $ccodes->{$_} };
}
-my $CGIextChoice=CGI::scrolling_list(
- -name => 'MIME',
- -id => 'MIME',
- -values => ['CSV'], # FIXME translation
- -size => 1,
- -multiple => 0 );
-
+my $CGIextChoice = ( 'CSV' ); # FIXME translation
my $CGIsepChoice=GetDelimiterChoices;
$template->param(
# Checking filters
#
my @loopfilter;
- for (my $i=0;$i<=10;$i++) {
+ for (my $i=0;$i<=12;$i++) {
my %cell;
(@$filters[$i]) or next;
if (($i==1) and (@$filters[$i-1])) {
if ($i>=2) {
$cell{filter} = @$filters[$i];
} else {
- $cell{filter} = format_date(@$filters[$i]);
+ $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); }
+ if ( @$filters[$i] );
}
$cell{crit} =
- ($i==0) ? "Period From" :
- ($i==1) ? "Period To" :
- ($i==2) ? "Patron Category =" :
- ($i==3) ? "Item Type =" :
- ($i==4) ? "Library =" :
- ($i==5) ? "Collection =" :
- ($i==6) ? "Location =" :
- ($i==7) ? "Item callnumber >=" :
- ($i==8) ? "Item callnumber <" :
- ($i==9) ? "sort1 =" :
- ($i==10)? "sort2 =" : "UNKNOWN FILTER ($i)";
+ ( $i == 0 ) ? "Period From"
+ : ( $i == 1 ) ? "Period To"
+ : ( $i == 2 ) ? "Patron Category ="
+ : ( $i == 3 ) ? "Item Type ="
+ : ( $i == 4 ) ? "Library ="
+ : ( $i == 5 ) ? "Collection ="
+ : ( $i == 6 ) ? "Location ="
+ : ( $i == 7 ) ? "Item callnumber >="
+ : ( $i == 8 ) ? "Item callnumber <"
+ : ( $i == 9 ) ? "sort1 ="
+ : ( $i == 10 ) ? "sort2 ="
+ : ( $i == 11 ) ? "Home library ="
+ : ( $i == 12 )? "Holding library ="
+ : "UNKNOWN FILTER ($i)";
+
# FIXME - no translation mechanism !
push @loopfilter, \%cell;
}
$debug and warn "filtres ". join "|", @filters;
my ($colsource, $linesource);
$linefilter[1] = @$filters[1] if ($line =~ /datetime/);
- $linefilter[0] = ($line =~ /datetime/) ? @$filters[0] :
- ($line =~ /category/) ? @$filters[2] :
- ($line =~ /itemtype/) ? @$filters[3] :
- ($line =~ /branch/ ) ? @$filters[4] :
- ($line =~ /ccode/ ) ? @$filters[5] :
- ($line =~ /location/) ? @$filters[6] :
- ($line =~ /sort1/ ) ? @$filters[9] :
- ($line =~ /sort2/ ) ? @$filters[10] : undef ;
- if ($line =~ /ccode/ or $line =~ /location/) {
+ $linefilter[0] =
+ ( $line =~ /datetime/ ) ? @$filters[0]
+ : ( $line =~ /category/ ) ? @$filters[2]
+ : ( $line =~ /itemtype/ ) ? @$filters[3]
+ : ( $line =~ /^branch/ ) ? @$filters[4]
+ : ( $line =~ /ccode/ ) ? @$filters[5]
+ : ( $line =~ /location/ ) ? @$filters[6]
+ : ( $line =~ /sort1/ ) ? @$filters[9]
+ : ( $line =~ /sort2/ ) ? @$filters[10]
+ : ( $line =~ /homebranch/) ? @$filters[11]
+ : ( $line =~ /holdingbranch/) ? @$filters[12]
+ : undef;
+
+ if ( $line =~ /ccode/ or $line =~ /location/ or $line =~ /homebranch/ or $line =~ /holdingbranch/ ) {
$linesource = 'items';
}
my @colfilter;
$colfilter[1] = @$filters[1] if ($column =~ /datetime/);
- $colfilter[0] = ($column =~ /datetime/) ? @$filters[0] :
- ($column =~ /category/) ? @$filters[2] :
- ($column =~ /itemtype/) ? @$filters[3] :
- ($column =~ /branch/ ) ? @$filters[4] :
- ($column =~ /ccode/ ) ? @$filters[5] :
- ($column =~ /location/) ? @$filters[6] :
- ($column =~ /sort1/ ) ? @$filters[9] :
- ($column =~ /sort1/ ) ? @$filters[10] : undef ;
- if ($column =~ /ccode/ or $column =~ /location/) {
+ $colfilter[0] =
+ ( $column =~ /datetime/ ) ? @$filters[0]
+ : ( $column =~ /category/ ) ? @$filters[2]
+ : ( $column =~ /itemtype/ ) ? @$filters[3]
+ : ( $column =~ /^branch/ ) ? @$filters[4]
+ : ( $column =~ /ccode/ ) ? @$filters[5]
+ : ( $column =~ /location/ ) ? @$filters[6]
+ : ( $column =~ /sort1/ ) ? @$filters[9]
+ : ( $column =~ /sort1/ ) ? @$filters[10]
+ : ( $column =~ /homebranch/) ? @$filters[11]
+ : ( $column =~ /holdingbranch/) ? @$filters[12]
+ : undef;
+
+ if ( $column =~ /ccode/ or $column =~ /location/ or $column =~ /homebranch/ or $column =~ /holdingbranch/ ) {
$colsource = 'items';
}
# 1st, loop rows.
$linefield = ($dsp == 1) ? " dayname($line)" :
($dsp == 2) ? "monthname($line)" :
($dsp == 3) ? " Year($line)" :
- 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through C4::Dates
+ 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through Koha::DateUtils
} else {
$linefield = $line;
}
$colfield = ($dsp == 1) ? " dayname($column)" :
($dsp == 2) ? "monthname($column)" :
($dsp == 3) ? " Year($column)" :
- 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through C4::Dates
+ 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through Koha::DateUtils
} else {
$colfield = $column;
}