[Koha-patches] [PATCH 06/78] fix for #2884: Add error management to branches
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu May 28 18:32:16 CEST 2009
From: Paul Poulain <paul.poulain at biblibre.com>
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".
---
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 73cd5fd..29b1a93 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 c2f37f7..9c6b2e9 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 5068691..5fbc653 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 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF name="add" -->
+ <!-- TMPL_IF name="ERROR1" --><div class="dialog message">Code already exist — Please enter a unique code</div><!-- /TMPL_IF -->
<h3><!-- TMPL_IF name="heading-branches-add-branch-p" -->New library<!-- TMPL_ELSE -->Modify library<!-- /TMPL_IF --></h3>
<form action="<!-- TMPL_VAR name="action" -->" name="Aform" method="post">
<fieldset class="rows">
@@ -69,7 +70,7 @@
<input type="hidden" name="add" value="0" />
<!-- /TMPL_IF -->
<ol><li>
- <!-- TMPL_IF name="branchcode" -->
+ <!-- TMPL_IF name="heading-branches-add-p" -->
<span class="label">Library code</span>
<input type="hidden" name="branchcode" value="<!-- TMPL_VAR name="branchcode" escape="HTML" -->" />
<!-- TMPL_VAR name="branchcode" -->
--
1.6.0.4
More information about the Koha-patches
mailing list