=head2 ModBiblio
+=over 4
+
ModBiblio( $record,$biblionumber,$frameworkcode);
- Exported function (core API) to modify a biblio
+
+=back
+
+Replace an existing bib record identified by C<$biblionumber>
+with one supplied by the MARC::Record object C<$record>. The embedded
+item, biblioitem, and biblionumber fields from the previous
+version of the bib record replace any such fields of those tags that
+are present in C<$record>. Consequently, ModBiblio() is not
+to be used to try to modify item records.
+
+C<$frameworkcode> specifies the MARC framework to use
+when storing the modified bib record; among other things,
+this controls how MARC fields get mapped to display columns
+in the C<biblio> and C<biblioitems> tables, as well as
+which fields are used to store embedded item, biblioitem,
+and biblionumber data for indexing.
=cut
# get the items before and append them to the biblio before updating the record, atm we just have the biblio
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",$frameworkcode);
my $oldRecord = GetMarcBiblio( $biblionumber );
+
+ # delete any item fields from incoming record to avoid
+ # duplication or incorrect data - use AddItem() or ModItem()
+ # to change items
+ foreach my $field ($record->field($itemtag)) {
+ $record->delete_field($field);
+ }
# parse each item, and, for an unknown reason, re-encode each subfield
# if you don't do that, the record will have encoding mixed
sub PrepareItemrecordDisplay {
- my ( $bibnum, $itemnum ) = @_;
+ my ( $bibnum, $itemnum, $defaultvalues ) = @_;
my $dbh = C4::Context->dbh;
my $frameworkcode = &GetFrameworkCode( $bibnum );
$tagslib->{$tag}->{$subfield}->{'kohafield'};
# $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
- $subfield_data{marc_lib} =
- "<span id=\"error\" title=\""
- . $tagslib->{$tag}->{$subfield}->{lib} . "\">"
- . substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 12 )
- . "</span>";
+ $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib};
$subfield_data{mandatory} =
$tagslib->{$tag}->{$subfield}->{mandatory};
$subfield_data{repeatable} =
$value = $temp->subfield($CNsubfield);
}
}
+ if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq
+ 'items.itemcallnumber'
+ && $defaultvalues->{'callnumber'} )
+ {
+ my $temp = $itemrecord->field($subfield) if ($itemrecord);
+ unless ($temp) {
+ $value = $defaultvalues->{'callnumber'};
+ }
+ }
+ if ( ($tagslib->{$tag}->{$subfield}->{kohafield} eq
+ 'items.holdingbranch' ||
+ $tagslib->{$tag}->{$subfield}->{kohafield} eq
+ 'items.homebranch')
+ && $defaultvalues->{'branchcode'} )
+ {
+ my $temp = $itemrecord->field($subfield) if ($itemrecord);
+ unless ($temp) {
+ $value = $defaultvalues->{branchcode};
+ }
+ }
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
my @authorised_values;
my %authorised_lib;
}
elsif ( $tagslib->{$tag}->{$subfield}->{thesaurus_category} ) {
$subfield_data{marc_value} =
-"<input type=\"text\" name=\"field_value\" size=47 maxlength=255> <a href=\"javascript:Dopop('cataloguing/thesaurus_popup.pl?category=$tagslib->{$tag}->{$subfield}->{thesaurus_category}&index=',)\">...</a>";
+"<input type=\"text\" name=\"field_value\" size=\"47\" maxlength=\"255\" /> <a href=\"javascript:Dopop('cataloguing/thesaurus_popup.pl?category=$tagslib->{$tag}->{$subfield}->{thesaurus_category}&index=',)\">...</a>";
#"
# COMMENTED OUT because No $i is provided with this API.
}
else {
$subfield_data{marc_value} =
-"<input type=\"text\" name=\"field_value\" value=\"$value\" size=50 maxlength=255>";
+"<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"50\" maxlength=\"255\" />";
}
push( @loop_data, \%subfield_data );
}
# lock the nozebra table : we will read index lines, update them in Perl process
# and write everything in 1 transaction.
# lock the table to avoid someone else overwriting what we are doing
- $dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE');
- my %result; # the result hash that will be builded by deletion / add, and written on mySQL at the end, to improve speed
+ $dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE, auth_subfield_structure READ');
+ my %result; # the result hash that will be built by deletion / add, and written on mySQL at the end, to improve speed
if ($op eq 'specialUpdate') {
# OK, we have to add or update the record
# 1st delete (virtually, in indexes), if record actually exists
}
}
$dbh->do('UNLOCK TABLES');
-
} else {
#
# we use zebra, just fill zebraqueue table