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: Sun, 24 Sep 2006 21:02:27 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/09/24 21:02:27

Modified files:
        C4             : Biblio.pm 

Log message:
        moveing NEWmoditem to ModItem

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.24&r2=1.115.2.51.2.25

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.51.2.24
retrieving revision 1.115.2.51.2.25
diff -u -b -r1.115.2.51.2.24 -r1.115.2.51.2.25
--- Biblio.pm   24 Sep 2006 20:37:31 -0000      1.115.2.51.2.24
+++ Biblio.pm   24 Sep 2006 21:02:26 -0000      1.115.2.51.2.25
@@ -35,9 +35,9 @@
 
 @EXPORT = qw(
 
-  &AddBiblio
-  &ModBiblio
-  &DelBiblio
+  &AddBiblio &AddItem
+  &ModBiblio &ModItem
+  &DelBiblio &DelItem
 
   &ModBiblioframework
 
@@ -60,11 +60,6 @@
   &MARCgettagslib
   &MARCmoditemonefield
  
-  &NEWnewitem
-
-  &NEWmoditem
-
-  &NEWdelitem
   &zebraop
 
   &MARCaddbiblio &MARCadditem 
@@ -218,6 +213,71 @@
     return ( $biblionumber, $oldbibnum, $oldbibitemnum );
 }
 
+=head2 AddItem
+
+=over 4
+
+AddItem()
+
+Add a new item to Koha
+
+=back
+
+=cut
+
+sub AddItem {
+    my ( $dbh, $record, $bibid ) = @_;
+    # add item in old-DB
+    my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid);
+    my $item = &MARCmarc2koha( $dbh, $record,$frameworkcode );
+    # needs old biblionumber and biblioitemnumber
+    $item->{'biblionumber'} = $bibid;
+    my $sth =
+      $dbh->prepare(
+        "select biblioitemnumber,itemtype from biblioitems where 
biblionumber=?");
+    $sth->execute( $item->{'biblionumber'} );
+    my $itemtype;
+    ( $item->{'biblioitemnumber'}, $itemtype ) = $sth->fetchrow;
+    $sth=$dbh->prepare("select notforloan from itemtypes where 
itemtype='$itemtype'");
+    $sth->execute();
+    my $notforloan=$sth->fetchrow;
+    ##Change the notforloan field if $notforloan found
+    if ($notforloan >0){
+        $item->{'notforloan'}=$notforloan;
+        &MARCitemchange($dbh,$record,"items.notforloan",$notforloan);
+    }
+    if(!$item->{'dateaccessioned'}||$item->{'dateaccessioned'} eq ''){
+        # find today's date
+        my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+            localtime(time); $year +=1900; $mon +=1;
+        my $date = "$year-".sprintf ("%0.2d", $mon)."-".sprintf("%0.2d",$mday);
+        $item->{'dateaccessioned'}=$date;
+        &MARCitemchange($dbh,$record,"items.dateaccessioned",$date);
+    }
+    my ( $itemnumber, $error ) = &OLDnewitems( $dbh, $item, $item->{barcode} );
+    # add itemnumber to MARC::Record before adding the item.
+    $sth =
+      $dbh->prepare(
+"select tagfield,tagsubfield from marc_subfield_structure where 
frameworkcode=? and kohafield=?"
+    );
+    &MARCkoha2marcOnefield( $sth, $record, "items.itemnumber", 
$itemnumber,$frameworkcode );
+
+    ##NEU specific add cataloguers cardnumber as well
+    my $cardtag=C4::Context->preference('itemcataloguersubfield');
+    if ($cardtag){
+        $sth->execute($frameworkcode,"items.itemnumber");
+        my ($itemtag,$subtag)=$sth->fetchrow;
+        my $me= C4::Context->userenv;
+        my $cataloguer=$me->{'cardnumber'} if ($me);
+        my $newtag= $record->field($itemtag);
+        $newtag->update($cardtag=>$cataloguer) if ($me);
+        $record->delete_field($newtag);
+        $record->append_fields($newtag);
+    }
+    # add the item
+    my $bib = &MARCadditem( $dbh, $record, $item->{'biblionumber'} );
+}
+
 =head2 ModBiblio
 
 =over 4
@@ -280,6 +340,24 @@
     return 1;
 }
 
+=head2 ModItem
+
+=over 4
+
+=back
+
+=cut
+
+
+sub ModItem {
+    my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_;
+
+    &MARCmoditem( $dbh, $record, $bibid, $itemnumber, $delete );
+    my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid);
+    my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
+    OLDmoditem( $dbh, $olditem );
+}
+
 =head2 DelBiblio
 
 =over 4
@@ -355,6 +433,23 @@
 }
 
 
+=head2 DelItem
+
+=over 4
+
+Deletes an item record
+
+=back
+
+=cut
+
+sub DelItem {
+    my ( $dbh, $bibid, $itemnumber ) = @_;
+    my $biblio = $bibid;
+    &_koha_delete_item( $dbh, $itemnumber );
+    my $newrec=&MARCdelitem( $dbh, $bibid, $itemnumber );
+    &MARCaddbiblio($dbh,$newrec,$bibid,);
+}
 
 =head2 z3950_extended_services
 
