Lines 156-162
sub delete_confirm {
Link Here
|
156 |
return; |
156 |
return; |
157 |
} |
157 |
} |
158 |
|
158 |
|
159 |
sub add_form { |
159 |
sub add_form { |
160 |
my $curr = shift; |
160 |
my $curr = shift; |
161 |
|
161 |
|
162 |
$template->param( add_form => 1 ); |
162 |
$template->param( add_form => 1 ); |
Lines 175-180
sub add_form {
Link Here
|
175 |
$template->param( 'timestamp' => format_date($date) ); |
175 |
$template->param( 'timestamp' => format_date($date) ); |
176 |
} |
176 |
} |
177 |
|
177 |
|
|
|
178 |
my $dbh = C4::Context->dbh; |
179 |
my $query = " |
180 |
SELECT currency,timestamp,rate |
181 |
FROM ex_rates where currency=?; |
182 |
"; |
183 |
my $sth = $dbh->prepare($query); |
184 |
$sth->execute($curr); |
185 |
my @results = (); |
186 |
while ( my $data = $sth->fetchrow_hashref ) { |
187 |
push( @results, $data ); |
188 |
} |
189 |
$template->param( |
190 |
ex_result => \@results, |
191 |
); |
192 |
|
178 |
return; |
193 |
return; |
179 |
} |
194 |
} |
180 |
|
195 |
|
Lines 188-193
sub add_validate {
Link Here
|
188 |
currency => $input->param('currency'), |
203 |
currency => $input->param('currency'), |
189 |
}; |
204 |
}; |
190 |
|
205 |
|
|
|
206 |
$dbh->do( |
207 |
q|INSERT INTO ex_rates (currency, rate, timestamp) VALUES (?,?,now()) |, |
208 |
{}, |
209 |
$rec->{currency}, |
210 |
$rec->{rate} |
211 |
); |
212 |
|
191 |
if ( $rec->{active} == 1 ) { |
213 |
if ( $rec->{active} == 1 ) { |
192 |
$dbh->do('UPDATE currency SET active = 0'); |
214 |
$dbh->do('UPDATE currency SET active = 0'); |
193 |
} |
215 |
} |
Lines 204-209
q|UPDATE currency SET rate = ?, symbol = ?, active = ? WHERE currency = ? |,
Link Here
|
204 |
$rec->{active}, |
226 |
$rec->{active}, |
205 |
$rec->{currency} |
227 |
$rec->{currency} |
206 |
); |
228 |
); |
|
|
229 |
|
207 |
} else { |
230 |
} else { |
208 |
$dbh->do( |
231 |
$dbh->do( |
209 |
q|INSERT INTO currency (currency, rate, symbol, active) VALUES (?,?,?,?) |, |
232 |
q|INSERT INTO currency (currency, rate, symbol, active) VALUES (?,?,?,?) |, |