diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc index 8b2df92..fe80689 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc @@ -10,6 +10,7 @@
  • Catalog
  • Circulation
  • Serials
  • +
  • Cash Register
  • Holds
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt new file mode 100644 index 0000000..1e75b57 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -0,0 +1,301 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Reports [% IF ( do_it ) %]› Cash Register Statistics › Results[% ELSE %]› Cash Register Statistics[% END %] +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    + +
    +
    +
    + +[% IF ( do_it ) %] +

    Cash register statistics

    +
    +
    + Cash Register statistics [% beginDate %] to [% endDate %] + + + + + + + + + + + + + +
    Interval
    From + Show Calendar + + [% INCLUDE 'date-format.inc' %] + To + Show Calendar + + [% INCLUDE 'date-format.inc' %] +

    +
    + +
    + Output +
      +
    1. + + +
    2. +
    3. + + + + [% CGIextChoice %] + [% CGIsepChoice %] +
    4. +
    +
    + +
    + + + +
    +
    + + + + + + + + + + [% FOREACH loopresul IN loopresult %] + + + + + + + + [% END %] + + + + + +
    Borrower NumberDateSurnameFirstnameAmount
    [% loopresul.borrowernumber %][% loopresul.date %][% loopresul.surname %][% loopresul.firstname %][% loopresul.amount %]
    TOTAL[% total %]
    + +[% ELSE %] +

    Cash register report

    +
    +
    + Cash Register statistics + + + + + + + + + + + + + +
    Interval
    From + Show Calendar + + [% INCLUDE 'date-format.inc' %] + To + Show Calendar + + [% INCLUDE 'date-format.inc' %] +

    +
    + +
    + Output +
      +
    1. + + +
    2. +
    3. + + + + [% CGIextChoice %] + [% CGIsepChoice %] +
    4. +
    +
    + +
    + + + +
    +
    +[% END %] +
    +
    +
    +[% INCLUDE 'reports-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt index e8bb4d5..ad17210 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt @@ -34,6 +34,7 @@
  • Catalog
  • Circulation
  • Serials
  • +
  • Cash Register
  • Holds
  • diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl new file mode 100755 index 0000000..285a1fc --- /dev/null +++ b/reports/cash_register_stats.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +#use warnings; FIXME - Bug 2505 +use C4::Auth; +use CGI; +use C4::Context; +use C4::Reports; +use C4::Output; +use C4::Koha; +use C4::Circulation; +use C4::Dates qw/format_date format_date_in_iso/; +use C4::Budgets qw/GetCurrency GetCurrencies/; + +BEGIN { $C4::Debug::debug = 1; } + +my $input = new CGI; +my $do_it = $input->param('do_it'); +my $fullreportname = "reports/cash_register_stats.tt"; +my @filters = $input->param("Filter"); +my $podsp = $input->param("PlacedOnDisplay"); +my $rodsp = $input->param("ReceivedOnDisplay"); +my $aodsp = $input->param("AcquiredOnDisplay"); ##added by mason. +my $output = $input->param("output"); +my $basename = $input->param("basename"); +our $sep = " "; + +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => $fullreportname, + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {reports => '*'}, + debug => 1, + }); + +$template->param(do_it => $do_it, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + ); + +$filters[0]= format_date_in_iso($filters[0]); +$filters[1]= format_date_in_iso($filters[1]); + +if ($do_it) { + my $dbh = C4::Context->dbh; + my $req = $dbh->prepare("SELECT round(amount,2),description,surname,firstname,t1.borrowernumber,t1.date,t1.amountoutstanding + FROM accountlines t1 LEFT JOIN borrowers t2 ON t1.borrowernumber=t2.borrowernumber + WHERE amount<0 AND accounttype IN ('L','Pay') AND CAST(t1.date AS DATE) between ? AND ? ORDER BY t1.date;"); + $req->execute($filters[0],$filters[1]); + + my @loopresult; + my $grantotal =0; + while ( my (@celvalue) = $req->fetchrow) { + if((($celvalue[0]*-1)-$celvalue[6])>0){ + push @loopresult, { amount => sprintf("%.2f", ($celvalue[0] * -1)), surname => $celvalue[2], firstname => $celvalue[3], + borrowernumber => $celvalue[4], date => format_date_in_iso($celvalue[5])}; + $grantotal += ($celvalue[0]*-1); + } + } + my @currency = GetCurrency(); + $grantotal = sprintf("%.2f", $grantotal); + + if($output eq 'screen'){ + $template->param( loopresult => \@loopresult, + total => $grantotal, + beginDate => $filters[0], + endDate => $filters[1] + ); + }else{ + binmode STDOUT, ':utf8'; + print $input->header( + -type => 'application/vnd.sun.xml.calc', + -encoding => 'utf-8', + -name => "$basename.csv", + -attachment => "$basename.csv" + ); + print "Borrower Number".$sep; + print "Date".$sep; + print "Surname".$sep; + print "Firstname".$sep; + print "Amount"."\n"; + + foreach my $item (@loopresult){ + print $item->{borrowernumber}.$sep; + print $item->{date}.$sep; + print $item->{surname}.$sep; + print $item->{firstname}.$sep; + print $item->{amount}."\n"; + } + print $sep; + print $sep; + print $sep; + print $sep; + print $grantotal."\n"; + exit(1); + } + +} +output_html_with_http_headers $input, $cookie, $template->output; + +1;