[Koha-patches] [PATCH] [labels_recon] Nicer error message if a branch is not set

Chris Cormack chrisc at catalyst.net.nz
Thu Sep 3 03:16:34 CEST 2009


---
 labels/label-edit-batch.pl |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl
index 1bcadb3..93cd07b 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);
-- 
1.6.0.4




More information about the Koha-patches mailing list