From 0af3d16b278cc89fea4be707b92a0ffb65f9958f Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 3 Sep 2009 13:16:34 +1200 Subject: [PATCH] Nicer error message if a branch is not set Signed-off-by: Galen Charlton --- labels/label-edit-batch.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl index 1bcadb3a74..93cd07b393 100755 --- a/labels/label-edit-batch.pl +++ b/labels/label-edit-batch.pl @@ -80,10 +80,16 @@ elsif ($op eq 'delete') { elsif ($op eq 'add') { $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); $batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2; - foreach my $item_number (@item_numbers) { - $err = $batch->add_item($item_number); + if ($branch_code){ + foreach my $item_number (@item_numbers) { + $err = $batch->add_item($item_number); + } + $errstr = "item(s) not added to batch $batch_id." if $err; + } + else { + $err = 1; + $errstr = "items(s) not added, the error was: Branch is not set, you please set your branch before adding items to a batch"; } - $errstr = "item(s) not added to batch $batch_id." if $err; } elsif ($op eq 'new') { $batch = C4::Labels::Batch->new(branch_code => $branch_code); -- 2.39.5