X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=reports%2Fissues_stats.pl;h=8f86fdb113fa81e0ac8d192ad02f03a00e182338;hb=638786e719fb297ae976061b09a71f3d788416f4;hp=cd004245b30ea4a5c79a932dfa0b8b996d56fbb6;hpb=8c1b8b47c57ca7c1671c54abc293b30d15231fd0;p=srvgit diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index cd004245b3..8f86fdb113 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -1,58 +1,62 @@ #!/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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . -use strict; +use Modern::Perl; -use CGI; +use CGI qw ( -utf8 ); use Date::Manip; use C4::Auth; use C4::Debug; use C4::Context; -use C4::Branch; # GetBranches use C4::Koha; use C4::Output; use C4::Circulation; use C4::Reports; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; +use Koha::AuthorisedValues; +use Koha::DateUtils; +use Koha::ItemTypes; +use Koha::Patron::Attribute::Types; + =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 $input = CGI->new; +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"); @@ -60,82 +64,89 @@ my $monthsel = $input->param("PeriodMonthSel"); my $calc = $input->param("Cellvalue"); my $output = $input->param("output"); my $basename = $input->param("basename"); -my $mime = $input->param("MIME"); + +my $attribute_filters; +my $vars = $input->Vars; +foreach(keys %$vars) { + if(/^Filter_borrower_attributes\.(.*)/) { + $attribute_filters->{$1} = $vars->{$_}; + } +} + + my ($template, $borrowernumber, $cookie) = get_template_and_user({ template_name => $fullreportname, query => $input, type => "intranet", - authnotrequired => 0, - flagsrequired => {reports => 1}, + flagsrequired => {reports => '*'}, debug => 0, }); -our $sep = $input->param("sep"); +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(); -my $categoryloop = GetBorrowercategoryList; +our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed; -my $ccodes = GetKohaAuthorisedValues("items.ccode"); -my $locations = GetKohaAuthorisedValues("items.location"); +our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']}); -my $Bsort1 = GetAuthorisedValues("Bsort1"); -my $Bsort2 = GetAuthorisedValues("Bsort2"); +our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) }; +our $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) }; + +our $Bsort1 = GetAuthorisedValues("Bsort1"); +our $Bsort2 = GetAuthorisedValues("Bsort2"); my ($hassort1,$hassort2); $hassort1=1 if $Bsort1; $hassort2=1 if $Bsort2; - if ($do_it) { -# Displaying results - my $results = calculate($line, $column, $podsp, $type, $daysel, $monthsel, $calc, \@filters); - if ($output eq "screen"){ -# Printing results to screen - $template->param(mainloop => $results); - output_html_with_http_headers $input, $cookie, $template->output; - } else { -# Printing to a csv file - print $input->header(-type => 'application/vnd.sun.xml.calc', - -encoding => 'utf-8', - -attachment=>"$basename.csv", - -filename=>"$basename.csv" ); - my $cols = @$results[0]->{loopcol}; - my $lines = @$results[0]->{looprow}; -# header top-right - print @$results[0]->{line} ."/". @$results[0]->{column} .$sep; -# Other header - foreach my $col ( @$cols ) { - print $col->{coltitle}.$sep; - } - print "Total\n"; -# Table - foreach my $line ( @$lines ) { - my $x = $line->{loopcell}; - print $line->{rowtitle}.$sep; - print map {$_->{value}.$sep} @$x; - print $line->{totalrow}, "\n"; - } -# footer + # Displaying results + my $results = calculate( $line, $column, $podsp, $type, $daysel, $monthsel, $calc, \@filters, $attribute_filters); + if ( $output eq "screen" ) { + + # Printing results to screen + $template->param( mainloop => $results ); + output_html_with_http_headers $input, $cookie, $template->output; + } else { + + # Printing to a csv file + print $input->header( + -type => 'application/vnd.sun.xml.calc', + -encoding => 'utf-8', + -attachment => "$basename.csv", + -filename => "$basename.csv" + ); + my $cols = @$results[0]->{loopcol}; + my $lines = @$results[0]->{looprow}; + + # header top-right + print @$results[0]->{line} . "/" . @$results[0]->{column} . $sep; + + # Other header + foreach my $col (@$cols) { + print $col->{coltitle} . $sep; + } + print "Total\n"; + + # Table + foreach my $line (@$lines) { + my $x = $line->{loopcell}; + print $line->{rowtitle} . $sep; + print map { $_->{value} . $sep } @$x; + print $line->{totalrow}, "\n"; + } + + # footer print "TOTAL"; $cols = @$results[0]->{loopfooter}; - print map {$sep.$_->{totalcol}} @$cols; + print map {$sep.$_->{totalcol}} @$cols; print $sep.@$results[0]->{total}; - } - exit(1); # exit either way after $do_it + } + exit; } + my $dbh = C4::Context->dbh; -my @values; -my %labels; -my %select; - -# create itemtype arrayref for