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>
(-)a/reports/cash_register_stats.pl (+116 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use strict;
19
#use warnings; FIXME - Bug 2505
20
use C4::Auth;
21
use CGI;
22
use C4::Context;
23
use C4::Reports;
24
use C4::Output;
25
use C4::Koha;
26
use C4::Circulation;
27
use C4::Dates qw/format_date format_date_in_iso/;
28
use C4::Budgets qw/GetCurrency GetCurrencies/;
29
30
BEGIN { $C4::Debug::debug = 1; }
31
32
my $input           = new CGI;
33
my $do_it           = $input->param('do_it');
34
my $fullreportname  = "reports/cash_register_stats.tt";
35
my @filters         = $input->param("Filter");
36
my $podsp           = $input->param("PlacedOnDisplay");
37
my $rodsp           = $input->param("ReceivedOnDisplay");
38
my $aodsp           = $input->param("AcquiredOnDisplay");   ##added by mason.
39
my $output          = $input->param("output");
40
my $basename        = $input->param("basename");
41
our $sep = "    ";
42
43
my ($template, $borrowernumber, $cookie)
44
    = get_template_and_user({template_name => $fullreportname,
45
                query => $input,
46
                type => "intranet",
47
                authnotrequired => 0,
48
                flagsrequired => {reports => '*'},
49
                debug => 1,
50
                });
51
52
$template->param(do_it => $do_it,
53
        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
54
        );
55
56
$filters[0]= format_date_in_iso($filters[0]);
57
$filters[1]= format_date_in_iso($filters[1]);
58
59
if ($do_it) {
60
   my $dbh = C4::Context->dbh;
61
   my $req = $dbh->prepare("SELECT round(amount,2),description,surname,firstname,t1.borrowernumber,t1.date,t1.amountoutstanding
62
        FROM accountlines t1 LEFT JOIN borrowers t2 ON t1.borrowernumber=t2.borrowernumber
63
        WHERE amount<0  AND accounttype IN ('L','Pay') AND CAST(t1.date AS DATE) between ? AND ? ORDER BY t1.date;");
64
    $req->execute($filters[0],$filters[1]);
65
66
    my @loopresult;
67
    my $grantotal =0;
68
    while ( my (@celvalue) = $req->fetchrow) {
69
        if((($celvalue[0]*-1)-$celvalue[6])>0){
70
            push @loopresult, { amount => sprintf("%.2f", ($celvalue[0] * -1)), surname => $celvalue[2], firstname => $celvalue[3], 
71
                borrowernumber => $celvalue[4], date => format_date_in_iso($celvalue[5])};
72
            $grantotal += ($celvalue[0]*-1);
73
        }
74
    }
75
    my @currency = GetCurrency();
76
    $grantotal = sprintf("%.2f", $grantotal);
77
78
    if($output eq 'screen'){
79
        $template->param(   loopresult => \@loopresult,
80
                            total => $grantotal,
81
                            beginDate => $filters[0],
82
                            endDate => $filters[1]
83
            );
84
    }else{
85
        binmode STDOUT, ':utf8';
86
        print $input->header(
87
                        -type => 'application/vnd.sun.xml.calc',
88
                        -encoding => 'utf-8',
89
                        -name => "$basename.csv",
90
                        -attachment => "$basename.csv"
91
                        );
92
        print "Borrower Number".$sep;
93
        print "Date".$sep;
94
        print "Surname".$sep;
95
        print "Firstname".$sep;
96
        print "Amount"."\n";
97
98
        foreach my $item (@loopresult){
99
            print $item->{borrowernumber}.$sep;
100
                print $item->{date}.$sep;
101
                print $item->{surname}.$sep;
102
                print $item->{firstname}.$sep;
103
                print $item->{amount}."\n";
104
        }
105
                print $sep;
106
                print $sep;
107
                print $sep;
108
                print $sep;
109
                print $grantotal."\n";
110
        exit(1);
111
    }
112
113
}
114
output_html_with_http_headers $input, $cookie, $template->output;
115
116
1;

Return to bug 6934