$sth->finish;
}
$dbh->do("unlock tables");
- zebraop($authid,'specialUpdate',"authorityserver");
+ ModZebra($authid,'specialUpdate',"authorityserver");
# if ($record->field($linkidfield)){
# my @fields=$record->field($linkidfield);
$sth->execute($record->as_usmarc,$linkid);
$sth->finish;
$dbh->do("unlock tables");
- zebraop($linkid,'specialUpdate',"authorityserver");
+ ModZebra($linkid,'specialUpdate',"authorityserver");
}
sub AUTH2marcOnefieldlink {
if ($linkfield->subfield($linkidsubfield2) eq $authid){
$linkrecord->delete_field($linkfield);
$sth->execute($linkrecord->as_usmarc,$linkid);
- zebraop($linkid,'specialUpdate',"authorityserver");
+ ModZebra($linkid,'specialUpdate',"authorityserver");
}
}#foreach linkfield
}
my $dbh=C4::Context->dbh;
# if the keep_biblio is set to 1, then authority entries in biblio are preserved.
-zebraop($authid,"recordDelete","authorityserver");
+ModZebra($authid,"recordDelete","authorityserver");
$dbh->do("delete from auth_header where authid=$authid") ;
# FIXME : delete or not in biblio tables (depending on $keep_biblio flag)
$update=1;
}#for each tag
}#foreach tagfield
- my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,"") ;
+ my $oldbiblio = TransformMarcToKoha($dbh,$marcrecord,"") ;
if ($update==1){
# FIXME : this NEWmodbiblio does not exist anymore...
- &ModBiblio($marcrecord,$oldbiblio->{'biblionumber'},MARCfind_frameworkcode($oldbiblio->{'biblionumber'})) ;
+ &ModBiblio($marcrecord,$oldbiblio->{'biblionumber'},GetFrameworkCode($oldbiblio->{'biblionumber'})) ;
}
}#foreach $marc
# $Id$
# $Log$
+# Revision 1.41 2007/03/29 13:30:31 tipaul
+# Code cleaning :
+# == Biblio.pm cleaning (useless) ==
+# * some sub declaration dropped
+# * removed modbiblio sub
+# * removed moditem sub
+# * removed newitems. It was used only in finishrecieve. Replaced by a Koha2Marc+AddItem, that is better.
+# * removed MARCkoha2marcItem
+# * removed MARCdelsubfield declaration
+# * removed MARCkoha2marcBiblio
+#
+# == Biblio.pm cleaning (naming conventions) ==
+# * MARCgettagslib renamed to GetMarcStructure
+# * MARCgetitems renamed to GetMarcItem
+# * MARCfind_frameworkcode renamed to GetFrameworkCode
+# * MARCmarc2koha renamed to TransformMarcToKoha
+# * MARChtml2marc renamed to TransformHtmlToMarc
+# * MARChtml2xml renamed to TranformeHtmlToXml
+# * zebraop renamed to ModZebra
+#
+# == MARC=OFF ==
+# * removing MARC=OFF related scripts (in cataloguing directory)
+# * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
+# * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
+#
# Revision 1.40 2007/03/28 10:39:16 hdl
# removing $dbh as a parameter in AuthoritiesMarc functions
# And reporting all differences into the scripts taht relies on those functions.
&GetBiblioItemByBiblioNumber
&GetBiblioFromItemNumber
+ &GetMarcItem
&GetItemInfosOf
&GetItemStatus
&GetItemLocation
+ &GetMarcNotes
+ &GetMarcSubjects
+ &GetMarcBiblio
+ &GetMarcAuthors
+ &GetMarcSeries
+
&GetItemsInfo
&GetItemFromBarcode
- &getitemsbybiblioitem
&get_itemnumbers_of
- &GetAuthorisedValueDesc
&GetXmlBiblio
+
+ &GetAuthorisedValueDesc
+ &GetMarcStructure
+ &GetMarcFromKohaField
+ &GetFrameworkCode
+ &Koha2Marc
);
# To modify something
&ModBiblio
&ModItem
&ModBiblioframework
+ &ModZebra
);
# To delete something
# Marc related functions
push @EXPORT, qw(
- &MARCfind_marc_from_kohafield
- &MARCfind_frameworkcode
- &MARCgettagslib
&MARCmoditemonefield
&MARCaddbiblio
&MARCadditem
&MARCmodbiblio
&MARCmoditem
- &MARCkoha2marcBiblio
- &MARCmarc2koha
- &MARCkoha2marcItem
- &MARChtml2marc
- &MARChtml2xml
- &MARCgetitem
- &MARCaddword
- &MARCdelword
- &MARCdelsubfield
- &GetMarcNotes
- &GetMarcSubjects
- &GetMarcBiblio
- &GetMarcAuthors
- &GetMarcSeries
- &Koha2Marc
);
# Others functions
push @EXPORT, qw(
+ &TransformMarcToKoha
+ &TransformHtmlToMarc
+ &TransformHtmlToXml
&PrepareItemrecordDisplay
- &zebraop
&char_decode
&itemcalculator
&calculatelc
);
-# OLD functions,
-push @EXPORT, qw(
- &newitems
- &modbiblio
- &modbibitem
- &moditem
- &checkitems
-);
-
=head1 NAME
C4::Biblio - acquisitions and cataloging management functions
=item 5. internal helper functions such as char_decode, checkitems, etc. Some of these probably belong in Koha.pm
-=item 6. other functions that don't belong in Biblio.pm that will be cleaned out in time. (like MARCfind_marc_from_kohafield which belongs in Search.pm)
+=item 6. other functions that don't belong in Biblio.pm that will be cleaned out in time. (like GetMarcFromKohaField which belongs in Search.pm)
In time, as we solidify the new API these older functions will be weeded out.
my $oldbibitemnum;
my $dbh = C4::Context->dbh;
# transform the data into koha-table style data
- my $olddata = MARCmarc2koha( $dbh, $record, $frameworkcode );
+ my $olddata = TransformMarcToKoha( $dbh, $record, $frameworkcode );
$oldbibnum = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
$olddata->{'biblionumber'} = $oldbibnum;
$oldbibitemnum = _koha_add_biblioitem( $dbh, $olddata );
my $dbh = C4::Context->dbh;
# add item in old-DB
- my $frameworkcode = MARCfind_frameworkcode( $biblionumber );
- my $item = &MARCmarc2koha( $dbh, $record, $frameworkcode );
+ my $frameworkcode = GetFrameworkCode( $biblionumber );
+ my $item = &TransformMarcToKoha( $dbh, $record, $frameworkcode );
# needs old biblionumber and biblioitemnumber
$item->{'biblionumber'} = $biblionumber;
&MARCmodbiblio( $dbh, $biblionumber, $record, $frameworkcode, 1 );
# load the koha-table data object
- my $oldbiblio = MARCmarc2koha( $dbh, $record, $frameworkcode );
+ my $oldbiblio = TransformMarcToKoha( $dbh, $record, $frameworkcode );
# modify the other koha tables
my $oldbiblionumber = _koha_modify_biblio( $dbh, $oldbiblio );
# we do the whole routine: update the MARC and zebra, then update the koha
# tables
if ($record) {
- my $frameworkcode = MARCfind_frameworkcode( $biblionumber );
+ my $frameworkcode = GetFrameworkCode( $biblionumber );
MARCmoditem( $record, $biblionumber, $itemnumber, $frameworkcode, $delete );
- my $olditem = MARCmarc2koha( $dbh, $record, $frameworkcode );
+ my $olditem = TransformMarcToKoha( $dbh, $record, $frameworkcode );
_koha_modify_item( $dbh, $olditem );
return $biblionumber;
}
return $error if $error;
# Delete in Zebra
- zebraop($biblionumber,"delete_record","biblioserver");
+ ModZebra($biblionumber,"delete_record","biblioserver");
# delete biblio from Koha tables and save in deletedbiblio
$error = &_koha_delete_biblio( $dbh, $biblionumber );
my $dbh = C4::Context->dbh;
&_koha_delete_item( $dbh, $itemnumber );
my $newrec = &MARCdelitem( $biblionumber, $itemnumber );
- &MARCaddbiblio( $newrec, $biblionumber, MARCfind_frameworkcode($biblionumber) );
+ &MARCaddbiblio( $newrec, $biblionumber, GetFrameworkCode($biblionumber) );
&logaction(C4::Context->userenv->{'number'},"CATALOGUING","DELETE",$itemnumber,"item")
if C4::Context->preference("CataloguingLog");
}
my $sth;
$fwk = '' unless ($fwk);
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.notforloan", $fwk );
+ GetMarcFromKohaField( $dbh, "items.notforloan", $fwk );
if ( $tag and $subfield ) {
my $sth =
$dbh->prepare(
my $sth;
$fwk = '' unless ($fwk);
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.location", $fwk );
+ GetMarcFromKohaField( $dbh, "items.location", $fwk );
if ( $tag and $subfield ) {
my $sth =
$dbh->prepare(
return ( $count, @results );
} # sub GetBiblio
-=head2 getitemsbybiblioitem
-
-( $count, @results ) = &getitemsbybiblioitem($biblioitemnum);
-
-=cut
-
-sub getitemsbybiblioitem {
- my ($biblioitemnum) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "Select * from items, biblio where
-biblio.biblionumber = items.biblionumber and biblioitemnumber
-= ?"
- );
-
- # || die "Cannot prepare $query\n" . $dbh->errstr;
- my $count = 0;
- my @results;
-
- $sth->execute($biblioitemnum);
-
- # || die "Cannot execute $query\n" . $sth->errstr;
- while ( my $data = $sth->fetchrow_hashref ) {
- $results[$count] = $data;
- $count++;
- } # while
-
- $sth->finish;
- return ( $count, @results );
-} # sub getitemsbybiblioitem
-
=head2 get_itemnumbers_of
my @itemnumbers_of = get_itemnumbers_of(@biblionumbers);
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
-=head2 MARCgettagslib
+=head2 GetMarcStructure
=cut
-sub MARCgettagslib {
+sub GetMarcStructure {
my ( $dbh, $forlibrarian, $frameworkcode ) = @_;
$frameworkcode = "" unless $frameworkcode;
my $sth;
return $res;
}
-=head2 MARCfind_marc_from_kohafield
+=head2 GetMarcFromKohaField
=cut
-sub MARCfind_marc_from_kohafield {
+sub GetMarcFromKohaField {
my ( $dbh, $kohafield, $frameworkcode ) = @_;
return 0, 0 unless $kohafield;
my $relations = C4::Context->marcfromkohafield;
$biblionumber );
# warn $record->as_xml_record();
$sth->finish;
- zebraop($biblionumber,"specialUpdate","biblioserver");
+ ModZebra($biblionumber,"specialUpdate","biblioserver");
return $biblionumber;
}
}
}
-=head2 MARCgetitem
+=head2 GetMarcItem
Returns MARC::Record of the item passed in parameter.
=cut
-sub MARCgetitem {
+sub GetMarcItem {
my ( $biblionumber, $itemnumber ) = @_;
my $dbh = C4::Context->dbh;
my $newrecord = MARC::Record->new();
# warn "record :".$record->as_formatted;
# now, find where the itemnumber is stored & extract only the item
my ( $itemnumberfield, $itemnumbersubfield ) =
- MARCfind_marc_from_kohafield( $dbh, 'items.itemnumber', '' );
+ GetMarcFromKohaField( $dbh, 'items.itemnumber', '' );
my @fields = $record->field($itemnumberfield);
foreach my $field (@fields) {
if ( $field->subfield($itemnumbersubfield) eq $itemnumber ) {
$newvalue = "";
}
- my $record = MARCgetitem( $biblionumber, $itemnumber );
+ my $record = GetMarcItem( $biblionumber, $itemnumber );
my $sth =
$dbh->prepare(
&MARCaddbiblio( $newrec, $biblionumber, $frameworkcode );
}
-=head2 MARCfind_frameworkcode
+=head2 GetFrameworkCode
-$frameworkcode = MARCfind_frameworkcode( $biblionumber )
+$frameworkcode = GetFrameworkCode( $biblionumber )
=cut
-sub MARCfind_frameworkcode {
+sub GetFrameworkCode {
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
my $sth =
}
return $record;
}
-
-=head2 MARCkoha2marcBiblio
-
-$record = MARCkoha2marcBiblio( $biblionumber, $biblioitemnumber )
-
-this function builds partial MARC::Record from the old koha-DB fields
-
-=cut
-
-sub MARCkoha2marcBiblio {
-
- my ( $biblionumber, $biblioitemnumber ) = @_;
- my $dbh = C4::Context->dbh;
- my $sth =
- $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
- );
- my $record = MARC::Record->new();
-
- #--- if biblionumber, then retrieve old-style koha data
- if ( $biblionumber > 0 ) {
- my $sth2 = $dbh->prepare(
-"select biblionumber,author,title,unititle,notes,abstract,serial,seriestitle,copyrightdate,timestamp
- from biblio where biblionumber=?"
- );
- $sth2->execute($biblionumber);
- my $row = $sth2->fetchrow_hashref;
- my $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "biblio." . $code,
- $row->{$code}, '' );
- }
- }
- }
-
- #--- if biblioitem, then retrieve old-style koha data
- if ( $biblioitemnumber > 0 ) {
- my $sth2 = $dbh->prepare(
- " SELECT biblioitemnumber,biblionumber,volume,number,classification,
- itemtype,url,isbn,issn,dewey,subclass,publicationyear,publishercode,
- volumedate,volumeddesc,timestamp,illus,pages,notes AS bnotes,size,place
- FROM biblioitems
- WHERE biblioitemnumber=?
- "
- );
- $sth2->execute($biblioitemnumber);
- my $row = $sth2->fetchrow_hashref;
- my $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "biblioitems." . $code,
- $row->{$code}, '' );
- }
- }
- }
- return $record;
-}
-
-=head2 MARCkoha2marcItem
-
-$record = MARCkoha2marcItem( $dbh, $biblionumber, $itemnumber );
-
-=cut
-
-sub MARCkoha2marcItem {
-
- # this function builds partial MARC::Record from the old koha-DB fields
- my ( $dbh, $biblionumber, $itemnumber ) = @_;
-
- # my $dbh=&C4Connect;
- my $sth =
- $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
- );
- my $record = MARC::Record->new();
-
- #--- if item, then retrieve old-style koha data
- if ( $itemnumber > 0 ) {
-
- # print STDERR "prepare $biblionumber,$itemnumber\n";
- my $sth2 = $dbh->prepare(
-"SELECT itemnumber,biblionumber,multivolumepart,biblioitemnumber,barcode,dateaccessioned,
- booksellerid,homebranch,price,replacementprice,replacementpricedate,datelastborrowed,
- datelastseen,multivolume,stack,notforloan,itemlost,wthdrawn,itemcallnumber,issues,renewals,
- reserves,restricted,binding,itemnotes,holdingbranch,timestamp,onloan,Cutterextra
- FROM items
- WHERE itemnumber=?"
- );
- $sth2->execute($itemnumber);
- my $row = $sth2->fetchrow_hashref;
- my $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "items." . $code,
- $row->{$code}, '' );
- }
- }
- }
- return $record;
-}
=head2 MARCkoha2marcOnefield
return $record;
}
-=head2 MARChtml2xml
+=head2 TransformHtmlToXml
-$xml = MARChtml2xml( $tags, $subfields, $values, $indicator, $ind_tag )
+$xml = TransformHtmlToXml( $tags, $subfields, $values, $indicator, $ind_tag )
=cut
-sub MARChtml2xml {
+sub TransformHtmlToXml {
my ( $tags, $subfields, $values, $indicator, $ind_tag ) = @_;
my $xml = MARC::File::XML::header('UTF-8');
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
return $xml;
}
-=head2 MARChtml2marc
+=head2 TransformHtmlToMarc
-$record = MARChtml2marc( $dbh, $rtags, $rsubfields, $rvalues, %indicators )
+$record = TransformHtmlToMarc( $dbh, $rtags, $rsubfields, $rvalues, %indicators )
=cut
-sub MARChtml2marc {
+sub TransformHtmlToMarc {
my ( $dbh, $rtags, $rsubfields, $rvalues, %indicators ) = @_;
my $prevtag = -1;
my $record = MARC::Record->new();
return $record;
}
-=head2 MARCmarc2koha
+=head2 TransformMarcToKoha
-$result = MARCmarc2koha( $dbh, $record, $frameworkcode )
+$result = TransformMarcToKoha( $dbh, $record, $frameworkcode )
=cut
-sub MARCmarc2koha {
+sub TransformMarcToKoha {
my ( $dbh, $record, $frameworkcode ) = @_;
my $sth =
$dbh->prepare(
my $field;
while ( ($field) = $sth2->fetchrow ) {
$result =
- &MARCmarc2kohaOneField( "biblio", $field, $record, $result,
+ &TransformMarcToKohaOneField( "biblio", $field, $record, $result,
$frameworkcode );
}
$sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
while ( ($field) = $sth2->fetchrow ) {
if ( $field eq 'notes' ) { $field = 'bnotes'; }
$result =
- &MARCmarc2kohaOneField( "biblioitems", $field, $record, $result,
+ &TransformMarcToKohaOneField( "biblioitems", $field, $record, $result,
$frameworkcode );
}
$sth2 = $dbh->prepare("SHOW COLUMNS from items");
$sth2->execute;
while ( ($field) = $sth2->fetchrow ) {
$result =
- &MARCmarc2kohaOneField( "items", $field, $record, $result,
+ &TransformMarcToKohaOneField( "items", $field, $record, $result,
$frameworkcode );
}
return $result;
}
-=head2 MARCmarc2kohaOneField
+=head2 TransformMarcToKohaOneField
-$result = MARCmarc2kohaOneField( $kohatable, $kohafield, $record, $result, $frameworkcode )
+$result = TransformMarcToKohaOneField( $kohatable, $kohafield, $record, $result, $frameworkcode )
=cut
-sub MARCmarc2kohaOneField {
+sub TransformMarcToKohaOneField {
# FIXME ? if a field has a repeatable subfield that is used in old-db, only the 1st will be retrieved...
my ( $kohatable, $kohafield, $record, $result, $frameworkcode ) = @_;
my $res = "";
my ( $tagfield, $subfield ) =
- MARCfind_marc_from_kohafield( "", $kohatable . "." . $kohafield,
+ GetMarcFromKohaField( "", $kohatable . "." . $kohafield,
$frameworkcode );
foreach my $field ( $record->field($tagfield) ) {
if ( $field->tag() < 10 ) {
my $dbh = C4::Context->dbh;
my ( $tagfield, $tagsubfield ) =
- MARCfind_marc_from_kohafield( $dbh, $itemfield, "" );
+ GetMarcFromKohaField( $dbh, $itemfield, "" );
if ( ($tagfield) && ($tagsubfield) ) {
my $tag = $record->field($tagfield);
if ($tag) {
return undef;
}
-
-
-=head2 modbiblio
-
- $biblionumber = &modbiblio($biblio);
-
-Update a biblio record.
-
-C<$biblio> is a reference-to-hash whose keys are the fields in the
-biblio table in the Koha database. All fields must be present, not
-just the ones you wish to change.
-
-C<&modbiblio> updates the record defined by
-C<$biblio-E<gt>{biblionumber}> with the values in C<$biblio>.
-
-C<&modbiblio> returns C<$biblio-E<gt>{biblionumber}> whether it was
-successful or not.
-
-=cut
-
-sub modbiblio {
- my ($biblio) = @_;
- my $dbh = C4::Context->dbh;
- my $biblionumber = _koha_modify_biblio( $dbh, $biblio );
- my $record = MARCkoha2marcBiblio( $biblionumber, $biblionumber );
- MARCmodbiblio( $dbh, $biblionumber, $record, "", 0 );
- return ($biblionumber);
-} # sub modbiblio
-
-=head2 modbibitem
-
-&modbibitem($biblioitem)
-
-=cut
-
-sub modbibitem {
- my ($biblioitem) = @_;
- my $dbh = C4::Context->dbh;
- &_koha_modify_biblio( $dbh, $biblioitem );
-} # sub modbibitem
-
-
-=head2 newitems
-
-$errors = &newitems( $item, @barcodes );
-
-=cut
-
-sub newitems {
- my ( $item, @barcodes ) = @_;
- my $dbh = C4::Context->dbh;
- my $errors;
- my $itemnumber;
- my $error;
- foreach my $barcode (@barcodes) {
- ( $itemnumber, $error ) = &_koha_new_items( $dbh, $item, uc($barcode) );
- $errors .= $error;
- my $MARCitem =
- &MARCkoha2marcItem( $dbh, $item->{biblionumber}, $itemnumber );
- &MARCadditem( $MARCitem, $item->{biblionumber} );
- }
- return ($errors);
-}
-
-=head2 moditem
-
-$errors = &moditem( $item, $op );
-
-=cut
-
-sub moditem {
- my ( $item, $op ) = @_;
- my $dbh = C4::Context->dbh;
- &_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'} );
- &MARCmoditem( $MARCitem, $item->{biblionumber}, $item->{itemnum},
- MARCfind_frameworkcode( $item->{biblionumber} ), 0 );
- }
-}
-
-=head2 checkitems
-
-$errors = &checkitems( $count, @barcodes );
-
-=cut
-
-sub checkitems {
- my ( $count, @barcodes ) = @_;
- my $dbh = C4::Context->dbh;
- my $error;
- my $sth = $dbh->prepare("Select * from items where barcode=?");
- for ( my $i = 0 ; $i < $count ; $i++ ) {
- $barcodes[$i] = uc $barcodes[$i];
- $sth->execute( $barcodes[$i] );
- if ( my $data = $sth->fetchrow_hashref ) {
- $error .= " Duplicate Barcode: $barcodes[$i]";
- }
- }
- $sth->finish;
- return ($error);
-}
-
=head1 OTHER FUNCTIONS
=head2 char_decode
my ( $bibnum, $itemnum ) = @_;
my $dbh = C4::Context->dbh;
- my $frameworkcode = &MARCfind_frameworkcode( $bibnum );
+ my $frameworkcode = &GetFrameworkCode( $bibnum );
my ( $itemtagfield, $itemtagsubfield ) =
- &MARCfind_marc_from_kohafield( $dbh, "items.itemnumber", $frameworkcode );
- my $tagslib = &MARCgettagslib( $dbh, 1, $frameworkcode );
- my $itemrecord = MARCgetitem( $bibnum, $itemnum) if ($itemnum);
+ &GetMarcFromKohaField( $dbh, "items.itemnumber", $frameworkcode );
+ my $tagslib = &GetMarcStructure( $dbh, 1, $frameworkcode );
+ my $itemrecord = GetMarcItem( $bibnum, $itemnum) if ($itemnum);
my @loop_data;
my $authorised_values_sth =
$dbh->prepare(
return ($string);
}
-=head2 zebraopfiles
+=head2 ModZebrafiles
-&zebraopfiles( $dbh, $biblionumber, $record, $folder, $server );
+&ModZebrafiles( $dbh, $biblionumber, $record, $folder, $server );
=cut
-sub zebraopfiles {
+sub ModZebrafiles {
my ( $dbh, $biblionumber, $record, $folder, $server ) = @_;
}
}
-=head2 zebraop
+=head2 ModZebra
-zebraop( $dbh, $biblionumber, $op, $server );
+ModZebra( $dbh, $biblionumber, $op, $server );
=cut
-sub zebraop {
+sub ModZebra {
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs
my ( $biblionumber, $op, $server ) = @_;
my $dbh=C4::Context->dbh;
#warn "SERVER:".$server;
#
-# true zebraop commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
+# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
# at the same time
-# replaced by a zebraqueue table, that is filled with zebraop to run.
+# replaced by a zebraqueue table, that is filled with ModZebra to run.
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script
my $sth=$dbh->prepare("insert into zebraqueue (biblio_auth_number ,server,operation) values(?,?,?)");
# "Error-$server $op $biblionumber /errcode:, $error, /MSG:,$errmsg,$addinfo \n";
# $Zpackage->destroy();
# $Zconnbiblio[0]->destroy();
-# zebraopfiles( $dbh, $biblionumber, $record, $op, $server );
+# ModZebrafiles( $dbh, $biblionumber, $record, $op, $server );
# return;
# }
# if ( C4::Context->$shadow ) {
# $Id$
# $Log$
+# Revision 1.192 2007/03/29 13:30:31 tipaul
+# Code cleaning :
+# == Biblio.pm cleaning (useless) ==
+# * some sub declaration dropped
+# * removed modbiblio sub
+# * removed moditem sub
+# * removed newitems. It was used only in finishrecieve. Replaced by a Koha2Marc+AddItem, that is better.
+# * removed MARCkoha2marcItem
+# * removed MARCdelsubfield declaration
+# * removed MARCkoha2marcBiblio
+#
+# == Biblio.pm cleaning (naming conventions) ==
+# * MARCgettagslib renamed to GetMarcStructure
+# * MARCgetitems renamed to GetMarcItem
+# * MARCfind_frameworkcode renamed to GetFrameworkCode
+# * MARCmarc2koha renamed to TransformMarcToKoha
+# * MARChtml2marc renamed to TransformHtmlToMarc
+# * MARChtml2xml renamed to TranformeHtmlToXml
+# * zebraop renamed to ModZebra
+#
+# == MARC=OFF ==
+# * removing MARC=OFF related scripts (in cataloguing directory)
+# * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
+# * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
+#
# Revision 1.191 2007/03/29 09:42:13 tipaul
# adding default value new feature into cataloguing. The system (definition) part has already been added by toins
#
# *** empty log message ***
#
# Revision 1.178.2.51 2007/01/15 15:16:44 hdl
-# Uncommenting zebraop.
+# Uncommenting ModZebra.
#
# Revision 1.178.2.50 2007/01/15 14:59:09 hdl
# Adding creation of an unexpected serial any time.
# BUT for bulkmarcimport & mod_perl, the zebra conn must be persistant.
#
# Revision 1.178.2.36 2006/12/06 16:54:21 alaurin
-# restore function zebraop for delete biblios :
+# restore function ModZebra for delete biblios :
#
# 1) restore C4::Circulation::Circ2::itemissues, (was missing)
-# 2) restore zebraop value : delete_record
+# 2) restore ModZebra value : delete_record
#
# Revision 1.178.2.35 2006/12/06 10:02:12 alaurin
# bugfixing for delete a biblio :
# Revision 1.178.2.32 2006/12/04 17:39:57 alaurin
# bugfix :
#
-# restore zebraop for update zebra
+# restore ModZebra for update zebra
#
# Revision 1.178.2.31 2006/12/01 17:00:19 tipaul
# additem needs $frameworkcode
# handling of UNIMARC :
# - better management of field 100 = automatic creation of the field if needed & filling encoding to unicode.
# - better management of encoding (MARC::File::XML new_from_xml()). This fix works only on my own version of M:F:XML, i think the actual one is buggy & have reported the problem to perl4lib mailing list
-# - fixing a bug on MARCgetitem, that uses biblioitems.marc and not biblioitems.marcxml
+# - fixing a bug on GetMarcItem, that uses biblioitems.marc and not biblioitems.marcxml
#
# Revision 1.178.2.14 2006/10/11 07:59:36 tipaul
# removing hardcoded ccode fiels in biblioitems
if (scalar($marcrecord->fields()) == 0) {
$notmarcrecord++;
} else {
- my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,'');
+ my $oldbiblio = TransformMarcToKoha($dbh,$marcrecord,'');
my $isbnlength=10;
if($oldbiblio->{isbn}){
$isbnlength = length($oldbiblio->{isbn});
# Return the value of the requested config variable
return $context->{"server"}->{$var};
}
-sub zebraoptions
+sub ModZebrations
{
my $self = shift;
my $var = shift; # The config variable to return
=cut
# $Log$
+# Revision 1.53 2007/03/29 13:30:31 tipaul
+# Code cleaning :
+# == Biblio.pm cleaning (useless) ==
+# * some sub declaration dropped
+# * removed modbiblio sub
+# * removed moditem sub
+# * removed newitems. It was used only in finishrecieve. Replaced by a Koha2Marc+AddItem, that is better.
+# * removed MARCkoha2marcItem
+# * removed MARCdelsubfield declaration
+# * removed MARCkoha2marcBiblio
+#
+# == Biblio.pm cleaning (naming conventions) ==
+# * MARCgettagslib renamed to GetMarcStructure
+# * MARCgetitems renamed to GetMarcItem
+# * MARCfind_frameworkcode renamed to GetFrameworkCode
+# * MARCmarc2koha renamed to TransformMarcToKoha
+# * MARChtml2marc renamed to TransformHtmlToMarc
+# * MARChtml2xml renamed to TranformeHtmlToXml
+# * zebraop renamed to ModZebra
+#
+# == MARC=OFF ==
+# * removing MARC=OFF related scripts (in cataloguing directory)
+# * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
+# * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
+#
# Revision 1.52 2007/03/16 01:25:08 kados
# Using my precrash CVS copy I did the following:
#
# reident programs, and adding branchcode value in reserves2
#
# Revision 1.43.2.7 2006/12/06 21:55:38 hdl
-# Adding zebraoptions for servers to get serverinfos in Context.pm
+# Adding ModZebrations for servers to get serverinfos in Context.pm
# Using this function in rebuild_zebra.pl
#
# Revision 1.43.2.6 2006/11/24 21:18:31 kados
use strict;
require Exporter;
use C4::Context;
-use C4::Biblio; # MARCfind_marc_from_kohafield
+use C4::Biblio; # GetMarcFromKohaField
use C4::Koha; # getFacets
use Lingua::Stem;
sub findseealso {
my ( $dbh, $fields ) = @_;
- my $tagslib = MARCgettagslib( $dbh, 1 );
+ my $tagslib = GetMarcStructure( $dbh, 1 );
for ( my $i = 0 ; $i <= $#{$fields} ; $i++ ) {
my ($tag) = substr( @$fields[$i], 1, 3 );
my ($subfield) = substr( @$fields[$i], 4, 1 );
my ($record) = @_;
return;
my $dbh = C4::Context->dbh;
- my $result = MARCmarc2koha( $dbh, $record, '' );
+ my $result = TransformMarcToKoha( $dbh, $record, '' );
my $sth;
my $query;
my $search;
if ($possible_duplicate_record) {
my $marcrecord =
MARC::Record->new_from_usmarc($possible_duplicate_record);
- my $result = MARCmarc2koha( $dbh, $marcrecord, '' );
+ my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
# FIXME :: why 2 $biblionumber ?
return $result->{'biblionumber'}, $result->{'biblionumber'},
for(my $i=0;$i<$hits;$i++) {
my %resultsloop;
my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
- my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+ my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
#build the hash for the template.
$resultsloop{highlight} = ($i % 2)?(1):(0);
my %subfieldstosearch;
while ( ( my $column ) = $sth2->fetchrow ) {
my ( $tagfield, $tagsubfield ) =
- &MARCfind_marc_from_kohafield( $dbh, "items." . $column, "" );
+ &GetMarcFromKohaField( $dbh, "items." . $column, "" );
$subfieldstosearch{$column} = $tagsubfield;
}
my $times;
my $marcrecord;
$marcrecord = MARC::File::USMARC::decode( $marcresults[$i] );
- my $oldbiblio = MARCmarc2koha( $dbh, $marcrecord, '' );
+ my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, '' );
# add image url if there is one
if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} =~ /^http:/ ) {
my @itemnumbers = split /,/, $data->{'itemnumber'};
foreach my $itemnum (@itemnumbers) {
- #It is ASSUMED that MARCgetitem ALWAYS WORK...
- #Maybe MARCgetitem should return values on failure
+ #It is ASSUMED that GetMarcItem ALWAYS WORK...
+ #Maybe GetMarcItem should return values on failure
# warn "itemnumber :$itemnum, bibnum :".$data->{'biblionumber'};
my $itemprocessed =
PrepareItemrecordDisplay( $data->{'biblionumber'}, $itemnum );
if ( $status eq 2 ) {
### TODO Add a feature that improves recognition and description.
- ### As such count (serialseq) i.e. : N°18,2(N°19),N°20
+ ### As such count (serialseq) i.e. : N18,2(N19),N20
### Would use substr and index But be careful to previous presence of ()
$recievedlist .= ",$serialseq" unless (index($recievedlist,$serialseq)>0);
}
}
}
- my $fwk = MARCfind_frameworkcode( $data->{'biblionumber'} );
+ my $fwk = GetFrameworkCode( $data->{'biblionumber'} );
if ( $info->{barcode} ) {
my @errors;
my $exists = itemdata( $info->{'barcode'} );
unless ($exists) {
my $marcrecord = MARC::Record->new();
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.barcode", $fwk );
+ GetMarcFromKohaField( $dbh, "items.barcode", $fwk );
my $newField =
MARC::Field->new( "$tag", '', '',
"$subfield" => $info->{barcode} );
$marcrecord->insert_fields_ordered($newField);
if ( $info->{branch} ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.homebranch",
+ GetMarcFromKohaField( $dbh, "items.homebranch",
$fwk );
#warn "items.homebranch : $tag , $subfield";
$marcrecord->insert_fields_ordered($newField);
}
( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.holdingbranch",
+ GetMarcFromKohaField( $dbh, "items.holdingbranch",
$fwk );
#warn "items.holdingbranch : $tag , $subfield";
}
if ( $info->{itemcallnumber} ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.itemcallnumber",
+ GetMarcFromKohaField( $dbh, "items.itemcallnumber",
$fwk );
#warn "items.itemcallnumber : $tag , $subfield";
}
if ( $info->{notes} ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.itemnotes", $fwk );
+ GetMarcFromKohaField( $dbh, "items.itemnotes", $fwk );
# warn "items.itemnotes : $tag , $subfield";
if ( $marcrecord->field($tag) ) {
}
if ( $info->{location} ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.location", $fwk );
+ GetMarcFromKohaField( $dbh, "items.location", $fwk );
# warn "items.location : $tag , $subfield";
if ( $marcrecord->field($tag) ) {
}
if ( $info->{status} ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.notforloan",
+ GetMarcFromKohaField( $dbh, "items.notforloan",
$fwk );
# warn "items.notforloan : $tag , $subfield";
}
if ( C4::Context->preference("RoutingSerials") ) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, "items.dateaccessioned",
+ GetMarcFromKohaField( $dbh, "items.dateaccessioned",
$fwk );
if ( $marcrecord->field($tag) ) {
$marcrecord->field($tag)
# create items if the user has entered barcodes
my $barcode=$input->param('barcode');
my @barcodes=split(/\,| |\|/,$barcode);
- my ($error) = newitems({ biblioitemnumber => $biblioitemnumber,
- biblionumber => $biblionumber,
- replacementprice => $replacement,
- price => $cost,
- booksellerid => $supplierid,
- homebranch => $branch,
- loan => 0 },
- @barcodes);
+ # foreach barcode provided, build the item MARC::Record and create the item
+ foreach my $bc (@barcodes) {
+ my $itemRecord = Koha2Marc({
+ "items.replacementprice" => $replacement,
+ "items.price" => $cost,
+ "items.booksellerid" => $supplierid,
+ "items.homebranch" => $branch,
+ "items.holdingbranch" => $branch,
+ "items.barcode" => $bc,
+ "items.loan" => 0, });
+ AddItem($itemRecord,$biblionumber);
+ }
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived");
} else {
print $input->header;
for(my $i=0;$i<$hits;$i++) {
my %resultsloop;
my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
- my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+ my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
#build the hash for the template.
%resultsloop=%$biblio;
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
# warn $record->as_formatted;
warn $xml;
my $record=MARC::Record->new_from_xml($xml,'UTF-8',(C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")));
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
my $record=MARC::Record->new_from_xml($xml,'UTF-8');
$record->encoding('UTF-8');
# adding an empty field
foreach my $marc (@marclist) {
if ($marc) {
my ( $tag, $subfield ) =
- MARCfind_marc_from_kohafield( $dbh, $marc );
+ GetMarcFromKohaField( $dbh, $marc );
if ($tag) {
push @tags, $dbh->quote("$tag$subfield");
}
my $dbh = C4::Context->dbh;
my $biblionumber = $query->param('biblionumber');
-my $itemtype = &MARCfind_frameworkcode($biblionumber);
-my $tagslib = &MARCgettagslib( $dbh, 1, $itemtype );
+my $itemtype = &GetFrameworkCode($biblionumber);
+my $tagslib = &GetMarcStructure( $dbh, 1, $itemtype );
my $record = GetMarcBiblio($biblionumber);
my $query = new CGI;
my $dbh = C4::Context->dbh;
my $biblionumber = $query->param('biblionumber');
-my $frameworkcode = MARCfind_frameworkcode( $biblionumber );
+my $frameworkcode = GetFrameworkCode( $biblionumber );
my $popup =
$query->param('popup')
; # if set to 1, then don't insert links, it's just to show the biblio
my $subscriptionid = $query->param('subscriptionid');
-my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
+my $tagslib = &GetMarcStructure($dbh,1,$frameworkcode);
my $record = GetMarcBiblio($biblionumber);
push( @big_array, \%this_row );
}
}
-my ($holdingbrtagf,$holdingbrtagsubf) = &MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$frameworkcode);
+my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField($dbh,"items.holdingbranch",$frameworkcode);
@big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
#fill big_row with missing datas
return -1;
} else {
if (C4::Context->preference("z3950NormalizeAuthor") and C4::Context->preference("z3950AuthorAuthFields")){
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.author");
+ my ($tag,$subfield) = GetMarcFromKohaField($dbh,"biblio.author");
# my $summary = C4::Context->preference("z3950authortemplate");
my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
my @auth_fields= split /,/,$auth_fields;
my $frameworkcode = $input->param('frameworkcode');
my $dbh = C4::Context->dbh;
-$frameworkcode = &MARCfind_frameworkcode($biblionumber) if ($biblionumber and not ($frameworkcode));
+$frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not ($frameworkcode));
$frameworkcode='' if ($frameworkcode eq 'Default');
my ($template, $loggedinuser, $cookie)
-multiple => 0 );
$template->param( framework => $framework, breedingid => $breedingid);
-$tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
+$tagslib = &GetMarcStructure($dbh,1,$frameworkcode);
my $record=-1;
my $encoding="";
$record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
if ($biblionumber) {
$is_a_modif=1;
# if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
- ($biblionumtagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",$frameworkcode);
- ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
+ ($biblionumtagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber",$frameworkcode);
+ ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &GetMarcFromKohaField($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
# search biblioitems value
my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
$sth->execute($biblionumber);
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
- $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
} else {
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
# warn "MARC :".$record->as_formatted;
# die;
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
my $record;
if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
my %indicators;
for (my $i=0;$i<=$#ind_tag;$i++) {
$indicators{$ind_tag[$i]} = $indicator[$i];
}
- $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+ $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,%indicators);
} else {
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
}
for (my $i=1;$i<=$cntrepeatfield;$i++){
for(my $i=0;$i<$total;$i++) {
my %resultsloop;
my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
- my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+ my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
#hilight the result
$biblio->{'title'} =~ s/$query/<span class=term>$&<\/span>/gi;
my $op = $input->param('op');
# find itemtype
-my $frameworkcode = &MARCfind_frameworkcode($biblionumber);
+my $frameworkcode = &GetFrameworkCode($biblionumber);
-my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
+my $tagslib = &GetMarcStructure($dbh,1,$frameworkcode);
my $record = GetMarcBiblio($biblionumber);
# warn "==>".$record->as_formatted;
-my $oldrecord = MARCmarc2koha($dbh,$record);
+my $oldrecord = TransformMarcToKoha($dbh,$record);
my $itemrecord;
my $nextop="additem";
my @errors; # store errors found while checking data BEFORE saving item.
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
# if autoBarcode is ON, calculate barcode...
if (C4::Context->preference('autoBarcode')) {
- my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.barcode");
+ my ($tagfield,$tagsubfield) = &GetMarcFromKohaField($dbh,"items.barcode");
unless ($record->field($tagfield)->subfield($tagsubfield)) {
my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
$sth_barcode->execute;
}
}
# check for item barcode # being unique
- my $addedolditem = MARCmarc2koha($dbh,$record);
+ my $addedolditem = TransformMarcToKoha($dbh,$record);
my $exists = get_item_from_barcode($addedolditem->{'barcode'});
push @errors,"barcode_not_unique" if($exists);
# if barcode exists, don't create, but report The problem.
} elsif ($op eq "edititem") {
#-------------------------------------------------------------------------------
# retrieve item if exist => then, it's a modif
- $itemrecord = MARCgetitem($biblionumber,$itemnumber);
+ $itemrecord = GetMarcItem($biblionumber,$itemnumber);
$nextop="saveitem";
#-------------------------------------------------------------------------------
} elsif ($op eq "delitem") {
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
# my $itemnumber = $input->param('itemnumber');
- my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
my $itemrecord=MARC::Record::new_from_xml($xml, 'UTF-8');
# MARC::Record builded => now, record in DB
# warn "R: ".$record->as_formatted;
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",$frameworkcode);
-my ($branchtagfield,$branchtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.homebranch",$frameworkcode);
+my ($itemtagfield,$itemtagsubfield) = &GetMarcFromKohaField($dbh,"items.itemnumber",$frameworkcode);
+my ($branchtagfield,$branchtagsubfield) = &GetMarcFromKohaField($dbh,"items.homebranch",$frameworkcode);
foreach my $field (@fields) {
next if ($field->tag()<10);
$big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
}
}
-my ($holdingbrtagf,$holdingbrtagsubf) = &MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$frameworkcode);
+my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField($dbh,"items.holdingbranch",$frameworkcode);
@big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
# now, construct template !
my @field_data = ($search);
for (my $i=$startfrom; $i<=(($startfrom+$resultsperpage)<scalar(@$results)?($startfrom+$resultsperpage):scalar(@$results));$i++){
my $record=MARC::Record::new_from_usmarc( $results->[$i] );
- my $rechash=MARCmarc2koha($dbh,$record);
+ my $rechash=TransformMarcToKoha($dbh,$record);
my $pos;
my $countitems=1 if ($rechash->{itemnumber});
while (index($rechash->{itemnumber},'|',$pos)>0){
} elsif ($title) {
$attr='1=4 ';
utf8::decode($title);
- $title=~tr/à âäéèêëîïôöùû/aaaeeeeiioouu/;
+ $title=~tr/������/aaaeeeeiioouu/;
$term=$title;
} elsif ($author) {
$attr='1=1003';
utf8::decode($author);
- $author=~tr/à âäéèêëîïôöùû/aaaeeeeiioouu/;
+ $author=~tr/������/aaaeeeeiioouu/;
$term=$author;
}
## In HEAD i change everything to UTF-8
# In rel2_2 i am not sure what encoding is so no character conversion is done here
##Add necessary encoding changes to here -TG
- my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,"");
+ my $oldbiblio = TransformMarcToKoha($dbh,$marcrecord,"");
$oldbiblio->{isbn} =~ s/ |-|\.//g,
$oldbiblio->{issn} =~ s/ |-|\.//g,
my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid)=ImportBreeding($marcdata,1,$serverhost[$k],$encoding[$k],$random);
<table>
<tr>
<th>Title</th>
- <th>Author</th>
- <th>publisher</th>
- <th>Publication year</th>
</tr>
<!-- TMPL_LOOP NAME="resultsloop" -->
<tr>
<a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">
<!-- TMPL_VAR NAME="title" -->
</a>
- <br />
- <small><!-- TMPL_VAR NAME="subtitle" --></small>
- </td>
- <td>
- <!-- TMPL_VAR NAME="author" -->
- </td>
- <td>
- <!-- TMPL_VAR NAME="publishercode" -->
- </td>
- <td>
- <!-- TMPL_VAR NAME="publicationyear" -->
- </td>
- </tr>
+ <!-- TMPL_IF name="summary" -->
+ <p><!-- TMPL_VAR name="summary" --></p>
+ <!-- TMPL_ELSE -->
+ <p>
+ <!-- TMPL_IF NAME="author" -->
+ <!-- TMPL_VAR NAME="author" -->
+ <!-- TMPL_ELSE -->
+
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="publicationyear" --> - <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="publishercode" -->- <!-- TMPL_VAR name="publishercode" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="place" --> ; <!-- TMPL_VAR name="place" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="pages" --> - <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="notes" --> : <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="size" --> ; <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF -->
+ </p>
+ <!-- /TMPL_IF -->
+</tr>
<!-- /TMPL_LOOP -->
</table>
</div>
<table>
<tr>
<th>Title</th>
- <th>Author</th>
<th>ISBN</th>
<th>coming from</th>
<th> </th>
</tr>
<!-- TMPL_LOOP NAME="breeding_loop" -->
<!-- TMPL_IF NAME="toggle" --><tr><!-- TMPL_ELSE --><tr class="hilighted"><!-- /TMPL_IF -->
- <td><!-- TMPL_VAR NAME="title" --></a>
- <td><!-- TMPL_VAR NAME="author" --></td>
+ <td><!-- TMPL_VAR NAME="title" -->
+ <!-- TMPL_VAR NAME="author" --></td>
<td><!-- TMPL_VAR NAME="isbn" --></td>
<td><!-- TMPL_VAR NAME="file" --></td>
<!-- TMPL_IF NAME="NOTMARC" -->
my $cleanword = $dbh->prepare("delete from marc_word where tag=? and subfieldid=?");
# get tags structure
-my $tags = MARCgettagslib($dbh,1);
+my $tags = GetMarcStructure($dbh,1);
foreach my $tag (sort keys(%{$tags})) {
foreach my $subfield (sort keys(%{$tags->{$tag}})) {
next if $subfield eq "lib";
#
# 1st : find where some informations are hidden : itemnumber, date_due, popularity
#
-my ($itemnumberTag,$itemnumberSubfield) = MARCfind_marc_from_kohafield($dbh,"items.itemnumber","");
-my ($date_dueTag,$date_dueSubfield) = MARCfind_marc_from_kohafield($dbh,"items.issues","");
+my ($itemnumberTag,$itemnumberSubfield) = GetMarcFromKohaField($dbh,"items.itemnumber","");
+my ($date_dueTag,$date_dueSubfield) = GetMarcFromKohaField($dbh,"items.issues","");
my (
while (my $biblionumber=$biblionumber_sth->fetchrow) {
$count++;
$batch->warnings_off();
$batch->strict_off();
my $i=0;
-my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber","");
+my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber","");
while ( my $record = $batch->next() ) {
my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield);
sub MARCmodbiblionumber{
my ($biblionumber,$biblioitemnumber,$record)=@_;
- my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber","");
- my ($tagfield2,$biblioitemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblioitemnumber","");
+ my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber","");
+ my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblioitemnumber","");
my $update=0;
my @tags = $record->field($tagfield);
$|=1;
while (my ($bibid,$biblionumber) = $sth->fetchrow) {
- my $record = MARCgetbiblio($dbh,$bibid);
+ my $record = LocalMARCgetbiblio($dbh,$bibid);
#Force UTF-8 in record leader
$record->encoding('UTF-8');
$sth_update->execute($record->as_usmarc(),$record->as_xml_record(),$biblionumber);
#
-# those 2 subs are a copy of Biblio.pm, version 2.2.4
-# they are useful only once, for moving from 2.2 to 3.0
-# the MARCgetbiblio & MARCgetitem subs in Biblio.pm
-# are still here, but uses other tables
+# this sub is a copy of Biblio.pm, version 2.2.4
+# It is useful only once, for moving from 2.2 to 3.0
+# the MARCgetbiblio in Biblio.pm
+# is still here, but uses other tables
# (the ones that are filled by updatedatabase !)
#
-sub MARCgetbiblio {
+sub LocalMARCgetbiblio {
# Returns MARC::Record of the biblio passed in parameter.
my ( $dbh, $bibid ) = @_;
}
}
return $record;
-}
-
-sub MARCgetitem {
-
- # Returns MARC::Record of the biblio passed in parameter.
- my ( $dbh, $bibid, $itemnumber ) = @_;
- my $record = MARC::Record->new();
-
- # search MARC tagorder
- my $sth2 =
- $dbh->prepare(
-"select tagorder from marc_subfield_table,marc_subfield_structure where marc_subfield_table.tag=marc_subfield_structure.tagfield and marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and bibid=? and kohafield='items.itemnumber' and subfieldvalue=?"
- );
- $sth2->execute( $bibid, $itemnumber );
- my ($tagorder) = $sth2->fetchrow_array();
-
- #---- TODO : the leader is missing
- my $sth =
- $dbh->prepare(
-"select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
- from marc_subfield_table
- where bibid=? and tagorder=? order by subfieldcode,subfieldorder
- "
- );
- $sth2 =
- $dbh->prepare(
- "select subfieldvalue from marc_blob_subfield where blobidlink=?");
- $sth->execute( $bibid, $tagorder );
- while ( my $row = $sth->fetchrow_hashref ) {
- if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
- $sth2->execute( $row->{'valuebloblink'} );
- my $row2 = $sth2->fetchrow_hashref;
- $sth2->finish;
- $row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
- }
- if ( $record->field( $row->{'tag'} ) ) {
- my $field;
-
-#--- this test must stay as this, because of strange behaviour of mySQL/Perl DBI with char var containing a number...
- #--- sometimes, eliminates 0 at beginning, sometimes no ;-\\\
- if ( length( $row->{'tag'} ) < 3 ) {
- $row->{'tag'} = "0" . $row->{'tag'};
- }
- $field = $record->field( $row->{'tag'} );
- if ($field) {
- my $x =
- $field->add_subfields( $row->{'subfieldcode'},
- $row->{'subfieldvalue'} );
- $record->delete_field($field);
- $record->add_fields($field);
- }
- }
- else {
- if ( length( $row->{'tag'} ) < 3 ) {
- $row->{'tag'} = "0" . $row->{'tag'};
- }
- my $temp =
- MARC::Field->new( $row->{'tag'}, " ", " ",
- $row->{'subfieldcode'} => $row->{'subfieldvalue'} );
- $record->add_fields($temp);
- }
-
- }
- return $record;
-}
+}
\ No newline at end of file
}
#1st of all, find item MARC tag.
-my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",'');
+my ($tagfield,$tagsubfield) = &GetMarcFromKohaField($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() ) {
# warn "=>".$record->as_formatted;
my $kohadir = C4::Context->config('intranetdir');
my $dbh = C4::Context->dbh;
-my ($biblionumbertagfield,$biblionumbertagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber","");
-my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber","");
+my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber","");
+my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField($dbh,"biblioitems.biblioitemnumber","");
print "some informations\n";
print "=================\n";
$created_dir_or_file++;
}
- unless (-f C4::Context->zebraoptions('authorityserver')->{ccl2rpn}) {
- system("cp -f $kohadir/misc/zebra/ccl.properties ".C4::Context->zebraoptions('authorityserver')->{ccl2rpn});
+ unless (-f C4::Context->ModZebrations('authorityserver')->{ccl2rpn}) {
+ system("cp -f $kohadir/misc/zebra/ccl.properties ".C4::Context->ModZebrations('authorityserver')->{ccl2rpn});
# system("cp -f $kohadir/misc/zebra/ccl.properties $authorityserverdir/etc/ccl.properties");
print "Info: copied ccl.properties\n";
$created_dir_or_file++;
print "Info: copied default.idx\n";
$created_dir_or_file++;
}
- unless (-f C4::Context->zebraoptions('biblioserver')->{ccl2rpn}) {
- system("cp -f $kohadir/misc/zebra/ccl.properties ".C4::Context->zebraoptions('biblioserver')->{ccl2rpn});
+ unless (-f C4::Context->ModZebrations('biblioserver')->{ccl2rpn}) {
+ system("cp -f $kohadir/misc/zebra/ccl.properties ".C4::Context->ModZebrations('biblioserver')->{ccl2rpn});
# system("cp -f $kohadir/misc/zebra/ccl.properties $biblioserverdir/etc/ccl.properties");
print "Info: copied ccl.properties\n";
$created_dir_or_file++;
sub MARCmodbiblionumber{
my ($biblionumber,$biblioitemnumber,$record)=@_;
-my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber","");
-my ($tagfield2,$biblioitemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblioitemnumber","");
+my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber","");
+my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblioitemnumber","");
my $update=0;
my @tags = $record->field($tagfield);
my $starttime = gettimeofday;
#1st of all, find item MARC tag.
-my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",'');
+my ($tagfield,$tagsubfield) = &GetMarcFromKohaField($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;
}
# print "$bibid\n";
# now, create biblio and items with NEWnewXX call.
- my $frameworkcode = MARCfind_frameworkcode($bibid);
+ my $frameworkcode = GetFrameworkCode($bibid);
localNEWmodbiblio($dbh,$record,$bibid,$frameworkcode) unless $test_parameter;
# warn 'B=>'.$record->as_formatted;
# print "biblio done\n";
for (my $i=0;$i<=$#items;$i++) {
- my $tmp = MARCmarc2koha($dbh,$items[$i],$frameworkcode) unless $test_parameter; # finds the itemnumber
+ my $tmp = TransformMarcToKoha($dbh,$items[$i],$frameworkcode) unless $test_parameter; # finds the itemnumber
# warn " I=> ".$items[$i]->as_formatted;
localNEWmoditem($dbh,$items[$i],$bibid,$tmp->{itemnumber},0) unless $test_parameter;
# print "1 item done\n";
my ($dbh,$record,$bibid,$frameworkcode) =@_;
$frameworkcode="" unless $frameworkcode;
# &MARCmodbiblio($dbh,$bibid,$record,$frameworkcode,0);
- my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode);
+ my $oldbiblio = TransformMarcToKoha($dbh,$record,$frameworkcode);
return 1;
}
sub localNEWmoditem {
my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_;
# warn "NEWmoditem $bibid / $itemnumber / $delete ".$record->as_formatted;
- my $frameworkcode=MARCfind_frameworkcode($bibid);
- my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
+ my $frameworkcode=GetFrameworkCode($bibid);
+ my $olditem = TransformMarcToKoha( $dbh, $record,$frameworkcode );
C4::Biblio::_koha_modify_item( $dbh, $olditem );
}
my $dbh = C4::Context->dbh;
my $biblionumber = $query->param('biblionumber');
-my $itemtype = &MARCfind_frameworkcode($biblionumber);
-my $tagslib = &MARCgettagslib( $dbh, 1, $itemtype );
+my $itemtype = &GetFrameworkCode($biblionumber);
+my $tagslib = &GetMarcStructure( $dbh, 1, $itemtype );
my $record = GetMarcBiblio($biblionumber);
#coping with subscriptions
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
-my $dat = MARCmarc2koha( $dbh, $record );
+my $dat = TransformMarcToKoha( $dbh, $record );
my @subscriptions =
GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
my @subs;
my $dbh = C4::Context->dbh;
my $biblionumber = $query->param('biblionumber');
-my $itemtype = &MARCfind_frameworkcode($biblionumber);
-my $tagslib = &MARCgettagslib( $dbh, 0, $itemtype );
+my $itemtype = &GetFrameworkCode($biblionumber);
+my $tagslib = &GetMarcStructure( $dbh, 0, $itemtype );
my $record = GetMarcBiblio($biblionumber);
}
}
my ( $holdingbrtagf, $holdingbrtagsubf ) =
- &MARCfind_marc_from_kohafield( $dbh, "items.holdingbranch", $itemtype );
+ &GetMarcFromKohaField( $dbh, "items.holdingbranch", $itemtype );
@big_array =
sort { $a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf} } @big_array;
$index = $i if ($itemhash{$item}->{'serial'} eq $serialids[$i]);
}
if ($status[$index]==2){
- my $xml = MARChtml2xml( $itemhash{$item}->{'tags'},
+ my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'},
$itemhash{$item}->{'subfields'},
$itemhash{$item}->{'field_values'},
$itemhash{$item}->{'ind_tag'},
if ($item=~/^N/){
#New Item
# if autoBarcode is ON, calculate barcode...
- my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.barcode");
+ my ($tagfield,$tagsubfield) = &GetMarcFromKohaField($dbh,"items.barcode");
if (C4::Context->preference('autoBarcode')) {
unless ($record->field($tagfield)->subfield($tagsubfield)) {
my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
if (C4::Context->preference("serialsadditems")){
- my $fwk=MARCfind_frameworkcode($subscription->{biblionumber});
+ my $fwk=GetFrameworkCode($subscription->{biblionumber});
my $branches = GetBranches;
my @branchloop;
for(my $i=0;$i<$total;$i++) {
my %resultsloop;
my $marcrecord = MARC::File::USMARC::decode($marcrecords->[$i]);
- my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+ my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
#build the hash for the template.
$resultsloop{highlight} = ($i % 2)?(1):(0);
if ( $dont_export_items ) {
# now, find where the itemnumber is stored & extract only the item
my ( $itemnumberfield, $itemnumbersubfield ) =
- MARCfind_marc_from_kohafield( $dbh, 'items.itemnumber', '' );
+ GetMarcFromKohaField( $dbh, 'items.itemnumber', '' );
# and delete it.
foreach ($record->field($itemnumberfield)){