Bug 31121: Fix date formatting in cashup summary modal
[koha-ffzg.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     [% INCLUDE 'header.inc' %]
14     [% INCLUDE 'circ-search.inc' %]
15
16     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
17         <ol>
18             <li>
19                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
20             </li>
21             <li>
22                 <a href="/cgi-bin/koha/pos/pay.pl">Cash management</a>
23             </li>
24             <li>
25                 <a href="#" aria-current="page">
26                     Cash summary for [% library.branchname | html %]
27                 </a>
28             </li>
29         </ol>
30     </nav>
31
32     <div class="main container-fluid">
33         <div class="row">
34             <div class="col-sm-10 col-sm-push-2">
35                 <main>
36                     [% IF ( error_registers ) %]
37                         <div id="error_message" class="dialog message">
38                             <p>
39                                 You must have at least one cash register associated with the library before you can record payments.
40                             </p>
41                             [% IF ( CAN_user_parameters_manage_cash_registers ) %]
42                                 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
43                                     <input type="hidden" name="op" value="add_form" />
44                                     <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
45                                 </form>
46                             [% END %]
47                         </div>
48                     [% ELSE %]
49
50                     [% IF ( error_cashup_permission ) %]
51                     <div id="error_message" class="dialog alert">
52                         You do not have permission to perform cashup actions.
53                     </div>
54                     [% END %]
55
56                     [% IF CAN_user_cash_management_cashup %]
57                     <div id="toolbar" class="btn-toolbar">
58                         <button type="button" class="cashup_all btn btn-default" data-toggle="modal" data-target="#confirmCashupAllModal"><i class="fa fa-money"></i> Cashup all</button>
59                     </div>
60                     [% END %]
61
62                     <h1>Cash summary for [% library.branchname | html %]</h1>
63
64                     <h2>Summary</h2>
65                     <ul>
66                         <li>Total income (cash): <span id="income"></span></li>
67                         <li>Total outgoing (cash): <span id="outgoing"></span></li>
68                         <li>Total bankable: <span id="bankable"></span></li>
69                     </ul>
70
71                     <table id="registers" class="table_registers">
72                         <thead>
73                             <th>Register name</th>
74                             <th>Register description</th>
75                             <th>Last cashup</th>
76                             <th>Float</th>
77                             <th>Bankable</th>
78                             <th>Income (cash)</th>
79                             <th>Outgoing (cash)</th>
80                             [% IF CAN_user_cash_management_cashup %]
81                             <th class="noExport">Actions</th>
82                             [% END %]
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 fa-money"></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 fa-money"></i> Cashup all</button>
134                                 </td>
135                                 [% END %]
136                             </tr>
137                         </tfoot>
138                     </table>
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         <script>
202             $(document).ready(function () {
203
204                 [%# js used here as we don't have access to these template variables where we need them #%]
205                 $("#bankable").text('[% bankable | $Price %]');
206                 $("#income").text('[% ctotal | $Price %] ([% cctotal | $Price %])');
207                 $("#outgoing").text('[% dtotal | $Price %] ([% cdtotal | $Price %])');
208
209                 var registers_table = $("#registers").dataTable($.extend(true, {}, dataTablesDefaults, {
210                     "bFilter": false,
211                     "paginationType": "full"
212                 }));
213
214                 $("#confirmCashupModal").on("shown.bs.modal", function(e){
215                    var button = $(e.relatedTarget);
216                    var register = button.data('register');
217                    $("#registerc").text(register);
218                    var bankable = button.data('bankable');
219                    $("#cashc").text(bankable);
220                    var rfloat = button.data('float');
221                    $('#floatc').text(rfloat);
222                    var rid = button.data('registerid');
223                    $('#cashup_confirm').attr("href", '/cgi-bin/koha/pos/registers.pl?op=cashup&registerid='+rid);
224                 });
225             });
226         </script>
227         [% END %]
228 [% INCLUDE 'intranet-bottom.inc' %]