#!/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 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 C4::Auth; use CGI; use C4::Context; use C4::Branch; # GetBranches use C4::Koha; use C4::Output; use C4::Circulation; use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; use Date::Manip; =head1 NAME plugin that shows a stats on borrowers =head1 DESCRIPTION =over 2 =cut my $debug = 1; my $input = new CGI; my $do_it=$input->param('do_it'); my $fullreportname = "reports/issues_stats.tmpl"; 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 $podsp = $input->param("DisplayBy"); my $type = $input->param("PeriodTypeSel"); my $daysel = $input->param("PeriodDaySel"); 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 $del = $input->param("sep"); my ($template, $borrowernumber, $cookie) = get_template_and_user({template_name => $fullreportname, query => $input, type => "intranet", authnotrequired => 0, flagsrequired => {reports => 1}, debug => 0, }); $template->param(do_it => $do_it, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); my $itemtypes = GetItemTypes(); my $categoryloop = GetBorrowercategoryList; my $ccodes = GetKohaAuthorisedValues("items.ccode"); my $locations = GetKohaAuthorisedValues("items.location"); my $Bsort1 = GetAuthorisedValues("Bsort1"); my $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; exit(1); } 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}; my $sep; $sep =C4::Context->preference("delimiter"); # 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; foreach my $cell (@$x) { print $cell->{value}.$sep; } print $line->{totalrow}; print "\n"; } # footer print "TOTAL"; $cols = @$results[0]->{loopfooter}; foreach my $col ( @$cols ) { print $sep.$col->{totalcol}; } print $sep.@$results[0]->{total}; exit(1); } # Displaying choices } else { my $dbh = C4::Context->dbh; my @values; my %labels; my %select; # create itemtype arrayref for