@@ -1400,59 +1495,6 @@
        return 1;
 }
 
-sub NEWnewitem {
-    my ( $dbh, $record, $bibid ) = @_;
-    # add item in old-DB
-       my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid);
-    my $item = &MARCmarc2koha( $dbh, $record,$frameworkcode );
-    # needs old biblionumber and biblioitemnumber
-    $item->{'biblionumber'} = $bibid;
-    my $sth =
-      $dbh->prepare(
-        "select biblioitemnumber,itemtype from biblioitems where 
biblionumber=?");
-    $sth->execute( $item->{'biblionumber'} );
-       my $itemtype;
-    ( $item->{'biblioitemnumber'}, $itemtype ) = $sth->fetchrow;
-       $sth=$dbh->prepare("select notforloan from itemtypes where 
itemtype='$itemtype'");
-       $sth->execute();
-       my $notforloan=$sth->fetchrow;
-       ##Change the notforloan field if $notforloan found
-       if ($notforloan >0){
-               $item->{'notforloan'}=$notforloan;
-               &MARCitemchange($dbh,$record,"items.notforloan",$notforloan);
-       }
-       if(!$item->{'dateaccessioned'}||$item->{'dateaccessioned'} eq ''){
-               # find today's date
-               my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =      
                                                     
-                       localtime(time); $year +=1900; $mon +=1;
-               my $date = "$year-".sprintf ("%0.2d", 
$mon)."-".sprintf("%0.2d",$mday);
-               $item->{'dateaccessioned'}=$date;
-               &MARCitemchange($dbh,$record,"items.dateaccessioned",$date);
-       }
-    my ( $itemnumber, $error ) = &OLDnewitems( $dbh, $item, $item->{barcode} );
-    # add itemnumber to MARC::Record before adding the item.
-    $sth =
-      $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where 
frameworkcode=? and kohafield=?"
-    );
-    &MARCkoha2marcOnefield( $sth, $record, "items.itemnumber", 
$itemnumber,$frameworkcode );
-
-       ##NEU specific add cataloguers cardnumber as well
-       my $cardtag=C4::Context->preference('itemcataloguersubfield');
-       if ($cardtag){  
-               $sth->execute($frameworkcode,"items.itemnumber");
-               my ($itemtag,$subtag)=$sth->fetchrow;   
-               my $me= C4::Context->userenv;
-               my $cataloguer=$me->{'cardnumber'} if ($me);
-               my $newtag= $record->field($itemtag);
-               $newtag->update($cardtag=>$cataloguer) if ($me);
-               $record->delete_field($newtag);
-               $record->append_fields($newtag);        
-       }
-    # add the item
-    my $bib = &MARCadditem( $dbh, $record, $item->{'biblionumber'} );
-}
-
 sub MARCitemchange {
        my ($dbh,$record,$itemfield,$newvalue)address@hidden;
     my ($tagfield, 
$tagsubfield)=MARCfind_marc_from_kohafield($dbh,$itemfield,"");
@@ -1466,29 +1508,9 @@
     }
 }
 
-sub NEWmoditem {
-    my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_;
-
-       &MARCmoditem( $dbh, $record, $bibid, $itemnumber, $delete );
-       my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid);
-    my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
-    OLDmoditem( $dbh, $olditem );
-}
-
-sub NEWdelitem {
-    my ( $dbh, $bibid, $itemnumber ) = @_;
-    my $biblio = $bibid;
-    &OLDdelitem( $dbh, $itemnumber );
-    my $newrec=&MARCdelitem( $dbh, $bibid, $itemnumber );
-&MARCaddbiblio($dbh,$newrec,$bibid,);
-}
-#
-#
-# OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
-#
-#
+=head1 INTERNAL FUNCTIONS
 
-=item $biblionumber = _koha_add_biblio($dbh,$biblio);
+=head2 $biblionumber = _koha_add_biblio($dbh,$biblio);
 
 adds a record in biblio table. Datas are in the hash $biblio.
 
@@ -1529,10 +1551,6 @@
 
 modify item
 
-=item OLDdelitem($dbh,$itemnum);
-
-delete item
-
 =item OLDdeletebiblioitem($dbh,$biblioitemnumber);
 
 deletes a biblioitem
@@ -1990,10 +2008,19 @@
     #  $dbh->disconnect;
 }
 
-sub OLDdelitem {
+=head2 _koha_delete_item
+
+=over 4
+
+Internal function to delete an item record from the koha tables
+
+=back
+
+=cut
+
+sub _koha_delete_item {
     my ( $dbh, $itemnum ) = @_;
 
-    #  my $dbh=C4Connect;
     my $sth = $dbh->prepare("select * from items where itemnumber=?");
     $sth->execute($itemnum);
     my $data = $sth->fetchrow_hashref;
@@ -2991,8 +3018,11 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.51.2.24 2006/09/24 20:37:31 kados Exp $
+# $Id: Biblio.pm,v 1.115.2.51.2.25 2006/09/24 21:02:26 kados Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.115.2.51.2.25  2006/09/24 21:02:26  kados
+# moveing NEWmoditem to ModItem
+#
 # Revision 1.115.2.51.2.24  2006/09/24 20:37:31  kados
 # missed items
 #




reply via email to

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