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 <galen.charlton@liblime.com>
This commit is contained in:
Paul Poulain 2009-05-28 18:32:16 +02:00 committed by Galen Charlton
parent 2f3714e2e6
commit 950f753f11
3 changed files with 14 additions and 6 deletions

View File

@ -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

View File

@ -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' ) {

View File

@ -59,6 +59,7 @@
<!-- /TMPL_IF -->
<!-- TMPL_IF name="add" -->
<!-- TMPL_IF name="ERROR1" --><div class="dialog message">Code already exist &mdash; 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" -->