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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc (+6 lines)
Lines 1-5 Link Here
1
<div id="navmenu">
1
<div id="navmenu">
2
    <div id="navmenulist">
2
    <div id="navmenulist">
3
        [% IF ( CAN_user_cash_management_cashup_cash_registers ) %]
4
        <h5>Point of sale</h5>
5
        <ul>
6
            <li><a href="/cgi-bin/koha/pos/register.pl">Register details</a></li>
7
        </ul>
8
        [% END %]
3
        [% IF ( CAN_user_parameters_manage_cash_registers || CAN_user_parameters_manage_accounts) %]
9
        [% IF ( CAN_user_parameters_manage_cash_registers || CAN_user_parameters_manage_accounts) %]
4
        <h5>Administration</h5>
10
        <h5>Administration</h5>
5
        <ul>
11
        <ul>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt (-1 lines)
Lines 173-179 Link Here
173
[% END %]
173
[% END %]
174
174
175
[% MACRO jsinclude BLOCK %]
175
[% MACRO jsinclude BLOCK %]
176
    [% Asset.js("js/admin-menu.js") | $raw %]
177
    [% INCLUDE 'format_price.inc' %]
176
    [% INCLUDE 'format_price.inc' %]
178
    [% INCLUDE 'datatables.inc' %]
177
    [% INCLUDE 'datatables.inc' %]
179
    [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
178
    [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (+180 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
[% 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
                <a id="cashup" href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default"><i class="fa fa-money"></i> Record cashup</a>
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>
55
                        ID
56
                    </th>
57
                    <th>
58
                        DATA
59
                    </th>
60
                    <th>
61
                        Transaction
62
                    </th>
63
                    <th>
64
                        Description
65
                    </th>
66
                    <th>
67
                        Price
68
                    </th>
69
                    <th>
70
                        Total
71
                    </th>
72
                    <th>
73
                        Actions
74
                    </th>
75
                </thead>
76
                <tbody>
77
                    [% FOREACH accountline IN accountlines %]
78
                        [% IF accountline.is_credit %]
79
                            [% FOREACH credit IN accountline.credit_offsets %]
80
                            [% IF credit.debit %]
81
                            <tr>
82
                                <td>
83
                                    [% accountline.accountlines_id %]
84
                                </td>
85
                                <td>
86
                                    { "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }
87
                                </td>
88
                                <td></td>
89
                                <td>
90
                                    [%- PROCESS account_type_description account=credit.debit -%]
91
                                    [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
92
                                    [%- 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 -%]
93
                                </td>
94
                                <td>
95
                                    [% credit.debit.amount | $Price %]
96
                                </td>
97
                                <td></td>
98
                                <td></td>
99
                            </tr>
100
                            [% END %]
101
                            [% END %]
102
                        [% ELSE %]
103
                            [% FOREACH debit IN accountline.debit_offsets %]
104
                            [% IF debit.credit %]
105
                            <tr>
106
                                <td>
107
                                    [% accountline.accountlines_id %]
108
                                </td>
109
                                <td>
110
                                    { "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }
111
                                </td>
112
                                <td></td>
113
                                <td>
114
                                    [%- PROCESS account_type_description account=debit.credit -%]
115
                                </td>
116
                                <td>
117
                                    [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
118
                                    [%- 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 -%]
119
                                </td>
120
                                <td>
121
                                    [% debit.credit.amount | $Price %]
122
                                </td>
123
                                <td></td>
124
                            </tr>
125
                            [% END %]
126
                            [% END %]
127
                        [% END %]
128
                    [% END %]
129
                </tbody>
130
                <tfoot>
131
                    <tr>
132
                        <td colspan="5">Total income: </td>
133
                        <td>[% accountlines.total * -1 | $Price %]</td>
134
                        <td></td>
135
                    </tr>
136
                </tfoot>
137
            </table>
138
            [% END %]
139
        </div>
140
141
        <div class="col-sm-2 col-sm-pull-10">
142
            <aside>
143
                [% INCLUDE 'pos-menu.inc' %]
144
            </aside>
145
        </div>
146
    </div><!-- /.row -->
147
148
[% MACRO jsinclude BLOCK %]
149
    [% INCLUDE 'datatables.inc' %]
150
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
151
    <script>
152
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
153
            orderFixed: [ 0, 'asc'],
154
            columnDefs: [ {
155
                targets: [ 0, 1 ],
156
                visible: false
157
            }],
158
            rowGroup: {
159
                dataSrc: 0,
160
                startRender: function ( rows, group ) {
161
                    var details = JSON.parse(rows.data().pluck(1).pop());
162
                    return $('<tr class="'+details.type+'"/>')
163
                        .append( '<td>'+group+'</td>' )
164
                        .append( '<td colspan="2">'+details.description+'</td>' )
165
                        .append( '<td>'+details.amount+'</td>' )
166
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
167
                },
168
                endRender: null,
169
            }
170
        }));
171
172
        $(".printReceipt").click(function() {
173
            var accountlines_id = $(this).data('accountline');
174
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
175
            win.focus();
176
        });
177
    </script>
178
[% END %]
179
180
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/pos/register.pl (-1 / +84 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/register.tt',
35
        query           => $input,
36
        type            => 'intranet',
37
        authnotrequired => 0,
38
        flagsrequired   => { cash_management => 'cashup' },
39
    }
40
);
41
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
42
43
my $library_id = C4::Context->userenv->{'branch'};
44
my $registerid = $input->param('registerid');
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
    if ( !$registerid ) {
55
        my $default_register = Koha::Cash::Registers->find(
56
            { branch => $library_id, branch_default => 1 } );
57
        $registerid = $default_register->id if $default_register;
58
    }
59
    $registerid = $registers->next->id if !$registerid;
60
61
    $template->param(
62
        registerid => $registerid,
63
        registers  => $registers,
64
    );
65
66
    my $cash_register = Koha::Cash::Registers->find( { id => $registerid } );
67
    my $accountlines = $cash_register->outstanding_accountlines();
68
    $template->param(
69
        register     => $cash_register,
70
        accountlines => $accountlines
71
    );
72
73
    my $op = $input->param('op') // '';
74
    if ( $op eq 'cashup' ) {
75
        $cash_register->add_cashup(
76
            {
77
                staff_id => $logged_in_user->id,
78
                amount   => $cash_register->outstanding_accountlines->total
79
            }
80
        );
81
    }
82
}
83
84
output_html_with_http_headers( $input, $cookie, $template->output );

Return to bug 23355