diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-batches-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-batches-toolbar.inc
index 47a0b8f66a..f3a20060e9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-batches-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-batches-toolbar.inc
@@ -46,7 +46,13 @@
}
};
function Add() {
- window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=&type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
+ var barcodes = document.getElementById("barcode");
+ if (barcodes.value == '') {
+ window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=&type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
+ }
+ else {
+ document.forms["add_by_barcode"].submit();
+ }
};
function DeDuplicate() {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&batch_id=";
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tmpl
index df1f5569e1..7ca0d02962 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tmpl
@@ -1,9 +1,26 @@
+
Koha › Tools › Labels › Manage Label Batches
+
-
+
@@ -21,6 +38,21 @@
Current Branch:
+
-
There are no items in Batch yet
-
Use the toolbar above to add items.
+
diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl
index 94d56b4e72..370807ca6f 100755
--- a/labels/label-edit-batch.pl
+++ b/labels/label-edit-batch.pl
@@ -27,6 +27,7 @@ use CGI;
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::Items qw(GetItemnumberFromBarcode);
use C4::Creators 1.000000;
use C4::Labels 1.000000;
@@ -57,7 +58,8 @@ my $display_columns = [ {_label_number => {label => 'Label Number', link_field
my $op = $cgi->param('op') || 'edit';
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
-my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
+my @item_numbers = $cgi->param('item_number') || ();
+my $barcode = $cgi->param('barcode') if $cgi->param('barcode');
my $branch_code = get_branch_code_from_name($template->param('LoginBranchname'));
@@ -76,6 +78,15 @@ elsif ($op eq 'delete') {
$errstr = "batch $batch_id was not deleted." if $err;
}
elsif ($op eq 'add') {
+ if ($barcode) {
+ my @barcodes = split /\n/, $barcode; # $barcode is effectively passed in as a
separated list
+ foreach my $number (@barcodes) {
+ $number =~ s/\r$//; # strip any naughty return chars
+ if (my $item_number = GetItemnumberFromBarcode($number)) { # we must test in case an invalid barcode is passed in; we effectively disgard them atm
+ push @item_numbers, $item_number;
+ }
+ }
+ }
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
$batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2;
if ($branch_code){