[Koha-cvs] CVS: koha/acqui.simple additem.pl,1.27.2.8,1.27.2.9

Paul POULAIN tipaul at users.sourceforge.net
Tue Oct 25 14:17:04 CEST 2005


Update of /cvsroot/koha/koha/acqui.simple
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1168/acqui.simple

Modified Files:
      Tag: rel_2_2
	additem.pl 
Log Message:
fixing a bug : when Autobarcode=ON and MARC=ON, the barcode was not calculated automatically.

Index: additem.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/additem.pl,v
retrieving revision 1.27.2.8
retrieving revision 1.27.2.9
diff -C2 -r1.27.2.8 -r1.27.2.9
*** additem.pl	5 Oct 2005 12:41:41 -0000	1.27.2.8
--- additem.pl	25 Oct 2005 12:17:02 -0000	1.27.2.9
***************
*** 61,65 ****
  my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
  my $record = MARCgetbiblio($dbh,$bibid);
! warn "==>".$record->as_formatted;
  my $oldrecord = MARCmarc2koha($dbh,$record);
  my $itemrecord;
--- 61,65 ----
  my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
  my $record = MARCgetbiblio($dbh,$bibid);
! # warn "==>".$record->as_formatted;
  my $oldrecord = MARCmarc2koha($dbh,$record);
  my $itemrecord;
***************
*** 81,84 ****
--- 81,99 ----
  	}
  	my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+ 	# if autoBarcode is ON, calculate barcode...
+ 	if (C4::Context->preference('autoBarcode')) {
+ 		my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.barcode");
+ 		unless ($record->field($tagfield)->subfield($tagsubfield)) {
+ 			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
+ 			my $fieldItem = $record->field($tagfield);
+ 			$record->delete_field($fieldItem);
+ 			$fieldItem->add_subfields($tagsubfield => $newbarcode);
+ 			$record->insert_fields_ordered($fieldItem);
+ 		}
+ 	}
  # check for item barcode # being unique
  	my $oldbibid = MARCmarc2koha($dbh,$record);





More information about the Koha-cvs mailing list