Lines 27-32
use C4::Auth;
Link Here
|
27 |
use C4::Items; |
27 |
use C4::Items; |
28 |
use C4::Biblio; |
28 |
use C4::Biblio; |
29 |
use C4::Serials; |
29 |
use C4::Serials; |
|
|
30 |
use C4::Koha; |
30 |
use C4::Reserves qw/MergeHolds/; |
31 |
use C4::Reserves qw/MergeHolds/; |
31 |
|
32 |
|
32 |
my $input = new CGI; |
33 |
my $input = new CGI; |
Lines 61-67
if ($merge) {
Link Here
|
61 |
# Rewriting the leader |
62 |
# Rewriting the leader |
62 |
$record->leader(GetMarcBiblio($tobiblio)->leader()); |
63 |
$record->leader(GetMarcBiblio($tobiblio)->leader()); |
63 |
|
64 |
|
64 |
my $frameworkcode = &GetFrameworkCode($tobiblio); |
65 |
my $frameworkcode = $input->param('frameworkcode'); |
65 |
my @notmoveditems; |
66 |
my @notmoveditems; |
66 |
|
67 |
|
67 |
# Modifying the reference record |
68 |
# Modifying the reference record |
Lines 108-184
if ($merge) {
Link Here
|
108 |
push @errors, $error if ($error); |
109 |
push @errors, $error if ($error); |
109 |
} |
110 |
} |
110 |
|
111 |
|
111 |
# Errors |
|
|
112 |
my @errors_loop = map{{error => $_}}@errors; |
113 |
|
114 |
# Parameters |
112 |
# Parameters |
115 |
$template->param( |
113 |
$template->param( |
116 |
errors => \@errors_loop, |
|
|
117 |
result => 1, |
114 |
result => 1, |
118 |
biblio1 => $input->param('biblio1') |
115 |
biblio1 => $input->param('biblio1') |
119 |
); |
116 |
); |
120 |
|
117 |
|
121 |
|
|
|
122 |
#------------------------- |
118 |
#------------------------- |
123 |
# Show records to merge |
119 |
# Show records to merge |
124 |
#------------------------- |
120 |
#------------------------- |
125 |
} else { |
121 |
} else { |
126 |
|
|
|
127 |
my $mergereference = $input->param('mergereference'); |
122 |
my $mergereference = $input->param('mergereference'); |
128 |
my $biblionumber = $input->param('biblionumber'); |
123 |
my $biblionumber = $input->param('biblionumber'); |
129 |
|
124 |
|
130 |
my $data1 = GetBiblioData($biblionumber[0]); |
125 |
if (scalar(@biblionumber) != 2) { |
131 |
my $data2 = GetBiblioData($biblionumber[1]); |
126 |
push @errors, "An unexpected number of records was provided for merging. Currently only two records at a time can be merged."; |
132 |
|
127 |
} |
133 |
# Ask the user to choose which record will be the kept |
128 |
else { |
134 |
if (not $mergereference) { |
129 |
my $data1 = GetBiblioData($biblionumber[0]); |
135 |
$template->param( |
130 |
my $data2 = GetBiblioData($biblionumber[1]); |
136 |
choosereference => 1, |
131 |
|
137 |
biblio1 => $biblionumber[0], |
132 |
# Checks if both records use the same framework |
138 |
biblio2 => $biblionumber[1], |
133 |
my $frameworkcode1 = &GetFrameworkCode($biblionumber[0]); |
139 |
title1 => $data1->{'title'}, |
134 |
my $frameworkcode2 = &GetFrameworkCode($biblionumber[1]); |
140 |
title2 => $data2->{'title'} |
135 |
|
141 |
); |
136 |
if ($mergereference) { |
142 |
} else { |
137 |
|
143 |
|
138 |
my $framework; |
144 |
if (scalar(@biblionumber) != 2) { |
139 |
if ($frameworkcode1 ne $frameworkcode2) { |
145 |
push @errors, "An unexpected number of records was provided for merging. Currently only two records at a time can be merged."; |
140 |
$framework = $input->param('frameworkcode') |
146 |
} |
141 |
or push @errors, "Famework not selected."; |
147 |
|
142 |
} else { |
148 |
# Checks if both records use the same framework |
143 |
$framework = $frameworkcode1; |
149 |
my $frameworkcode1 = &GetFrameworkCode($biblionumber[0]); |
144 |
} |
150 |
my $frameworkcode2 = &GetFrameworkCode($biblionumber[1]); |
145 |
|
151 |
my $framework; |
146 |
# Getting MARC Structure |
152 |
if ($frameworkcode1 ne $frameworkcode2) { |
147 |
my $tagslib = GetMarcStructure(1, $framework); |
153 |
push @errors, "The records selected for merging are using different frameworks. Currently merging is only available for records using the same framework."; |
148 |
|
154 |
} else { |
149 |
my $notreference = ($biblionumber[0] == $mergereference) ? $biblionumber[1] : $biblionumber[0]; |
155 |
$framework = $frameworkcode1; |
150 |
|
156 |
} |
151 |
# Creating a loop for display |
157 |
|
152 |
my @record1 = _createMarcHash(GetMarcBiblio($mergereference), $tagslib); |
158 |
# Getting MARC Structure |
153 |
my @record2 = _createMarcHash(GetMarcBiblio($notreference), $tagslib); |
159 |
my $tagslib = GetMarcStructure(1, $framework); |
154 |
|
160 |
|
155 |
# Parameters |
161 |
my $notreference = ($biblionumber[0] == $mergereference) ? $biblionumber[1] : $biblionumber[0]; |
156 |
$template->param( |
162 |
|
157 |
biblio1 => $mergereference, |
163 |
# Creating a loop for display |
158 |
biblio2 => $notreference, |
164 |
my @record1 = _createMarcHash(GetMarcBiblio($mergereference), $tagslib); |
159 |
mergereference => $mergereference, |
165 |
my @record2 = _createMarcHash(GetMarcBiblio($notreference), $tagslib); |
160 |
record1 => @record1, |
166 |
|
161 |
record2 => @record2, |
167 |
# Errors |
162 |
framework => $framework, |
168 |
my @errors_loop = map{{error => $_}}@errors; |
163 |
); |
169 |
|
164 |
} |
170 |
# Parameters |
165 |
else { |
171 |
$template->param( |
166 |
|
172 |
errors => \@errors_loop, |
167 |
# Ask the user to choose which record will be the kept |
173 |
biblio1 => $mergereference, |
168 |
$template->param( |
174 |
biblio2 => $notreference, |
169 |
choosereference => 1, |
175 |
mergereference => $mergereference, |
170 |
biblio1 => $biblionumber[0], |
176 |
record1 => @record1, |
171 |
biblio2 => $biblionumber[1], |
177 |
record2 => @record2, |
172 |
title1 => $data1->{'title'}, |
178 |
framework => $framework |
173 |
title2 => $data2->{'title'} |
179 |
); |
174 |
); |
|
|
175 |
if ($frameworkcode1 ne $frameworkcode2) { |
176 |
my $frameworks = getframeworks; |
177 |
my @frameworkselect; |
178 |
foreach my $thisframeworkcode ( keys %$frameworks ) { |
179 |
my %row = ( |
180 |
value => $thisframeworkcode, |
181 |
frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'}, |
182 |
); |
183 |
if ($frameworkcode1 eq $thisframeworkcode){ |
184 |
$row{'selected'} = 1; |
185 |
} |
186 |
push @frameworkselect, \%row; |
187 |
} |
188 |
$template->param( |
189 |
frameworkselect => \@frameworkselect, |
190 |
frameworkcode1 => $frameworkcode1, |
191 |
frameworkcode2 => $frameworkcode2, |
192 |
); |
193 |
} |
194 |
} |
180 |
} |
195 |
} |
181 |
} |
196 |
} |
|
|
197 |
|
198 |
if (@errors) { |
199 |
# Errors |
200 |
my @errors_loop = map{{error => $_}}@errors; |
201 |
$template->param( errors => \@errors_loop ); |
202 |
} |
203 |
|
182 |
output_html_with_http_headers $input, $cookie, $template->output; |
204 |
output_html_with_http_headers $input, $cookie, $template->output; |
183 |
exit; |
205 |
exit; |
184 |
|
206 |
|