Bug Fixing : Authorised values could not be edited
authorHenri-Damien LAURENT <henridamien@koha-fr.org>
Fri, 14 Dec 2007 16:56:21 +0000 (17:56 +0100)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 14 Dec 2007 16:51:16 +0000 (10:51 -0600)
If id provided and authorised value exists,
then change it and get back to authorised_value page.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/authorised_values.pl

index 396af1f..cb5a626 100755 (executable)
@@ -117,12 +117,22 @@ if ($op eq 'add_form') {
        my $dbh = C4::Context->dbh;
 
     if (_already_exists($input->param('category'), $input->param('authorised_value'))) {
+     if ($id){
+      my $sth=$dbh->prepare("UPDATE authorised_values SET category=?,authorised_value=?,lib=? where id=?");
+      my $lib = $input->param('lib');
+      undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
+  
+      $sth->execute($input->param('category'), $input->param('authorised_value'), $lib,$input->param('id'));          
+      print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$input->param('category')."\"></html>";
+      exit;
+     } else {       
         $template->param(duplicate_category => $input->param('category'),
                          duplicate_value =>  $input->param('authorised_value'),
                          else => 1);
         default_form();
+     }           
     } else {
-           my $sth=$dbh->prepare("replace authorised_values (id,category,authorised_value,lib) values (?,?,?,?)");
+           my $sth=$dbh->prepare("INSERT INTO authorised_values (id,category,authorised_value,lib) values (?,?,?,?)");
            my $lib = $input->param('lib');
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string