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>
=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.
$data->{'branchfax'}, $data->{'branchemail'},
$data->{'branchip'}, $data->{'branchprinter'},
);
+ return 1 if $dbh->err;
} else {
my $query = "
UPDATE branches
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' ) {
<!-- /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">
<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" -->