-
- my $date = $template->param('timestamp');
- ($date) and $template->param('timestamp' => format_date($date));
- # END $OP eq ADD_FORM
-################## ADD_VALIDATE ##################################
-# called by add_form, used to insert/modify data in DB
-} elsif ($op eq 'add_validate') {
- $template->param(add_validate => 1);
- my $dbh = C4::Context->dbh;
- my $check = $dbh->prepare("select count(*) as count from currency where currency = ?");
-
- $dbh->do("UPDATE currency SET active = 0") if ( $input->param('active') == 1);
-
- $check->execute($input->param('currency'));
- my $count = $check->fetchrow ;
- if ( $count > 0 )
- {
- my $sth = $dbh->prepare(qq|
- UPDATE currency
- SET rate = ?,
- symbol = ?,
- active = ?
- WHERE currency = ? | );
-
- $sth->execute( $input->param('rate'),
- $input->param('symbol')||'',
- $input->param('active')||0,
- $input->param('currency'),
- );
- }
- else
- {
- my $sth = $dbh->prepare(qq|
- INSERT INTO currency (currency, rate, symbol, active) VALUES (?,?,?,?) |);
-
- $sth->execute( $input->param('currency'),
- $input->param('rate'),
- $input->param('symbol')||'',
- $input->param('active')||0,
- );