From 5e37fec1846da0c8291f60862bf64c56c973c9a8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Apr 2015 13:51:31 +0200 Subject: [PATCH] [PASSED QA] Bug 10011: Save branch limitations on creating a new patron category The code was just badly placed. It should be executed on update but also on insert. Test plan: 1/ Create a new patron category and select 1+ branch limitations 2/ Confirm it's correctly saved 3/ Edit it and change the branch limitations 4/ Confirm it's correctly saved Signed-off-by: Mark Tompsett NOTE: Not a C4 or Koha library, so tests not required. Though, 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. Signed-off-by: Katrin Fischer --- admin/categorie.pl | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/admin/categorie.pl b/admin/categorie.pl index bb0b72e..445645e 100755 --- a/admin/categorie.pl +++ b/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 ); -- 1.9.1