Lines 42-47
use Koha::Old::Checkouts;
Link Here
|
42 |
use Koha::Patron::Categories; |
42 |
use Koha::Patron::Categories; |
43 |
use Koha::Account::DebitTypes; |
43 |
use Koha::Account::DebitTypes; |
44 |
use Koha::AdditionalFields; |
44 |
use Koha::AdditionalFields; |
|
|
45 |
use Koha::Number::Price; |
46 |
use C4::Context; |
45 |
|
47 |
|
46 |
my $input = CGI->new; |
48 |
my $input = CGI->new; |
47 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
49 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
Lines 78-94
output_and_exit_if_error(
Link Here
|
78 |
my $library_id = C4::Context->userenv->{'branch'}; |
80 |
my $library_id = C4::Context->userenv->{'branch'}; |
79 |
my $desc = $input->param('desc'); |
81 |
my $desc = $input->param('desc'); |
80 |
my $amount = $input->param('amount'); |
82 |
my $amount = $input->param('amount'); |
|
|
83 |
$amount = Koha::Number::Price->new( $amount )->format(); |
81 |
my $note = $input->param('note'); |
84 |
my $note = $input->param('note'); |
82 |
my $debit_type = $input->param('type'); |
85 |
my $debit_type = $input->param('type'); |
83 |
my $barcode = $input->param('barcode'); |
86 |
my $barcode = $input->param('barcode'); |
|
|
87 |
my $decimal_delimiter = |
88 |
C4::Context->preference('CurrencyFormat') eq 'FR' ? ',' : '.'; |
89 |
my $decimal_input_pattern = |
90 |
C4::Context->preference('CurrencyFormat') eq 'FR' |
91 |
? '^\d+(\,\d{2})?$' |
92 |
: '^\d+(\.\d{2})?$'; |
84 |
$template->param( |
93 |
$template->param( |
85 |
desc => $desc, |
94 |
desc => $desc, |
86 |
amount => $amount, |
95 |
amount => $amount, |
87 |
note => $note, |
96 |
note => $note, |
88 |
type => $debit_type, |
97 |
type => $debit_type, |
89 |
barcode => $barcode |
98 |
barcode => $barcode, |
|
|
99 |
decimal_delimiter => $decimal_delimiter, |
100 |
decimal_input_pattern => $decimal_input_pattern, |
90 |
); |
101 |
); |
91 |
|
102 |
|
|
|
103 |
|
92 |
my $add = $input->param('add'); |
104 |
my $add = $input->param('add'); |
93 |
if ($add) { |
105 |
if ($add) { |
94 |
output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) |
106 |
output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) |
Lines 101-110
if ($add) {
Link Here
|
101 |
|
113 |
|
102 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
114 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
103 |
# Here we are trusting librarians not to hack the system |
115 |
# Here we are trusting librarians not to hack the system |
104 |
my $desc = $input->param('desc'); |
116 |
my $desc = $input->param('desc'); |
105 |
my $amount = $input->param('amount'); |
117 |
my $amount = $input->param('amount'); |
106 |
my $note = $input->param('note'); |
118 |
$amount = Koha::Number::Price->new($amount)->unformat(); |
107 |
my $debit_type = $input->param('type'); |
119 |
my $note = $input->param('note'); |
|
|
120 |
my $debit_type = $input->param('type'); |
121 |
|
108 |
|
122 |
|
109 |
# If barcode is passed, attempt to find the associated item |
123 |
# If barcode is passed, attempt to find the associated item |
110 |
my $failed; |
124 |
my $failed; |
Lines 133-139
if ($add) {
Link Here
|
133 |
my $checkouts = Koha::Checkouts->search( |
147 |
my $checkouts = Koha::Checkouts->search( |
134 |
{ |
148 |
{ |
135 |
itemnumber => $item_id, |
149 |
itemnumber => $item_id, |
136 |
borrowernumber => $borrowernumber |
150 |
borrowernumber => $borrowernumber |
137 |
} |
151 |
} |
138 |
); |
152 |
); |
139 |
my $checkout = |
153 |
my $checkout = |
Lines 162-168
if ($add) {
Link Here
|
162 |
library_id => $library_id, |
176 |
library_id => $library_id, |
163 |
type => $debit_type, |
177 |
type => $debit_type, |
164 |
( $olditem ? () : ( item_id => $item_id ) ), |
178 |
( $olditem ? () : ( item_id => $item_id ) ), |
165 |
issue_id => $issue_id |
179 |
issue_id => $issue_id, |
166 |
} |
180 |
} |
167 |
); |
181 |
); |
168 |
|
182 |
|