=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
<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>