koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Joshua Ferraro
Subject: [Koha-cvs] koha/C4 Biblio.pm [dev_week]
Date: Wed, 11 Oct 2006 03:10:50 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/10/11 03:10:50

Modified files:
        C4             : Biblio.pm 

Log message:
        fix for bug 1214: Frameworkcode lost on additem
        
        Also, some API cleaning ... Toins, please synch these changes into
        rel3_0

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.40&r2=1.115.2.51.2.41

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.51.2.40
retrieving revision 1.115.2.51.2.41
diff -u -b -r1.115.2.51.2.40 -r1.115.2.51.2.41
--- Biblio.pm   11 Oct 2006 02:02:30 -0000      1.115.2.51.2.40
+++ Biblio.pm   11 Oct 2006 03:10:49 -0000      1.115.2.51.2.41
@@ -313,7 +313,7 @@
         $record->append_fields($newtag);
     }
     # add the item
-    my $bib = &MARCadditem( $dbh, $record, $item->{'biblionumber'} );
+    my $bib = &MARCadditem( $dbh, $record, 
$item->{'biblionumber'},$frameworkcode );
 }
 
 =head2 ModBiblio
@@ -384,22 +384,21 @@
 
 Exported function (core API) for modifying an item in Koha.
 
-
 =back
 
 =cut
 
-
 sub ModItem {
     my ( $dbh, $record, $biblionumber, $itemnumber, $delete, 
$new_item_hashref) = @_;
        # if we have a MARC record, we're coming from cataloging and so
        # we do the whole routine: update the MARC and zebra, then update the 
koha
        # tables
        if ($record) {
-       &MARCmoditem( $dbh, $record, $biblionumber, $itemnumber, $delete );
+       MARCmoditem( $dbh, $record, $biblionumber, $itemnumber, $delete );
        my $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
-       my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
+       my $olditem = MARCmarc2koha( $dbh, $record, $frameworkcode );
        _koha_modify_item( $dbh, $olditem );
+               $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
                return $biblionumber;
        }
        # otherwise, we're just looking to modify something quickly
@@ -751,17 +750,16 @@
 
 sub MARCadditem {
 # pass the MARC::Record to this function, and it will create the records in 
the marc tables
-    my ($dbh,$record,$biblionumber) = @_;
+    my ($dbh,$record,$biblionumber,$frameworkcode) = @_;
        my $newrec=&MARCgetbiblio($dbh,$biblionumber);
 
        # 2nd recreate it
        my @fields = $record->fields();
- 
      foreach my $field (@fields) {
          $newrec->append_fields($field);
        }
        # FIXME: should we be making sure the biblionumbers are the same?
-       my $newbiblionumber=&MARCaddbiblio($dbh,$newrec,$biblionumber);
+       my 
$newbiblionumber=&MARCaddbiblio($dbh,$newrec,$biblionumber,$frameworkcode);
     return $newbiblionumber;
 }
 
@@ -948,38 +946,33 @@
 
 =head2 MARCdelitem
 
+delete the item field from the MARC record for the itemnumber specified
+
 =cut
 
 sub MARCdelitem {
+    my ( $dbh, $biblionumber, $itemnumber ) = @_;
 
-    # delete the item passed in parameter in MARC tables.
-    my ( $dbh, $bibid, $itemnumber ) = @_;
+    # get the MARC record
+    my $record = MARCgetbiblio( $dbh, $biblionumber);
 
-    #    my $record = MARC::Record->new();
-    # search MARC tagorder
-    my $record = MARCgetbiblio( $dbh, $bibid);
-    my $copy2deleted =
-      $dbh->prepare("update deleteditems set marc=? where itemnumber=?");
+       # backup the record
+    my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE 
itemnumber=?");
     $copy2deleted->execute( $record->as_usmarc(), $itemnumber );
 
-    #search item field code
-        my $sth =
-          $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where kohafield like 
'items.itemnumber'"
-        );
+    # search item field code
+       my $sth = $dbh->prepare("SELECT tagfield,tagsubfield FROM 
marc_subfield_structure WHERE kohafield LIKE 'items.itemnumber'");
         $sth->execute;
         my ($itemtag,$itemsubfield) = $sth->fetchrow;
  my @fields = $record->field($itemtag);
  
+       # delete the item specified
      foreach my $field (@fields) {
-#   my $field_item = $record->field($itemtag);
-#my $pos=index($field->as_string() ,$itemnumber );
       if ($field->subfield($itemsubfield) eq $itemnumber ){
        $record->delete_field($field);
-       }#if
-       }#foreach
-           
-return $record;
+               }
+       }
+       return $record;
 }
 
 =head2 MARCmoditemonefield
@@ -1022,15 +1015,15 @@
 =cut
 
 sub MARCmoditem {
-       my ($dbh,$record,$bibid,$itemnumber,$delete)address@hidden;
-       my $biblionumber = $bibid;
-       my $newrec=&MARCdelitem($dbh,$bibid,$itemnumber);
+       my ($dbh,$record,$biblionumber,$itemnumber,$delete)address@hidden;
 
-# 2nd recreate it
+       # delete this item from MARC
+       my $newrec=&MARCdelitem($dbh,$biblionumber,$itemnumber);
+
+       # 2nd recreate it
        my @fields = $record->fields();
  ###NEU specific add cataloguers cardnumber as well
-my $cardtag=C4::Context->preference('itemcataloguersubfield');
-
+       my $cardtag=C4::Context->preference('itemcataloguersubfield');
      foreach my $field (@fields) {
        if ($cardtag){  
        my $me= C4::Context->userenv;
@@ -1040,7 +1033,6 @@
          $newrec->append_fields($field);
        }
        &MARCaddbiblio($dbh,$newrec,$biblionumber);
-       
 }
 
 =head2 MARCmodsubfield
@@ -1178,9 +1170,9 @@
 =cut
 
 sub MARCfind_frameworkcode {
-    my ( $dbh, $bibid ) = @_;
+    my ( $dbh, $biblionumber ) = @_;
     my $sth = $dbh->prepare("select frameworkcode from biblio where 
biblionumber=?");
-    $sth->execute($bibid);
+    $sth->execute($biblionumber);
     my ($frameworkcode) = $sth->fetchrow;
     return $frameworkcode;
 }
@@ -3164,8 +3156,14 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.51.2.40 2006/10/11 02:02:30 kados Exp $
+# $Id: Biblio.pm,v 1.115.2.51.2.41 2006/10/11 03:10:49 kados Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.115.2.51.2.41  2006/10/11 03:10:49  kados
+# fix for bug 1214: Frameworkcode lost on additem
+#
+# Also, some API cleaning ... Toins, please synch these changes into
+# rel3_0
+#
 # Revision 1.115.2.51.2.40  2006/10/11 02:02:30  kados
 # ModItem wasn't returning the correct value for the redirect
 # in additem




reply via email to

[Prev in Thread] Current Thread [Next in Thread]