View | Details | Raw Unified | Return to bug 6934
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc (+1 lines)
Lines 10-15 Link Here
10
		<li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
10
		<li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
11
		<li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
11
		<li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
12
        <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
12
        <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
13
        <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register</a></li>
13
        <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>        
14
        <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>        
14
	</ul>
15
	</ul>
15
16
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt (+301 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Cash Register Statistics &rsaquo; Results[% ELSE %]&rsaquo; Cash Register Statistics[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script type="text/javascript">
6
//<![CDATA[
7
actTotal = "";
8
9
function isNull(f,noalert) {
10
    if (f.value.length > 0) {
11
        return false;
12
    }
13
    return true;
14
}
15
16
17
function Check(ff) {
18
    var ok=0;
19
    var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
20
21
    _alertString +="-------------------------------------------------------------------\n\n";
22
23
    if ( isNull(ff.fromRO,1)  ||  isNull(ff.toRO,1)   ){
24
        ok=1;
25
        _alertString += "\n- " + _("Dates cannot be empty");
26
    }
27
28
	if (ok) {
29
       alert(_alertString);
30
   }else{
31
		ff.submit();
32
	}
33
34
}
35
36
37
//]]>
38
</script>
39
40
</head>
41
<body>
42
[% INCLUDE 'header.inc' %]
43
[% INCLUDE 'cat-search.inc' %]
44
45
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> [% IF ( do_it ) %]&rsaquo; <a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register Statistics</a> &rsaquo; Results[% ELSE %] &rsaquo; Cash Register Statistics [% END %]</div>
46
47
<div id="doc3" class="yui-t2">
48
49
   <div id="bd">
50
	<div id="yui-main">
51
	<div class="yui-b">
52
53
[% IF ( do_it ) %]
54
		<h1>Cash register statistics</h1>
55
     	<form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl">
56
			<fieldset class="rows">
57
			<legend>Cash Register statistics [% beginDate %] to [% endDate %]</legend>
58
			<table>
59
				<thead>
60
					<tr>
61
						<th>Interval</th>
62
					</tr>
63
				</thead>
64
				<tbody>
65
			
66
					<tr>
67
						<td> From <input type="text" size="10" id="fromRO" name="Filter" value="[% beginDate %]" />
68
									<img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendarFromRO" style="cursor: pointer;" />
69
											<script type="text/javascript">
70
											//<![CDATA[
71
											function validate1(date) {
72
												var day = date.getDate();
73
												var month = date.getMonth() + 1;
74
												var year = date.getFullYear();
75
												var weekDay = date.getDay();
76
												var dayMonth = month + '-' + day;
77
												var dateString = year + '-' + month + '-' + day;
78
												var dateTo = document.getElementById('toRO').value.split("-");
79
												var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]);
80
												if (date > limitDate) {
81
													return true;
82
												} else {
83
													return false;
84
												}
85
											}
86
87
											Calendar.setup(
88
												{
89
													inputField : "fromRO",
90
													ifFormat : "[% DHTMLcalendar_dateformat %]",
91
													button : "openCalendarFromRO",
92
													disableFunc : validate1,
93
													dateStatusFunc : validate1
94
												}
95
											);
96
											//]]>
97
											</script>
98
						<span class="hint">[% INCLUDE 'date-format.inc' %]</span>
99
							To <input type="text" size="10" id="toRO" name="Filter" value="[% endDate %]" />
100
								<img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" id="openCalendarToRO" style="cursor: pointer;" border="0" />
101
										<script type="text/javascript">
102
										//<![CDATA[
103
										function validate2(date) {
104
											var day = date.getDate();
105
											var month = date.getMonth() + 1;
106
											var year = date.getFullYear();
107
											var weekDay = date.getDay();
108
											var dayMonth = month + '-' + day;
109
											var dateString = year + '-' + month + '-' + day;
110
											var dateFrom = document.getElementById('fromRO').value.split("-");
111
											var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]);
112
											if (limitDate > date) {
113
												return true;
114
											} else {
115
												return false;
116
											}
117
										}
118
119
										Calendar.setup(
120
											{
121
												inputField : "toRO",
122
												ifFormat : "[% DHTMLcalendar_dateformat %]",
123
												button : "openCalendarToRO",
124
												disableFunc : validate2,
125
												dateStatusFunc : validate2
126
											}
127
										);
128
										//]]>
129
										</script>
130
						<span class="hint">[% INCLUDE 'date-format.inc' %]</span>
131
						</td>
132
					</tr>
133
			
134
				</tbody>
135
			</table><br />
136
			</fieldset>
137
			
138
			<fieldset class="rows">
139
				<legend>Output</legend>
140
				<ol>
141
					<li>
142
						<label for="outputscreen">To screen into the browser: </label>
143
						<input type="radio" checked="checked" name="output" id="outputscreen" value="screen" />
144
					</li>
145
					<li>
146
						<label for="outputfile">To a file:</label> 		
147
						<input type="radio" name="output" value="file" id="outputfile" /> 
148
						<label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" />
