From 111044b7a13cf760602e6c15c374a8bab560581d Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Fri, 14 Dec 2007 17:56:21 +0100 Subject: [PATCH] Bug Fixing : Authorised values could not be edited If id provided and authorised value exists, then change it and get back to authorised_value page. Signed-off-by: Joshua Ferraro --- admin/authorised_values.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index 396af1ff95..cb5a6263e6 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -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\nparam('category')."\">"; + 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 -- 2.39.5