Bug 23355: (RM follow-up) Tidy Template
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / pos / register.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% PROCESS 'accounts.inc' %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha &rsaquo; Cashup</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css") | $raw %]
12 </head>
13
14 <body id="register" class="pos">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'circ-search.inc' %]
17
18 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/pos/pay.pl">Point of sale</a> &rsaquo; Register details</div>
19
20 <div class="main container-fluid">
21     <div class="row">
22         <div class="col-sm-10 col-sm-push-2">
23
24             [% IF ( error_registers ) %]
25             <div id="error_message" class="dialog alert">
26                 You must have at least one cash register associated with this branch before you can record payments.
27             </div>
28             [% ELSE %]
29
30             <div id="toolbar" class="btn-toolbar">
31                 <button type="button" class="btn btn-default" data-toggle="modal" data-target="#confirmCashupModal" ><i class="fa fa-money"></i> Record cashup</button>
32             </div>
33
34             <h1>Register transaction details for [% register.name | html %]</h1>
35
36             <h2>Summary</h2>
37             <ul>
38                 [% IF register.last_cashup %]
39                 <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</li>
40                 [% END %]
41                 <li>Float: [% register.starting_float | $Price %]</li>
42                 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
43                 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
44                 <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
45             </ul>
46
47             [% IF register.last_cashup %]
48             <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
49             [% ELSE %]
50             <h2>Transactions to date</h2>
51             [% END %]
52             <table id="sales" class="table_sales">
53                 <thead>
54                     <th>ID</th>
55                     <th>DATA</th>
56                     <th>Transaction</th>
57                     <th>Description</th>
58                     <th>Price</th>
59                     <th>Total</th>
60                     <th>Actions</th>
61                 </thead>
62                 <tbody>
63                     [% FOREACH accountline IN accountlines %]
64                         [% IF accountline.is_credit %]
65                             [% FOREACH credit IN accountline.credit_offsets %]
66                             [% IF credit.debit %]
67                             <tr>
68                                 <td>[% accountline.accountlines_id | html %]</td>
69                                 <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
70                                 <td></td>
71                                 <td>
72                                     [%- PROCESS account_type_description account=credit.debit -%]
73                                     [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
74                                     [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&amp;itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
75                                 </td>
76                                 <td>[% credit.debit.amount | $Price %]</td>
77                                 <td></td>
78                                 <td></td>
79                             </tr>
80                             [% END %]
81                             [% END %]
82                         [% ELSE %]
83                             [% FOREACH debit IN accountline.debit_offsets %]
84                             [% IF debit.credit %]
85                             <tr>
86                                 <td>[% accountline.accountlines_id | html %]</td>
87                                 <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
88                                 <td></td>
89                                 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
90                                 <td>
91                                     [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
92                                     [%- IF ( debit.credit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&amp;itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>)[%- END -%]
93                                 </td>
94                                 <td>[% debit.credit.amount | $Price %]</td>
95                                 <td></td>
96                             </tr>
97                             [% END %]
98                             [% END %]
99                         [% END %]
100                     [% END %]
101                 </tbody>
102                 <tfoot>
103                     <tr>
104                         <td colspan="5">Total income: </td>
105                         <td>[% accountlines.total * -1 | $Price %]</td>
106                         <td></td>
107                     </tr>
108                 </tfoot>
109             </table>
110             [% END %]
111         </div>
112
113         <div class="col-sm-2 col-sm-pull-10">
114             <aside>
115                 [% INCLUDE 'pos-menu.inc' %]
116             </aside>
117         </div>
118     </div><!-- /.row -->
119
120     <!-- Confirm cashup modal -->
121     <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
122         <div class="modal-dialog" role="document">
123             <div class="modal-content">
124                 <div class="modal-header">
125                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
126                     <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
127                 </div>
128                 <div class="modal-body">
129                     Please confirm that you have removed [% accountlines.total( payment_type => 'CASH') * -1 | $Price %] from the cash register and left a float of [% register.starting_float | $Price %].
130                 </div> <!-- /.modal-body -->
131                 <div class="modal-footer">
132                     <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default">Confirm</a>
133                     <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
134                 </div> <!-- /.modal-footer -->
135             </div> <!-- /.modal-content -->
136         </div> <!-- /.modal-dialog -->
137     </div> <!-- /#confirmCashupModal -->
138
139 [% MACRO jsinclude BLOCK %]
140     [% INCLUDE 'datatables.inc' %]
141     [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
142     <script>
143         var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
144             orderFixed: [ 0, 'asc'],
145             columnDefs: [ {
146                 targets: [ 0, 1 ],
147                 visible: false
148             }],
149             rowGroup: {
150                 dataSrc: 0,
151                 startRender: function ( rows, group ) {
152                     var details = JSON.parse(rows.data().pluck(1).pop());
153                     return $('<tr class="'+details.type+'"/>')
154                         .append( '<td>'+group+'</td>' )
155                         .append( '<td colspan="2">'+details.description+'</td>' )
156                         .append( '<td>'+details.amount+'</td>' )
157                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
158                 },
159                 endRender: null,
160             }
161         }));
162
163         $(".printReceipt").click(function() {
164             var accountlines_id = $(this).data('accountline');
165             var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
166             win.focus();
167         });
168     </script>
169 [% END %]
170
171 [% INCLUDE 'intranet-bottom.inc' %]