@@ -, +, @@ new patron category this code could be cleaned up and have the DB stuff put into some sort of library with tests to prevent regression. However, that dream is beyond the scope of this bug. --- admin/categorie.pl | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) --- a/admin/categorie.pl +++ a/admin/categorie.pl @@ -207,22 +207,6 @@ elsif ( $op eq 'add_validate' ) { 'categorycode' ) ); - my @branches = $input->param("branches"); - if (@branches) { - $sth = $dbh->prepare( - "DELETE FROM categories_branches WHERE categorycode = ?" - ); - $sth->execute( $input->param("categorycode") ); - $sth = $dbh->prepare( - "INSERT INTO categories_branches ( categorycode, branchcode ) VALUES ( ?, ? )" - ); - for my $branchcode (@branches) { - next if not $branchcode; - $sth->bind_param( 1, $input->param("categorycode") ); - $sth->bind_param( 2, $branchcode ); - $sth->execute; - } - } $sth->finish; } else { @@ -261,6 +245,23 @@ elsif ( $op eq 'add_validate' ) { } } + my @branches = $input->param("branches"); + if (@branches) { + my $sth = $dbh->prepare( + "DELETE FROM categories_branches WHERE categorycode = ?" + ); + $sth->execute( $input->param("categorycode") ); + $sth = $dbh->prepare( + "INSERT INTO categories_branches ( categorycode, branchcode ) VALUES ( ?, ? )" + ); + for my $branchcode (@branches) { + next if not $branchcode; + $sth->bind_param( 1, $input->param("categorycode") ); + $sth->bind_param( 2, $branchcode ); + $sth->execute; + } + } + if ( C4::Context->preference('EnhancedMessagingPreferences') ) { C4::Form::MessagingPreferences::handle_form_action( $input, { categorycode => $input->param('categorycode') }, $template ); --