Bug 23805: (QA follow-up) Corrections for cash_register_stats
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / cash_register_stats.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Price %]
5 [% USE ItemTypes %]
6 [% SET footerjs = 1 %]
7 [% PROCESS 'accounts.inc' %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Cash register statistics &rsaquo; Results[% ELSE %]&rsaquo; Cash register statistics[% END %]</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 </head>
12
13 <body id="cash_register_stats" class="rep">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'cat-search.inc' %]
16
17 <div id="breadcrumbs">
18     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
19     &rsaquo;
20     [% IF ( do_it ) %]
21         <a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register statistics</a> &rsaquo; Results
22     [% ELSE %]
23         Cash register statistics
24     [% END %]
25 </div>
26
27 <div class="main container-fluid">
28     <div class="row">
29         <div class="col-sm-10 col-sm-push-2">
30             <main>
31
32     <h1>Cash register statistics</h1>
33     <form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl" id="frmCashRegister">
34         <fieldset class="rows">
35             <legend>Cash register statistics [% beginDate | $KohaDates %] to [% endDate | $KohaDates %]</legend>
36             <ol>
37                 <br>
38                 <li>
39                     <label for="from">From: </label>
40                     <input type="text" size="10" id="from" name="from" value="[% beginDate | $KohaDates %]" class="datepickerfrom" />
41                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
42                 </li>
43                 <li>
44                     <label for="to">To: </label>
45                     <input type="text" size="10" id="to" name="to" value="[% endDate | $KohaDates %]" class="datepickerto" />
46                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
47                 </li>
48
49                 <li>
50                     <label for="">Transaction type:</label>
51                     <select name="transaction_type" id="transaction_type">
52                         [% IF transaction_type == "ALL" %]
53                         <option value="ALL" selected="selected">All transactions</option>
54                         [% ELSE %]
55                         <option value="ALL">All transactions</option>
56                         [% END %]
57
58                         [% IF transaction_type == "ACT" %]
59                         <option value="ACT" selected="selected">All payments to the library</option>
60                         [% ELSE %]
61                         <option value="ACT">All payments to the library</option>
62                         [% END %]
63
64                         [% IF transaction_type == "FORW" %]
65                         <option value="FORW" selected="selected">Write off</option>
66                         [% ELSE %]
67                         <option value="FORW">Write off</option>
68                         [% END %]
69
70                         [% FOREACH debit_type IN debit_types %]
71                             [% IF transaction_type == debit_type.code %]
72                             <option value="[% debit_type.code | html %]" selected="selected">[% debit_type.description | html %]</option>
73                             [% ELSE %]
74                             <option value="[% debit_type.code | html %]">[% debit_type.description | html %]</option>
75                             [% END %]
76                         [% END %]
77                         
78                         [% FOREACH credit_type IN credit_types %]
79                             [% IF transaction_type == credit_type.code %]
80                             <option value="[% credit_type.code | html %]" selected="selected">[% credit_type.description | html %]</option>
81                             [% ELSE %]
82                             <option value="[% credit_type.code | html %]">[% credit_type.description | html %]</option>
83                             [% END %]
84                         [% END %]
85                     </select>
86                 </li>
87                 <li>
88                     <label>Transaction library</label>
89                     <select name="branch" id="branch">
90                         <option value="ALL">All</option>
91                         [% FOREACH branchloo IN branchloop %]
92                             [% IF ( branchloo.selected ) %]
93                             <option value="[% branchloo.branchcode | html %]" selected="selected">[% branchloo.branchname | html %]</option>
94                             [% ELSE %]
95                             <option value="[% branchloo.branchcode | html %]">[% branchloo.branchname | html %]</option>
96                             [% END %]
97                         [% END %]
98                     </select>
99              </td>
100         </tr>
101                 </li>
102             </ol>
103         </fieldset>
104
105         <fieldset class="rows">
106             <legend>Output</legend>
107             <ol>
108                 <li>
109                     <label for="outputscreen">To screen into the browser: </label>
110                     <input type="radio" checked="checked" name="output" id="outputscreen" value="screen" />
111                 </li>
112                 <li>
113                     <label for="outputfile">To a file:</label>
114                     <input type="radio" name="output" value="file" id="outputfile" />
115                     <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" />
116
117                 </li>
118             </ol>
119         </fieldset>
120
121         <fieldset class="action">
122         <input type="submit" value="Submit" name="do_it" />
123         </fieldset>
124     </form>
125
126     [% IF ( do_it ) %]
127     <div>&nbsp;</div>
128     <table id="tbl_cash_register_stats">
129         <thead>
130         <tr>
131             <th>Manager name</th>
132             <th>Patron card number</th>
133             <th>Patron name</th>
134             <th>Transaction library</th>
135             <th>Transaction date</th>
136             <th>Transaction type</th>
137             <th>Notes</th>
138             <th>Amount</th>
139             <th>Bibliographic record title</th>
140             <th>Barcode</th>
141             <th>Item type</th>
142         </tr>
143         </thead>
144         [% FOREACH loopresul IN loopresult %]
145             <tr>
146                 <td>[% loopresul.mfirstname | html %] [% loopresul.msurname | html %]</td>
147                 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopresul.borrowernumber | uri %]">[% loopresul.cardnumber | html %]</a></td>
148                 <td>[% loopresul.bfirstname | html %] [% loopresul.bsurname | html %]</td>
149                 <td>[% loopresul.branchname | html %]</td>
150                 <td>[% loopresul.date | $KohaDates %]</td>
151                 <td>
152                     [% IF loopresul.credit_type == "ACT" %]
153                         <span>All payments to the library</span>
154                     [% ELSE %]
155                         [%- PROCESS account_type_description account=loopresul -%]
156                     [% END %]
157                 </td>
158                 <td>[% loopresul.note | html %]</td>
159                 <td style="text-align:right;">[% loopresul.amount | $Price %]</td>
160                 <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopresul.biblionumber | uri %]">[% loopresul.title | html %]</a></td>
161                 <td>[% loopresul.barcode | html %]</td>
162                 <td>[% ItemTypes.GetDescription(loopresul.itype) | html %]</td>
163             </tr>
164         [% END %]
165         <tfoot>
166         <tr>
167             [% IF transaction_type == "ACT" %]
168             <th colspan="7" style="text-align:right;">TOTAL</th>
169             <th style="text-align:right;">[% total  | $Price %]</th>
170             <th colspan="3">&nbsp;</th>
171             [% END %]
172         </tr>
173         </tfoot>
174     </table>
175
176     [% END %] [%# do_it %]
177
178             </main>
179         </div> <!-- /.col-sm-10.col-sm-push-2 -->
180
181         <div class="col-sm-2 col-sm-pull-10">
182             <aside>
183                 [% INCLUDE 'reports-menu.inc' %]
184             </aside>
185         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
186      </div> <!-- /.row -->
187
188 [% MACRO jsinclude BLOCK %]
189     [% INCLUDE 'datatables.inc' %]
190     <script id="js">
191         $(document).ready(function() {
192             $("#tbl_cash_register_stats").dataTable($.extend(true, {}, dataTablesDefaults, {
193                 "iDisplayLength": 50,
194                 "sPaginationType": "full_numbers"
195             }));
196         });
197     </script>
198     [% INCLUDE 'calendar.inc' %]
199     <script>
200         actTotal = "";
201
202         $(document).ready(function() {
203             // http://jqueryui.com/demos/datepicker/#date-range
204             var dates = $( "#filter_date_begin, #filter_date_end" ).datepicker({
205                 changeMonth: true,
206                 numberOfMonths: 1,
207                 onSelect: function( selectedDate ) {
208                     var option = this.id == "filter_date_begin" ? "minDate" : "maxDate",
209                         instance = $( this ).data( "datepicker" );
210                         date = $.datepicker.parseDate(
211                             instance.settings.dateFormat ||
212                             $.datepicker._defaults.dateFormat,
213                             selectedDate, instance.settings );
214                     dates.not( this ).datepicker( "option", option, date );
215                 }
216             });
217
218             $('#frmCashRegister').submit(function() {
219                 var isFormValid = true;
220                 var alertString= _("Form not submitted because of the following problem(s)")+"\n";
221
222                 alertString +="-------------------------------------------------------------------\n\n";
223
224                 if ( !$('#from').val() || !$('#to').val()){
225                     isFormValid = false;
226                     alertString += "\n- " + _("Dates cannot be empty");
227                 }
228
229                 if (!isFormValid) {
230                    alert(alertString);
231                    return false;
232                 }
233             });
234         });
235     </script>
236 [% END %]
237
238 [% INCLUDE 'intranet-bottom.inc' %]