From 334bebd130fcb57e47869b2a459ed25a6f1f9aca Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Thu, 28 May 2009 18:32:16 +0200 Subject: [PATCH] fix for #2884: Add error management to branches While trying to add a new Branch with an existing Branch code, the UI says "Library saved" instead of something such as "Please select a unique branch code". Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Branch.pm | 5 +++-- admin/branches.pl | 12 +++++++++--- .../prog/en/modules/admin/branches.tmpl | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index 73cd5fd229..29b1a93829 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -177,9 +177,9 @@ sub GetBranchName { =head2 ModBranch -&ModBranch($newvalue); +$error = &ModBranch($newvalue); -This function modify an existing branches. +This function modify an existing branch C<$newvalue> is a ref to an array wich is containt all the column from branches table. @@ -205,6 +205,7 @@ sub ModBranch { $data->{'branchfax'}, $data->{'branchemail'}, $data->{'branchip'}, $data->{'branchprinter'}, ); + return 1 if $dbh->err; } else { my $query = " UPDATE branches diff --git a/admin/branches.pl b/admin/branches.pl index c2f37f7cbe..9c6b2e9000 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -114,9 +114,15 @@ elsif ( $op eq 'add_validate' ) { default("MESSAGE1",$template); } else { - ModBranch($params); - $template->param( else => 1 ); - default("MESSAGE2",$template); + my $error = ModBranch($params); + # if error saving, stay on edit and rise error + if ($error) { + editbranchform($branchcode,$template); + $template->param( 'heading-branches-add-branch-p' => 1, 'add' => 1, "ERROR$error" => 1 ); + } else { + $template->param( else => 1); + default("MESSAGE2",$template); + } } } elsif ( $op eq 'delete' ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl index 506869108a..5fbc653d38 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl @@ -59,6 +59,7 @@ +
Code already exist — Please enter a unique code

New libraryModify library

" name="Aform" method="post">
@@ -69,7 +70,7 @@
  1. - + Library code " /> -- 2.39.5