[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Biblio.pm [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha/C4 Biblio.pm [rel_3_0] |
Date: |
Fri, 20 Oct 2006 15:26:42 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/10/20 15:26:42
Modified files:
C4 : Biblio.pm
Log message:
sync with dev_week.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.18&r2=1.178.2.19
Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.18
retrieving revision 1.178.2.19
diff -u -b -r1.178.2.18 -r1.178.2.19
--- Biblio.pm 19 Oct 2006 11:57:04 -0000 1.178.2.18
+++ Biblio.pm 20 Oct 2006 15:26:41 -0000 1.178.2.19
@@ -199,7 +199,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");
@@ -350,7 +350,7 @@
# update the MARC record with the new record data
&MARCmodbiblio($dbh,$biblionumber,$record,$frameworkcode,1);
- # loat the koha-style data
+ # load the koha-table data object
my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode);
# modify the other koha tables
@@ -372,7 +372,7 @@
my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
# delete & create subtitle again because _koha_modify_subtitle can't
handle new subtitles
# between 2 modifs
- $dbh->do("delete from bibliosubtitle where
biblionumber=$oldbiblionumber");
+ $dbh->do("DELETE FROM bibliosubtitle WHERE
biblionumber=$oldbiblionumber");
foreach my $subfieldcount (0..$#subtitlesubfields) {
foreach my $subtit(split
/\||#/,$subtitlesubfields[$subfieldcount]) {
_koha_add_subtitle($dbh,$oldbiblionumber,$subtit);
@@ -402,18 +402,18 @@
=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 );
_koha_modify_item( $dbh, $olditem );
- return undef;
+ $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
+ return $biblionumber;
}
# otherwise, we're just looking to modify something quickly
# (like a status) so we just update the koha tables
@@ -644,7 +644,6 @@
=cut
-
sub MARCgettagslib {
my ( $dbh, $forlibrarian, $frameworkcode ) = @_;
$frameworkcode = "" unless $frameworkcode;
@@ -791,18 +790,17 @@
=cut
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;
}
@@ -822,9 +820,13 @@
return $record;
}
-sub XMLgetbiblio {
+=head2 XMLgetbiblio
+
+Returns MARC::XML of the biblio passed in parameter.
- # Returns MARC::XML of the biblio passed in parameter.
+=cut
+
+sub XMLgetbiblio {
my ( $dbh, $biblionumber ) = @_;
my $sth = $dbh->prepare("select marcxml from biblioitems where
biblionumber=? " );
@@ -847,6 +849,7 @@
$marc=MARC::File::USMARC::decode($marc);
my $marcxml=$marc->as_xml_record();
return $marcxml;
+
=cut
sub MARCgetbiblio2 {
@@ -1022,37 +1025,32 @@
=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'"
- );
+ 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;
}
@@ -1097,9 +1095,10 @@
=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;
+
+ # delete this item from MARC
+ my $newrec=&MARCdelitem($dbh,$biblionumber,$itemnumber);
# 2nd recreate it
my @fields = $record->fields();
@@ -1253,9 +1252,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;
}
@@ -1437,14 +1436,11 @@
}
$sth->execute($frameworkcode,$kohafieldname);
if ( ( $tagfield, $tagsubfield ) = $sth->fetchrow ) {
- # if ( $record->field($tagfield) ) {
my $tag = $record->field($tagfield);
if ($tag) {
$tag->update( $tagsubfield=> $value );
$record->delete_field($tag);
$record->insert_fields_ordered($tag);
-
-
}else {
$record->add_fields( $tagfield, " ", " ", $tagsubfield => $value );
}
@@ -1761,13 +1757,25 @@
}
}
-sub NEWmodbiblioframework {
- my ($bibid,$frameworkcode) address@hidden;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("Update biblio SET frameworkcode=? WHERE
biblionumber=$bibid");
+=head2 ModBiblioframework
+
+=over 4
+
+ModBiblioframework($dbh,$biblionumber,$frameworkcode);
+
+Exported function to modify a biblio framework
+
+=back
+
+=cut
+
+sub ModBiblioframework {
+ my ($dbh,$biblionumber,$frameworkcode) address@hidden;
+ my $sth = $dbh->prepare("UPDATE biblio SET frameworkcode=? WHERE
biblionumber=$biblionumber");
$sth->execute($frameworkcode);
return 1;
}
+
sub NEWmodbiblio {
my ($record,$bibid,$frameworkcode) address@hidden;
my $dbh = C4::Context->dbh;
@@ -1887,25 +1895,6 @@
my $bib = &MARCadditem( $dbh, $record, $item->{'biblionumber'} );
}
-=head2 ModBiblioframework
-
-=over 4
-
-ModBiblioframework($dbh,$biblionumber,$frameworkcode);
-
-Exported function to modify a biblio framework
-
-=back
-
-=cut
-
-sub ModBiblioframework {
- my ($dbh,$bibid,$frameworkcode) address@hidden;
- my $sth = $dbh->prepare("Update biblio SET frameworkcode=? WHERE
biblionumber=$bibid");
- $sth->execute($frameworkcode);
- return 1;
-}
-
sub NEWmoditem {
my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_;
@@ -1984,7 +1973,6 @@
$biblio->{'unititle'}, $biblio->{'notes'},
$biblio->{'biblionumber'}
);
-
$sth->finish;
return ( $biblio->{'biblionumber'} );
}
@@ -2192,7 +2180,7 @@
size
= ?, lccn = ?,
marc
= ?,
- place
= ?, lcsort=?
+ place
= ?, lcsort=?, ccode = ?
"
);
my
($lcsort)=calculatelc($biblioitem->{'classification'}).$biblioitem->{'subclass'};
@@ -2325,23 +2313,37 @@
}
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'});
- my $query = "update items set
barcode=?,itemnotes=?,itemcallnumber=?,notforloan=?,location=?,multivolumepart=?,multivolume=?,stack=?,wthdrawn=?,holdingbranch=?,homebranch=?,cutterextra=?,
onloan=?";
+
+ my $query = "UPDATE items SET
+barcode=?,itemnotes=?,itemcallnumber=?,notforloan=?,location=?,multivolumepart=?,multivolume=?,stack=?,wthdrawn=?,holdingbranch=?,homebranch=?,cutterextra=?,
onloan=?, binding=?";
+
my @bind = (
$item->{'barcode'}, $item->{'notes'},
$item->{'itemcallnumber'}, $item->{'notforloan'},
$item->{'location'}, $item->{multivolumepart},
$item->{multivolume}, $item->{stack},
-
$item->{wthdrawn},$item->{holdingbranch},$item->{homebranch},$cutterextra,$item->{onloan}
+
$item->{wthdrawn},$item->{holdingbranch},$item->{homebranch},$cutterextra,$item->{onloan},$item->{binding}
);
if ( $item->{'lost'} ne '' ) {
$query = "update items set
biblioitemnumber=?,barcode=?,itemnotes=?,homebranch=?,
itemlost=?,wthdrawn=?,itemcallnumber=?,notforloan=?,
-
location=?,multivolumepart=?,multivolume=?,stack=?,wthdrawn=?,holdingbranch=?,cutterextra=?,onloan=?";
+
location=?,multivolumepart=?,multivolume=?,stack=?,wthdrawn=?,holdingbranch=?,cutterextra=?,onloan=?,
binding=?";
@bind = (
$item->{'bibitemnum'}, $item->{'barcode'},
$item->{'notes'}, $item->{'homebranch'},
@@ -2349,16 +2351,16 @@
$item->{'itemcallnumber'}, $item->{'notforloan'},
$item->{'location'}, $item->{multivolumepart},
$item->{multivolume}, $item->{stack},
-
$item->{wthdrawn},$item->{holdingbranch},$cutterextra,$item->{onloan}
+
$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'};
@@ -2368,8 +2370,6 @@
my $sth = $dbh->prepare($query);
$sth->execute(@bind);
$sth->finish;
-
- # $dbh->disconnect;
}
=head2 _koha_delete_item
@@ -2776,14 +2776,16 @@
}
sub moditem {
- my ($item) = @_;
+ my ($item,$op) = @_;
my $dbh = C4::Context->dbh;
- &_koha_modify_item( $dbh, $item );
- my $MARCitem =
- &MARCkoha2marcItem( $dbh, $item->{'biblionumber'}, $item->{'itemnum'} );
- my $bibid =
- &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, $item->{biblionumber} );
+ &_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 {
@@ -3649,6 +3651,7 @@
$record = $record->as_xml_record() if $record;
#warn "RECORD".$record->as_usmarc();
$shadow="biblioservershadow";
+
}elsif($server eq "authorityserver"){
$record
=C4::AuthoritiesMarc::XMLgetauthority($dbh,$biblionumber);
$shadow="authorityservershadow";
@@ -3657,6 +3660,7 @@
my $Zpackage = $Zconnbiblio[0]->package();
$Zpackage->option(action => $op);
$Zpackage->option(record => $record);
+
retry:
$Zpackage->send("update");
my $i;
@@ -3666,6 +3670,7 @@
$event = $Zconnbiblio[0]->last_event();
last if $event == ZOOM::Event::ZEND;
}
+
my($error, $errmsg, $addinfo, $diagset) = $Zconnbiblio[0]->error_x();
if ($error==10000 && $reconnect==0) { ## This is serious ZEBRA server
is not available -reconnect
warn "problem with zebra server connection";
@@ -3824,8 +3829,11 @@
=cut
-# $Id: Biblio.pm,v 1.178.2.18 2006/10/19 11:57:04 btoumi Exp $
+# $Id: Biblio.pm,v 1.178.2.19 2006/10/20 15:26:41 toins Exp $
# $Log: Biblio.pm,v $
+# Revision 1.178.2.19 2006/10/20 15:26:41 toins
+# sync with dev_week.
+#
# Revision 1.178.2.18 2006/10/19 11:57:04 btoumi
# bug fix : wrong syntax in sub call
#
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], Henri-Damien LAURENT, 2006/10/02
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], paul poulain, 2006/10/11
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], paul poulain, 2006/10/11
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], Antoine Farnault, 2006/10/16
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], Bruno Toumi, 2006/10/19
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0],
Antoine Farnault <=
- [Koha-cvs] koha/C4 Biblio.pm [rel_3_0], Antoine Farnault, 2006/10/31