From 37d454a82af85740ca2124677768f7c27e66b410 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 13 Aug 2004 16:37:25 +0000 Subject: [PATCH] adding frameworkcode to API in some subs --- C4/Biblio.pm | 50 +++++++++++++++++++--------------- acqui.simple/addbiblio.pl | 4 +-- acqui.simple/addbooks.pl | 2 +- acqui.simple/additem-nomarc.pl | 5 +++- acqui.simple/additem.pl | 2 +- acqui.simple/isbnsearch.pl | 2 +- acqui.simple/keywordsearch.pl | 2 +- acqui.simple/savebiblio.pl | 2 +- acqui.simple/saveitem.pl | 2 +- acqui.simple/websitesearch.pl | 2 +- misc/bulkmarcimport.pl | 4 +-- misc/rebuildnonmarc.pl | 2 +- 12 files changed, 44 insertions(+), 35 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 96ec9e5151..9436abe3bd 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -288,13 +288,13 @@ sub MARCgettagslib { } sub MARCfind_marc_from_kohafield { - my ( $dbh, $kohafield ) = @_; + my ( $dbh, $kohafield,$frameworkcode ) = @_; return 0, 0 unless $kohafield; my $sth = $dbh->prepare( -"select tagfield,tagsubfield from marc_subfield_structure where kohafield=?" +"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?" ); - $sth->execute($kohafield); + $sth->execute($frameworkcode,$kohafield); my ( $tagfield, $tagsubfield ) = $sth->fetchrow; return ( $tagfield, $tagsubfield ); } @@ -1071,29 +1071,29 @@ sub MARChtml2marc { } sub MARCmarc2koha { - my ($dbh,$record) = @_; - my $sth=$dbh->prepare("select tagfield,tagsubfield from marc_subfield_structure where kohafield=?"); + my ($dbh,$record,$frameworkcode) = @_; + my $sth=$dbh->prepare("select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"); my $result; my $sth2=$dbh->prepare("SHOW COLUMNS from biblio"); $sth2->execute; my $field; while (($field)=$sth2->fetchrow) { - $result=&MARCmarc2kohaOneField($sth,"biblio",$field,$record,$result); + $result=&MARCmarc2kohaOneField($sth,"biblio",$field,$record,$result,$frameworkcode); } $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems"); $sth2->execute; while (($field)=$sth2->fetchrow) { if ($field eq 'notes') { $field = 'bnotes'; } - $result=&MARCmarc2kohaOneField($sth,"biblioitems",$field,$record,$result); + $result=&MARCmarc2kohaOneField($sth,"biblioitems",$field,$record,$result,$frameworkcode); } $sth2=$dbh->prepare("SHOW COLUMNS from items"); $sth2->execute; while (($field)=$sth2->fetchrow) { - $result = &MARCmarc2kohaOneField($sth,"items",$field,$record,$result); + $result = &MARCmarc2kohaOneField($sth,"items",$field,$record,$result,$frameworkcode); } # additional authors : specific - $result = &MARCmarc2kohaOneField($sth,"bibliosubtitle","subtitle",$record,$result); - $result = &MARCmarc2kohaOneField($sth,"additionalauthors","additionalauthors",$record,$result); + $result = &MARCmarc2kohaOneField($sth,"bibliosubtitle","subtitle",$record,$result,$frameworkcode); + $result = &MARCmarc2kohaOneField($sth,"additionalauthors","additionalauthors",$record,$result,$frameworkcode); # modify copyrightdate to keep only the 1st year found my $temp = $result->{'copyrightdate'}; $temp =~ m/c(\d\d\d\d)/; # search cYYYY first @@ -1118,13 +1118,13 @@ sub MARCmarc2koha { sub MARCmarc2kohaOneField { # FIXME ? if a field has a repeatable subfield that is used in old-db, only the 1st will be retrieved... - my ( $sth, $kohatable, $kohafield, $record, $result ) = @_; + my ( $sth, $kohatable, $kohafield, $record, $result,$frameworkcode ) = @_; # warn "kohatable / $kohafield / $result / "; my $res = ""; my $tagfield; my $subfield; - $sth->execute( $kohatable . "." . $kohafield ); + $sth->execute( $frameworkcode,$kohatable . "." . $kohafield ); ( $tagfield, $subfield ) = $sth->fetchrow; foreach my $field ( $record->field($tagfield) ) { if ( $field->subfield($subfield) ) { @@ -1202,14 +1202,14 @@ sub NEWnewbiblio { my ( $dbh, $record, $frameworkcode ) = @_; my $oldbibnum; my $oldbibitemnum; - my $olddata = MARCmarc2koha( $dbh, $record ); + my $olddata = MARCmarc2koha( $dbh, $record,$frameworkcode ); $oldbibnum = OLDnewbiblio( $dbh, $olddata ); $olddata->{'biblionumber'} = $oldbibnum; $oldbibitemnum = OLDnewbiblioitem( $dbh, $olddata ); # search subtiles, addiauthors and subjects my ( $tagfield, $tagsubfield ) = - MARCfind_marc_from_kohafield( $dbh, "additionalauthors.author" ); + MARCfind_marc_from_kohafield( $dbh, "additionalauthors.author",$frameworkcode ); my @addiauthfields = $record->field($tagfield); foreach my $addiauthfield (@addiauthfields) { my @addiauthsubfields = $addiauthfield->subfield($tagsubfield); @@ -1219,7 +1219,7 @@ sub NEWnewbiblio { } } ( $tagfield, $tagsubfield ) = - MARCfind_marc_from_kohafield( $dbh, "bibliosubtitle.title" ); + MARCfind_marc_from_kohafield( $dbh, "bibliosubtitle.title",$frameworkcode ); my @subtitlefields = $record->field($tagfield); foreach my $subtitlefield (@subtitlefields) { my @subtitlesubfields = $subtitlefield->subfield($tagsubfield); @@ -1229,7 +1229,7 @@ sub NEWnewbiblio { } } ( $tagfield, $tagsubfield ) = - MARCfind_marc_from_kohafield( $dbh, "bibliosubject.subject" ); + MARCfind_marc_from_kohafield( $dbh, "bibliosubject.subject",$frameworkcode ); my @subj = $record->field($tagfield); my @subjects; foreach my $subject (@subj) { @@ -1278,11 +1278,11 @@ sub NEWmodbiblio { my ($dbh,$record,$bibid,$frameworkcode) =@_; $frameworkcode="" unless $frameworkcode; &MARCmodbiblio($dbh,$bibid,$record,$frameworkcode,0); - my $oldbiblio = MARCmarc2koha($dbh,$record); + my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode); my $oldbiblionumber = OLDmodbiblio($dbh,$oldbiblio); OLDmodbibitem($dbh,$oldbiblio); # now, modify addi authors, subject, addititles. - my ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"additionalauthors.author"); + my ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"additionalauthors.author",$frameworkcode); my @addiauthfields = $record->field($tagfield); foreach my $addiauthfield (@addiauthfields) { my @addiauthsubfields = $addiauthfield->subfield($tagsubfield); @@ -1290,7 +1290,7 @@ sub NEWmodbiblio { OLDmodaddauthor($dbh,$oldbiblionumber,$addiauthsubfields[$subfieldcount]); } } - ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"bibliosubtitle.subtitle"); + ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"bibliosubtitle.subtitle",$frameworkcode); my @subtitlefields = $record->field($tagfield); foreach my $subtitlefield (@subtitlefields) { my @subtitlesubfields = $subtitlefield->subfield($tagsubfield); @@ -1298,7 +1298,7 @@ sub NEWmodbiblio { OLDmodsubtitle($dbh,$oldbiblionumber,$subtitlesubfields[$subfieldcount]); } } - ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject"); + ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject",$frameworkcode); my @subj = $record->field($tagfield); my @subjects; foreach my $subject (@subj) { @@ -1329,7 +1329,9 @@ sub NEWnewitem { my ( $dbh, $record, $bibid ) = @_; # add item in old-DB - my $item = &MARCmarc2koha( $dbh, $record ); + my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid); + + my $item = &MARCmarc2koha( $dbh, $record,$frameworkcode ); # needs old biblionumber and biblioitemnumber $item->{'biblionumber'} = @@ -1355,7 +1357,8 @@ sub NEWnewitem { sub NEWmoditem { my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_; &MARCmoditem( $dbh, $record, $bibid, $itemnumber, $delete ); - my $olditem = MARCmarc2koha( $dbh, $record ); + my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid); + my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode ); OLDmoditem( $dbh, $olditem ); } @@ -2531,6 +2534,9 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.100 2004/08/13 16:37:25 tipaul +# adding frameworkcode to API in some subs +# # Revision 1.99 2004/07/30 13:54:50 doxulting # Beginning of serial commit # diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 58dba11e6a..dd1025b7e7 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -351,8 +351,8 @@ my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioit if ($bibid) { $is_a_modif=1; # if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB. - ($oldbiblionumtagfield,$oldbiblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber"); - ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber"); + ($oldbiblionumtagfield,$oldbiblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",$frameworkcode); + ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber",$frameworkcode); # search biblioitems value my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?"); $sth->execute($oldbiblionumber); diff --git a/acqui.simple/addbooks.pl b/acqui.simple/addbooks.pl index 52834fc535..18304b207f 100755 --- a/acqui.simple/addbooks.pl +++ b/acqui.simple/addbooks.pl @@ -35,7 +35,7 @@ use strict; use CGI; use C4::Auth; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; use C4::Output; use C4::Interface::CGI::Output; diff --git a/acqui.simple/additem-nomarc.pl b/acqui.simple/additem-nomarc.pl index 5b8a0ab475..49f9e61c1e 100755 --- a/acqui.simple/additem-nomarc.pl +++ b/acqui.simple/additem-nomarc.pl @@ -20,6 +20,9 @@ # Suite 330, Boston, MA 02111-1307 USA # $Log$ +# Revision 1.3 2004/08/13 16:37:25 tipaul +# adding frameworkcode to API in some subs +# # Revision 1.2 2003/05/11 06:59:11 rangi # Mostly templated. # Still needs some work @@ -27,7 +30,7 @@ use CGI; use strict; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; use C4::Output; use HTML::Template; diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 696934dd57..d8323b0f96 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -138,7 +138,7 @@ my @fields = $temp->fields(); my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code my @big_array; #---- finds where items.itemnumber is stored -my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber"); +my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",$itemtype); my @itemnums; # array to store itemnums foreach my $field (@fields) { next if ($field->tag()<10); diff --git a/acqui.simple/isbnsearch.pl b/acqui.simple/isbnsearch.pl index 384d9711ab..742d2563dc 100755 --- a/acqui.simple/isbnsearch.pl +++ b/acqui.simple/isbnsearch.pl @@ -20,7 +20,7 @@ use strict; use CGI; use C4::Auth; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; use C4::Search; use C4::Output; diff --git a/acqui.simple/keywordsearch.pl b/acqui.simple/keywordsearch.pl index ddf1ba637a..a5b4f2524e 100755 --- a/acqui.simple/keywordsearch.pl +++ b/acqui.simple/keywordsearch.pl @@ -20,7 +20,7 @@ use CGI; use strict; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; use C4::Search; use C4::Output; diff --git a/acqui.simple/savebiblio.pl b/acqui.simple/savebiblio.pl index 8cb587ad35..d203646d92 100755 --- a/acqui.simple/savebiblio.pl +++ b/acqui.simple/savebiblio.pl @@ -19,7 +19,7 @@ use CGI; use strict; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; my $input = new CGI; diff --git a/acqui.simple/saveitem.pl b/acqui.simple/saveitem.pl index 97af08164b..4df94f3c14 100755 --- a/acqui.simple/saveitem.pl +++ b/acqui.simple/saveitem.pl @@ -21,7 +21,7 @@ use CGI; use strict; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; my $input = new CGI; diff --git a/acqui.simple/websitesearch.pl b/acqui.simple/websitesearch.pl index b1fa0dbdfc..2faeae2717 100755 --- a/acqui.simple/websitesearch.pl +++ b/acqui.simple/websitesearch.pl @@ -20,7 +20,7 @@ use CGI; use strict; -use C4::Catalogue; +# use C4::Catalogue; use C4::Biblio; use C4::Output; diff --git a/misc/bulkmarcimport.pl b/misc/bulkmarcimport.pl index 1a24a45c18..0cc71a29ff 100755 --- a/misc/bulkmarcimport.pl +++ b/misc/bulkmarcimport.pl @@ -74,7 +74,7 @@ $batch->warnings_off(); $batch->strict_off(); my $i=0; #1st of all, find item MARC tag. -my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber"); +my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",''); # $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write, stopwords write"); while ( my $record = $batch->next() ) { $i++; @@ -130,7 +130,7 @@ while ( my $record = $batch->next() ) { print "$i : $nbitems items found\n" if $verbose; # now, create biblio and items with NEWnewXX call. unless ($test_parameter) { - my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$newRecord); + my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$newRecord,''); warn "ADDED biblio NB $bibid in DB\n" if $verbose; for (my $i=0;$i<=$#items;$i++) { NEWnewitem($dbh,$items[$i],$bibid); diff --git a/misc/rebuildnonmarc.pl b/misc/rebuildnonmarc.pl index 5c35c21eea..7a9e6096b3 100755 --- a/misc/rebuildnonmarc.pl +++ b/misc/rebuildnonmarc.pl @@ -38,7 +38,7 @@ my $dbh = C4::Context->dbh; my $i=0; my $starttime = time(); #1st of all, find item MARC tag. -my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber"); +my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",''); # $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write, stopwords write"); my $sth = $dbh->prepare("select bibid from marc_biblio"); $sth->execute; -- 2.39.5