[Koha-cvs] koha/C4 Biblio.pm [dev_week]

Ryan Higgins rch at liblime.com
Mon Jan 1 04:23:37 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Ryan Higgins <rych>	07/01/01 03:23:37

Modified files:
	C4             : Biblio.pm 

Log message:
	passing $record object between newbiblio and newbiblioitem, etc, so we can add a minimal marc record in acquisitions, and then add multiple associated items.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.115.2.51.2.42&r2=1.115.2.51.2.43

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.51.2.42
retrieving revision 1.115.2.51.2.43
diff -u -b -r1.115.2.51.2.42 -r1.115.2.51.2.43
--- Biblio.pm	28 Nov 2006 14:43:18 -0000	1.115.2.51.2.42
+++ Biblio.pm	1 Jan 2007 03:23:36 -0000	1.115.2.51.2.43
@@ -1206,18 +1206,20 @@
 sub MARCkoha2marcBiblio {
 
     # this function builds partial MARC::Record from the old koha-DB fields
-    my ( $dbh, $biblionumber, $biblioitemnumber ) = @_;
-    my $sth =
-      $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
+    my ( $dbh, $biblionumber, $biblioitemnumber, $record ) = @_;
+    my $sth =  $dbh->prepare(
+		"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
     );
-    my $record = MARC::Record->new();
+    if ( ! $record ) {
+		$record = MARC::Record->new();
+		$record->encoding('UTF-8');
+	}
 
     #--- if bibid, then retrieve old-style koha data
     if ( $biblionumber > 0 ) {
-        my $sth2 =
-          $dbh->prepare(
-"select biblionumber,author,title,unititle,notes,abstract,serial,seriestitle,copyrightdate,timestamp
+		$record = addBiblionumber ( $dbh, $record, $biblionumber, $biblioitemnumber );
+        my $sth2 =	 $dbh->prepare(
+					"select biblionumber,author,title,unititle,notes,abstract,serial,seriestitle,copyrightdate,timestamp
 		from biblio where biblionumber=?"
         );
         $sth2->execute($biblionumber);
@@ -1992,8 +1994,7 @@
 
 sub _koha_new_items {
     my ( $dbh, $item, $barcode ) = @_;
-
-    #  my $dbh   = C4Connect;
+	$barcode =  $item->{'barcode'} unless ($barcode);
     my $sth = $dbh->prepare("Select max(itemnumber) from items");
     my $data;
     my $itemnumber;
@@ -2003,7 +2004,6 @@
     $data       = $sth->fetchrow_hashref;
     $itemnumber = $data->{'max(itemnumber)'} + 1;
     $sth->finish;
-    $sth->finish;
 ## Now calculate lccalnumber
 my ($cutterextra)=itemcalculator($dbh,$item->{'biblioitemnumber'},$item->{'itemcallnumber'});
 # FIXME the "notforloan" field seems to be named "loan" in some places. workaround bugfix.
@@ -2400,7 +2400,7 @@
     # 	my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$bibnum);
     my $record = &MARCkoha2marcBiblio( $dbh, $bibnum );
     MARCaddbiblio( $dbh, $record, $bibnum,'' );
-    return ($bibnum);
+    return ($bibnum , $record );
 }
 
 =item modsubtitle
@@ -2471,16 +2471,16 @@
 }
 
 sub newbiblioitem {
-    my ($biblioitem) = @_;
+    my ($biblioitem, $record ) = @_;
     my $dbh        = C4::Context->dbh;
     my $bibitemnum = &_koha_add_biblioitem( $dbh, $biblioitem );
 
     my $MARCbiblio =
-      MARCkoha2marcBiblio( $dbh, 0, $bibitemnum )
+      MARCkoha2marcBiblio( $dbh, 0, $bibitemnum, $record )
       ; # the 0 means "do NOT retrieve biblio, only biblioitem, in the MARC record
    
     &MARCaddbiblio( $dbh, $MARCbiblio, $biblioitem->{biblionumber}, '' );
-    return ($bibitemnum);
+    return ($bibitemnum, $record);
 }
 
 sub newsubject {
@@ -2496,13 +2496,13 @@
 }
 
 sub newitems {
-    my ( $item, @barcodes ) = @_;
+    my ( $items ) = @_;
     my $dbh = C4::Context->dbh;
     my $errors;
     my $itemnumber;
     my $error;
-    foreach my $barcode (@barcodes) {
-        ( $itemnumber, $error ) = &_koha_new_items( $dbh, $item, uc($barcode) );
+    foreach my $item (@$items) {
+        ( $itemnumber, $error ) = &_koha_new_items( $dbh, $item );
         $errors .= $error;
         my $MARCitem = &MARCkoha2marcItem( $dbh, $item->{biblionumber}, $itemnumber );
         &MARCadditem( $dbh, $MARCitem, $item->{biblionumber} );
@@ -3137,7 +3137,7 @@
 	$recordSyntax = "xml" unless $recordSyntax;
     my $Zconn = C4::Context->Zconn($server,0,1,1,$recordSyntax);
     my $rs = $Zconn->search(new ZOOM::Query::CCL2RPN($koha_query,$Zconn));
-	if ($rs->record(0)) {
+	if ($rs->size() > 0) {
     	return $rs->record(0)->raw();
 	}
 }
@@ -3158,8 +3158,11 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.51.2.42 2006/11/28 14:43:18 kados Exp $
+# $Id: Biblio.pm,v 1.115.2.51.2.43 2007/01/01 03:23:36 rych Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.115.2.51.2.43  2007/01/01 03:23:36  rych
+# passing $record object between newbiblio and newbiblioitem, etc, so we can add a minimal marc record in acquisitions, and then add multiple associated items.
+#
 # Revision 1.115.2.51.2.42  2006/11/28 14:43:18  kados
 # deleteditems table wasn't getting populaated because the execute was commented out. This puts it back
 # -- some table changes are needed as well, I'll commit those separately.





More information about the Koha-cvs mailing list