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