}
};
function Add() {
- window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="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=<!-- TMPL_VAR NAME="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=<!-- TMPL_VAR NAME="batch_id" -->";
+ <!-- PLEASE MAINTAIN PROPER INDENTATION!!!! -->
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha › Tools › Labels › Manage Label Batches</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="greybox.inc" -->
+ <script type="text/javascript">
+ //<![CDATA[
+ function dofocus() { // named function req'd for body onload event by some FF and IE7 security models
+ $(".focus:last").select();
+ }
+ function verifyBarcodes(barcodes) {
+ if (barcodes.value == '') {
+ alert("Please add barcodes using either the direct entry text area or the item search.");
+ return false; // not ok
+ }
+ else {
+ return true; // ok
+ };
+ }
+ //]]>
+ </script>
</head>
-<body>
+<body onload="dofocus();">
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs">
<div class="yui-g">
<div class="yui-u first" id="manage-label-batches">
<div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
+ <form name="add_by_barcode" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
+ <div>
+ <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
+ <ol><li>
+ <input type="hidden" name="op" value="add" \>
+ <input type="hidden" name="batch_id" value="<!-- TMPL_VAR NAME="batch_id" -->" \>
+ <label for="barcode">Add by Barcode(s):
+ <br \> <span class="hint">One barcode per line.</span>
+ <br \> <span class="hint">Leave empty to add via item search.</span>
+ </label>
+ <textarea rows="5" id="barcode" name="barcode" tabindex="1" class="focus"></textarea>
+ </li></ol>
+ </fieldset>
+ </div>
+ </form>
<!-- TMPL_IF NAME="table_loop" -->
<form name="items" class="checkboxed">
<h2>Items in batch number <!-- TMPL_VAR NAME="batch_id" --></h2>
</table>
</form>
<!-- TMPL_ELSE -->
- <div class="dialog message"><h4>There are no items in Batch <!-- TMPL_VAR NAME="batch_id" --> yet</h4>
- <p>Use the toolbar above to add items.</p></div>
+ <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
+ <ol><li>
+ <div class="dialog message">
+ <h4>There are no items in Batch <!-- TMPL_VAR NAME="batch_id" --> yet</h4>
+ <p>Add items by barcode using the text area above or leave empty to add via item search.</p>
+ </div>
+ </li></ol>
+ </fieldset>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_IF NAME="err" -->
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;
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'));
$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 <cr> 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){