From f937b1c606ab64c250c1359a4646c138b020afe3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 19 Feb 2016 01:51:19 +0000 Subject: [PATCH] Bug 14752 - [QA followup] Auto-Generate barcode if left blank and autoBarcode is set Adds a warning/notice to item form and modal that barcodes will be auto-filled using syspref if autoBarcode is turned on Fills in barcodes if passed in blank --- acqui/addorder.pl | 11 ++++++++++- .../intranet-tmpl/prog/en/modules/acqui/neworderempty.tt | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index f58e58d..fa171a5 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -129,6 +129,7 @@ use C4::Biblio; # AddBiblio TransformKohaToMarc use C4::Budgets; use C4::Items; use C4::Output; +use C4::Barcodes; ### "-------------------- addorder.pl ----------" @@ -303,7 +304,6 @@ if ( $orderinfo->{quantity} ne '0' ) { push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i]; } foreach my $item (keys %itemhash){ - my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'}, $itemhash{$item}->{'subfields'}, $itemhash{$item}->{'field_values'}, @@ -311,6 +311,15 @@ if ( $orderinfo->{quantity} ne '0' ) { $itemhash{$item}->{'ind_tag'}, 'ITEM'); my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); + my ($barcodefield,$barcodesubfield) = GetMarcFromKohaField('items.barcode'); + my $barcode = $record->subfield($barcodefield,$barcodesubfield); + my $aBpref = C4::Context->preference('autoBarcode'); + if( $barcode eq '' && $aBpref ne 'OFF'){ + my $barcodeobj = C4::Barcodes->new; + $barcode = $barcodeobj->next_value(); + $record->field($barcodefield)->delete_subfield( code => $barcodesubfield); + $record->field($barcodefield)->add_subfields($barcodesubfield => $barcode); + } my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$$orderinfo{biblionumber}); $order->add_item($itemnumber); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index c993e1c..a009c44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -1,5 +1,6 @@ [% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] +[% USE Koha %] Koha › Acquisitions › Basket [% basketno %] › [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -451,6 +452,10 @@ $(document).ready(function()
No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used
[% END %] + [% UNLESS Koha.Preference('autoBarcode') == 'OFF' %] +
The autoBarcode system preference is set to [% Koha.Preference('autoBarcode') %] and items with blank barcodes will have barcodes generated upon save to database
+ [% END %] +
@@ -657,6 +662,9 @@ $(document).ready(function()
  • [% uniqueField %]
  • [% END %] + [% UNLESS Koha.Preference('autoBarcode') == 'OFF' %] +

    If barcode is blank and/or listed in UniqueItemFields barcodes will be generate using the autoBarcode preference setting ([% Koha.Preference('autoBarcode') %]) when saved

    + [% END %] [% END %] -- 2.1.4