From d25f060d983858757c95062975d32c5c13ca6b34 Mon Sep 17 00:00:00 2001 From: Maxime Pelletier Date: Wed, 28 Sep 2011 16:40:43 -0400 Subject: [PATCH] Bug 6934 Cash Register Report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cash register report --- .../prog/en/includes/reports-menu.inc | 1 + .../prog/en/modules/reports/cash_register_stats.tt | 299 ++++++++++++++++++++ .../prog/en/modules/reports/reports-home.tt | 1 + .../po/zh-Hans-CN-i-staff-t-prog-v-3006000.po | 2 + reports/cash_register_stats.pl | 117 ++++++++ 5 files changed, 420 insertions(+), 0 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt create mode 100755 reports/cash_register_stats.pl 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 8c4fe9f..41dd0d2 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..ac8dab4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -0,0 +1,299 @@ +[% 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 32c1803..7a79f14 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/misc/translator/po/zh-Hans-CN-i-staff-t-prog-v-3006000.po b/misc/translator/po/zh-Hans-CN-i-staff-t-prog-v-3006000.po index d8162d0..a5c0f82 100644 --- a/misc/translator/po/zh-Hans-CN-i-staff-t-prog-v-3006000.po +++ b/misc/translator/po/zh-Hans-CN-i-staff-t-prog-v-3006000.po @@ -88488,3 +88488,5 @@ msgstr "
 " msgid "%s " msgstr "%s " + + diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl new file mode 100755 index 0000000..f73af74 --- /dev/null +++ b/reports/cash_register_stats.pl @@ -0,0 +1,117 @@ +#!/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 ('C', 'FOR', '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; -- 1.7.2.5