149
						<label class="inline" for="MIME">Into an application</label>[% CGIextChoice %]
150
						[% CGIsepChoice %]
151
					</li>
152
				</ol>
153
			</fieldset>				
154
155
			<fieldset class="action">
156
			<input type="button" value="Submit" onclick="Check(this.form)"/>
157
			<input type="hidden" name="report_name" value="[% report_name %]" />
158
			<input type="hidden" name="do_it" value="1" />
159
			</fieldset>
160
		</form>
161
162
		<table style="margin-top:30px;">
163
			<tr >
164
				<th>Borrower Number</th>
165
				<th>Date</th>
166
				<th>Surname</th>
167
				<th>Firstname</th>
168
				<th>Amount</th>
169
			</tr>
170
			[% FOREACH loopresul IN loopresult %]
171
				<tr>
172
					<td>[% loopresul.borrowernumber %]</td>
173
					<td>[% loopresul.date %]</td>
174
					<td>[% loopresul.surname %]</td>
175
					<td>[% loopresul.firstname %]</td>
176
					<td style="text-align:right;">[% loopresul.amount %]</td>
177
				</tr>
178
			[% END %]
179
			<tr>	
180
				<th colspan="4" style="text-align:right;">TOTAL</th>
181
				<th style="text-align:right;">[% total %]</th>
182
			</tr>
183
				
184
		</table>
185
186
[% ELSE %]
187
	<h1>Cash register report</h1>
188
	<form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl">
189
		<fieldset class="rows">
190
			<legend>Cash Register statistics</legend>
191
			<table>
192
				<thead>
193
					<tr>
194
						<th>Interval</th>
195
					</tr>
196
				</thead>
197
				<tbody>
198
			
199
					<tr>
200
						<td> From <input type="text" size="10" id="fromRO" name="Filter" value="" />
201
									<img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendarFromRO" style="cursor: pointer;" />
202
											<script type="text/javascript">
203
											//<![CDATA[
204
											function validate1(date) {
205
												var day = date.getDate();
206
												var month = date.getMonth() + 1;
207
												var year = date.getFullYear();
208
												var weekDay = date.getDay();
209
												var dayMonth = month + '-' + day;
210
												var dateString = year + '-' + month + '-' + day;
211
												var dateTo = document.getElementById('toRO').value.split("-");
212
												var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]);
213
												if (date > limitDate) {
214
													return true;
215
												} else {
216
													return false;
217
												}
218
											}
219
220
											Calendar.setup(
221
												{
222
													inputField : "fromRO",
223
													ifFormat : "[% DHTMLcalendar_dateformat %]",
224
													button : "openCalendarFromRO",
225
													disableFunc : validate1,
226
													dateStatusFunc : validate1
227
												}
228
											);
229
											//]]>
230
											</script>
231
						<span class="hint">[% INCLUDE 'date-format.inc' %]</span>
232
							To <input type="text" size="10" id="toRO" name="Filter" value="" />
233
								<img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" id="openCalendarToRO" style="cursor: pointer;" border="0" />
234
										<script type="text/javascript">
235
										//<![CDATA[
236
										function validate2(date) {
237
											var day = date.getDate();
238
											var month = date.getMonth() + 1;
239
											var year = date.getFullYear();
240
											var weekDay = date.getDay();
241
											var dayMonth = month + '-' + day;
242
											var dateString = year + '-' + month + '-' + day;
243
											var dateFrom = document.getElementById('fromRO').value.split("-");
244
											var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]);
245
											if (limitDate > date) {
246
												return true;
247
											} else {
248
												return false;
249
											}
250
										}
251
252
										Calendar.setup(
253
											{
254
												inputField : "toRO",
255
												ifFormat : "[% DHTMLcalendar_dateformat %]",
256
												button : "openCalendarToRO",
257
												disableFunc : validate2,
258
												dateStatusFunc : validate2
259
											}
260
										);
261
										//]]>
262
										</script>
263
						<span class="hint">[% INCLUDE 'date-format.inc' %]</span>
264
						</td>
265
					</tr>
266
			
267
				</tbody>
268
			</table><br />
269
		</fieldset>
270
271
		<fieldset class="rows">
272
			<legend>Output</legend>
273
			<ol>
274
				<li>
275
					<label for="outputscreen">To screen into the browser: </label>
276
					<input type="radio" checked="checked" name="output" id="outputscreen" value="screen" />
277
				</li>
278
				<li>
279
					<label for="outputfile">To a file:</label> 		
280
					<input type="radio" name="output" value="file" id="outputfile" /> 
281
					<label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" />
282
					<label class="inline" for="MIME">Into an application</label>[% CGIextChoice %]
283
					[% CGIsepChoice %]
284
				</li>
285
			</ol>
286
		</fieldset>	
287
288
		<fieldset class="action">
289
			<input type="button" value="Submit" onclick="Check(this.form)"/>
290
			<input type="hidden" name="report_name" value="[% report_name %]" />
291
			<input type="hidden" name="do_it" value="1" />
