-#!/usr/bin/perl
+#!/usr/bin/perl
# Copyright 2009 BibLibre
# Moving items from the other record to the reference record
my $itemnumbers = get_itemnumbers_of($frombiblio);
foreach my $itloop ($itemnumbers->{$frombiblio}) {
- foreach my $itemnumber (@$itloop) {
- my $res = MoveItemFromBiblio($itemnumber, $frombiblio, $tobiblio);
- if (not defined $res) {
- push @notmoveditems, $itemnumber;
- }
- }
+ foreach my $itemnumber (@$itloop) {
+ my $res = MoveItemFromBiblio($itemnumber, $frombiblio, $tobiblio);
+ if (not defined $res) {
+ push @notmoveditems, $itemnumber;
+ }
+ }
}
# If some items could not be moved :
if (scalar(@notmoveditems) > 0) {
- my $itemlist = join(' ',@notmoveditems);
- push @errors, "The following items could not be moved from the old record to the new one: $itemlist";
+ my $itemlist = join(' ',@notmoveditems);
+ push @errors, { code => "CANNOT_MOVE", value => $itemlist };
}
# Moving subscriptions from the other record to the reference record
my $subcount = CountSubscriptionFromBiblionumber($frombiblio);
if ($subcount > 0) {
- $sth = $dbh->prepare("UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?");
- $sth->execute($tobiblio, $frombiblio);
+ $sth = $dbh->prepare("UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?");
+ $sth->execute($tobiblio, $frombiblio);
- $sth = $dbh->prepare("UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?");
- $sth->execute($tobiblio, $frombiblio);
+ $sth = $dbh->prepare("UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?");
+ $sth->execute($tobiblio, $frombiblio);
}
# Deleting the other record
if (scalar(@errors) == 0) {
- # Move holds
- MergeHolds($dbh,$tobiblio,$frombiblio);
- my $error = DelBiblio($frombiblio);
- push @errors, $error if ($error);
+ # Move holds
+ MergeHolds($dbh,$tobiblio,$frombiblio);
+ my $error = DelBiblio($frombiblio);
+ push @errors, $error if ($error);
}
# Parameters
$template->param(
- result => 1,
- biblio1 => $input->param('biblio1')
+ result => 1,
+ biblio1 => $input->param('biblio1')
);
#-------------------------
my $biblionumber = $input->param('biblionumber');
if (scalar(@biblionumber) != 2) {
- push @errors, "An unexpected number of records was provided for merging. Currently only two records at a time can be merged.";
+ push @errors, { code => "WRONG_COUNT", value => scalar(@biblionumber) };
}
else {
my $data1 = GetBiblioData($biblionumber[0]);
if (@errors) {
# Errors
- my @errors_loop = map{{error => $_}}@errors;
- $template->param( errors => \@errors_loop );
+ $template->param( errors => \@errors );
}
output_html_with_http_headers $input, $cookie, $template->output;
foreach my $field (@fields) {
- my $fieldtag = $field->tag();
- if ($fieldtag < 10) {
- if ($tagslib->{$fieldtag}->{'@'}->{'tab'} >= 0) {
- push @array, {
- field => [
- {
- tag => $fieldtag,
- key => createKey(),
- value => $field->data(),
- }
- ]
- };
- }
- } else {
- my @subfields = $field->subfields();
- my @subfield_array;
- foreach my $subfield (@subfields) {
- if ($tagslib->{$fieldtag}->{@$subfield[0]}->{'tab'} >= 0) {
- push @subfield_array, {
- subtag => @$subfield[0],
- subkey => createKey(),
- value => @$subfield[1],
- };
- }
-
- }
-
- if ($tagslib->{$fieldtag}->{'tab'} >= 0 && $fieldtag ne '995') {
- push @array, {
- field => [
- {
- tag => $fieldtag,
- key => createKey(),
- indicator1 => $field->indicator(1),
- indicator2 => $field->indicator(2),
- subfield => [@subfield_array],
- }
- ]
- };
- }
-
- }
+ my $fieldtag = $field->tag();
+ if ($fieldtag < 10) {
+ if ($tagslib->{$fieldtag}->{'@'}->{'tab'} >= 0) {
+ push @array, {
+ field => [
+ {
+ tag => $fieldtag,
+ key => createKey(),
+ value => $field->data(),
+ }
+ ]
+ };
+ }
+ } else {
+ my @subfields = $field->subfields();
+ my @subfield_array;
+ foreach my $subfield (@subfields) {
+ if ($tagslib->{$fieldtag}->{@$subfield[0]}->{'tab'} >= 0) {
+ push @subfield_array, {
+ subtag => @$subfield[0],
+ subkey => createKey(),
+ value => @$subfield[1],
+ };
+ }
+
+ }
+
+ if ($tagslib->{$fieldtag}->{'tab'} >= 0 && $fieldtag ne '995') {
+ push @array, {
+ field => [
+ {
+ tag => $fieldtag,
+ key => createKey(),
+ indicator1 => $field->indicator(1),
+ indicator2 => $field->indicator(2),
+ subfield => [@subfield_array],
+ }
+ ]
+ };
+ }
+
+ }
}
return [@array];
return int(rand(1000000));
}
-
-