|
Lines 86-118
if ($merge) {
Link Here
|
| 86 |
# Rewriting the leader |
86 |
# Rewriting the leader |
| 87 |
my $biblio = Koha::Biblios->find($ref_biblionumber); |
87 |
my $biblio = Koha::Biblios->find($ref_biblionumber); |
| 88 |
$record->leader($biblio->metadata->record->leader()); |
88 |
$record->leader($biblio->metadata->record->leader()); |
| 89 |
|
89 |
#Take new framework code |
| 90 |
my $frameworkcode = $input->param('frameworkcode'); |
90 |
my $frameworkcode = $input->param('frameworkcode'); |
| 91 |
|
91 |
|
| 92 |
# Modifying the reference record |
92 |
# Modifying the reference record |
| 93 |
ModBiblio($record, $ref_biblionumber, $frameworkcode); |
93 |
ModBiblio($record, $ref_biblionumber, $frameworkcode); |
| 94 |
|
94 |
|
| 95 |
# Moving items and article requests from the other record to the reference record |
|
|
| 96 |
$biblio = $biblio->get_from_storage; |
| 97 |
foreach my $biblionumber (@biblionumbers) { |
| 98 |
my $from_biblio = Koha::Biblios->find($biblionumber); |
| 99 |
$from_biblio->items->move_to_biblio($biblio); |
| 100 |
$from_biblio->article_requests->update({ biblionumber => $ref_biblionumber }, { no_triggers => 1 }); |
| 101 |
} |
| 102 |
|
| 103 |
my $sth_subscription = $dbh->prepare(" |
| 104 |
UPDATE subscription SET biblionumber = ? WHERE biblionumber = ? |
| 105 |
"); |
| 106 |
my $sth_subscriptionhistory = $dbh->prepare(" |
| 107 |
UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ? |
| 108 |
"); |
| 109 |
my $sth_serial = $dbh->prepare(" |
| 110 |
UPDATE serial SET biblionumber = ? WHERE biblionumber = ? |
| 111 |
"); |
| 112 |
my $sth_suggestions = $dbh->prepare(" |
| 113 |
UPDATE suggestions SET biblionumber = ? WHERE biblionumber = ? |
| 114 |
"); |
| 115 |
|
| 116 |
my $report_header = {}; |
95 |
my $report_header = {}; |
| 117 |
foreach my $biblionumber ($ref_biblionumber, @biblionumbers) { |
96 |
foreach my $biblionumber ($ref_biblionumber, @biblionumbers) { |
| 118 |
# build report |
97 |
# build report |
|
Lines 148-189
if ($merge) {
Link Here
|
| 148 |
push @report_records, \%report_record; |
127 |
push @report_records, \%report_record; |
| 149 |
} |
128 |
} |
| 150 |
|
129 |
|
| 151 |
foreach my $biblionumber (@biblionumbers) { |
130 |
my $rmerge; |
| 152 |
# Moving subscriptions from the other record to the reference record |
131 |
eval { |
| 153 |
my $subcount = CountSubscriptionFromBiblionumber($biblionumber); |
132 |
my $newbiblio = Koha::Biblios->find($ref_biblionumber); |
| 154 |
if ($subcount > 0) { |
133 |
$rmerge = $newbiblio->merge_with( \@biblionumbers ); |
| 155 |
$sth_subscription->execute($ref_biblionumber, $biblionumber); |
134 |
}; |
| 156 |
$sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber); |
135 |
if ($@) { |
| 157 |
} |
136 |
push @errors, $@; |
| 158 |
|
|
|
| 159 |
# Moving serials |
| 160 |
$sth_serial->execute($ref_biblionumber, $biblionumber); |
| 161 |
|
| 162 |
# Moving suggestions |
| 163 |
$sth_suggestions->execute($ref_biblionumber, $biblionumber); |
| 164 |
|
| 165 |
# Moving orders (orders linked to items of frombiblio have already been moved by move_to_biblio) |
| 166 |
my @allorders = GetOrdersByBiblionumber($biblionumber); |
| 167 |
foreach my $myorder (@allorders) { |
| 168 |
$myorder->{'biblionumber'} = $ref_biblionumber; |
| 169 |
ModOrder ($myorder); |
| 170 |
# TODO : add error control (in ModOrder?) |
| 171 |
} |
137 |
} |
| 172 |
|
138 |
|
| 173 |
# Deleting the other records |
|
|
| 174 |
if (scalar(@errors) == 0) { |
| 175 |
# Move holds |
| 176 |
MergeHolds($dbh, $ref_biblionumber, $biblionumber); |
| 177 |
my $error = DelBiblio($biblionumber); |
| 178 |
push @errors, $error if ($error); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
# Parameters |
139 |
# Parameters |
| 183 |
$template->param( |
140 |
$template->param( |
| 184 |
result => 1, |
141 |
result => 1, |
| 185 |
report_records => \@report_records, |
142 |
report_records => \@report_records, |
| 186 |
report_header => $report_header, |
143 |
report_header => $report_header, |
| 187 |
ref_biblionumber => scalar $input->param('ref_biblionumber') |
144 |
ref_biblionumber => scalar $input->param('ref_biblionumber') |
| 188 |
); |
145 |
); |
| 189 |
|
146 |
|