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