[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.1.2.2,1.1.2.3
From: |
Alan Millar |
Subject: |
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.1.2.2,1.1.2.3 |
Date: |
Wed, 26 Jun 2002 00:24:14 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv20326/C4
Modified Files:
Tag: rel-1-2
Biblio.pm
Log Message:
New subs to streamline biblio additions: addcompletebiblioitem and
getoraddbiblio
Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** Biblio.pm 24 Jun 2002 16:15:01 -0000 1.1.2.2
--- Biblio.pm 26 Jun 2002 07:24:12 -0000 1.1.2.3
***************
*** 1,8 ****
--- 1,17 ----
package C4::Biblio; #assumes C4/Biblio.pm
+ # $Id$
+
+ #-----------------
+ # General requirements
use strict;
+
require Exporter;
+
+ # Other Koha modules
use C4::Database;
+ #-----------------
+
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 20,23 ****
--- 29,34 ----
&getbiblioitem &getitemsbybiblioitem &isbnsearch &keywordsearch
&websitesearch &addwebsite &updatewebsite &deletewebsite
+ &newcompletebiblioitem
+ &getoraddbiblio
);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
***************
*** 38,42 ****
-
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
--- 49,52 ----
***************
*** 844,846 ****
--- 854,980 ----
+
+
+ #------------------------------------------------
+
+ # Add a biblioitem and related data to Koha database
+ sub newcompletebiblioitem {
+ use strict;
+
+ my (
+ $dbh, # DBI handle
+ $biblio, # hash ref to biblio record
+ $biblioitem, # hash ref to biblioitem record
+ $subjects, # list ref of subjects
+ $addlauthors, # list ref of additional authors
+ )address@hidden ;
+
+ my ( $biblionumber, $biblioitemnumber, $error); # return values
+
+ my $debug=0;
+ my $sth;
+ my $subjectheading;
+ my $additionalauthor;
+
+ #--------
+ requireDBI($dbh,"newcompletebiblioitem");
+
+ print "<PRE>Trying to add biblio item Title=$biblio->{title} " .
+ "ISBN=$biblioitem->{isbn} </PRE>\n" if $debug;
+
+ # Make sure master biblio entry exists
+ ($biblionumber,$error)=getoraddbiblio($dbh, $biblio);
+
+ if ( ! $error ) {
+
+ $biblioitem->{biblionumber}=$biblionumber;
+
+ # Add biblioitem
+ $biblioitemnumber=newbiblioitem($biblioitem);
+
+ # Add subjects
+ $sth=$dbh->prepare("insert into bibliosubject
+ (biblionumber,subject)
+ values (?, ? )" );
+ foreach $subjectheading (@{$subjects} ) {
+ $sth->execute($biblionumber, $subjectheading)
+ or $error.=$sth->errstr ;
+
+ } # foreach subject
+
+ # Add additional authors
+ $sth=$dbh->prepare("insert into additionalauthors
+ (biblionumber,author)
+ values (?, ? )");
+ foreach $additionalauthor (@{$addlauthors} ) {
+ $sth->execute($biblionumber, $additionalauthor)
+ or $error.=$sth->errstr ;
+ } # foreach author
+
+ } else {
+ # couldn't get biblio
+ $biblionumber='';
+ $biblioitemnumber='';
+
+ } # if no biblio error
+
+ return ( $biblionumber, $biblioitemnumber, $error);
+
+ } # sub newcompletebiblioitem
+
+ #---------------------------------------
+ # Find a biblio entry, or create a new one if it doesn't exist.
+ # If a "subtitle" entry is in hash, add it to subtitle table
+ sub getoraddbiblio {
+ # input params
+ my (
+ $dbh, # db handle
+ $biblio, # hash ref to fields
+ )address@hidden;
+
+ # return
+ my $biblionumber;
+
+ my $debug=0;
+ my $sth;
+ my $error;
+
+ #-----
+ requireDBI($dbh,"getoraddbiblio");
+
+ print "<PRE>Looking for biblio </PRE>\n" if $debug;
+ $sth=$dbh->prepare("select biblionumber
+ from biblio
+ where title=? and author=?
+ and copyrightdate=? and seriestitle=?");
+ $sth->execute(
+ $biblio->{title}, $biblio->{author},
+ $biblio->{copyright}, $biblio->{seriestitle} );
+ if ($sth->rows) {
+ ($biblionumber) = $sth->fetchrow;
+ print "<PRE>Biblio exists with number $biblionumber</PRE>\n" if
$debug;
+ } else {
+ # Doesn't exist. Add new one.
+ print "<PRE>Adding biblio</PRE>\n" if $debug;
+ ($biblionumber,$error)=&newbiblio($biblio);
+ if ( $biblionumber ) {
+ print "<PRE>Added with biblio number=$biblionumber</PRE>\n" if
$debug;
+ if ( $biblio->{subtitle} ) {
+ &newsubtitle($biblionumber,$biblio->{subtitle} );
+ } # if subtitle
+ } else {
+ print "<PRE>Couldn't add biblio: $error</PRE>\n" if $debug;
+ } # if added
+ }
+
+ return $biblionumber,$error;
+
+ } # sub getoraddbiblio
+
END { } # module clean-up code here (global destructor)
+
+ #---------------------------------------
+ # $Log$
+ # Revision 1.1.2.3 2002/06/26 07:24:12 amillar
+ # New subs to streamline biblio additions: addcompletebiblioitem and
getoraddbiblio
+ #
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Biblio.pm,1.1.2.2,1.1.2.3,
Alan Millar <=