Bug 11273: FIX barcode generation in acquisition if hbyymmincr

When AutoBarcode is activated and you have set AcqCreateItem to 'on
order' there is a Javascript error when you try to generate a barcode
for the item:

TypeError: document.f is undefined
http://localhost:8080/intranet-tmpl/lib/jquery/jquery.js
Line 11

Test plan:
0/ a. Set AutoBarcode to hbyymmincr
   b. Set AcqCreateItem to 'on ordering'
   c. Set the plugin barcode.pl to the barcode field for the default
   and the ACQ frameworks
1/ Go on the add items page (cataloguing/additem.pl) and confirm that
the plugin works as expected.
2/ Go on the New order page (acqui/neworderempty.pl) and confirm that
the plugin works as expected.

Followed test plan, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 5b521eb394)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
(cherry picked from commit 272650cb3f)
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
This commit is contained in:
Jonathan Druart 2015-07-14 13:12:46 +01:00 committed by Mason James
parent 821aa63e41
commit beb77b06bd
1 changed files with 7 additions and 3 deletions

View File

@ -60,13 +60,17 @@ sub get_barcode {
$nextnum = $year . $month . $nextnum;
warn "New hbyymmincr Barcode = $nextnum" if $DEBUG;
my $scr = "
for (i=0 ; i<document.f.field_value.length ; i++) {
if (document.f.tag[i].value == '$args->{loctag}' && document.f.subfield[i].value == '$args->{locsubfield}') {
var form = document.getElementById('f');
if ( !form ) {
form = document.getElementById('Aform');
}
for (i=0 ; i<form.field_value.length ; i++) {
if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') {
fnum = i;
}
}
if (\$('#' + id).val() == '') {
\$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
\$('#' + id).val(form.field_value[fnum].value + '$nextnum');
}
";
return $nextnum, $scr;