From fc1d41f012d012fb2ddf885e429d862f7c66d17e Mon Sep 17 00:00:00 2001 From: Maxime Pelletier Date: Wed, 28 Sep 2011 16:40:43 -0400 Subject: [PATCH] Reworked patch to do a few date fixes and proper indentation reworked patch to fix indentation, whitespace and a lot of date format issues --- .../prog/en/includes/reports-menu.inc | 1 + .../prog/en/modules/reports/cash_register_stats.tt | 301 ++++++++++++++++++++ .../prog/en/modules/reports/reports-home.tt | 1 + reports/cash_register_stats.pl | 162 +++++++++++ 4 files changed, 465 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 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..7a6efba --- /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..c41c715 --- /dev/null +++ b/reports/cash_register_stats.pl @@ -0,0 +1,162 @@ +#!/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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# test comment + +use strict; +use warnings; +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; } + +=head1 NAME + +plugin that shows a stats on borrowers + +=head1 DESCRIPTION + +=over 2 + +=cut + +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, + }); + +my $CGIextChoice=CGI::scrolling_list( + -name => 'MIME', + -id => 'MIME', + -values => ['CSV'], + -size => 1, + -multiple => 0 ); + +my $CGIsepChoice=GetDelimiterChoices; + +$template->param(do_it => $do_it, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + CGIextChoice => $CGIextChoice, + CGIsepChoice => $CGIsepChoice, +); + +$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 like '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($celvalue[5])}; + $grantotal += ($celvalue[0]*-1); + } + } + + my @currency = GetCurrency(); + $grantotal = sprintf("%.2f", $grantotal); + + + + if($output eq 'screen'){ + $template->param( loopresult => \@loopresult, + total => $grantotal, + beginDate => format_date($filters[0]), + endDate => format_date($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; + + +=header + +ate/) ? format_date_in_iso($filters[0]) : undef); +$filters[1]= (($line =~ /closedate/ || $column =~ /closedate/) ? format_date_in_iso($filters[1]) : undef); + +=cut + -- 1.5.6.5