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