Bug 31041: add modal_printer.js asset to registers.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / pos / registers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Cashup &rsaquo; Koha</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 </head>
11
12 <body id="cashup" class="pos">
13     [% WRAPPER 'header.inc' %]
14     [% INCLUDE 'circ-search.inc' %]
15 [% END %]
16
17     [% WRAPPER 'sub-header.inc' %]
18         [% WRAPPER breadcrumbs %]
19             [% WRAPPER breadcrumb_item %]
20                     <a href="/cgi-bin/koha/pos/pay.pl">Cash management</a>
21             [% END %]
22             [% WRAPPER breadcrumb_item bc_active= 1 %]
23                 <span>Cash summary for [% library.branchname | html %]</span>
24             [% END %]
25         [% END #/ WRAPPER breadcrumbs %]
26     [% END #/ WRAPPER sub-header.inc %]
27
28     <div class="main container-fluid">
29         <div class="row">
30             <div class="col-sm-10 col-sm-push-2">
31                 <main>
32                     [% IF ( error_registers ) %]
33                         <div id="error_message" class="dialog message">
34                             <p>
35                                 You must have at least one cash register associated with the library before you can record payments.
36                             </p>
37                             [% IF ( CAN_user_parameters_manage_cash_registers ) %]
38                                 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
39                                     <input type="hidden" name="op" value="add_form" />
40                                     <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
41                                 </form>
42                             [% END %]
43                         </div>
44                     [% ELSE %]
45
46                     [% IF ( error_cashup_permission ) %]
47                     <div id="error_message" class="dialog alert">
48                         You do not have permission to perform cashup actions.
49                     </div>
50                     [% END %]
51
52                     [% IF CAN_user_cash_management_cashup %]
53                     <div id="toolbar" class="btn-toolbar">
54                         <button type="button" class="cashup_all btn btn-default" data-toggle="modal" data-target="#confirmCashupAllModal"><i class="fa fa-money"></i> Cashup all</button>
55                     </div>
56                     [% END %]
57
58                     <h1>Cash summary for [% library.branchname | html %]</h1>
59
60                     <h2>Summary</h2>
61                     <ul>
62                         <li>Total income (cash): <span id="income"></span></li>
63                         <li>Total outgoing (cash): <span id="outgoing"></span></li>
64                         <li>Total bankable: <span id="bankable"></span></li>
65                     </ul>
66
67                     <div class="page-section">
68                         <table id="registers" class="table_registers">
69                             <thead>
70                                 <tr>
71                                     <th>Register name</th>
72                                     <th>Register description</th>
73                                     <th>Last cashup</th>
74                                     <th>Float</th>
75                                     <th>Bankable</th>
76                                     <th>Income (cash)</th>
77                                     <th>Outgoing (cash)</th>
78                                     [% IF CAN_user_cash_management_cashup %]
79                                         <th class="noExport">Actions</th>
80                                     [% END %]
81                                 </tr>
82                             </thead>
83                             <tbody>
84                                 [% SET bankable = 0, ctotal = 0, dtotal = 0, cctotal = 0, cdtotal = 0 %]
85                                 [% FOREACH register IN registers %]
86                                 <tr>
87                                     <td><a href="/cgi-bin/koha/pos/register.pl?registerid=[% register.id | uri %]">[% register.name | html %]</a></td>
88                                     <td>[% register.description | html %]</td>
89                                     <td>
90                                         [%- IF register.last_cashup -%]
91                                         [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" data-cashup="[% register.last_cashup.id | html %]" data-register="[% register.description | html %]" href="#cashupSummaryModal" class="button">Summary</a>)
92                                         [%- ELSE -%]
93                                         No last cashup
94                                         [%- END -%]
95                                     </td>
96                                     <td>[% register.starting_float | $Price %]</td>
97                                     <td>
98                                         [% SET rbankable = ( register.outstanding_accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 ) %]
99                                         [% SET bankable = bankable + rbankable %]
100                                         [% rbankable | $Price %]
101                                     </td>
102                                     <td>
103                                         [% SET rctotal = ( register.outstanding_accountlines.credits_total * -1 ) %]
104                                         [% SET rcctotal = ( register.outstanding_accountlines.credits_total( payment_type => [ 'CASH', 'SIP00' ]) * -1 ) %]
105                                         [% rctotal | $Price %] ([% rcctotal | $Price %])
106                                         [% SET ctotal = ctotal + rctotal %]
107                                         [% SET cctotal = cctotal + rcctotal %]
108                                     </td>
109                                     <td>
110                                         [% SET rdtotal = ( register.outstanding_accountlines.debits_total * -1 ) %]
111                                         [% SET rcdtotal = ( register.outstanding_accountlines.debits_total( payment_type => [ 'CASH', 'SIP00' ]) * -1 ) %]
112                                         [% rdtotal | $Price %] ([% rcdtotal | $Price %])
113                                         [% SET dtotal = dtotal + rdtotal %]
114                                         [% SET cdtotal = cdtotal + rcdtotal %]
115                                     </td>
116                                     [% IF CAN_user_cash_management_cashup %]
117                                     <td>
118                                         <button type="button" class="cashup_individual btn btn-xs btn-default" data-toggle="modal" data-target="#confirmCashupModal" data-register="[% register.description | html %]" data-bankable="[% rbankable | $Price %]" data-float="[% register.starting_float | $Price %]" data-registerid="[% register.id | html %]"><i class="fa fa-money"></i> Record cashup</button>
119                                     </td>
120                                     [% END %]
121                                 </tr>
122                                 [% END %]
123                             </tbody>
124                             <tfoot>
125                                 <tr>
126                                     <td colspan="4" align="right">Totals:</td>
127                                     <td>[% bankable | $Price %]</td>
128                                     <td>[% ctotal | $Price %] ([% cctotal | $Price %])</td>
129                                     <td>[% dtotal | $Price %] ([% cdtotal | $Price %])</td>
130                                     [% IF CAN_user_cash_management_cashup %]
131                                     <td>
132                                         <button type="button" class="cashup_all btn btn-xs btn-default" data-toggle="modal" data-target="#confirmCashupAllModal"><i class="fa fa-money"></i> Cashup all</button>
133                                     </td>
134                                     [% END %]
135                                 </tr>
136                             </tfoot>
137                         </table>
138                     </div> <!-- /.page-section -->
139                     [% END %]
140                 </main>
141             </div>
142
143             <div class="col-sm-2 col-sm-pull-10">
144                 <aside>
145                     [% INCLUDE 'pos-menu.inc' %]
146                 </aside>
147             </div>
148
149         </div>
150         <!-- /.row -->
151
152         <!-- Confirm cashup modal -->
153         <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
154             <div class="modal-dialog" role="document">
155                 <div class="modal-content">
156                     <div class="modal-header">
157                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
158                         <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em><span id="registerc"></span></em></h4>
159                     </div>
160                     <div class="modal-body">
161                         Please confirm that you have removed <span id="cashc"></span> from the cash register and left a float of <span id="floatc"></span>.
162                     </div> <!-- /.modal-body -->
163                     <div class="modal-footer">
164                         <a id="cashup_confirm" href="" class="btn btn-default">Confirm</a>
165                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
166                     </div> <!-- /.modal-footer -->
167                 </div> <!-- /.modal-content -->
168             </div> <!-- /.modal-dialog -->
169         </div> <!-- /#confirmCashupModal -->
170
171         <!-- Confirm cashupall modal -->
172         <div class="modal" id="confirmCashupAllModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupAllLabel">
173             <div class="modal-dialog" role="document">
174                 <div class="modal-content">
175                     <div class="modal-header">
176                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
177                         <h4 class="modal-title" id="confirmCashupAllLabel">Confirm cashup of <em>all</em> cash registers</h4>
178                     </div>
179                     <div class="modal-body">
180                         <p>Please confirm that you have received [% bankable | $Price %] to cashup.</p>
181                         <ul>
182                             <li>Total income (cash): [% ctotal | $Price %] ([% cctotal | $Price %])</li>
183                             <li>Total outgoing (cash): [% dtotal | $Price %] ([% cdtotal | $Price %])</li>
184                         </ul>
185                     </div> <!-- /.modal-body -->
186                     <div class="modal-footer">
187                         <a id="cashup_all_confirm" href="/cgi-bin/koha/pos/registers.pl?op=cashup" class="btn btn-default">Confirm</a>
188                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
189                     </div> <!-- /.modal-footer -->
190                 </div> <!-- /.modal-content -->
191             </div> <!-- /.modal-dialog -->
192         </div> <!-- /#confirmCashupAllModal -->
193
194         [% INCLUDE 'modals/cashup_summary.inc' %]
195
196         [% MACRO jsinclude BLOCK %]
197         [% INCLUDE 'datatables.inc' %]
198         [% INCLUDE 'format_price.inc' %]
199         [% INCLUDE 'js-date-format.inc' %]
200         [% Asset.js("js/cashup_modal.js") | $raw %]
201         [% Asset.js("js/modal_printer.js") | $raw %]
202         <script>
203             $(document).ready(function () {
204
205                 [%# js used here as we don't have access to these template variables where we need them #%]
206                 $("#bankable").text('[% bankable | $Price %]');
207                 $("#income").text('[% ctotal | $Price %] ([% cctotal | $Price %])');
208                 $("#outgoing").text('[% dtotal | $Price %] ([% cdtotal | $Price %])');
209
210                 var registers_table = $("#registers").dataTable($.extend(true, {}, dataTablesDefaults, {
211                     "bFilter": false,
212                     "paginationType": "full"
213                 }));
214
215                 $("#confirmCashupModal").on("shown.bs.modal", function(e){
216                    var button = $(e.relatedTarget);
217                    var register = button.data('register');
218                    $("#registerc").text(register);
219                    var bankable = button.data('bankable');
220                    $("#cashc").text(bankable);
221                    var rfloat = button.data('float');
222                    $('#floatc').text(rfloat);
223                    var rid = button.data('registerid');
224                    $('#cashup_confirm').attr("href", '/cgi-bin/koha/pos/registers.pl?op=cashup&registerid='+rid);
225                 });
226             });
227         </script>
228         [% END %]
229 [% INCLUDE 'intranet-bottom.inc' %]