use MARC::File::XML;
use ZOOM;
use C4::Koha;
-use C4::Date;
+use C4::Dates qw/format_date/;
use C4::Log; # logaction
+use C4::ClassSource;
use vars qw($VERSION @ISA @EXPORT);
-# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+# TODO: fix version
+# $VERSION = ?;
@ISA = qw( Exporter );
&GetMarcBiblio
&GetMarcAuthors
&GetMarcSeries
+ GetMarcUrls
&GetUsedMarcStructure
&GetItemsInfo
push @EXPORT, qw(
&ModBiblioMarc
&AddItemInMarc
- &calculatelc
- &itemcalculator
);
# Others functions
sub AddBiblio {
my ( $record, $frameworkcode ) = @_;
- my $biblionumber;
- my $biblioitemnumber;
+ my ($biblionumber,$biblioitemnumber,$error);
my $dbh = C4::Context->dbh;
# transform the data into koha-table style data
my $olddata = TransformMarcToKoha( $dbh, $record, $frameworkcode );
- $biblionumber = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
+ ($biblionumber,$error) = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
$olddata->{'biblionumber'} = $biblionumber;
- $biblioitemnumber = _koha_add_biblioitem( $dbh, $olddata );
+ ($biblioitemnumber,$error) = _koha_add_biblioitem( $dbh, $olddata );
- # we must add bibnum and bibitemnum in MARC::Record...
- # we build the new field with biblionumber and biblioitemnumber
- # we drop the original field
- # we add the new builded field.
- ( my $biblio_tag, my $biblio_subfield ) = GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
- ( my $biblioitem_tag, my $biblioitem_subfield ) = GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
-
- my $newfield;
-
- # biblionumber & biblioitemnumber are in different fields
- if ( $biblio_tag != $biblioitem_tag ) {
-
- # deal with biblionumber
- if ( $biblio_tag < 10 ) {
- $newfield = MARC::Field->new( $biblio_tag, $biblionumber );
- }
- else {
- $newfield =
- MARC::Field->new( $biblio_tag, '', '',
- "$biblio_subfield" => $biblionumber );
- }
-
- # drop old field and create new one...
- my $old_field = $record->field($biblio_tag);
- $record->delete_field($old_field);
- $record->append_fields($newfield);
-
- # deal with biblioitemnumber
- if ( $biblioitem_tag < 10 ) {
- $newfield = MARC::Field->new( $biblioitem_tag, $biblioitemnumber, );
- }
- else {
- $newfield =
- MARC::Field->new( $biblioitem_tag, '', '',
- "$biblioitem_subfield" => $biblioitemnumber, );
- }
- # drop old field and create new one...
- $old_field = $record->field($biblioitem_tag);
- $record->delete_field($old_field);
- $record->insert_fields_ordered($newfield);
-
-# biblionumber & biblioitemnumber are in the same field (can't be <10 as fields <10 have only 1 value)
- }
- else {
- my $newfield = MARC::Field->new(
- $biblio_tag, '', '',
- "$biblio_subfield" => $biblionumber,
- "$biblioitem_subfield" => $biblioitemnumber
- );
-
- # drop old field and create new one...
- my $old_field = $record->field($biblio_tag);
- $record->delete_field($old_field);
- $record->insert_fields_ordered($newfield);
- }
+ _koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
# now add the record
$biblionumber = ModBiblioMarc( $record, $biblionumber, $frameworkcode );
$item->{'biblionumber'} = $biblionumber;
my $sth =
$dbh->prepare(
- "select biblioitemnumber,itemtype from biblioitems where biblionumber=?"
+ "SELECT biblioitemnumber,itemtype FROM biblioitems WHERE biblionumber=?"
);
$sth->execute( $item->{'biblionumber'} );
my $itemtype;
( $item->{'biblioitemnumber'}, $itemtype ) = $sth->fetchrow;
$sth =
$dbh->prepare(
- "select notforloan from itemtypes where itemtype='$itemtype'");
+ "SELECT notforloan FROM itemtypes WHERE itemtype='$itemtype'");
$sth->execute();
my $notforloan = $sth->fetchrow;
##Change the notforloan field if $notforloan found
$item->{'dateaccessioned'} = $date;
&MARCitemchange( $record, "items.dateaccessioned", $date );
}
- my ( $itemnumber, $error ) =
- &_koha_new_items( $dbh, $item, $item->{barcode} );
-
+ my ( $itemnumber, $error ) = &_koha_new_items( $dbh, $item, $item->{barcode} );
# add itemnumber to MARC::Record before adding the item.
$sth = $dbh->prepare(
-"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
+"SELECT tagfield,tagsubfield
+FROM marc_subfield_structure
+WHERE frameworkcode=?
+ AND kohafield=?"
);
&TransformKohaToMarcOneField( $sth, $record, "items.itemnumber", $itemnumber,
$frameworkcode );
# add the item
&AddItemInMarc( $record, $item->{'biblionumber'},$frameworkcode );
-
+
&logaction(C4::Context->userenv->{'number'},"CATALOGUING","ADD",$itemnumber,"item")
if C4::Context->preference("CataloguingLog");
$record->append_fields($field);
}
- # adding biblionumber
- my ($tag_biblionumber, $subfield_biblionumber) = GetMarcFromKohaField('biblio.biblionumber',$frameworkcode);
- $record->append_fields(
- MARC::Field->new(
- $tag_biblionumber,'','',$subfield_biblionumber => $biblionumber
- )
- ) unless ($record->subfield($tag_biblionumber,$subfield_biblionumber));
-
+ # update biblionumber and biblioitemnumber in MARC
+ # FIXME - this is assuming a 1 to 1 relationship between
+ # biblios and biblioitems
+ my $sth = $dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
+ $sth->execute($biblionumber);
+ my ($biblioitemnumber) = $sth->fetchrow;
+ $sth->finish();
+ _koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
+
# update the MARC record (that now contains biblio and items) with the new record data
&ModBiblioMarc( $record, $biblionumber, $frameworkcode );
my $oldbiblio = TransformMarcToKoha( $dbh, $record, $frameworkcode );
# modify the other koha tables
- _koha_modify_biblio( $dbh, $oldbiblio );
- _koha_modify_biblioitem( $dbh, $oldbiblio );
+ _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
+ _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
return 1;
}
if ($record) {
my $frameworkcode = GetFrameworkCode( $biblionumber );
ModItemInMarc( $record, $biblionumber, $itemnumber, $frameworkcode );
- my $olditem = TransformMarcToKoha( $dbh, $record, $frameworkcode );
+ my $olditem = TransformMarcToKoha( $dbh, $record, $frameworkcode,'items');
+ $olditem->{'biblionumber'} = $biblionumber;
+ my $sth = $dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
+ $sth->execute($biblionumber);
+ my ($biblioitemnumber) = $sth->fetchrow;
+ $sth->finish();
+ $olditem->{'biblioitemnumber'} = $biblioitemnumber;
_koha_modify_item( $dbh, $olditem );
return $biblionumber;
}
#new entry in branchtransfers....
my $sth = $dbh->prepare(
"INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch)
- VALUES (?, ?, now(), ?)");
+ VALUES (?, ?, NOW(), ?)");
$sth->execute($itemnumber, $frombranch, $tobranch);
#update holdingbranch in items .....
$sth= $dbh->prepare(
- "UPDATE items set holdingbranch = ? WHERE items.itemnumber = ?");
+ "UPDATE items SET holdingbranch = ? WHERE items.itemnumber = ?");
$sth->execute($tobranch,$itemnumber);
&ModDateLastSeen($itemnumber);
$sth = $dbh->prepare(
my ( $biblionumber, $frameworkcode ) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(
- "UPDATE biblio SET frameworkcode=? WHERE biblionumber=$biblionumber"
+ "UPDATE biblio SET frameworkcode=? WHERE biblionumber=?"
);
- $sth->execute($frameworkcode);
+ $sth->execute($frameworkcode, $biblionumber);
return 1;
}
}
}
# save the record
- my $sth = $dbh->prepare("update biblioitems set marc=?,marcxml=? where biblionumber=?");
+ my $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?");
$sth->execute( $completeRecord->as_usmarc(), $completeRecord->as_xml_record(),$biblionumber );
$sth->finish;
ModZebra($biblionumber,"specialUpdate","biblioserver",$completeRecord);
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
- "update items set itemlost=0, datelastseen = now() where items.itemnumber = ?"
+ "UPDATE items SET itemlost=0,datelastseen = NOW() WHERE items.itemnumber = ?"
);
$sth->execute($itemnum);
return;
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
my $error; # for error handling
+
+ # First make sure this biblio has no items attached
+ my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?");
+ $sth->execute($biblionumber);
+ if (my $itemnumber = $sth->fetchrow){
+ # Fix this to use a status the template can understand
+ $error .= "This Biblio has items attached, please delete them first before deleting this biblio ";
+ }
- # First make sure there are no items with issues are still attached
- my $sth =
- $dbh->prepare(
- "SELECT itemnumber FROM items WHERE biblionumber=?");
- $sth->execute($biblionumber);
- while ( my $itemnumber = $sth->fetchrow ) {
- my $issues = GetItemIssues($itemnumber);
- foreach my $issue (@$issues) {
- if ( ( $issue->{date_due} )
- && ( $issue->{date_due} ne "Available" ) )
- {
-
-#FIXME: we need a status system in Biblio like in Circ to return standard codes and messages
-# instead of hard-coded strings
- $error .=
-"Item is checked out to a patron -- you must return it before deleting the Biblio";
- }
- }
- }
return $error if $error;
# Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio
# and we would have no way to remove it (except manually in zebra, but I bet it would be very hard to handle the problem)
ModZebra($biblionumber, "delete_record", "biblioserver", undef);
- # delete biblio from Koha tables and save in deletedbiblio
- $error = &_koha_delete_biblio( $dbh, $biblionumber );
-
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems
$sth =
$dbh->prepare(
while ( my $biblioitemnumber = $sth->fetchrow ) {
# delete this biblioitem
- $error = &_koha_delete_biblioitems( $dbh, $biblioitemnumber );
+ $error = _koha_delete_biblioitems( $dbh, $biblioitemnumber );
return $error if $error;
-
- # delete items
- my $items_sth =
- $dbh->prepare(
- "SELECT itemnumber FROM items WHERE biblioitemnumber=?");
- $items_sth->execute($biblioitemnumber);
- while ( my $itemnumber = $items_sth->fetchrow ) {
- $error = &_koha_delete_item( $dbh, $itemnumber );
- return $error if $error;
- }
}
+
+ # delete biblio from Koha tables and save in deletedbiblio
+ # must do this *after* _koha_delete_biblioitems, otherwise
+ # delete cascade will prevent deletedbiblioitems rows
+ # from being generated by _koha_delete_biblioitems
+ $error = _koha_delete_biblio( $dbh, $biblionumber );
+
&logaction(C4::Context->userenv->{'number'},"CATALOGUING","DELETE",$biblionumber,"")
if C4::Context->preference("CataloguingLog");
return;
=cut
sub DelItem {
- my ( $biblionumber, $itemnumber ) = @_;
- my $dbh = C4::Context->dbh;
+ my ( $dbh, $biblionumber, $itemnumber ) = @_;
+
+ # check the item has no current issues
+
+
&_koha_delete_item( $dbh, $itemnumber );
+
# get the MARC record
my $record = GetMarcBiblio($biblionumber);
my $frameworkcode = GetFrameworkCode($biblionumber);
# backup the record
- my $copy2deleted =
- $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?");
+ my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?");
$copy2deleted->execute( $record->as_usmarc(), $itemnumber );
#search item field code
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",$frameworkcode);
my @fields = $record->field($itemtag);
+
# delete the item specified
foreach my $field (@fields) {
if ( $field->subfield($itemsubfield) eq $itemnumber ) {
my $dbh = C4::Context->dbh;
my $query = "
- SELECT * , biblioitems.notes AS bnotes, biblio.notes
+ SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes
FROM biblio
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
if ( $tag and $subfield ) {
my $sth =
$dbh->prepare(
-"select authorised_value from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?"
+ "SELECT authorised_value
+ FROM marc_subfield_structure
+ WHERE tagfield=?
+ AND tagsubfield=?
+ AND frameworkcode=?
+ "
);
$sth->execute( $tag, $subfield, $fwk );
if ( my ($authorisedvaluecat) = $sth->fetchrow ) {
my $authvalsth =
$dbh->prepare(
-"select authorised_value, lib from authorised_values where category=? order by lib"
+ "SELECT authorised_value,lib
+ FROM authorised_values
+ WHERE category=?
+ ORDER BY lib
+ "
);
$authvalsth->execute($authorisedvaluecat);
while ( my ( $authorisedvalue, $lib ) = $authvalsth->fetchrow ) {
if ( $tag and $subfield ) {
my $sth =
$dbh->prepare(
-"select authorised_value from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?"
+ "SELECT authorised_value
+ FROM marc_subfield_structure
+ WHERE tagfield=?
+ AND tagsubfield=?
+ AND frameworkcode=?"
);
$sth->execute( $tag, $subfield, $fwk );
if ( my ($authorisedvaluecat) = $sth->fetchrow ) {
my $authvalsth =
$dbh->prepare(
-"select authorised_value, lib from authorised_values where category=? order by lib"
+ "SELECT authorised_value,lib
+ FROM authorised_values
+ WHERE category=?
+ ORDER BY lib"
);
$authvalsth->execute($authorisedvaluecat);
while ( my ( $authorisedvalue, $lib ) = $authvalsth->fetchrow ) {
my $dbh = C4::Context->dbh;
my $rq =
- $dbh->prepare("SELECT itemnumber from items where items.barcode=?");
+ $dbh->prepare("SELECT itemnumber FROM items WHERE items.barcode=?");
$rq->execute($barcode);
my ($result) = $rq->fetchrow;
return ($result);
sub GetBiblioItemByBiblioNumber {
my ($biblionumber) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("Select * from biblioitems where biblionumber = ?");
+ my $sth = $dbh->prepare("Select * FROM biblioitems WHERE biblionumber = ?");
my $count = 0;
my @results;
sub GetBiblio {
my ($biblionumber) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("Select * from biblio where biblionumber = ?");
+ my $sth = $dbh->prepare("SELECT * FROM biblio WHERE biblionumber = ?");
my $count = 0;
my @results;
$sth->execute($biblionumber);
# check that framework exists
$sth =
$dbh->prepare(
- "select count(*) from marc_tag_structure where frameworkcode=?");
+ "SELECT COUNT(*) FROM marc_tag_structure WHERE frameworkcode=?");
$sth->execute($frameworkcode);
my ($total) = $sth->fetchrow;
$frameworkcode = "" unless ( $total > 0 );
$sth =
$dbh->prepare(
-"select tagfield,liblibrarian,libopac,mandatory,repeatable from marc_tag_structure where frameworkcode=? order by tagfield"
+ "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable
+ FROM marc_tag_structure
+ WHERE frameworkcode=?
+ ORDER BY tagfield"
);
$sth->execute($frameworkcode);
my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
{
$res->{$tag}->{lib} =
( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
- # why the hell do we need to explicitly decode utf8 ?
- # that's a good question, but we must do it...
- $res->{$tab}->{tab} = ""; # XXX
+ $res->{$tab}->{tab} = "";
$res->{$tag}->{mandatory} = $mandatory;
$res->{$tag}->{repeatable} = $repeatable;
}
$sth =
$dbh->prepare(
-"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield"
+ "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue
+ FROM marc_subfield_structure
+ WHERE frameworkcode=?
+ ORDER BY tagfield,tagsubfield
+ "
);
$sth->execute($frameworkcode);
my $biblionumber = shift;
my $dbh = C4::Context->dbh;
my $sth =
- $dbh->prepare("select marcxml from biblioitems where biblionumber=? ");
+ $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? ");
$sth->execute($biblionumber);
my ($marcxml) = $sth->fetchrow;
MARC::File::XML->default_record_format(C4::Context->preference('marcflavour'));
$marcxml =~ s/\x0c//g;
# warn $marcxml;
my $record = MARC::Record->new();
-
- $record = eval {MARC::Record::new_from_xml( $marcxml, "utf8",C4::Context->preference('marcflavour'))} if ($marcxml);
- if ($@) {warn $@;}
+ if ($marcxml) {
+ $record = eval {MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour'))};
+ if ($@) {warn $@;}
# $record = MARC::Record::new_from_usmarc( $marc) if $marc;
- return $record;
+ return $record;
+ } else {
+ return undef;
+ }
}
=head2 GetXmlBiblio
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
my $sth =
- $dbh->prepare("select marcxml from biblioitems where biblionumber=? ");
+ $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? ");
$sth->execute($biblionumber);
my ($marcxml) = $sth->fetchrow;
return $marcxml;
if ( $category ne "" ) {
my $sth =
$dbh->prepare(
- "select lib from authorised_values where category = ? and authorised_value = ?"
+ "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?"
);
$sth->execute( $category, $value );
my $data = $sth->fetchrow_hashref;
# tagslib useful for UNIMARC author reponsabilities
my $tagslib = &GetMarcStructure( 1, '' ); # FIXME : we don't have the framework available, we take the default framework. May be bugguy on some setups, will be usually correct.
if ( $marcflavour eq "MARC21" ) {
- $mintag = "100";
- $maxtag = "111";
+ $mintag = "700";
+ $maxtag = "720";
}
- else { # assume unimarc if not marc21
+ elsif ( $marcflavour eq "UNIMARC" ) { # assume unimarc if not marc21
$mintag = "701";
$maxtag = "712";
}
-
+ else {
+ return;
+ }
my @marcauthors;
foreach my $field ( $record->fields ) {
my %hash;
my @subfields = $field->subfields();
my $count_auth = 0;
- my $and ;
for my $authors_subfield (@subfields) {
- if (
- $marcflavour ne 'MARC21'
- and (
- ($authors_subfield->[0] eq '3') or
- ($authors_subfield->[0] eq '5')
- )
- )
- {
- next;
- }
- if ($count_auth ne '0'){
- $and = " and au:";
- }
- $count_auth++;
+ #unimarc-specific line
+ next if ($marcflavour eq 'UNIMARC' and (($authors_subfield->[0] eq '3') or ($authors_subfield->[0] eq '5')));
my $subfieldcode = $authors_subfield->[0];
my $value;
# deal with UNIMARC author responsibility
- if (
- $marcflavour ne 'MARC21'
- and ($authors_subfield->[0] eq '4')
- )
- {
- $value = "(".GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ).")";
+ if ( $marcflavour eq 'UNIMARC' and ($authors_subfield->[0] eq '4')) {
+ $value = "(".GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ).")";
} else {
$value = $authors_subfield->[1];
}
return \@marcauthors;
}
+=head2 GetMarcUrls
+
+=over 4
+
+$marcurls = GetMarcUrls($record,$marcflavour);
+Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
+Assumes web resources (not uncommon in MARC21 to omit resource type ind)
+
+=back
+
+=cut
+
+sub GetMarcUrls {
+ my ($record, $marcflavour) = @_;
+ my @marcurls;
+ my $marcurl;
+ for my $field ($record->field('856')) {
+ my $url = $field->subfield('u');
+ my @notes;
+ for my $note ( $field->subfield('z')) {
+ push @notes , {note => $note};
+ }
+ $marcurl = { MARCURL => $url,
+ notes => \@notes,
+ };
+ if($marcflavour eq 'MARC21') {
+ my $s3 = $field->subfield('3');
+ my $link = $field->subfield('y');
+ $marcurl->{'linktext'} = $link || $s3 || $url ;;
+ $marcurl->{'part'} = $s3 if($link);
+ $marcurl->{'toc'} = 1 if($s3 =~ /^[Tt]able/) ;
+ } else {
+ $marcurl->{'linktext'} = $url;
+ }
+ push @marcurls, $marcurl;
+ }
+ return \@marcurls;
+} #end GetMarcUrls
+
=head2 GetMarcSeries
=over 4
-$marcseriessarray = GetMarcSeries($record,$marcflavour);
+$marcseriesarray = GetMarcSeries($record,$marcflavour);
Get all series from the MARC record and returns them in an array.
The series are stored in differents places depending on MARC flavour
sub GetFrameworkCode {
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("select frameworkcode from biblio where biblionumber=?");
+ my $sth = $dbh->prepare("SELECT frameworkcode FROM biblio WHERE biblionumber=?");
$sth->execute($biblionumber);
my ($frameworkcode) = $sth->fetchrow;
return $frameworkcode;
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
- "select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
+ "SELECT tagfield,tagsubfield FROM marc_subfield_structure WHERE frameworkcode=? AND kohafield=?"
);
my $record = MARC::Record->new();
foreach (keys %{$hash}) {
if ( !defined $sth ) {
my $dbh = C4::Context->dbh;
$sth = $dbh->prepare(
- "select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
+ "SELECT tagfield,tagsubfield FROM marc_subfield_structure WHERE frameworkcode=? AND kohafield=?"
);
}
$sth->execute( $frameworkcode, $kohafieldname );
=cut
sub TransformMarcToKoha {
- my ( $dbh, $record, $frameworkcode ) = @_;
-
- # FIXME :: This query is unused..
- # my $sth =
- # $dbh->prepare(
- #"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
- # );
-
+ my ( $dbh, $record, $frameworkcode, $table ) = @_;
+
my $result;
- my $sth2 = $dbh->prepare("SHOW COLUMNS from biblio");
- $sth2->execute;
- my $field;
- while ( ($field) = $sth2->fetchrow ) {
- $result =
- &TransformMarcToKohaOneField( "biblio", $field, $record, $result,
- $frameworkcode );
- }
- my $sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
- $sth2->execute;
- while ( ($field) = $sth2->fetchrow ) {
- if ( $field eq 'notes' ) { $field = 'bnotes'; }
- $result =
- &TransformMarcToKohaOneField( "biblioitems", $field, $record, $result,
- $frameworkcode );
- }
- $sth2 = $dbh->prepare("SHOW COLUMNS from items");
- $sth2->execute;
- while ( ($field) = $sth2->fetchrow ) {
- $result =
- &TransformMarcToKohaOneField( "items", $field, $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
- if ( $1 > 0 ) {
- $result->{'copyrightdate'} = $1;
- }
- else { # if no cYYYY, get the 1st date.
- $temp =~ m/(\d\d\d\d)/;
- $result->{'copyrightdate'} = $1;
+ # sometimes we only want to return the items data
+ if ($table eq 'items') {
+ my $sth = $dbh->prepare("SHOW COLUMNS FROM items");
+ $sth->execute();
+ while ( (my $field) = $sth->fetchrow ) {
+ my $value = get_koha_field_from_marc($table,$field,$record,$frameworkcode);
+ my $key = _disambiguate($table, $field);
+ if ($result->{$key}) {
+ $result->{$key} .= " | " . $value;
+ } else {
+ $result->{$key} = $value;
+ }
+ }
+ return $result;
+ } else {
+ my @tables = ('biblio','biblioitems','items');
+ foreach my $table (@tables){
+ my $sth2 = $dbh->prepare("SHOW COLUMNS from $table");
+ $sth2->execute;
+ while (my ($field) = $sth2->fetchrow){
+ # FIXME use of _disambiguate is a temporary hack
+ # $result->{_disambiguate($table, $field)} = get_koha_field_from_marc($table,$field,$record,$frameworkcode);
+ my $value = get_koha_field_from_marc($table,$field,$record,$frameworkcode);
+ my $key = _disambiguate($table, $field);
+ if ($result->{$key}) {
+ # FIXME - hack to not bring in duplicates of the same value
+ unless (($key eq "biblionumber" or $key eq "biblioitemnumber") and ($value eq "")) {
+ $result->{$key} .= " | " . $value;
+ }
+ } else {
+ $result->{$key} = $value;
+ }
+ }
+ $sth2->finish();
+ }
+ # modify copyrightdate to keep only the 1st year found
+ my $temp = $result->{'copyrightdate'};
+ $temp =~ m/c(\d\d\d\d)/; # search cYYYY first
+ if ( $1 > 0 ) {
+ $result->{'copyrightdate'} = $1;
+ }
+ else { # if no cYYYY, get the 1st date.
+ $temp =~ m/(\d\d\d\d)/;
+ $result->{'copyrightdate'} = $1;
+ }
+
+ # modify publicationyear to keep only the 1st year found
+ $temp = $result->{'publicationyear'};
+ $temp =~ m/c(\d\d\d\d)/; # search cYYYY first
+ if ( $1 > 0 ) {
+ $result->{'publicationyear'} = $1;
+ }
+ else { # if no cYYYY, get the 1st date.
+ $temp =~ m/(\d\d\d\d)/;
+ $result->{'publicationyear'} = $1;
+ }
+ return $result;
}
+}
- # modify publicationyear to keep only the 1st year found
- $temp = $result->{'publicationyear'};
- $temp =~ m/c(\d\d\d\d)/; # search cYYYY first
- if ( $1 > 0 ) {
- $result->{'publicationyear'} = $1;
- }
- else { # if no cYYYY, get the 1st date.
- $temp =~ m/(\d\d\d\d)/;
- $result->{'publicationyear'} = $1;
+
+=head2 _disambiguate
+
+=over 4
+
+$newkey = _disambiguate($table, $field);
+
+This is a temporary hack to distinguish between the
+following sets of columns when using TransformMarcToKoha.
+
+items.cn_source & biblioitems.cn_source
+items.cn_sort & biblioitems.cn_sort
+
+Columns that are currently NOT distinguished (FIXME
+due to lack of time to fully test) are:
+
+biblio.notes and biblioitems.notes
+biblionumber
+timestamp
+biblioitemnumber
+
+FIXME - this is necessary because prefixing each column
+name with the table name would require changing lots
+of code and templates, and exposing more of the DB
+structure than is good to the UI templates, particularly
+since biblio and bibloitems may well merge in a future
+version. In the future, it would also be good to
+separate DB access and UI presentation field names
+more.
+
+=back
+
+=cut
+
+sub _disambiguate {
+ my ($table, $column) = @_;
+ if ($column eq "cn_sort" or $column eq "cn_source") {
+ return $table . '.' . $column;
+ } else {
+ return $column;
}
- return $result;
+
}
+=head2 get_koha_field_from_marc
+
+=over 4
+
+$result->{_disambiguate($table, $field)} = get_koha_field_from_marc($table,$field,$record,$frameworkcode);
+
+Internal function to map data from the MARC record to a specific non-MARC field.
+FIXME: this is meant to replace TransformMarcToKohaOneField after more testing.
+
+=back
+
+=cut
+
+sub get_koha_field_from_marc {
+ my ($koha_table,$koha_column,$record,$frameworkcode) = @_;
+ my ( $tagfield, $subfield ) = GetMarcFromKohaField( $koha_table.'.'.$koha_column, $frameworkcode );
+ my $kohafield;
+ foreach my $field ( $record->field($tagfield) ) {
+ if ( $field->tag() < 10 ) {
+ if ( $kohafield ) {
+ $kohafield .= " | " . $field->data();
+ }
+ else {
+ $kohafield = $field->data();
+ }
+ }
+ else {
+ if ( $field->subfields ) {
+ my @subfields = $field->subfields();
+ foreach my $subfieldcount ( 0 .. $#subfields ) {
+ if ( $subfields[$subfieldcount][0] eq $subfield ) {
+ if ( $kohafield ) {
+ $kohafield .=
+ " | " . $subfields[$subfieldcount][1];
+ }
+ else {
+ $kohafield =
+ $subfields[$subfieldcount][1];
+ }
+ }
+ }
+ }
+ }
+ }
+ return $kohafield;
+}
+
+
=head2 TransformMarcToKohaOneField
=over 4
my @loop_data;
my $authorised_values_sth =
$dbh->prepare(
-"select authorised_value,lib from authorised_values where category=? order by lib"
+"SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib"
);
foreach my $tag ( sort keys %{$tagslib} ) {
my $previous_tag = '';
{
my $sth =
$dbh->prepare(
-"select branchcode,branchname from branches where branchcode = ? order by branchname"
+ "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname"
);
$sth->execute( C4::Context->userenv->{branch} );
push @authorised_values, ""
else {
my $sth =
$dbh->prepare(
-"select branchcode,branchname from branches order by branchname"
+ "SELECT branchcode,branchname FROM branches ORDER BY branchname"
);
$sth->execute;
push @authorised_values, ""
{
my $sth =
$dbh->prepare(
-"select itemtype,description from itemtypes order by description"
+ "SELECT itemtype,description FROM itemtypes ORDER BY description"
);
$sth->execute;
push @authorised_values, ""
#
# we use zebra, just fill zebraqueue table
#
- my $sth=$dbh->prepare("insert into zebraqueue (biblio_auth_number ,server,operation) values(?,?,?)");
+ my $sth=$dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)");
$sth->execute($biblionumber,$server,$op);
$sth->finish;
}
}
}
}
-
-=head2 _koha_add_biblio
-
-=over 4
-
-_koha_add_biblio($dbh,$biblioitem);
-
-Internal function to add a biblio ($biblio is a hash with the values)
-
-=back
-
-=cut
-
-sub _koha_add_biblio {
- my ( $dbh, $biblio, $frameworkcode ) = @_;
- my $sth = $dbh->prepare("Select max(biblionumber) from biblio");
- $sth->execute;
- my $data = $sth->fetchrow_arrayref;
- my $biblionumber = $$data[0] + 1;
- my $series = 0;
-
- if ( $biblio->{'seriestitle'} ) { $series = 1 }
- $sth->finish;
- $sth = $dbh->prepare(
- "INSERT INTO biblio
- SET datecreated=NOW(), biblionumber = ?, title = ?, author = ?, copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?, frameworkcode = ? "
- );
- $sth->execute(
- $biblionumber, $biblio->{'title'},
- $biblio->{'author'}, $biblio->{'copyrightdate'},
- $biblio->{'serial'}, $biblio->{'seriestitle'},
- $biblio->{'notes'}, $biblio->{'abstract'},
- $biblio->{'unititle'}, $frameworkcode
- );
-
- $sth->finish;
- return ($biblionumber);
-}
-
=head2 _find_value
=over 4
return ( $indicator, @result );
}
+=head2 _koha_marc_update_bib_ids
+
+=over 4
+
+_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
+
+Internal function to add or update biblionumber and biblioitemnumber to
+the MARC XML.
+
+=back
+
+=cut
+
+sub _koha_marc_update_bib_ids {
+ my ($record, $frameworkcode, $biblionumber, $biblioitemnumber) = @_;
+
+ # we must add bibnum and bibitemnum in MARC::Record...
+ # we build the new field with biblionumber and biblioitemnumber
+ # we drop the original field
+ # we add the new builded field.
+ my ($biblio_tag, $biblio_subfield ) = GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
+ my ($biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
+
+ if ($biblio_tag != $biblioitem_tag) {
+ # biblionumber & biblioitemnumber are in different fields
+
+ # deal with biblionumber
+ my ($new_field, $old_field);
+ if ($biblio_tag < 10) {
+ $new_field = MARC::Field->new( $biblio_tag, $biblionumber );
+ } else {
+ $new_field =
+ MARC::Field->new( $biblio_tag, '', '',
+ "$biblio_subfield" => $biblionumber );
+ }
+
+ # drop old field and create new one...
+ $old_field = $record->field($biblio_tag);
+ $record->delete_field($old_field);
+ $record->append_fields($new_field);
+
+ # deal with biblioitemnumber
+ if ($biblioitem_tag < 10) {
+ $new_field = MARC::Field->new( $biblioitem_tag, $biblioitemnumber, );
+ } else {
+ $new_field =
+ MARC::Field->new( $biblioitem_tag, '', '',
+ "$biblioitem_subfield" => $biblioitemnumber, );
+ }
+ # drop old field and create new one...
+ $old_field = $record->field($biblioitem_tag);
+ $record->delete_field($old_field);
+ $record->insert_fields_ordered($new_field);
+
+ } else {
+ # biblionumber & biblioitemnumber are in the same field (can't be <10 as fields <10 have only 1 value)
+ my $new_field = MARC::Field->new(
+ $biblio_tag, '', '',
+ "$biblio_subfield" => $biblionumber,
+ "$biblioitem_subfield" => $biblioitemnumber
+ );
+
+ # drop old field and create new one...
+ my $old_field = $record->field($biblio_tag);
+ $record->delete_field($old_field);
+ $record->insert_fields_ordered($new_field);
+ }
+}
+
+=head2 _koha_add_biblio
+
+=over 4
+
+my ($biblionumber,$error) = _koha_add_biblio($dbh,$biblioitem);
+
+Internal function to add a biblio ($biblio is a hash with the values)
+
+=back
+
+=cut
+
+sub _koha_add_biblio {
+ my ( $dbh, $biblio, $frameworkcode ) = @_;
+
+ my $error;
+
+ # set the series flag
+ my $serial = 0;
+ if ( $biblio->{'seriestitle'} ) { $serial = 1 };
+
+ my $query =
+ "INSERT INTO biblio
+ SET frameworkcode = ?,
+ author = ?,
+ title = ?,
+ unititle =?,
+ notes = ?,
+ serial = ?,
+ seriestitle = ?,
+ copyrightdate = ?,
+ datecreated=NOW(),
+ abstract = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute(
+ $frameworkcode,
+ $biblio->{'author'},
+ $biblio->{'title'},
+ $biblio->{'unititle'},
+ $biblio->{'notes'},
+ $serial,
+ $biblio->{'seriestitle'},
+ $biblio->{'copyrightdate'},
+ $biblio->{'abstract'}
+ );
+
+ my $biblionumber = $dbh->{'mysql_insertid'};
+ if ( $dbh->errstr ) {
+ $error.="ERROR in _koha_add_biblio $query".$dbh->errstr;
+ warn $error;
+ }
+
+ $sth->finish();
+ #warn "LEAVING _koha_add_biblio: ".$biblionumber."\n";
+ return ($biblionumber,$error);
+}
+
=head2 _koha_modify_biblio
=over 4
-$biblionumber = _koha_modify_biblio($dbh,$biblio);
+my ($biblionumber,$error) == _koha_modify_biblio($dbh,$biblio,$frameworkcode);
+
Internal function for updating the biblio table
=back
=cut
sub _koha_modify_biblio {
- my ( $dbh, $biblio ) = @_;
- # FIXME: this code could be made more portable by not hard-coding
- # the values that are supposed to be in biblio table
- my $query = qq{
+ my ( $dbh, $biblio, $frameworkcode ) = @_;
+ my $error;
+
+ my $query = "
UPDATE biblio
- SET title = ?,
- author = ?,
- abstract = ?,
- copyrightdate = ?,
- seriestitle = ?,
- serial = ?,
- unititle = ?,
- notes = ?
+ SET frameworkcode = ?,
+ author = ?,
+ title = ?,
+ unititle = ?,
+ notes = ?,
+ serial = ?,
+ seriestitle = ?,
+ copyrightdate = ?,
+ abstract = ?
WHERE biblionumber = ?
- };
+ "
+ ;
my $sth = $dbh->prepare($query);
$sth->execute(
- $biblio->{'title'},
+ $frameworkcode,
$biblio->{'author'},
- $biblio->{'abstract'},
- $biblio->{'copyrightdate'},
- $biblio->{'seriestitle'},
- $biblio->{'serial'},
+ $biblio->{'title'},
$biblio->{'unititle'},
$biblio->{'notes'},
+ $biblio->{'serial'},
+ $biblio->{'seriestitle'},
+ $biblio->{'copyrightdate'},
+ $biblio->{'abstract'},
$biblio->{'biblionumber'}
) if $biblio->{'biblionumber'};
-
- warn $sth->err if $sth->err;
- warn "BIG ERROR :: No biblionumber for $biblio->{title}" if $biblio->{biblionumber} !~ /\d+/; # if it is not a number
- return ( $biblio->{'biblionumber'} );
+
+ if ( $dbh->errstr || !$biblio->{'biblionumber'} ) {
+ $error.="ERROR in _koha_modify_biblio $query".$dbh->errstr;
+ warn $error;
+ }
+ return ( $biblio->{'biblionumber'},$error );
}
-=head2 _koha_modify_biblioitem
+=head2 _koha_modify_biblioitem_nonmarc
=over 4
-_koha_modify_biblioitem( $dbh, $biblioitem );
+my ($biblioitemnumber,$error) = _koha_modify_biblioitem_nonmarc( $dbh, $biblioitem );
+
+Updates biblioitems row except for marc and marcxml, which should be changed
+via ModBiblioMarc
=back
=cut
-sub _koha_modify_biblioitem {
+sub _koha_modify_biblioitem_nonmarc {
my ( $dbh, $biblioitem ) = @_;
- my $query;
-##Recalculate LC in case it changed --TG
-
- $biblioitem->{'itemtype'} = $dbh->quote( $biblioitem->{'itemtype'} );
- $biblioitem->{'url'} = $dbh->quote( $biblioitem->{'url'} );
- $biblioitem->{'isbn'} = $dbh->quote( $biblioitem->{'isbn'} );
- $biblioitem->{'issn'} = $dbh->quote( $biblioitem->{'issn'} );
- $biblioitem->{'publishercode'} =
- $dbh->quote( $biblioitem->{'publishercode'} );
- $biblioitem->{'publicationyear'} =
- $dbh->quote( $biblioitem->{'publicationyear'} );
- $biblioitem->{'classification'} =
- $dbh->quote( $biblioitem->{'classification'} );
- $biblioitem->{'dewey'} = $dbh->quote( $biblioitem->{'dewey'} );
- $biblioitem->{'subclass'} = $dbh->quote( $biblioitem->{'subclass'} );
- $biblioitem->{'illus'} = $dbh->quote( $biblioitem->{'illus'} );
- $biblioitem->{'pages'} = $dbh->quote( $biblioitem->{'pages'} );
- $biblioitem->{'volumeddesc'} = $dbh->quote( $biblioitem->{'volumeddesc'} );
- $biblioitem->{'bnotes'} = $dbh->quote( $biblioitem->{'bnotes'} );
- $biblioitem->{'size'} = $dbh->quote( $biblioitem->{'size'} );
- $biblioitem->{'place'} = $dbh->quote( $biblioitem->{'place'} );
- $biblioitem->{'collectiontitle'} = $dbh->quote( $biblioitem->{'collectiontitle'} );
- $biblioitem->{'collectionissn'} = $dbh->quote( $biblioitem->{'collectionissn'} );
- $biblioitem->{'collectionvolume'} = $dbh->quote( $biblioitem->{'collectionvolume'} );
- $biblioitem->{'editionstatement'} = $dbh->quote( $biblioitem->{'editionstatement'} );
- $biblioitem->{'editionresponsibility'} = $dbh->quote( $biblioitem->{'editionresponsibility'} );
- $biblioitem->{'ccode'} = $dbh->quote( $biblioitem->{'ccode'} );
- $biblioitem->{'biblionumber'} =
- $dbh->quote( $biblioitem->{'biblionumber'} );
-
- $query = "UPDATE biblioitems SET
- itemtype = $biblioitem->{'itemtype'},
- url = $biblioitem->{'url'},
- isbn = $biblioitem->{'isbn'},
- issn = $biblioitem->{'issn'},
- publishercode = $biblioitem->{'publishercode'},
- publicationyear = $biblioitem->{'publicationyear'},
- classification = $biblioitem->{'classification'},
- dewey = $biblioitem->{'dewey'},
- subclass = $biblioitem->{'subclass'},
- illus = $biblioitem->{'illus'},
- pages = $biblioitem->{'pages'},
- volumeddesc = $biblioitem->{'volumeddesc'},
- notes = $biblioitem->{'bnotes'},
- size = $biblioitem->{'size'},
- place = $biblioitem->{'place'},
- collectiontitle = $biblioitem->{'collectiontitle'},
- collectionissn = $biblioitem->{'collectionissn'},
- collectionvolume= $biblioitem->{'collectionvolume'},
- editionstatement= $biblioitem->{'editionstatement'},
- editionresponsibility= $biblioitem->{'editionresponsibility'},
- ccode = $biblioitem->{'ccode'}
- where biblionumber = $biblioitem->{'biblionumber'}";
-
- $dbh->do($query);
+ my $error;
+
+ # re-calculate the cn_sort, it may have changed
+ my ($cn_sort) = GetClassSort($biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'} );
+
+ my $query =
+ "UPDATE biblioitems
+ SET biblionumber = ?,
+ volume = ?,
+ number = ?,
+ itemtype = ?,
+ isbn = ?,
+ issn = ?,
+ publicationyear = ?,
+ publishercode = ?,
+ volumedate = ?,
+ volumedesc = ?,
+ collectiontitle = ?,
+ collectionissn = ?,
+ collectionvolume= ?,
+ editionstatement= ?,
+ editionresponsibility = ?,
+ illus = ?,
+ pages = ?,
+ notes = ?,
+ size = ?,
+ place = ?,
+ lccn = ?,
+ url = ?,
+ cn_source = ?,
+ cn_class = ?,
+ cn_item = ?,
+ cn_suffix = ?,
+ cn_sort = ?,
+ totalissues = ?
+ where biblioitemnumber = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute(
+ $biblioitem->{'biblionumber'},
+ $biblioitem->{'volume'},
+ $biblioitem->{'number'},
+ $biblioitem->{'itemtype'},
+ $biblioitem->{'isbn'},
+ $biblioitem->{'issn'},
+ $biblioitem->{'publicationyear'},
+ $biblioitem->{'publishercode'},
+ $biblioitem->{'volumedate'},
+ $biblioitem->{'volumedesc'},
+ $biblioitem->{'collectiontitle'},
+ $biblioitem->{'collectionissn'},
+ $biblioitem->{'collectionvolume'},
+ $biblioitem->{'editionstatement'},
+ $biblioitem->{'editionresponsibility'},
+ $biblioitem->{'illus'},
+ $biblioitem->{'pages'},
+ $biblioitem->{'bnotes'},
+ $biblioitem->{'size'},
+ $biblioitem->{'place'},
+ $biblioitem->{'lccn'},
+ $biblioitem->{'url'},
+ $biblioitem->{'biblioitems.cn_source'},
+ $biblioitem->{'cn_class'},
+ $biblioitem->{'cn_item'},
+ $biblioitem->{'cn_suffix'},
+ $cn_sort,
+ $biblioitem->{'totalissues'},
+ $biblioitem->{'biblioitemnumber'}
+ );
if ( $dbh->errstr ) {
- warn "ERROR in _koha_modify_biblioitem $query";
+ $error.="ERROR in _koha_modify_biblioitem_nonmarc $query".$dbh->errstr;
+ warn $error;
}
+ return ($biblioitem->{'biblioitemnumber'},$error);
}
=head2 _koha_add_biblioitem
=over 4
-_koha_add_biblioitem( $dbh, $biblioitem );
+my ($biblioitemnumber,$error) = _koha_add_biblioitem( $dbh, $biblioitem );
Internal function to add a biblioitem
sub _koha_add_biblioitem {
my ( $dbh, $biblioitem ) = @_;
-
- # my $dbh = C4Connect;
- my $sth = $dbh->prepare("SELECT max(biblioitemnumber) FROM biblioitems");
- my $data;
- my $bibitemnum;
-
- $sth->execute;
- $data = $sth->fetchrow_arrayref;
- $bibitemnum = $$data[0] + 1;
-
- $sth->finish;
-
- $sth = $dbh->prepare(
- "INSERT INTO biblioitems SET
- biblioitemnumber = ?, biblionumber = ?,
- volume = ?, number = ?,
- classification = ?, itemtype = ?,
- url = ?, isbn = ?,
- issn = ?, dewey = ?,
- subclass = ?, publicationyear = ?,
- publishercode = ?, volumedate = ?,
- volumeddesc = ?, illus = ?,
- pages = ?, notes = ?,
- size = ?, lccn = ?,
- marc = ?, lcsort = ?,
- place = ?, ccode = ?,
- collectiontitle = ?, collectionissn = ?,
- collectionvolume = ?, editionstatement= ?,
- editionresponsibility= ?
- "
- );
- my ($lcsort) =
- calculatelc( $biblioitem->{'classification'} )
- . $biblioitem->{'subclass'};
+ my $error;
+
+ my ($cn_sort) = GetClassSort($biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'} );
+ my $query =
+ "INSERT INTO biblioitems SET
+ biblionumber = ?,
+ volume = ?,
+ number = ?,
+ itemtype = ?,
+ isbn = ?,
+ issn = ?,
+ publicationyear = ?,
+ publishercode = ?,
+ volumedate = ?,
+ volumedesc = ?,
+ collectiontitle = ?,
+ collectionissn = ?,
+ collectionvolume= ?,
+ editionstatement= ?,
+ editionresponsibility = ?,
+ illus = ?,
+ pages = ?,
+ notes = ?,
+ size = ?,
+ place = ?,
+ lccn = ?,
+ marc = ?,
+ url = ?,
+ cn_source = ?,
+ cn_class = ?,
+ cn_item = ?,
+ cn_suffix = ?,
+ cn_sort = ?,
+ totalissues = ?
+ ";
+ my $sth = $dbh->prepare($query);
$sth->execute(
- $bibitemnum, $biblioitem->{'biblionumber'},
- $biblioitem->{'volume'}, $biblioitem->{'number'},
- $biblioitem->{'classification'}, $biblioitem->{'itemtype'},
- $biblioitem->{'url'}, $biblioitem->{'isbn'},
- $biblioitem->{'issn'}, $biblioitem->{'dewey'},
- $biblioitem->{'subclass'}, $biblioitem->{'publicationyear'},
- $biblioitem->{'publishercode'}, $biblioitem->{'volumedate'},
- $biblioitem->{'volumeddesc'}, $biblioitem->{'illus'},
- $biblioitem->{'pages'}, $biblioitem->{'bnotes'},
- $biblioitem->{'size'}, $biblioitem->{'lccn'},
- $biblioitem->{'marc'}, $biblioitem->{'place'},
- $lcsort, $biblioitem->{'ccode'},
- $biblioitem->{'collectiontitle'},$biblioitem->{'collectionissn'},
- $biblioitem->{'collectionvolume'},$biblioitem->{'editionstatement'},
- $biblioitem->{'editionresponsibility'}
+ $biblioitem->{'biblionumber'},
+ $biblioitem->{'volume'},
+ $biblioitem->{'number'},
+ $biblioitem->{'itemtype'},
+ $biblioitem->{'isbn'},
+ $biblioitem->{'issn'},
+ $biblioitem->{'publicationyear'},
+ $biblioitem->{'publishercode'},
+ $biblioitem->{'volumedate'},
+ $biblioitem->{'volumedesc'},
+ $biblioitem->{'collectiontitle'},
+ $biblioitem->{'collectionissn'},
+ $biblioitem->{'collectionvolume'},
+ $biblioitem->{'editionstatement'},
+ $biblioitem->{'editionresponsibility'},
+ $biblioitem->{'illus'},
+ $biblioitem->{'pages'},
+ $biblioitem->{'bnotes'},
+ $biblioitem->{'size'},
+ $biblioitem->{'place'},
+ $biblioitem->{'lccn'},
+ $biblioitem->{'marc'},
+ $biblioitem->{'url'},
+ $biblioitem->{'biblioitems.cn_source'},
+ $biblioitem->{'cn_class'},
+ $biblioitem->{'cn_item'},
+ $biblioitem->{'cn_suffix'},
+ $cn_sort,
+ $biblioitem->{'totalissues'}
);
- $sth->finish;
- return ($bibitemnum);
+ my $bibitemnum = $dbh->{'mysql_insertid'};
+ if ( $dbh->errstr ) {
+ $error.="ERROR in _koha_add_biblioitem $query".$dbh->errstr;
+ warn $error;
+ }
+ $sth->finish();
+ return ($bibitemnum,$error);
}
=head2 _koha_new_items
=over 4
-_koha_new_items( $dbh, $item, $barcode );
+my ($itemnumber,$error) = _koha_new_items( $dbh, $item, $barcode );
=back
sub _koha_new_items {
my ( $dbh, $item, $barcode ) = @_;
+ my $error;
- # my $dbh = C4Connect;
- my $sth = $dbh->prepare("Select max(itemnumber) from items");
- my $data;
- my $itemnumber;
- my $error = "";
-
- $sth->execute;
- $data = $sth->fetchrow_hashref;
- $itemnumber = $data->{'max(itemnumber)'} + 1;
- $sth->finish;
-## Now calculate lccalnumber
- my ($cutterextra) = itemcalculator(
- $dbh,
- $item->{'biblioitemnumber'},
- $item->{'itemcallnumber'}
- );
-
-# FIXME the "notforloan" field seems to be named "loan" in some places. workaround bugfix.
- if ( $item->{'loan'} ) {
- $item->{'notforloan'} = $item->{'loan'};
- }
+ my ($items_cn_sort) = GetClassSort($item->{'items.cn_source'}, $item->{'itemcallnumber'}, "");
# if dateaccessioned is provided, use it. Otherwise, set to NOW()
if ( $item->{'dateaccessioned'} eq '' || !$item->{'dateaccessioned'} ) {
-
- $sth = $dbh->prepare(
- "Insert into items set
- itemnumber = ?, biblionumber = ?,
- biblioitemnumber = ?, barcode = ?,
- booksellerid = ?, dateaccessioned = NOW(),
- homebranch = ?, holdingbranch = ?,
- price = ?, replacementprice = ?,
- replacementpricedate = NOW(), datelastseen = NOW(),
- stack = ?,
- itemlost = ?, wthdrawn = ?,
- paidfor = ?, itemnotes = ?,
- itemcallnumber =?, notforloan = ?,
- location = ?, Cutterextra = ?
- "
- );
- $sth->execute(
- $itemnumber, $item->{'biblionumber'},
+ my $today = C4::Dates->new();
+ $item->{'dateaccessioned'} = $today->output("iso"); #TODO: check time issues
+ }
+ my $query =
+ "INSERT INTO items SET
+ biblionumber = ?,
+ biblioitemnumber = ?,
+ barcode = ?,
+ dateaccessioned = ?,
+ booksellerid = ?,
+ homebranch = ?,
+ price = ?,
+ replacementprice = ?,
+ replacementpricedate = NOW(),
+ datelastborrowed = ?,
+ datelastseen = NOW(),
+ stack = ?,
+ notforloan = ?,
+ damaged = ?,
+ itemlost = ?,
+ wthdrawn = ?,
+ itemcallnumber = ?,
+ restricted = ?,
+ itemnotes = ?,
+ holdingbranch = ?,
+ paidfor = ?,
+ location = ?,
+ onloan = ?,
+ cn_source = ?,
+ cn_sort = ?,
+ ccode = ?,
+ materials = ?,
+ uri = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute(
+ $item->{'biblionumber'},
$item->{'biblioitemnumber'},
- $barcode, $item->{'booksellerid'},
- $item->{'homebranch'}, $item->{'holdingbranch'},
- $item->{'price'}, $item->{'replacementprice'},
+ $barcode,
+ $item->{'dateaccessioned'},
+ $item->{'booksellerid'},
+ $item->{'homebranch'},
+ $item->{'price'},
+ $item->{'replacementprice'},
+ $item->{datelastborrowed},
$item->{stack},
- $item->{itemlost}, $item->{wthdrawn},
- $item->{paidfor}, $item->{'itemnotes'},
- $item->{'itemcallnumber'}, $item->{'notforloan'},
- $item->{'location'}, $cutterextra
- );
- }
- else {
- $sth = $dbh->prepare(
- "INSERT INTO items SET
- itemnumber = ?, biblionumber = ?,
- biblioitemnumber = ?, barcode = ?,
- booksellerid = ?, dateaccessioned = ?,
- homebranch = ?, holdingbranch = ?,
- price = ?, replacementprice = ?,
- replacementpricedate = NOW(), datelastseen = NOW(),
- stack = ?,
- itemlost = ?, wthdrawn = ?,
- paidfor = ?, itemnotes = ?,
- itemcallnumber = ?, notforloan = ?,
- location = ?,
- Cutterextra = ?
- "
- );
- $sth->execute(
- $itemnumber, $item->{'biblionumber'},
- $item->{'biblioitemnumber'},
- $barcode, $item->{'booksellerid'},
- $item->{'dateaccessioned'}, $item->{'homebranch'},
- $item->{'holdingbranch'}, $item->{'price'},
- $item->{'replacementprice'},
- $item->{stack}, $item->{itemlost},
- $item->{wthdrawn}, $item->{paidfor},
- $item->{'itemnotes'}, $item->{'itemcallnumber'},
- $item->{'notforloan'}, $item->{'location'},
- $cutterextra
- );
- }
+ $item->{'notforloan'},
+ $item->{'damaged'},
+ $item->{'itemlost'},
+ $item->{'wthdrawn'},
+ $item->{'itemcallnumber'},
+ $item->{'restricted'},
+ $item->{'itemnotes'},
+ $item->{'holdingbranch'},
+ $item->{'paidfor'},
+ $item->{'location'},
+ $item->{'onloan'},
+ $item->{'items.cn_source'},
+ $items_cn_sort,
+ $item->{'ccode'},
+ $item->{'materials'},
+ $item->{'uri'},
+ );
+ my $itemnumber = $dbh->{'mysql_insertid'};
if ( defined $sth->errstr ) {
- $error .= $sth->errstr;
+ $error.="ERROR in _koha_new_items $query".$sth->errstr;
}
+ $sth->finish();
return ( $itemnumber, $error );
}
=over 4
-_koha_modify_item( $dbh, $item, $op );
+my ($itemnumber,$error) =_koha_modify_item( $dbh, $item, $op );
=back
=cut
sub _koha_modify_item {
- my ( $dbh, $item, $op ) = @_;
- $item->{'itemnum'} = $item->{'itemnumber'} unless $item->{'itemnum'};
+ my ( $dbh, $item ) = @_;
+ my $error;
- # 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=? WHERE itemnumber=?";
- my @bind = (
- $item->{'itemlost'}, $item->{'wthdrawn'},
- $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=?,stack=?,wthdrawn=?,holdingbranch=?,homebranch=?,cutterextra=?, onloan=?";
-
- my @bind = (
- $item->{'barcode'}, $item->{'notes'},
- $item->{'itemcallnumber'}, $item->{'notforloan'},
- $item->{'location'}, $item->{stack},
- $item->{wthdrawn}, $item->{holdingbranch},
- $item->{homebranch}, $cutterextra,
- $item->{onloan},
- );
- if ( $item->{'lost'} ne '' ) {
- $query =
-"update items set biblioitemnumber=?,barcode=?,itemnotes=?,homebranch=?,
- itemlost=?,wthdrawn=?,itemcallnumber=?,notforloan=?,
- location=?,stack=?,wthdrawn=?,holdingbranch=?,cutterextra=?,onloan=?";
- @bind = (
- $item->{'bibitemnum'}, $item->{'barcode'},
- $item->{'notes'}, $item->{'homebranch'},
- $item->{'lost'}, $item->{'wthdrawn'},
- $item->{'itemcallnumber'}, $item->{'notforloan'},
- $item->{'location'}, $item->{stack},
- $item->{wthdrawn}, $item->{holdingbranch},
- $cutterextra, $item->{onloan}
- );
- 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'};
- if ( $item->{'replacement'} ne '' ) {
- $query =~ s/ where/,replacementprice='$item->{'replacement'}' where/;
+ # calculate items.cn_sort
+ $item->{'cn_sort'} = GetClassSort($item->{'items.cn_source'}, $item->{'itemcallnumber'}, "");
+
+ my $query = "UPDATE items SET ";
+ my @bind;
+ for my $key ( keys %$item ) {
+ $query.="$key=?,";
+ push @bind, $item->{$key};
}
+ $query =~ s/,$//;
+ $query .= " WHERE itemnumber=?";
+ push @bind, $item->{'itemnumber'};
my $sth = $dbh->prepare($query);
$sth->execute(@bind);
- $sth->finish;
+ if ( $dbh->errstr ) {
+ $error.="ERROR in _koha_modify_item $query".$dbh->errstr;
+ warn $error;
+ }
+ $sth->finish();
+ return ($item->{'itemnumber'},$error);
}
=head2 _koha_delete_biblio
sub _koha_delete_item {
my ( $dbh, $itemnum ) = @_;
- my $sth = $dbh->prepare("select * from items where itemnumber=?");
+ # save the deleted item to deleteditems table
+ my $sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
$sth->execute($itemnum);
- my $data = $sth->fetchrow_hashref;
- $sth->finish;
- my $query = "Insert into deleteditems set ";
+ my $data = $sth->fetchrow_hashref();
+ $sth->finish();
+ my $query = "INSERT INTO deleteditems SET ";
my @bind = ();
- foreach my $temp ( keys %$data ) {
- $query .= "$temp = ?,";
- push( @bind, $data->{$temp} );
+ foreach my $key ( keys %$data ) {
+ $query .= "$key = ?,";
+ push( @bind, $data->{$key} );
}
$query =~ s/\,$//;
-
- # print $query;
$sth = $dbh->prepare($query);
$sth->execute(@bind);
- $sth->finish;
- $sth = $dbh->prepare("Delete from items where itemnumber=?");
+ $sth->finish();
+
+ # delete from items table
+ $sth = $dbh->prepare("DELETE FROM items WHERE itemnumber=?");
$sth->execute($itemnum);
- $sth->finish;
+ $sth->finish();
+ return undef;
}
=head1 UNEXPORTED FUNCTIONS
-=over 4
-
-=head2 calculatelc
-
-$lc = calculatelc($classification);
-
-=back
-
-=cut
-
-sub calculatelc {
- my ($classification) = @_;
- $classification =~ s/^\s+|\s+$//g;
- my $i = 0;
- my $lc2;
- my $lc1;
-
- for ( $i = 0 ; $i < length($classification) ; $i++ ) {
- my $c = ( substr( $classification, $i, 1 ) );
- if ( $c ge '0' && $c le '9' ) {
-
- $lc2 = substr( $classification, $i );
- last;
- }
- else {
- $lc1 .= substr( $classification, $i, 1 );
-
- }
- } #while
-
- my $other = length($lc1);
- if ( !$lc1 ) {
- $other = 0;
- }
-
- my $extras;
- if ( $other < 4 ) {
- for ( 1 .. ( 4 - $other ) ) {
- $extras .= "0";
- }
- }
- $lc1 .= $extras;
- $lc2 =~ s/^ //g;
-
- $lc2 =~ s/ //g;
- $extras = "";
- ##Find the decimal part of $lc2
- my $pos = index( $lc2, "." );
- if ( $pos < 0 ) { $pos = length($lc2); }
- if ( $pos >= 0 && $pos < 5 ) {
- ##Pad lc2 with zeros to create a 5digit decimal needed in marc record to sort as numeric
-
- for ( 1 .. ( 5 - $pos ) ) {
- $extras .= "0";
- }
- }
- $lc2 = $extras . $lc2;
- return ( $lc1 . $lc2 );
-}
-
-=head2 itemcalculator
-
-=over 4
-
-$cutterextra = itemcalculator( $dbh, $biblioitem, $callnumber );
-
-=back
-
-=cut
-
-sub itemcalculator {
- my ( $dbh, $biblioitem, $callnumber ) = @_;
- my $sth =
- $dbh->prepare(
-"select classification, subclass from biblioitems where biblioitemnumber=?"
- );
-
- $sth->execute($biblioitem);
- my ( $classification, $subclass ) = $sth->fetchrow;
- my $all = $classification . " " . $subclass;
- my $total = length($all);
- my $cutterextra = substr( $callnumber, $total - 1 );
-
- return $cutterextra;
-}
-
=head2 ModBiblioMarc
&ModBiblioMarc($newrec,$biblionumber,$frameworkcode);
ModZebra($biblionumber,"specialUpdate","biblioserver",$record);
$sth =
$dbh->prepare(
- "update biblioitems set marc=?,marcxml=? where biblionumber=?");
+ "UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?");
$sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding),
$biblionumber );
$sth->finish;
sub GetItemsCount {
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
- my $query = qq|SELECT count(*)
+ my $query = "SELECT count(*)
FROM items
- WHERE biblionumber=?|;
+ WHERE biblionumber=?";
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
my $count = $sth->fetchrow;
Joshua Ferraro jmf@liblime.com
=cut
-
-# $Id$
-# $Log$
-# Revision 1.221 2007/07/31 16:01:11 toins
-# Some new functions.
-# TransformHTMLtoMarc rewrited.
-#
-# Revision 1.220 2007/07/20 15:43:16 hdl
-# Bug Fixing GetMarcSubjects.
-# Links parameters were mixed.
-#
-# Revision 1.218 2007/07/19 07:40:08 hdl
-# Adding selection by location for inventory
-#
-# Revision 1.217 2007/07/03 13:47:44 tipaul
-# fixing some display bugs (itemtype not properly returned and a html table bug that makes items appear strangely
-#
-# Revision 1.216 2007/07/03 09:40:58 tipaul
-# return itemtype description properly
-#
-# Revision 1.215 2007/07/03 09:33:05 tipaul
-# if you just replace su by a space in subjects, you'll replace jesus by je s, which is strange for users. this fix solves the problem and introduces authoritysep systempref as separator of subfields, for a better identification of where the authority starts and end
-#
-# Revision 1.214 2007/07/02 09:13:22 tipaul
-# unimarc bugfix : the encoding is in field 100 in UNIMARC. when TransformHTMLtoXML on an item, you must not automatically add a 100 field in items, otherwise there will be 2 100 fields in the biblio, which is wrong
-#
-# Revision 1.213 2007/06/25 15:01:45 tipaul
-# bugfixes on unimarc 100 handling (the field used for encoding)
-#
-# Revision 1.212 2007/06/15 13:44:44 tipaul
-# some fixes (and only fixes)
-#
-# Revision 1.211 2007/06/15 09:40:06 toins
-# do not get $3 $4 and $5 on GetMarcSubjects GetMarcAuthors on unimarc flavour.
-#
-# Revision 1.210 2007/06/13 13:03:34 toins
-# removing warn compilation.
-#
-# Revision 1.209 2007/05/23 16:19:40 tipaul
-# various bugfixes (minor) and french translation updated
-#
-# Revision 1.208 2007/05/22 09:13:54 tipaul
-# Bugfixes & improvements (various and minor) :
-# - updating templates to have tmpl_process3.pl running without any errors
-# - adding a drupal-like css for prog templates (with 3 small images)
-# - fixing some bugs in circulation & other scripts
-# - updating french translation
-# - fixing some typos in templates
-#
-# Revision 1.207 2007/05/22 08:51:19 hdl
-# Changing GetMarcStructure signature.
-# Deleting first parameter $dbh
-#
-# Revision 1.206 2007/05/21 08:44:17 btoumi
-# add security when u delete biblio :
-# u must delete linked items before delete biblio
-#
-# Revision 1.205 2007/05/11 16:04:03 btoumi
-# bug fix:
-# problem in displayed label link with subject in detail.tmpl
-# ex: label random => rdom
-#
-# Revision 1.204 2007/05/10 14:45:15 tipaul
-# Koha NoZebra :
-# - support for authorities
-# - some bugfixes in ordering and "CCL" parsing
-# - support for authorities <=> biblios walking
-#
-# Seems I can do what I want now, so I consider its done, except for bugfixes that will be needed i m sure !
-#
-# Revision 1.203 2007/05/03 15:16:02 tipaul
-# BUGFIX for : NoZebra
-# - NoZebra features : seems they work fine now (adding, modifying, deleting)
-# - Biblio edition major bugfix : before this commit editing a biblio resulted in an item removal in marcxml field
-#
-# Revision 1.202 2007/05/02 16:44:31 tipaul
-# NoZebra SQL index management :
-# * adding 3 subs in Biblio.pm
-# - GetNoZebraIndexes, that get the index structure in a new systempreference (added with this commit)
-# - _DelBiblioNoZebra, that retrieve all index entries for a biblio and remove in a variable the biblio reference
-# - _AddBiblioNoZebra, that add index entries for a biblio.
-# Note that the 2 _Add and _Del subs work only in a hash variable, to speed up things in case of a modif (ie : delete+add). The effective SQL update is done in the ModZebra sub (that existed before, and dealed with zebra index).
-# I think the code has to be more deeply tested, but it works at least partially.
-#
-# Revision 1.201 2007/04/27 14:00:49 hdl
-# Removing $dbh from GetMarcFromKohaField (dbh is not used in this function.)
-#
-# Revision 1.200 2007/04/25 16:26:42 tipaul
-# Koha 3.0 nozebra 1st commit : the script misc/migration_tools/rebuild_nozebra.pl build the nozebra table, and, if you set NoZebra to Yes, queries will be done through zebra. TODO :
-# - add nozebra table management on biblio editing
-# - the index table content is hardcoded. I still have to add some specific systempref to let the library update it
-# - manage pagination (next/previous)
-# - manage facets
-# WHAT works :
-# - NZgetRecords : has exactly the same API & returns as zebra getQuery, except that some parameters are unused
-# - search & sort works quite good
-# - CQL parser is better that what I thought I could do : title="harry and sally" and publicationyear>2000 not itemtype=LIVR should work fine
-#
-# Revision 1.199 2007/04/24 09:07:53 tipaul
-# moving dotransfer to Biblio.pm::ModItemTransfer + some CheckReserves fixes
-#
-# Revision 1.198 2007/04/23 15:21:17 tipaul
-# renaming currenttransfers to transferstoreceive
-#
-# Revision 1.197 2007/04/18 17:00:14 tipaul
-# removing all useless %env / $env
-#
-# Revision 1.196 2007/04/17 08:48:00 tipaul
-# circulation cleaning continued: bufixing
-#
-# Revision 1.195 2007/04/04 16:46:22 tipaul
-# HUGE COMMIT : code cleaning circulation.
-#
-# some stuff to do, i'll write a mail on koha-devel NOW !
-#
-# Revision 1.194 2007/03/30 12:00:42 tipaul
-# why the hell do we need to explicitly utf8 decode this string ? I really don't know, but it seems it's mandatory, otherwise, tag descriptions are not properly encoded...
-#
-# Revision 1.193 2007/03/29 16:45:53 tipaul
-# Code cleaning of Biblio.pm (continued)
-#
-# All subs have be cleaned :
-# - removed useless
-# - merged some
-# - reordering Biblio.pm completly
-# - using only naming conventions
-#
-# Seems to have broken nothing, but it still has to be heavily tested.
-# Note that Biblio.pm is now much more efficient than previously & probably more reliable as well.
-#
-# 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 TransformKohaToMarc+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
-#
-# Revision 1.190 2007/03/29 08:45:19 hdl
-# Deleting ignore_errors(1) pour MARC::Charset
-#
-# Revision 1.189 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.