=cut
use strict;
+use warnings;
use CGI;
use C4::Auth;
use C4::Context;
my $categorycode = $input->param('categorycode');
my $op = $input->param('op');
+if(!defined($op)){
+ $op = '';
+}
+
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "admin/branches.tmpl",
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) {
+ # copy input parameters back to form
+ # FIXME - doing this doesn't preserve any branch group selections, but good enough for now
+ $template->param(%$params);
+ $template->param(branch_name => $params->{branchname});
+ $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' ) {
# printer loop
foreach my $thisprinter ( keys %$printers ) {
+
my $selected = 1
- if $oldprinter eq $printers->{$thisprinter}->{'printqueue'};
+ if $oldprinter and ( $oldprinter eq $printers->{$thisprinter} );
+
my %row = (
value => $thisprinter,
selected => $selected,
$branchinfo = GetBranchInfo($branchcode);
}
else {
- $branchinfo = GetBranchInfo(undef,'properties');
+ $branchinfo = GetBranchInfo();
}
my $toggle;
- my $i;
+ my $i = 0;
my @loop_data = ();
foreach my $branch (@$branchinfo) {
( $i % 2 ) ? ( $toggle = 1 ) : ( $toggle = 0 );