Bug 4098: Fixes missing error templates.
[koha_fer] / labels / label-edit-batch.pl
index 1bcadb3..1240a26 100755 (executable)
@@ -4,7 +4,7 @@
 # Parts Copyright 2009 Foundations Bible College.
 #
 # This file is part of Koha.
-#       
+#
 # Koha is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
 # Foundation; either version 2 of the License, or (at your option) any later
@@ -22,14 +22,12 @@ use strict;
 use warnings;
 use vars qw($debug);
 
-use Sys::Syslog qw(syslog);
 use CGI;
-use HTML::Template::Pro;
 
 use C4::Auth qw(get_template_and_user);
 use C4::Output qw(output_html_with_http_headers);
 use C4::Branch qw(get_branch_code_from_name);
-use C4::Labels::Lib 1.000000 qw(get_label_summary html_table);
+use C4::Creators::Lib 1.000000 qw(get_label_summary html_table);
 use C4::Labels::Batch 1.000000;
 
 my $cgi = new CGI;
@@ -80,10 +78,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);
@@ -104,7 +108,7 @@ $db_rows = get_label_summary(items => $items, batch_id => $batch_id);
 
 my $table = html_table($display_columns, $db_rows);
 
-$template->param(   
+$template->param(
                 err         => $err,
                 errstr      => $errstr,
                 ) if ($err ne 0);