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 <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Henri-Damien LAURENT 2007-11-07 12:12:18 -06:00 committed by Joshua Ferraro
parent 599c941d68
commit 855d9697de

View file

@ -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<scalar(@serialids);$i++){
$index = $i if ($itemhash{$item}->{'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 );