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: Thu, 05 Oct 2006 21:05:21 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/10/05 21:05:20

Modified files:
        C4             : Biblio.pm 

Log message:
        just cleanup, no changes

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.35&r2=1.115.2.51.2.36

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.51.2.35
retrieving revision 1.115.2.51.2.36
diff -u -b -r1.115.2.51.2.35 -r1.115.2.51.2.36
--- Biblio.pm   3 Oct 2006 20:49:56 -0000       1.115.2.51.2.35
+++ Biblio.pm   5 Oct 2006 21:05:20 -0000       1.115.2.51.2.36
@@ -141,14 +141,12 @@
 =cut
 
 sub AddBiblio {
-    my ( $dbh, $record, $frameworkcode) = @_;
+    my ($dbh,$record,$frameworkcode) = @_;
     my $oldbibnum;
     my $oldbibitemnum;
 
     # transform the data into koha-table style data
     my $olddata = MARCmarc2koha( $dbh, $record,$frameworkcode );
-
-    #
     $oldbibnum = _koha_add_biblio( $dbh, $olddata );
     $olddata->{'biblionumber'} = $oldbibnum;
     $oldbibitemnum = _koha_add_biblioitem( $dbh, $olddata );
@@ -187,7 +185,7 @@
     # we add the new builded field.
     # NOTE : Works only if the field is ONLY for biblionumber and 
biblioitemnumber
     # (steve and paul : thinks 090 is a good choice)
-    my $sth = $dbh->prepare("select tagfield,tagsubfield from 
marc_subfield_structure where kohafield=?");
+    my $sth = $dbh->prepare("SELECT tagfield,tagsubfield FROM 
marc_subfield_structure WHERE kohafield=?");
     $sth->execute("biblio.biblionumber");
     ( my $tagfield1, my $tagsubfield1 ) = $sth->fetchrow;
     $sth->execute("biblioitems.biblioitemnumber");
@@ -386,18 +384,29 @@
 
 Exported function (core API) for modifying an item in Koha.
 
+
 =back
 
 =cut
 
 
 sub ModItem {
-    my ( $dbh, $record, $biblionumber, $itemnumber, $delete ) = @_;
-
+    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 );
     my $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
     my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
     _koha_modify_item( $dbh, $olditem );
+               return undef;
+       }
+       # otherwise, we're just looking to modify something quickly
+       # (like a status) so we just update the koha tables
+       elsif ($new_item_hashref) {
+               _koha_modify_item( $dbh, $new_item_hashref );
+       }
 }
 
 =head2 DelBiblio
@@ -1690,32 +1699,28 @@
 
 sub _koha_add_biblio {
     my ( $dbh, $biblio ) = @_;
-
-    #  my $dbh    = &C4Connect;
     my $sth = $dbh->prepare("Select max(biblionumber) from biblio");
     $sth->execute;
     my $data   = $sth->fetchrow_arrayref;
-    my $bibnum = $$data[0] + 1;
+    my $biblionumber = $$data[0] + 1;
     my $series = 0;
 
     if ( $biblio->{'seriestitle'} ) { $series = 1 }
     $sth->finish;
-    $sth =
-      $dbh->prepare(
-"insert into biblio set biblionumber  = ?, title = ?, author = ?, 
copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, 
unititle = ?"
+    $sth = $dbh->prepare(
+       "INSERT INTO biblio
+       SET biblionumber  = ?, title = ?, author = ?, copyrightdate = ?, serial 
= ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?"
     );
     $sth->execute(
-        $bibnum,             $biblio->{'title'},
+        $biblionumber,$biblio->{'title'},
         $biblio->{'author'}, $biblio->{'copyrightdate'},
-        $biblio->{'serial'},             $biblio->{'seriestitle'},
-        $biblio->{'notes'},  $biblio->{'abstract'},
+        $biblio->{'serial'},$biblio->{'seriestitle'},
+        $biblio->{'notes'},$biblio->{'abstract'},
                $biblio->{'unititle'},
     );
 
     $sth->finish;
-
-    #  $dbh->disconnect;
-    return ($bibnum);
+    return ($biblionumber);
 }
 
 =head2 _koha_modify_biblio
@@ -2081,9 +2086,20 @@
 }
 
 sub _koha_modify_item {
-    my ( $dbh, $item ) = @_;
+    my ( $dbh, $item, $op ) = @_;
     $item->{'itemnum'} = $item->{'itemnumber'} unless $item->{'itemnum'};
 
+       # if all we're doing is setting statuses, just update those and get out
+       if ($op eq "setstatus") {
+               my $query = "UPDATE items SET itemlost=?,wthdrawn=?,binding=? 
WHERE itemnumber=?";
+               my @bind = (
+                       $item->{'itemlost'}, $item->{'wthdrawn'}, 
$item->{'binding'},$item->{'itemnumber'}
+                       );
+               my $sth = $dbh->prepare($query);
+               $sth->execute(@bind);
+               $sth->finish;
+               return undef;
+       }
        ## Now calculate lccalnumber
        my 
($cutterextra)=itemcalculator($dbh,$item->{'bibitemnum'},$item->{'itemcallnumber'});
 
@@ -2110,14 +2126,14 @@
                        $item->{multivolume},           $item->{stack},
                        
$item->{wthdrawn},$item->{holdingbranch},$cutterextra,$item->{onloan},$item->{binding}
         );
-#              if ($item->{homebranch}) {
-#                      $query.=",homebranch=?";
-#                      push @bind, $item->{homebranch};
-#              }
-#              if ($item->{holdingbranch}) {
-#                      $query.=",holdingbranch=?";
-#                      push @bind, $item->{holdingbranch};
-#              }
+               if ($item->{homebranch}) {
+                       $query.=",homebranch=?";
+                       push @bind, $item->{homebranch};
+               }
+               if ($item->{holdingbranch}) {
+                       $query.=",holdingbranch=?";
+                       push @bind, $item->{holdingbranch};
+               }
     }
        $query.=" where itemnumber=?";
        push @bind,$item->{'itemnum'};
@@ -2498,12 +2514,16 @@
 }
 
 sub moditem {
-    my ($item) = @_;
+    my ($item,$op) = @_;
     my $dbh = C4::Context->dbh;
-    &_koha_modify_item( $dbh, $item );
+    &_koha_modify_item( $dbh, $item, $op);
+       # if we're just setting statuses, just update items table
+       # it's faster and zebra and marc will be synched anyway by the cron job
+       unless ($op eq "setstatus") {
     my $MARCitem = &MARCkoha2marcItem( $dbh, $item->{'biblionumber'}, 
$item->{'itemnum'} );
     my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, 
$item->{biblionumber} );
     &MARCmoditem( $dbh, $MARCitem, $bibid, $item->{itemnum}, 0 );
+       }
 }
 
 sub checkitems {
@@ -3139,8 +3159,11 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.51.2.35 2006/10/03 20:49:56 kados Exp $
+# $Id: Biblio.pm,v 1.115.2.51.2.36 2006/10/05 21:05:20 kados Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.115.2.51.2.36  2006/10/05 21:05:20  kados
+# just cleanup, no changes
+#
 # Revision 1.115.2.51.2.35  2006/10/03 20:49:56  kados
 # I've changed items.binding to be a flag and linked it to an authorized
 # value in the framework -- now there are three statuses that can be set




reply via email to

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