View | Details | Raw Unified | Return to bug 10345
Collapse All | Expand All

(-)a/cataloguing/additem.pl (-4 / +11 lines)
Lines 536-544 if ($op eq "additem") { Link Here
536
536
537
        use C4::Barcodes;
537
        use C4::Barcodes;
538
        my $barcodeobj = C4::Barcodes->new;
538
        my $barcodeobj = C4::Barcodes->new;
539
        my $copynumber = $addedolditem->{'copynumber'};
539
        my $oldbarcode = $addedolditem->{'barcode'};
540
        my $oldbarcode = $addedolditem->{'barcode'};
540
        my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
541
        my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
541
542
        my ($copytagfield,$copytagsubfield) = &GetMarcFromKohaField("items.copynumber",$frameworkcode);
543
        
542
    # If there is a barcode and we can't find their new values, we can't add multiple copies
544
    # If there is a barcode and we can't find their new values, we can't add multiple copies
543
	my $testbarcode;
545
	my $testbarcode;
544
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
546
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
Lines 567-577 if ($op eq "additem") { Link Here
567
		    if ($barcodevalue) {
569
		    if ($barcodevalue) {
568
			$record->field($tagfield)->update($tagsubfield => $barcodevalue);
570
			$record->field($tagfield)->update($tagsubfield => $barcodevalue);
569
		    }
571
		    }
570
572
            
571
		    # Checking if the barcode already exists
573
		    # Checking if the barcode already exists
572
		    $exist_itemnumber = get_item_from_barcode($barcodevalue);
574
		    $exist_itemnumber = get_item_from_barcode($barcodevalue);
573
		}
575
		}
574
576
        # Updating record with the new copynumber 
577
        if ( $copynumber  ){
578
            $record->field($copytagfield)->update($copytagsubfield => $copynumber);
579
        }
580
        
575
		# Adding the item
581
		# Adding the item
576
        if (!$exist_itemnumber) {
582
        if (!$exist_itemnumber) {
577
            my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
583
            my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
Lines 581-586 if ($op eq "additem") { Link Here
581
            # That way, all items are added, even if there was some already existing barcodes
587
            # That way, all items are added, even if there was some already existing barcodes
582
            # FIXME : Please note that there is a risk of infinite loop here if we never find a suitable barcode
588
            # FIXME : Please note that there is a risk of infinite loop here if we never find a suitable barcode
583
            $i++;
589
            $i++;
590
            # Only increment copynumber if item was really added
591
            $copynumber++  if ( $copynumber && $copynumber =~ m/^\d+$/ );
584
        }
592
        }
585
593
586
		# Preparing the next iteration
594
		# Preparing the next iteration
587
- 

Return to bug 10345