} elsif ($op eq 'add_validate') {
$template->param(add_validate => 1);
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("REPLACE printers (printername,printqueue,printtype) values (?,?,?)");
- $sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'));
- $sth->finish;
+ if ($input->param('add')){
+ my $sth=$dbh->prepare("INSERT INTO printers (printername,printqueue,printtype) VALUES (?,?,?)");
+ $sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'));
+ $sth->finish;
+ }
+ else {
+ my $sth=$dbh->prepare("UPDATE printers SET printqueue=?,printtype=? WHERE printername=?");
+ $sth->execute($input->param('printqueue'),$input->param('printtype'),$input->param('printername'));
+ $sth->finish;
+ }
# END $OP eq ADD_VALIDATE
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
<!-- /TMPL_IF -->
<form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="add_validate" />
+ <!-- TMPL_IF NAME="searchfield" -->
+ <input type="hidden" name="add" value="0" />
+ <!-- TMPL_ELSE -->
+ <input type="hidden" name="add" value="1" />
+ <!-- /TMPL_IF -->
<fieldset class="rows">
<ol> <!-- TMPL_IF NAME="searchfield" -->
<li>