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_cash_management_manage_cash_registers || CAN_user_parameters_manage_auth_values) %]
9
        [% IF ( CAN_user_cash_management_manage_cash_registers || CAN_user_parameters_manage_auth_values) %]
4
        <h5>Administration</h5>
10
        <h5>Administration</h5>
5
        <ul>
11
        <ul>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (+125 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE AuthorisedValues %]
6
[% USE Price %]
7
[% SET footerjs = 1 %]
8
[% PROCESS 'accounts.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Koha &rsaquo; Cashup</title>
11
[% INCLUDE 'doc-head-close.inc' %]
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
            <div id="toolbar" class="btn-toolbar">
30
                <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>
31
            </div>
32
33
            <h1>Register transaction details for [% register.name | html %]</h1>
34
35
            <h2>Summary</h2>
36
            <ul>
37
                [% IF register.last_cashup %]
38
                <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</li>
39
                [% END %]
40
                <li>Float: [% register.starting_float | $Price %]</li>
41
                <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
42
                <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
43
                <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
44
            </ul>
45
46
            [% IF register.last_cashup %]
47
            <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
48
            [% ELSE %]
49
            <h2>Transactions to date</h2>
50
            [% END %]
51
            <table id="sales" class="table_sales">
52
                <thead>
53
                    <th>
54
                        Receipt ID
55
                    </th>
56
                    <th>
57
                        Description of charges
58
                    </th>
59
                    <th>
60
                        Item
61
                    </th>
62
                    <th>
63
                        Transaction
64
                    </th>
65
                    <th>
66
                        Actions
67
                    </th>
68
                </thead>
69
                <tbody>
70
                    [% FOREACH accountline IN accountlines %]
71
                        [% IF accountline.is_credit %]
72
                            <tr class="credit">
73
                                <td>[% accountline.accountlines_id %]</td>
74
                                <td>
75
                                    [%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])
76
                                </td>
77
                                <td></td>
78
                                <td>
79
                                    [% accountline.amount * -1 | $Price %]
80
                                </td>
81
                                <td>
82
                                    <button class="printReceipt" data-accountline="[%- accountline.accountlines_id | html -%]"><i class="fa fa-print"></i> Print receipt</button>
83
                                </td>
84
                            </tr>
85
                            [% FOREACH credit IN accountline.credit_offsets %]
86
                            <tr>
87
                                <td>[% accountline.accountlines_id %]</td>
88
                                <td>[%- PROCESS account_type_description account=credit.debit -%]</td>
89
                                <td>[% credit.debit.amount | $Price %]</td>
90
                                <td></td>
91
                                <td></td>
92
                            </tr>
93
                            [% END %]
94
                        [% END %]
95
                    [% END %]
96
                </tbody>
97
                <tfoot>
98
                    <tr>
99
                        <td colspan="3">Total income: </td>
100
                        <td>[% accountlines.total * -1 | $Price %]</td>
101
                        <td></td>
102
                    </tr>
103
                </tfoot>
104
            </table>
105
            [% END %]
106
        </div>
107
108
        <div class="col-sm-2 col-sm-pull-10">
109
            <aside>
110
                [% INCLUDE 'pos-menu.inc' %]
111
            </aside>
112
        </div>
113
    </div><!-- /.row -->
114
115
[% MACRO jsinclude BLOCK %]
116
    <script>
117
        $(".printReceipt").click(function() {
118
            var accountlines_id = $(this).data('accountline');
119
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
120
            win.focus();
121
        });
122
    </script>
123
[% END %]
124
125
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/pos/register.pl (-1 / +83 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# c 2015 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 $q = CGI->new();
31
32
my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
33
    {
34
        template_name   => 'pos/register.tt',
35
        query           => $q,
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_id = C4::Context->userenv->{'branch'};
43
my $registerid = $q->param('registerid');
44
my $registers  = Koha::Cash::Registers->search(
45
    { branch   => $library_id, archived => 0 },
46
    { order_by => { '-asc' => 'name' } }
47
);
48
49
if ( !$registers->count ) {
50
    $template->param( error_registers => 1 );
51
}
52
else {
53
    if ( !$registerid ) {
54
        my $default_register = Koha::Cash::Registers->find(
55
            { branch => $library_id, branch_default => 1 } );
56
        $registerid = $default_register->id if $default_register;
57
    }
58
    $registerid = $registers->next->id if !$registerid;
59
60
    $template->param(
61
        registerid => $registerid,
62
        registers  => $registers,
63
    );
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 = $q->param('op') // '';
74
if ( $op eq 'cashup' ) {
75
    $cash_register->add_cashup(
76
        {
77
            user_id => $logged_in_user->id,
78
            amount  => $cash_register->outstanding_accountlines->total
79
        }
80
    );
81
}
82
83
output_html_with_http_headers( $q, $cookie, $template->output );

Return to bug 23355