View | Details | Raw Unified | Return to bug 23355
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 (+149 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
[% INCLUDE 'doc-head-open.inc' %]
9
<title>Koha &rsaquo; Cashup</title>
10
[% INCLUDE 'doc-head-close.inc' %]
11
</head>
12
13
<body id="cashup" class="pos">
14
[% INCLUDE 'header.inc' %]
15
[% INCLUDE 'circ-search.inc' %]
16
17
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Point of sale</div>
18
19
<div class="main container-fluid">
20
    <div class="row">
21
        <div class="col-sm-10 col-sm-push-2">
22
            <main>
23
                [% IF ( error_registers ) %]
24
                <div id="error_message" class="dialog alert">
25
                    You must have at least one cash register associated with this branch before you can record payments.
26
                </div>
27
                [% ELSE %]
28
                <div id="toolbar" class="btn-toolbar">
29
                    <a class="cashup_all btn btn-default" href="/cgi-bin/koha/pos/registers.pl?op=cashup"><i class="fa fa-money"></i> Cashup all</a>
30
                </div>
31
32
                <h1>Branch transaction details for [% library.branchname | html %]</h1>
33
34
                <h2>Summary</h2>
35
36
37
38
                <table id="registers" class="table_registers">
39
                    <thead>
40
                        <th>
41
                            ID
42
                        </th>
43
                        <th>
44
                            Name
45
                        </th>
46
                        <th>
47
                            Description
48
                        </th>
49
                        <th>
50
                            Last cashup
51
                        </th>
52
                        <th>
53
                            Float
54
                        </th>
55
                        <th>
56
                            Bankable
57
                        </th>
58
                        <th>
59
                            Actions
60
                        </th>
61
                    </thead>
62
                    <tbody>
63
                        [% FOREACH register IN registers %]
64
                        <tr>
65
                            <td>
66
                                [% register.id | html %]
67
                            </td>
68
                            <td>
69
                                <a href="/cgi-bin/koha/pos/register.pl?registerid=[% register.id | uri %]">[% register.name | html %]</a>
70
                            </td>
71
                            <td>
72
                                [% register.description | html %]
73
                            </td>
74
                            <td>
75
                                [%- IF register.last_cashup -%]
76
                                [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] ([% register.last_cashup.amount | $Price %])
77
                                [%- ELSE -%]
78
                                No last cashup
79
                                [%- END -%]
80
                            </td>
81
                            <td>
82
                                [% register.starting_float | $Price %]
83
                            </td>
84
                            <td>
85
                                [% register.outstanding_accountlines.total * -1 | $Price %]
86
                            </td>
87
                            <td>
88
                                <a class="cashup_individual btn btn-default" href="/cgi-bin/koha/pos/register.pl?registerid=[% register.id | uri %]&op=cashup"><i class="fa fa-money"></i> Record cashup</a>
89
                            </td>
90
                        </tr>
91
                        [% END %]
92
                    </tbody>
93
                    <tfoot>
94
                        <tr>
95
                            <td colspan="5">Total bankable:</td>
96
                            <td></td>
97
                            <td></td>
98
                        </tr>
99
                    </tfoot>
100
                </table>
101
                [% END %]
102
            </main>
103
        </div>
104
105
        <div class="col-sm-2 col-sm-pull-10">
106
            <aside>
107
                [% INCLUDE 'pos-menu.inc' %]
108
            </aside>
109
        </div>
110
111
    </div> <!-- /.row -->
112
113
[% MACRO jsinclude BLOCK %]
114
    [% INCLUDE 'datatables.inc' %]
115
    <script>
116
        $(document).ready(function() {
117
            var registers_table = $("#registers").dataTable($.extend(true, {}, dataTablesDefaults, {
118
                "bFilter": false,
119
                "paginationType": "full",
120
                "footerCallback": function ( row, data, start, end, display ) {
121
                            var api = this.api(), data;
122
123
                            // Remove the formatting to get integer data for summation
124
                            var intVal = function ( i ) {
125
                                return typeof i === 'string' ?
126
                                    i.replace(/[\$,]/g, '')*1 :
127
                                    typeof i === 'number' ?
128
                                        i : 0;
129
                            };
130
131
                            // Total over all pages
132
                            total = api
133
                                .column( 5 )
134
                                .data()
135
                                .reduce( function (a, b) {
136
                                    return intVal(a) + intVal(b);
137
                                }, 0 );
138
139
                            // Update footer
140
                            $( api.column( 5 ).footer() ).html(
141
                                total
142
                            );
143
                        }
144
            }));
145
        });
146
    </script>
147
[% END %]
148
149
[% 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 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/registers.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 = 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 = $q->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( $q, $cookie, $template->output );

Return to bug 23355