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