Lines 31-36
use Koha::MetadataRecord::Authority;
Link Here
|
31 |
my $input = CGI->new; |
31 |
my $input = CGI->new; |
32 |
my @authid = $input->multi_param('authid'); |
32 |
my @authid = $input->multi_param('authid'); |
33 |
my $merge = $input->param('merge'); |
33 |
my $merge = $input->param('merge'); |
|
|
34 |
my $authtypecode = $input->param('authtypecode'); |
34 |
|
35 |
|
35 |
my @errors; |
36 |
my @errors; |
36 |
|
37 |
|
Lines 52-63
if ($merge) {
Link Here
|
52 |
my $record = TransformHtmlToMarc($input, 0); |
53 |
my $record = TransformHtmlToMarc($input, 0); |
53 |
my $recordid1 = $input->param('recordid1') // q{}; |
54 |
my $recordid1 = $input->param('recordid1') // q{}; |
54 |
my $recordid2 = $input->param('recordid2') // q{}; |
55 |
my $recordid2 = $input->param('recordid2') // q{}; |
55 |
my $typecode = $input->param('frameworkcode'); |
|
|
56 |
|
56 |
|
57 |
# Some error checking |
57 |
# Some error checking |
58 |
if( $recordid1 eq $recordid2 ) { |
58 |
if( $recordid1 eq $recordid2 ) { |
59 |
push @errors, { code => 'DESTRUCTIVE_MERGE' }; |
59 |
push @errors, { code => 'DESTRUCTIVE_MERGE' }; |
60 |
} elsif( !$typecode || !Koha::Authority::Types->find($typecode) ) { |
60 |
} elsif( !$authtypecode || !Koha::Authority::Types->find($authtypecode) ) { |
61 |
push @errors, { code => 'WRONG_FRAMEWORK' }; |
61 |
push @errors, { code => 'WRONG_FRAMEWORK' }; |
62 |
} elsif( scalar $record->fields == 0 ) { |
62 |
} elsif( scalar $record->fields == 0 ) { |
63 |
push @errors, { code => 'EMPTY_MARC' }; |
63 |
push @errors, { code => 'EMPTY_MARC' }; |
Lines 75-81
if ($merge) {
Link Here
|
75 |
|
75 |
|
76 |
# Modifying the reference record |
76 |
# Modifying the reference record |
77 |
# This triggers a merge for the biblios attached to $recordid1 |
77 |
# This triggers a merge for the biblios attached to $recordid1 |
78 |
ModAuthority( $recordid1, $record, $typecode ); |
78 |
ModAuthority( $recordid1, $record, $authtypecode ); |
79 |
|
79 |
|
80 |
# Now merge for biblios attached to $recordid2 |
80 |
# Now merge for biblios attached to $recordid2 |
81 |
my $MARCfrom = GetAuthority( $recordid2 ); |
81 |
my $MARCfrom = GetAuthority( $recordid2 ); |
Lines 129-147
else {
Link Here
|
129 |
|
129 |
|
130 |
if ($mergereference ) { |
130 |
if ($mergereference ) { |
131 |
|
131 |
|
132 |
my $framework; |
|
|
133 |
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode && $mergereference ne 'breeding' ) { |
132 |
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode && $mergereference ne 'breeding' ) { |
134 |
$framework = $input->param('frameworkcode'); |
|
|
135 |
} |
133 |
} |
136 |
else { |
134 |
else { # overwrite authtypecode parameter |
137 |
$framework = $recordObj1->authtypecode; |
135 |
$authtypecode = $recordObj1->authtypecode; |
138 |
} |
136 |
} |
139 |
if ($mergereference eq 'breeding') { |
137 |
if ($mergereference eq 'breeding') { |
140 |
$mergereference = $authid[0]; |
138 |
$mergereference = $authid[0]; |
141 |
} |
139 |
} |
142 |
|
140 |
|
143 |
# Getting MARC Structure |
141 |
# Getting MARC Structure |
144 |
my $tagslib = GetTagsLabels( 1, $framework ); |
142 |
my $tagslib = GetTagsLabels( 1, $authtypecode ); |
145 |
foreach my $field ( keys %$tagslib ) { |
143 |
foreach my $field ( keys %$tagslib ) { |
146 |
if ( defined $tagslib->{$field}->{'tab'} && $tagslib->{$field}->{'tab'} eq ' ' ) { |
144 |
if ( defined $tagslib->{$field}->{'tab'} && $tagslib->{$field}->{'tab'} eq ' ' ) { |
147 |
$tagslib->{$field}->{'tab'} = 0; |
145 |
$tagslib->{$field}->{'tab'} = 0; |
Lines 162-175
else {
Link Here
|
162 |
{ |
160 |
{ |
163 |
recordid => $mergereference, |
161 |
recordid => $mergereference, |
164 |
record => $recordObj1->record, |
162 |
record => $recordObj1->record, |
165 |
frameworkcode => $recordObj1->authtypecode, |
163 |
authtypecode => $recordObj1->authtypecode, |
166 |
display => $recordObj1->createMergeHash($tagslib), |
164 |
display => $recordObj1->createMergeHash($tagslib), |
167 |
reference => 1, |
165 |
reference => 1, |
168 |
}, |
166 |
}, |
169 |
{ |
167 |
{ |
170 |
recordid => $notreference, |
168 |
recordid => $notreference, |
171 |
record => $recordObj2->record, |
169 |
record => $recordObj2->record, |
172 |
frameworkcode => $recordObj2->authtypecode, |
170 |
authtypecode => $recordObj2->authtypecode, |
173 |
display => $recordObj2->createMergeHash($tagslib), |
171 |
display => $recordObj2->createMergeHash($tagslib), |
174 |
}, |
172 |
}, |
175 |
); |
173 |
); |
Lines 178-185
else {
Link Here
|
178 |
$template->param( |
176 |
$template->param( |
179 |
recordid1 => $mergereference, |
177 |
recordid1 => $mergereference, |
180 |
recordid2 => $notreference, |
178 |
recordid2 => $notreference, |
181 |
records => \@records, |
179 |
records => \@records, |
182 |
framework => $framework, |
180 |
authtypecode => $authtypecode, |
183 |
); |
181 |
); |
184 |
} |
182 |
} |
185 |
else { |
183 |
else { |
Lines 195-203
else {
Link Here
|
195 |
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode ) { |
193 |
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode ) { |
196 |
my $authority_types = Koha::Authority::Types->search( { authtypecode => { '!=' => '' } }, { order_by => ['authtypetext'] } ); |
194 |
my $authority_types = Koha::Authority::Types->search( { authtypecode => { '!=' => '' } }, { order_by => ['authtypetext'] } ); |
197 |
$template->param( |
195 |
$template->param( |
198 |
frameworkselect => $authority_types->unblessed, |
196 |
authority_types => $authority_types->unblessed, |
199 |
frameworkcode1 => $recordObj1->authtypecode, |
197 |
authtypecode1 => $recordObj1->authtypecode, |
200 |
frameworkcode2 => $recordObj2->authtypecode, |
198 |
authtypecode2 => $recordObj2->authtypecode, |
201 |
); |
199 |
); |
202 |
} |
200 |
} |
203 |
} |
201 |
} |