From 855d9697de88ed5d22123c528ea27f767e1d1476 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 7 Nov 2007 12:12:18 -0600 Subject: [PATCH] Bug Fixing : itemization would create undesirable items One item was created for "unexpected" issues if the first issue was received. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- serials/serials-edit.pl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 2e25ba33a8..b57bc578fc 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -207,32 +207,29 @@ if ($op eq 'serialchangestatus') { } foreach my $item (keys %itemhash){ # Verify Itemization is "Valid", i.e. serial status is Arrived or Missing - my $index; + my $index=-1; for (my $i=0; $i{'serial'} eq $serialids[$i]); + $index = $i if ($itemhash{$item}->{'serial'} eq $serialids[$i] || ($itemhash{$item}->{'serial'} == $newserial && $serialids[$i] eq "NEW")); } - if ($status[$index]==2){ + if ($index>=0 && $status[$index]==2){ my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'}, $itemhash{$item}->{'subfields'}, $itemhash{$item}->{'field_values'}, $itemhash{$item}->{'ind_tag'}, $itemhash{$item}->{'indicator'}); -# warn $xml; + # warn $xml; my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); if ($item=~/^N/){ #New Item - # if autoBarcode is ON, calculate barcode... my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode"); if (C4::Context->preference("autoBarcode") ne 'OFF' ) { - - eval { $record->field($tagfield)->subfield($tagsubfield) }; - if ($@) { + eval { $record->field($tagfield)->subfield($tagsubfield) }; + if ($@) { my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items"); $sth_barcode->execute; my ($newbarcode) = $sth_barcode->fetchrow; $newbarcode++; - # OK, we have the new barcode, now create the entry in MARC record $record->add_fields( $tagfield, "1", "0", $tagsubfield => $newbarcode ); -- 2.39.5