FROM biblio LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber ";
unless(C4::Context->preference('item-level_itypes')) {
$query .= "LEFT JOIN itemtypes on biblioitems.itemtype=itemtypes.itemtype ";
- }
- $query .= " WHERE biblioitemnumber = ? ";
+ } else {
+ $query .= "LEFT JOIN items on biblio.biblionumber=items.biblionumber ";
+ }
+ $query .= " WHERE biblioitems.biblioitemnumber = ? ";
my $sth = $dbh->prepare($query);
my $data;
$sth->execute($biblioitemnumber);
sub GetBiblioSummary {
my $recorddata =shift @_;
+ return unless $recorddata;
my $marcflavour = C4::Context->preference("marcflavour");
my $marc=MARC::Record::new_from_xml($recorddata,"utf-8",$marcflavour);
+ return unless $marc;
my $str;
}
$sth->execute( $frameworkcode, $kohafieldname );
if ( ( $tagfield, $tagsubfield ) = $sth->fetchrow ) {
- my $tag = $record->field($tagfield);
- if ($tag) {
- $tag->update( $tagsubfield => $value );
- $record->delete_field($tag);
- $record->insert_fields_ordered($tag);
- }
- else {
- $record->add_fields( $tagfield, " ", " ", $tagsubfield => $value );
+ my @values = split(/\s?\|\s?/, $value, -1);
+
+ foreach my $itemvalue (@values){
+ my $tag = $record->field($tagfield);
+ if ($tag) {
+ $tag->add_subfields( $tagsubfield => $itemvalue );
+ $record->delete_field($tag);
+ $record->insert_fields_ordered($tag);
+ }
+ else {
+ $record->add_fields( $tagfield, " ", " ", $tagsubfield => $itemvalue );
+ }
}
}
return $record;
# we drop the original field
# we add the new builded field.
my ($biblio_tag, $biblio_subfield ) = GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
+ unless ( $biblio_tag ) { die "can't GetMarcFromKohaField for framework $frameworkcode"; }
+
my ($biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
if ($biblio_tag != $biblioitem_tag) {
sub _koha_add_biblioitem {
my ( $dbh, $biblioitem ) = @_;
- my $error;
+ my @fields = qw/ biblionumber
+ cn_class cn_item cn_sort cn_source cn_suffix
+ collectionissn collectiontitle collectionvolume
+ editionresponsibility editionstatement
+ illus isbn issn itemtype lccn marc
+ notes number pages place
+ publicationyear publishercode size
+ totalissues url
+ volume volumedate volumedesc
+ /;
+
+ ($$biblioitem{cn_sort}) = GetClassSort( @$biblioitem{qw/ biblioitems.cn_source cn_class cn_item /} );
+
+ my $query = 'INSERT INTO biblioitems SET '
+ . join ( ',', map { "$_ =?" } @fields )
+ . ';'
+ ;
- 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(
- $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->execute( @$biblioitem{@fields} );
my $bibitemnum = $dbh->{'mysql_insertid'};
- if ( $dbh->errstr ) {
- $error.="ERROR in _koha_add_biblioitem $query".$dbh->errstr;
- warn $error;
- }
+ my $error = '';
+ $dbh->errstr and warn $error .=
+ 'ERROR in _koha_add_biblioitem '
+ . $query
+ . $dbh->errstr
+ ;
$sth->finish();
return ($bibitemnum,$error);
}