From 99b0a074eb765eecb33e8f6b935ef55ebc63c5ca Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Tue, 15 Mar 2011 13:00:17 -0400 Subject: [PATCH] Bug 5869 : Adding a reserve report Signed-off-by: Nicole C. Engard Signed-off-by: Chris Cormack --- .../prog/en/modules/reports/reports-home.tmpl | 1 + .../en/modules/reports/reserves_stats.tmpl | 549 ++++++++++++++++++ reports/reserves_stats.pl | 382 ++++++++++++ 3 files changed, 932 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tmpl create mode 100755 reports/reserves_stats.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tmpl index b2d848764d..7c6efaee67 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tmpl @@ -34,6 +34,7 @@
  • Catalog
  • Circulation
  • Serials
  • +
  • Reserves
  • Top Lists

    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tmpl new file mode 100644 index 0000000000..2b78133961 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tmpl @@ -0,0 +1,549 @@ + +Koha › Reports › Checkout statistics <!-- TMPL_IF NAME="do_it" -->› Results<!-- /TMPL_IF --> + + + + + + + + + + +
    + +
    +
    +
    + + + +

    Reserves statistics

    + +

    Filtered on

    +
      + +
    • Error: +
    • +
    • + + +
    • + +
    + + + + + + + + + + + + + + class="highlight"> + + + + + + + + + + + + + + +
    / TOTAL
    + "> +
    TOTAL
    + + + + +
    +
    + Reserve statistics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TitleRowColumnFilter
    Reserve status + Asked + Processing + Waiting + Satisfied + cancelled +
    reserve date + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openreservedateFrom" style="cursor: pointer;" /> + + + /lib/calendar/cal.gif" alt="Show Calendar" id="openreservedateTo" style="cursor: pointer;" border="0" /> + +
    notification date + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="opennotificationdateFrom" style="cursor: pointer;" /> + + + /lib/calendar/cal.gif" alt="Show Calendar" id="opennotificationdateTo" style="cursor: pointer;" border="0" /> + +
    Reminder date + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openreminderdateFrom" style="cursor: pointer;" /> + + + /lib/calendar/cal.gif" alt="Show Calendar" id="openreminderdateTo" style="cursor: pointer;" border="0" /> + +
    Waiting date + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openwaitingdateFrom" style="cursor: pointer;" /> + + + /lib/calendar/cal.gif" alt="Show Calendar" id="openwaitingdateTo" style="cursor: pointer;" border="0" /> + +
    cancellation date + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="opencancellationdateFrom" style="cursor: pointer;" /> + + + /lib/calendar/cal.gif" alt="Show Calendar" id="opencancellationdateTo" style="cursor: pointer;" border="0" /> + +
    Patron Category +
    Item Type +
    Pickup Library +
    Holding Library +
    Home Library +
    Collection +
    Shelving Location +
    Item Call NumberFrom (inclusive) to (exclusive)
    Patron sort1 +
    Patron sort2 +

    + +
    Cell value
    1. +
    + +
    + Output +
    1. +
    2. +
    +
    + +
    + + " /> + +
    +
    + + +
    +
    +
    + +
    +
    + diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl new file mode 100755 index 0000000000..93f2818eca --- /dev/null +++ b/reports/reserves_stats.pl @@ -0,0 +1,382 @@ +#!/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 CGI; + +use C4::Auth; +use C4::Debug; +use C4::Context; +use C4::Branch; # GetBranches +use C4::Koha; +use C4::Output; +use C4::Reports; +use C4::Members; +use C4::Dates qw/format_date format_date_in_iso/; +use C4::Category; +use List::MoreUtils qw/any/; +use YAML; + +=head1 NAME + +plugin that shows circulation stats + +=head1 DESCRIPTION + +=over 2 + +=cut + +# my $debug = 1; # override for now. +my $input = new CGI; +my $fullreportname = "reports/reserves_stats.tmpl"; +my $do_it = $input->param('do_it'); +my $line = $input->param("Line"); +my $column = $input->param("Column"); +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 $hash_params = $input->Vars; +my $filter_hashref; +foreach my $filter (grep {$_ =~/^filter/} keys %$hash_params){ + my $filterstring=$filter; + $filterstring=~s/^filter_//g; + $$filter_hashref{$filterstring}=$$hash_params{$filter} if (defined $$hash_params{$filter} && $$hash_params{$filter} ne ""); +} +my ($template, $borrowernumber, $cookie) = get_template_and_user({ + template_name => $fullreportname, + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {reports => '*'}, + debug => 0, +}); +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; + +my $ccodes = GetKohaAuthorisedValues("items.ccode"); +my $locations = GetKohaAuthorisedValues("items.location"); +my $authvalue = GetKohaAuthorisedValues("items.authvalue"); + +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, $calc, $filter_hashref); + 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 $sep.@$results[0]->{total}; + } + exit(1); # exit either way after $do_it +} + +my $dbh = C4::Context->dbh; +my @values; +my %labels; +my %select; + +# create itemtype arrayref for