292
		</fieldset>
293
	</form>
294
[% END %]
295
</div>
296
</div>
297
<div class="yui-b">
298
[% INCLUDE 'reports-menu.inc' %]
299
</div>
300
</div>
301
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (+1 lines)
Lines 34-39 Link Here
34
		<li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
34
		<li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
35
		<li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
35
		<li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
36
		<li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
36
		<li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
37
        <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register</a></li>
37
		<li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>
38
		<li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>
38
	</ul></div>
39
	</ul></div>
39
40
(-)a/reports/cash_register_stats.pl (-1 / +151 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
4
# Copyright 2000-2002 Katipo Communications
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
# test comment
22
23
use strict;
24
use warnings;
25
use C4::Auth;
26
use CGI;
27
use C4::Context;
28
use C4::Reports;
29
use C4::Output;
30
use C4::Koha;
31
use C4::Circulation;
32
use C4::Dates qw/format_date format_date_in_iso/;
33
use C4::Budgets qw/GetCurrency GetCurrencies/;
34
35
BEGIN { $C4::Debug::debug = 1; }
36
37
=head1 NAME
38
39
plugin that shows a stats on borrowers
40
41
=head1 DESCRIPTION
42
43
=over 2
44
45
=cut
46
47
my $input          = new CGI;
48
my $do_it          = $input->param('do_it');
49
my $fullreportname = "reports/cash_register_stats.tt";
50
my @filters        = $input->param("Filter");
51
my $podsp          = $input->param("PlacedOnDisplay");
52
my $rodsp          = $input->param("ReceivedOnDisplay");
53
my $aodsp          = $input->param("AcquiredOnDisplay");    ##added by mason.
54
my $output         = $input->param("output");
55
my $basename       = $input->param("basename");
56
our $sep = "    ";
57
58
my ($template, $borrowernumber, $cookie)
59
    = get_template_and_user({template_name => $fullreportname,
60
                query => $input,
61
                type => "intranet",
62
                authnotrequired => 0,
63
                flagsrequired => {reports => '*'},
64
                debug => 1,
65
                });
66
                
67
my $CGIextChoice=CGI::scrolling_list(
68
    -name     => 'MIME',
69
    -id       => 'MIME',
70
    -values   => ['CSV'],
71
    -size     => 1,
72
    -multiple => 0 );
73
    
74
my $CGIsepChoice=GetDelimiterChoices;
75
76
$template->param(do_it => $do_it,
77
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
78
    CGIextChoice => $CGIextChoice,
79
    CGIsepChoice => $CGIsepChoice,
80
);
81
82
$filters[0]= format_date_in_iso($filters[0]);
83
$filters[1]= format_date_in_iso($filters[1]);
84
85
if ($do_it) {
86
   my $dbh = C4::Context->dbh;
87
   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;");
88
    $req->execute($filters[0],$filters[1]);
89
    
90
    my @loopresult;
91
    my $grantotal =0;
92
    while ( my (@celvalue) = $req->fetchrow) {
93
        if((($celvalue[0]*-1)-$celvalue[6])>0){
94
            push @loopresult, { amount => sprintf("%.2f", ($celvalue[0] * -1)), surname => $celvalue[2], firstname => $celvalue[3], borrowernumber => $celvalue[4], date => format_date_in_iso($celvalue[5])};
95
            $grantotal += ($celvalue[0]*-1);
96
        }
97
    }
98
    my @currency = GetCurrency();
99
    $grantotal = sprintf("%.2f", $grantotal);
100
   
101
102
103
    if($output eq 'screen'){
104
        $template->param(   loopresult => \@loopresult,
105
                            total => $grantotal,
106
                            beginDate => $filters[0],
107
                            endDate => $filters[1]
108
            );
109
    }else{
110
        binmode STDOUT, ':utf8';
111
        print $input->header(-type => 'application/vnd.sun.xml.calc',
112
                         -encoding => 'utf-8',
113
                             -name => "$basename.csv",
114
                       -attachment => "$basename.csv");
115
        print "Borrower Number".$sep;
116
        print "Date".$sep;
117
        print "Surname".$sep;
118
        print "Firstname".$sep;
119
        print "Amount"."\n";
120
        
121
        foreach my $item (@loopresult){
122
            print $item->{borrowernumber}.$sep;
123
                print $item->{date}.$sep;
124
                print $item->{surname}.$sep;
125
                print $item->{firstname}.$sep;
126
                print $item->{amount}."\n";
127
        }
128
                print $sep;
129
                print $sep;
130
                print $sep;
131
                print $sep;
132
                print $grantotal."\n";
133
        exit(1);
134
    }
135
136
137
}
138
output_html_with_http_headers $input, $cookie, $template->output;
139
140
141
142
1;
143
144
145
=header
146
147
ate/) ? format_date_in_iso($filters[0]) : undef);
148
$filters[1]= (($line =~ /closedate/ || $column =~ /closedate/) ? format_date_in_iso($filters[1]) : undef);
149
150
=cut
151

Return to bug 6934