View | Details | Raw Unified | Return to bug 24492
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc (+1 lines)
Lines 4-9 Link Here
4
        <h5>Point of sale</h5>
4
        <h5>Point of sale</h5>
5
        <ul>
5
        <ul>
6
            <li><a href="/cgi-bin/koha/pos/register.pl">Register details</a></li>
6
            <li><a href="/cgi-bin/koha/pos/register.pl">Register details</a></li>
7
            <li><a href="/cgi-bin/koha/pos/registers.pl">Branch details</a></li>
7
        </ul>
8
        </ul>
8
        [% END %]
9
        [% END %]
9
        [% IF ( CAN_user_parameters_manage_cash_registers || CAN_user_parameters_manage_accounts) %]
10
        [% IF ( CAN_user_parameters_manage_cash_registers || CAN_user_parameters_manage_accounts) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/registers.tt (+184 lines)
Line 0 Link Here
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>Koha &rsaquo; Cashup</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
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Point of sale</div>
17
18
    <div class="main container-fluid">
19
        <div class="row">
20
            <div class="col-sm-10 col-sm-push-2">
21
                <main>
22
                    [% IF ( error_registers ) %]
23
                    <div id="error_message" class="dialog alert">
24
                        You must have at least one cash register associated with this branch before you
25
                        can record payments.
26
                    </div>
27
                    [% ELSE %]
28
                    <div id="toolbar" class="btn-toolbar">
29
                        <button type="button" class="cashup_all btn btn-default" data-toggle="modal" data-target="#confirmCashupAllModal"><i class="fa fa-money"></i> Cashup all</button>
30
                    </div>
31
32
                    <h1>Branch transaction details for [% library.branchname | html %]</h1>
33
34
                    <h2>Summary</h2>
35
                    <ul>
36
                        <li>Total income (cash): <span id="income"></span></li>
37
                        <li>Total outgoing (cash): <span id="outgoing"></span></li>
38
                        <li>Total bankable: <span id="bankable"></span></li>
39
                    </ul>
40
41
                    <table id="registers" class="table_registers">
42
                        <thead>
43
                            <th>Register name</th>
44
                            <th>Register description</th>
45
                            <th>Last cashup</th>
46
                            <th>Float</th>
47
                            <th>Bankable</th>
48
                            <th>Income (cash)</th>
49
                            <th>Outgoing (cash)</th>
50
                            <th>Actions</th>
51
                        </thead>
52
                        <tbody>
53
                            [% SET bankable = 0, ctotal = 0, dtotal = 0, cctotal = 0, cdtotal = 0 %]
54
                            [% FOREACH register IN registers %]
55
                            <tr>
56
                                <td><a href="/cgi-bin/koha/pos/register.pl?registerid=[% register.id | uri %]">[% register.name | html %]</a></td>
57
                                <td>[% register.description | html %]</td>
58
                                <td>
59
                                    [%- IF register.last_cashup -%]
60
                                    [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] ([% register.last_cashup.amount | $Price %])
61
                                    [%- ELSE -%]
62
                                    No last cashup
63
                                    [%- END -%]
64
                                </td>
65
                                <td>[% register.starting_float | $Price %]</td>
66
                                <td>
67
                                    [% SET rbankable = ( register.outstanding_accountlines.total( payment_type => 'CASH') * -1 ) %]
68
                                    [% SET bankable = bankable + rbankable %]
69
                                    [% rbankable | $Price %]
70
                                </td>
71
                                <td>
72
                                    [% SET rctotal = ( register.outstanding_accountlines.credits_total * -1 ) %]
73
                                    [% SET rcctotal = ( register.outstanding_accountlines.credits_total( payment_type => 'CASH') * -1 ) %]
74
                                    [% rctotal | $Price %] ([% rcctotal | $Price %])
75
                                    [% SET ctotal = ctotal + rctotal %]
76
                                    [% SET cctotal = cctotal + rcctotal %]
77
                                </td>
78
                                <td>
79
                                    [% SET rdtotal = ( register.outstanding_accountlines.debits_total * -1 ) %]
80
                                    [% SET rcdtotal = ( register.outstanding_accountlines.debits_total( payment_type => 'CASH') * -1 ) %]
81
                                    [% rdtotal | $Price %] ([% rcdtotal | $Price %])
82
                                    [% SET dtotal = dtotal + rdtotal %]
83
                                    [% SET cdtotal = cdtotal + rcdtotal %]
84
                                <td>
85
                                    <button type="button" class="cashup_individual btn 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>
86
                                </td>
87
                            </tr>
88
                            [% END %]
89
                        </tbody>
90
                        <tfoot>
91
                            <tr>
92
                                <td colspan="4" align="right">Totals:</td>
93
                                <td>[% bankable | $Price %]</td>
94
                                <td>[% ctotal | $Price %] ([% cctotal | $Price %])</td>
95
                                <td>[% dtotal | $Price %] ([% cdtotal | $Price %])</td>
96
                                <td><button type="button" class="cashup_all btn btn-default" data-toggle="modal" data-target="#confirmCashupAllModal"><i class="fa fa-money"></i> Cashup all</button></td>
97
                            </tr>
98
                        </tfoot>
99
                    </table>
100
                    [% END %]
101
                </main>
102
            </div>
103
104
            <div class="col-sm-2 col-sm-pull-10">
105
                <aside>
106
                    [% INCLUDE 'pos-menu.inc' %]
107
                </aside>
108
            </div>
109
110
        </div>
111
        <!-- /.row -->
112
113
        <!-- Confirm cashup modal -->
114
        <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
115
            <div class="modal-dialog" role="document">
116
                <div class="modal-content">
117
                    <div class="modal-header">
118
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
119
                        <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em><span id="registerc"></span></em></h4>
120
                    </div>
121
                    <div class="modal-body">
122
                        Please confirm that you have removed <span id="cashc"></span> from the cash register and left a float of <span id="floatc"></span>.
123
                    </div> <!-- /.modal-body -->
124
                    <div class="modal-footer">
125
                        <a id="cashup_confirm" href="" class="btn btn-default">Confirm</a>
126
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
127
                    </div> <!-- /.modal-footer -->
128
                </div> <!-- /.modal-content -->
129
            </div> <!-- /.modal-dialog -->
130
        </div> <!-- /#confirmCashupModal -->
131
132
        <!-- Confirm cashupall modal -->
133
        <div class="modal" id="confirmCashupAllModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupAllLabel">
134
            <div class="modal-dialog" role="document">
135
                <div class="modal-content">
136
                    <div class="modal-header">
137
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
138
                        <h4 class="modal-title" id="confirmCashupAllLabel">Confirm cashup of <em>all</em> cash registers</h4>
139
                    </div>
140
                    <div class="modal-body">
141
                        <p>Please confirm that you have recieved [% bankable | $Price %] to cashup.</p>
142
                        <ul>
143
                            <li>Total income (cash): [% ctotal | $Price %] ([% cctotal | $Price %])</li>
144
                            <li>Total outgoing (cash): [% dtotal | $Price %] ([% cdtotal | $Price %])</li>
145
                        </ul>
146
                    </div> <!-- /.modal-body -->
147
                    <div class="modal-footer">
148
                        <a href="/cgi-bin/koha/pos/registers.pl?op=cashup" class="btn btn-default">Confirm</a>
149
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
150
                    </div> <!-- /.modal-footer -->
151
                </div> <!-- /.modal-content -->
152
            </div> <!-- /.modal-dialog -->
153
        </div> <!-- /#confirmCashupAllModal -->
154
155
        [% MACRO jsinclude BLOCK %]
156
        [% INCLUDE 'datatables.inc' %]
157
        <script>
158
            $(document).ready(function () {
159
160
                [%# js used here as we don't have access to these template variables where we need them #%]
161
                $("#bankable").text('[% bankable | $Price %]');
162
                $("#income").text('[% ctotal | $Price %] ([% cctotal | $Price %])');
163
                $("#outgoing").text('[% dtotal | $Price %] ([% cdtotal | $Price %])');
164
165
                var registers_table = $("#registers").dataTable($.extend(true, {}, dataTablesDefaults, {
166
                    "bFilter": false,
167
                    "paginationType": "full"
168
                }));
169
170
                $("#confirmCashupModal").on("shown.bs.modal", function(e){
171
                   var button = $(e.relatedTarget);
172
                   var register = button.data('register');
173
                   $("#registerc").text(register);
174
                   var bankable = button.data('bankable');
175
                   $("#cashc").text(bankable);
176
                   var rfloat = button.data('float');
177
                   $('#floatc').text(rfloat);
178
                   var rid = button.data('registerid');
179
                   $('#cashup_confirm').attr("href", '/cgi-bin/koha/pos/register.pl?op=cashup&registerid='+rid);
180
                });
181
            });
182
        </script>
183
        [% END %]
184
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+8 lines)
Lines 129-134 Link Here
129
    <dd>Access files stored on the server, like log files or reports</dd>
129
    <dd>Access files stored on the server, like log files or reports</dd>
130
    [% END %]
130
    [% END %]
131
131
132
    [% IF ( Koha.Preference('UseCashRegisters') && CAN_user_cash_management_manage_cash_registers ) %]
133
        [% IF ( CAN_user_cash_management_manage_cash_registers ) %]
134
        <dt><a href="/cgi-bin/koha/pos/registers.pl">Cashup registers</a></dt>
135
        <dd>Perfrom cashup actions on cash registers</dd>
136
        [% END %]
137
    [% END %]
138
139
132
</dl>
140
</dl>
133
</div>
141
</div>
134
142
(-)a/pos/registers.pl (-1 / +69 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# c 2020 PTFS-Europe Ltd
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
#
20
21
use Modern::Perl;
22
use CGI;
23
use C4::Auth;
24
use C4::Output;
25
use C4::Context;
26
27
use Koha::Cash::Registers;
28
use Koha::Database;
29
30
my $input = CGI->new();
31
32
my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
33
    {
34
        template_name   => 'pos/registers.tt',
35
        query           => $input,
36
        type            => 'intranet',
37
        authnotrequired => 0,
38
    }
39
);
40
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
41
42
my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} );
43
$template->param( library => $library );
44
45
my $registers = Koha::Cash::Registers->search(
46
    { branch   => $library->id, archived => 0 },
47
    { order_by => { '-asc' => 'name' } }
48
);
49
50
if ( !$registers->count ) {
51
    $template->param( error_registers => 1 );
52
}
53
else {
54
    $template->param( registers => $registers );
55
}
56
57
my $op = $input->param('op') // '';
58
if ( $op eq 'cashup' ) {
59
    for my $register ( $registers->as_list ) {
60
        $register->add_cashup(
61
            {
62
                user_id => $logged_in_user->id,
63
                amount  => $register->outstanding_accountlines->total
64
            }
65
        );
66
    }
67
}
68
69
output_html_with_http_headers( $input, $cookie, $template->output );

Return to bug 24492