Removing replace statement from C4::Branch as per bug 1546
authorChris Cormack <crc@liblime.com>
Wed, 9 Jan 2008 00:03:25 +0000 (18:03 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 9 Jan 2008 01:23:41 +0000 (19:23 -0600)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Branch.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl

index 47cfd6c..4755168 100644 (file)
@@ -480,12 +480,20 @@ sets the data from the editbranch form, and writes to the database...
 =cut
 
 sub ModBranchCategoryInfo {
-
     my ($data) = @_;
     my $dbh    = C4::Context->dbh;
-    my $sth    = $dbh->prepare("replace branchcategories (categorycode,categoryname,codedescription,categorytype) values (?,?,?,?)");
-    $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
-    $sth->finish;
+       if ($data->{'add'}){
+               # we are doing an insert
+               my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)");
+               $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
+               $sth->finish();         
+       }
+       else {
+               # modifying
+               my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?");
+               $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) );
+               $sth->finish();
+       }
 }
 
 =head2 DeleteBranchCategory
index af1776f..70fc20b 100644 (file)
     <h3><!-- TMPL_IF NAME="categorycode" -->Edit Group <!-- TMPL_VAR NAME="categorycode" --><!-- TMPL_ELSE -->Add Group<!-- /TMPL_IF --></h3>
     <form action="<!-- TMPL_VAR name="action" -->" name="Aform" method="post">
     <input type="hidden" name="op" value="addcategory_validate" />
+       <!-- TMPL_IF NAME="categorycode" -->
+       <input type="hidden" name="add" value="0">
+       <!-- TMPL_ELSE -->
+       <input type="hidden" name="add" value="1">
+       <!-- /TMPL_IF -->
     <fieldset class="rows">
         
         <ol><li>