More replace statements, this time admin/printers.pl
authorChris Cormack <crc@liblime.com>
Wed, 9 Jan 2008 01:41:25 +0000 (19:41 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 9 Jan 2008 02:09:55 +0000 (20:09 -0600)
Bug 1546

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/printers.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tmpl

index 3e3071d..273c1ee 100755 (executable)
@@ -113,9 +113,16 @@ if ($op eq 'add_form') {
 } 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
index e388daa..b88fc99 100644 (file)
        <!-- /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>