3 # c 2020 PTFS-Europe Ltd
5 # This file is part of Koha.
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
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.
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
27 use Koha::Cash::Registers;
30 my $input = CGI->new();
32 my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
34 template_name => 'pos/registers.tt',
40 my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
42 my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} );
43 $template->param( library => $library );
45 my $registers = Koha::Cash::Registers->search(
46 { branch => $library->id, archived => 0 },
47 { order_by => { '-asc' => 'name' } }
50 if ( !$registers->count ) {
51 $template->param( error_registers => 1 );
54 $template->param( registers => $registers );
57 my $op = $input->param('op') // '';
58 if ( $op eq 'cashup' ) {
59 for my $register ( $registers->as_list ) {
60 $register->add_cashup(
62 user_id => $logged_in_user->id,
63 amount => $register->outstanding_accountlines->total
69 output_html_with_http_headers( $input, $cookie, $template->output );