Bugzilla – Attachment 5634 Details for
Bug 6934
New report Cash Register Statistics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
new report
0001-version-3.6-rapport-cash-register.patch (text/plain), 17.14 KB, created by
Maxime Pelletier
on 2011-09-28 21:43:01 UTC
(
hide
)
Description:
new report
Filename:
MIME Type:
Creator:
Maxime Pelletier
Created:
2011-09-28 21:43:01 UTC
Size:
17.14 KB
patch
obsolete
>From 0b97cd41d7eec3625d7514914078d55c90ee6742 Mon Sep 17 00:00:00 2001 >From: Maxime Pelletier <maxime.pelletier@libeo.com> >Date: Wed, 28 Sep 2011 16:40:43 -0400 >Subject: [PATCH] new report cash register > >--- > .../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 | 151 ++++++++++ > 4 files changed, 454 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 @@ > <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li> > <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li> > <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li> >+ <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register</a></li> > <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li> > </ul> > >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..6bab8a1 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt >@@ -0,0 +1,301 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Reports [% IF ( do_it ) %]› Cash Register Statistics › Results[% ELSE %]› Cash Register Statistics[% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% INCLUDE 'calendar.inc' %] >+<script type="text/javascript"> >+//<![CDATA[ >+actTotal = ""; >+ >+function isNull(f,noalert) { >+ if (f.value.length > 0) { >+ return false; >+ } >+ return true; >+} >+ >+ >+function Check(ff) { >+ var ok=0; >+ var _alertString= _("Form not submitted because of the following problem(s)")+"\n"; >+ >+ _alertString +="-------------------------------------------------------------------\n\n"; >+ >+ if ( isNull(ff.fromRO,1) || isNull(ff.toRO,1) ){ >+ ok=1; >+ _alertString += "\n- " + _("Dates cannot be empty"); >+ } >+ >+ if (ok) { >+ alert(_alertString); >+ }else{ >+ ff.submit(); >+ } >+ >+} >+ >+ >+//]]> >+</script> >+ >+</head> >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> [% IF ( do_it ) %]› <a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register Statistics</a> › Results[% ELSE %] › Cash Register Statistics [% END %]</div> >+ >+<div id="doc3" class="yui-t2"> >+ >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ >+[% IF ( do_it ) %] >+ <h1>Cash register statistics</h1> >+ <form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl"> >+ <fieldset class="rows"> >+ <legend>Cash Register statistics [% beginDate %] to [% endDate %]</legend> >+ <table> >+ <thead> >+ <tr> >+ <th>Interval</th> >+ </tr> >+ </thead> >+ <tbody> >+ >+ <tr> >+ <td> From <input type="text" size="10" id="fromRO" name="Filter" value="[% beginDate %]" /> >+ <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendarFromRO" style="cursor: pointer;" /> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function validate1(date) { >+ var day = date.getDate(); >+ var month = date.getMonth() + 1; >+ var year = date.getFullYear(); >+ var weekDay = date.getDay(); >+ var dayMonth = month + '-' + day; >+ var dateString = year + '-' + month + '-' + day; >+ var dateTo = document.getElementById('toRO').value.split("-"); >+ var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]); >+ if (date > limitDate) { >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ Calendar.setup( >+ { >+ inputField : "fromRO", >+ ifFormat : "[% DHTMLcalendar_dateformat %]", >+ button : "openCalendarFromRO", >+ disableFunc : validate1, >+ dateStatusFunc : validate1 >+ } >+ ); >+ //]]> >+ </script> >+ <span class="hint">[% INCLUDE 'date-format.inc' %]</span> >+ To <input type="text" size="10" id="toRO" name="Filter" value="[% endDate %]" /> >+ <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" id="openCalendarToRO" style="cursor: pointer;" border="0" /> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function validate2(date) { >+ var day = date.getDate(); >+ var month = date.getMonth() + 1; >+ var year = date.getFullYear(); >+ var weekDay = date.getDay(); >+ var dayMonth = month + '-' + day; >+ var dateString = year + '-' + month + '-' + day; >+ var dateFrom = document.getElementById('fromRO').value.split("-"); >+ var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]); >+ if (limitDate > date) { >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ Calendar.setup( >+ { >+ inputField : "toRO", >+ ifFormat : "[% DHTMLcalendar_dateformat %]", >+ button : "openCalendarToRO", >+ disableFunc : validate2, >+ dateStatusFunc : validate2 >+ } >+ ); >+ //]]> >+ </script> >+ <span class="hint">[% INCLUDE 'date-format.inc' %]</span> >+ </td> >+ </tr> >+ >+ </tbody> >+ </table><br /> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <legend>Output</legend> >+ <ol> >+ <li> >+ <label for="outputscreen">To screen into the browser: </label> >+ <input type="radio" checked="checked" name="output" id="outputscreen" value="screen" /> >+ </li> >+ <li> >+ <label for="outputfile">To a file:</label> >+ <input type="radio" name="output" value="file" id="outputfile" /> >+ <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" /> >+ <label class="inline" for="MIME">Into an application</label>[% CGIextChoice %] >+ [% CGIsepChoice %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="button" value="Submit" onclick="Check(this.form)"/> >+ <input type="hidden" name="report_name" value="[% report_name %]" /> >+ <input type="hidden" name="do_it" value="1" /> >+ </fieldset> >+ </form> >+ >+ <table style="margin-top:30px;"> >+ <tr > >+ <th>Borrower Number</th> >+ <th>Date</th> >+ <th>Surname</th> >+ <th>Firstname</th> >+ <th>Amount</th> >+ </tr> >+ [% FOREACH loopresul IN loopresult %] >+ <tr> >+ <td>[% loopresul.borrowernumber %]</td> >+ <td>[% loopresul.date %]</td> >+ <td>[% loopresul.surname %]</td> >+ <td>[% loopresul.firstname %]</td> >+ <td style="text-align:right;">[% loopresul.amount %]</td> >+ </tr> >+ [% END %] >+ <tr> >+ <th colspan="4" style="text-align:right;">TOTAL</th> >+ <th style="text-align:right;">[% total %]</th> >+ </tr> >+ >+ </table> >+ >+[% ELSE %] >+ <h1>Cash register report</h1> >+ <form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl"> >+ <fieldset class="rows"> >+ <legend>Cash Register statistics</legend> >+ <table> >+ <thead> >+ <tr> >+ <th>Interval</th> >+ </tr> >+ </thead> >+ <tbody> >+ >+ <tr> >+ <td> From <input type="text" size="10" id="fromRO" name="Filter" value="" /> >+ <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendarFromRO" style="cursor: pointer;" /> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function validate1(date) { >+ var day = date.getDate(); >+ var month = date.getMonth() + 1; >+ var year = date.getFullYear(); >+ var weekDay = date.getDay(); >+ var dayMonth = month + '-' + day; >+ var dateString = year + '-' + month + '-' + day; >+ var dateTo = document.getElementById('toRO').value.split("-"); >+ var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]); >+ if (date > limitDate) { >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ Calendar.setup( >+ { >+ inputField : "fromRO", >+ ifFormat : "[% DHTMLcalendar_dateformat %]", >+ button : "openCalendarFromRO", >+ disableFunc : validate1, >+ dateStatusFunc : validate1 >+ } >+ ); >+ //]]> >+ </script> >+ <span class="hint">[% INCLUDE 'date-format.inc' %]</span> >+ To <input type="text" size="10" id="toRO" name="Filter" value="" /> >+ <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" id="openCalendarToRO" style="cursor: pointer;" border="0" /> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function validate2(date) { >+ var day = date.getDate(); >+ var month = date.getMonth() + 1; >+ var year = date.getFullYear(); >+ var weekDay = date.getDay(); >+ var dayMonth = month + '-' + day; >+ var dateString = year + '-' + month + '-' + day; >+ var dateFrom = document.getElementById('fromRO').value.split("-"); >+ var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]); >+ if (limitDate > date) { >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ Calendar.setup( >+ { >+ inputField : "toRO", >+ ifFormat : "[% DHTMLcalendar_dateformat %]", >+ button : "openCalendarToRO", >+ disableFunc : validate2, >+ dateStatusFunc : validate2 >+ } >+ ); >+ //]]> >+ </script> >+ <span class="hint">[% INCLUDE 'date-format.inc' %]</span> >+ </td> >+ </tr> >+ >+ </tbody> >+ </table><br /> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <legend>Output</legend> >+ <ol> >+ <li> >+ <label for="outputscreen">To screen into the browser: </label> >+ <input type="radio" checked="checked" name="output" id="outputscreen" value="screen" /> >+ </li> >+ <li> >+ <label for="outputfile">To a file:</label> >+ <input type="radio" name="output" value="file" id="outputfile" /> >+ <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" /> >+ <label class="inline" for="MIME">Into an application</label>[% CGIextChoice %] >+ [% CGIsepChoice %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="button" value="Submit" onclick="Check(this.form)"/> >+ <input type="hidden" name="report_name" value="[% report_name %]" /> >+ <input type="hidden" name="do_it" value="1" /> >+ </fieldset> >+ </form> >+[% END %] >+</div> >+</div> >+<div class="yui-b"> >+[% INCLUDE 'reports-menu.inc' %] >+</div> >+</div> >+[% 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 @@ > <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li> > <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li> > <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li> >+ <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register</a></li> > <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li> > </ul></div> > >diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl >new file mode 100755 >index 0000000..7e1c6eb >--- /dev/null >+++ b/reports/cash_register_stats.pl >@@ -0,0 +1,151 @@ >+#!/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_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; >+ >+ >+=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 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6934
:
5634
|
5635
|
5640
|
5641
|
9379
|
9419
|
12602
|
12660
|
31210
|
36476
|
42564
|
42565
|
44847
|
44853
|
45972
|
45973
|
45974
|
48634
|
48642
|
48704
|
48705
|
48706
|
48707
|
48708
|
50429
|
50437
|
50938
|
53496
|
53500
|
53570
|
53571
|
53572
|
53573
|
53574
|
53575
|
53576
|
53577
|
53578
|
53579
|
53581
|
53582
|
53583
|
53584
|
53585
|
53586
|
53587
|
53588
|
53589
|
53590
|
53591
|
53648
|
53650
|
53651
|
53652
|
53653
|
53778
|
53780
|
54010
|
54088
|
54089
|
54090
|
54091
|
54092
|
54093
|
54094
|
54095
|
54096
|
54097
|
54098
|
54099
|
54100
|
55939
|
55988
|
55989
|
55990
|
55991
|
55992
|
55993
|
55994
|
55995
|
55996
|
55997
|
55998
|
55999
|
56000
|
56001
|
56763
|
56764