Lines 51-56
our $offset = $input->param('offset') || 0;
Link Here
|
51 |
my $op = $input->param('op') || q{}; |
51 |
my $op = $input->param('op') || q{}; |
52 |
my $script_name = '/cgi-bin/koha/admin/currency.pl'; |
52 |
my $script_name = '/cgi-bin/koha/admin/currency.pl'; |
53 |
our $pagesize = 20; |
53 |
our $pagesize = 20; |
|
|
54 |
my @messages; |
54 |
|
55 |
|
55 |
our ($template, $loggedinuser, $cookie) = get_template_and_user({ |
56 |
our ($template, $loggedinuser, $cookie) = get_template_and_user({ |
56 |
template_name => 'admin/currency.tt', |
57 |
template_name => 'admin/currency.tt', |
Lines 72-78
if ( $op eq 'add_form' ) {
Link Here
|
72 |
add_form($searchfield); |
73 |
add_form($searchfield); |
73 |
} elsif ( $op eq 'save' ) { |
74 |
} elsif ( $op eq 'save' ) { |
74 |
add_validate(); |
75 |
add_validate(); |
75 |
print $input->redirect('/cgi-bin/koha/admin/currency.pl'); |
76 |
default_path(); |
76 |
} elsif ( $op eq 'delete_confirm' ) { |
77 |
} elsif ( $op eq 'delete_confirm' ) { |
77 |
delete_confirm($searchfield); |
78 |
delete_confirm($searchfield); |
78 |
} elsif ( $op eq 'delete_confirmed' ) { |
79 |
} elsif ( $op eq 'delete_confirmed' ) { |
Lines 107-112
sub default_path {
Link Here
|
107 |
$template->param( |
108 |
$template->param( |
108 |
loop => \@display_curr, |
109 |
loop => \@display_curr, |
109 |
activecurrency => defined $activecurrency, |
110 |
activecurrency => defined $activecurrency, |
|
|
111 |
messages => \@messages, |
110 |
); |
112 |
); |
111 |
|
113 |
|
112 |
if ( $offset > 0 ) { |
114 |
if ( $offset > 0 ) { |
Lines 174-179
sub add_form {
Link Here
|
174 |
|
176 |
|
175 |
sub add_validate { |
177 |
sub add_validate { |
176 |
$template->param( add_validate => 1 ); |
178 |
$template->param( add_validate => 1 ); |
|
|
179 |
my $is_a_modif = $input->param('is_a_modif'); |
177 |
|
180 |
|
178 |
my $rec = { |
181 |
my $rec = { |
179 |
rate => $input->param('rate'), |
182 |
rate => $input->param('rate'), |
Lines 190-196
sub add_validate {
Link Here
|
190 |
my ($row_count) = $dbh->selectrow_array( |
193 |
my ($row_count) = $dbh->selectrow_array( |
191 |
'select count(*) as count from currency where currency = ?', |
194 |
'select count(*) as count from currency where currency = ?', |
192 |
{}, $input->param('currency') ); |
195 |
{}, $input->param('currency') ); |
193 |
if ($row_count) { |
196 |
if ($row_count and $is_a_modif) { |
194 |
$dbh->do( |
197 |
$dbh->do( |
195 |
q|UPDATE currency SET rate = ?, symbol = ?, isocode = ?, active = ? WHERE currency = ? |, |
198 |
q|UPDATE currency SET rate = ?, symbol = ?, isocode = ?, active = ? WHERE currency = ? |, |
196 |
{}, |
199 |
{}, |
Lines 200-206
q|UPDATE currency SET rate = ?, symbol = ?, isocode = ?, active = ? WHERE curren
Link Here
|
200 |
$rec->{active}, |
203 |
$rec->{active}, |
201 |
$rec->{currency} |
204 |
$rec->{currency} |
202 |
); |
205 |
); |
203 |
} else { |
206 |
} elsif (not $row_count and not $is_a_modif) { |
204 |
$dbh->do( |
207 |
$dbh->do( |
205 |
q|INSERT INTO currency (currency, rate, symbol, isocode, active) VALUES (?,?,?,?,?) |, |
208 |
q|INSERT INTO currency (currency, rate, symbol, isocode, active) VALUES (?,?,?,?,?) |, |
206 |
{}, |
209 |
{}, |
Lines 211-216
q|INSERT INTO currency (currency, rate, symbol, isocode, active) VALUES (?,?,?,?
Link Here
|
211 |
$rec->{active} |
214 |
$rec->{active} |
212 |
); |
215 |
); |
213 |
|
216 |
|
|
|
217 |
} else { |
218 |
push @messages, { |
219 |
type => 'error', |
220 |
code => 'already_exists' |
221 |
}; |
214 |
} |
222 |
} |
215 |
return; |
223 |
return; |
216 |
} |
224 |
} |