From 498f42b3eb35a621eb9f308c59042a8568ad2979 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Apr 2015 13:51:31 +0200 Subject: [PATCH] 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 --- 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 ); -- 2.1.0