View | Details | Raw Unified | Return to bug 14578
Collapse All | Expand All

(-)a/C4/ImportBatch.pm (-1 / +1 lines)
Lines 1130-1136 sub GetImportRecordsRange { Link Here
1130
1130
1131
    $order_by .= " $order_by_direction, authorized_heading" if $order_by eq 'title';
1131
    $order_by .= " $order_by_direction, authorized_heading" if $order_by eq 'title';
1132
1132
1133
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
1133
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id, import_records.import_batch_id,
1134
                                           record_sequence, status, overlay_status,
1134
                                           record_sequence, status, overlay_status,
1135
                                           matched_biblionumber, matched_authid, record_type
1135
                                           matched_biblionumber, matched_authid, record_type
1136
                                    FROM   import_records
1136
                                    FROM   import_records
(-)a/cataloguing/merge.pl (-81 / +193 lines)
Lines 29-38 use C4::Serials; Link Here
29
use C4::Koha;
29
use C4::Koha;
30
use C4::Reserves qw/MergeHolds/;
30
use C4::Reserves qw/MergeHolds/;
31
use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/;
31
use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/;
32
use C4::ImportBatch;
32
use Koha::MetadataRecord;
33
use Koha::MetadataRecord;
33
34
34
my $input = new CGI;
35
my $input = new CGI;
35
my @biblionumbers = $input->multi_param('biblionumber');
36
my @record_paths = $input->multi_param('record');
36
my $merge = $input->param('merge');
37
my $merge = $input->param('merge');
37
38
38
my @errors;
39
my @errors;
Lines 47-63 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
    }
48
    }
48
);
49
);
49
50
51
my $sources = {
52
    catalog => {
53
        delete => \&_delete_catalog,
54
        fetch => \&_fetch_catalog,
55
        get_link => \&_get_link_catalog,
56
        get_preview_link => \&_get_preview_link_catalog,
57
        merge_other => \&_merge_other_catalog,
58
        update => \&_update_catalog,
59
    },
60
    batch => {
61
        fetch => \&_fetch_import_batch,
62
        get_link => \&_get_preview_link_import_batch,
63
        get_preview_link => \&_get_preview_link_import_batch,
64
        update => \&_update_import_batch,
65
    },
66
};
67
68
sub split_record_path {
69
    my ($source, $num) = split /\//, shift, 2;
70
    $source =~ s/-.*//;
71
72
    return ( $source, $num );
73
}
74
50
#------------------------
75
#------------------------
51
# Merging
76
# Merging
52
#------------------------
77
#------------------------
53
if ($merge) {
78
if ($merge) {
54
79
55
    my $dbh = C4::Context->dbh;
56
57
    # Creating a new record from the html code
80
    # Creating a new record from the html code
58
    my $record       = TransformHtmlToMarc( $input, 1 );
81
    my $record       = TransformHtmlToMarc( $input );
59
    my $ref_biblionumber = $input->param('ref_biblionumber');
82
    my $ref_record_path = $input->param('ref_record');
60
    @biblionumbers = grep { $_ != $ref_biblionumber } @biblionumbers;
83
84
    my ( $ref_record_source, $ref_record_num ) = split_record_path $ref_record_path;
85
    my @other_record_paths = map +[ split_record_path $_ ], grep { $_ ne $ref_record_path } @record_paths;
61
86
62
    # prepare report
87
    # prepare report
63
    my @report_records;
88
    my @report_records;
Lines 75-120 if ($merge) { Link Here
75
    }
100
    }
76
101
77
    # Rewriting the leader
102
    # Rewriting the leader
78
    $record->leader(GetMarcBiblio($ref_biblionumber)->leader());
103
    my $orig_ref_record = $sources->{$ref_record_source}->{fetch}($ref_record_num);
104
    $record->leader( $orig_ref_record->leader() );
79
105
80
    my $frameworkcode = $input->param('frameworkcode');
106
    my $frameworkcode = $input->param('frameworkcode');
81
    my @notmoveditems;
107
    my @notmoveditems;
82
108
83
    # Modifying the reference record
109
    # Modifying the reference record
84
    ModBiblio($record, $ref_biblionumber, $frameworkcode);
110
    $sources->{$ref_record_source}->{update}( $record, $ref_record_num, $frameworkcode );
85
111
86
    # Moving items from the other record to the reference record
112
    # Are all the records from the same source?
87
    foreach my $biblionumber (@biblionumbers) {
113
    my $all_records_same_source = 1;
88
        my $itemnumbers = get_itemnumbers_of($biblionumber);
114
89
        foreach my $itemnumber (@{ $itemnumbers->{$biblionumber} }) {
115
    # Merging in information from other records
90
        my $res = MoveItemFromBiblio($itemnumber, $biblionumber, $ref_biblionumber);
116
    foreach my $record_path (@other_record_paths) {
91
        if (not defined $res) {
117
        my ( $record_source, $record_num ) = @$record_path;
92
            push @notmoveditems, $itemnumber;
118
119
        if ( $record_source eq $ref_record_source ) {
120
            # We only want to merge in information from the other records if they're the same kind.
121
            #
122
            # We can't merge serials from an import bib to a catalog bib, for instance.
123
            my @record_errors = $sources->{$record_source}->{merge_other}( $record_num, $ref_record_num );
124
125
            if ( @record_errors ) {
126
                push @errors, @record_errors;
127
            } else {
128
                push @errors, $sources->{$record_source}->{delete}( $record_num );
129
            }
130
        } else {
131
            $all_records_same_source = 0;
93
        }
132
        }
94
    }
133
    }
95
    }
96
    # If some items could not be moved :
97
    if (scalar(@notmoveditems) > 0) {
98
        my $itemlist = join(' ',@notmoveditems);
99
        push @errors, { code => "CANNOT_MOVE", value => $itemlist };
100
    }
101
102
    my $sth_subscription = $dbh->prepare("
103
        UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?
104
    ");
105
    my $sth_subscriptionhistory = $dbh->prepare("
106
        UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?
107
    ");
108
    my $sth_serial = $dbh->prepare("
109
        UPDATE serial SET biblionumber = ? WHERE biblionumber = ?
110
    ");
111
134
112
    my $report_header = {};
135
    my $report_header = {};
113
    foreach my $biblionumber ($ref_biblionumber, @biblionumbers) {
136
    foreach my $record_path ( [ $ref_record_source, $ref_record_num ], @other_record_paths ) {
137
        my ( $record_source, $record_num ) = @$record_path;
138
114
        # build report
139
        # build report
115
        my $marcrecord = GetMarcBiblio($biblionumber);
140
        my $marcrecord = $sources->{$record_source}->{fetch}($record_num);
116
        my %report_record = (
141
        my %report_record = (
117
            biblionumber => $biblionumber,
142
            record_num => $record_num,
118
            fields => {},
143
            fields => {},
119
        );
144
        );
120
        foreach my $field (@report_fields) {
145
        foreach my $field (@report_fields) {
Lines 143-195 if ($merge) { Link Here
143
        push @report_records, \%report_record;
168
        push @report_records, \%report_record;
144
    }
169
    }
145
170
146
    foreach my $biblionumber (@biblionumbers) {
147
        # Moving subscriptions from the other record to the reference record
148
        my $subcount = CountSubscriptionFromBiblionumber($biblionumber);
149
        if ($subcount > 0) {
150
            $sth_subscription->execute($ref_biblionumber, $biblionumber);
151
            $sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber);
152
        }
153
154
    # Moving serials
155
        $sth_serial->execute($ref_biblionumber, $biblionumber);
156
157
    # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
158
    my @allorders = GetOrdersByBiblionumber($biblionumber);
159
    my @tobiblioitem = GetBiblioItemByBiblioNumber ($ref_biblionumber);
160
    my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber };
161
    foreach my $myorder (@allorders) {
162
        $myorder->{'biblionumber'} = $ref_biblionumber;
163
        ModOrder ($myorder);
164
    # TODO : add error control (in ModOrder?)
165
    }
166
167
    # Deleting the other records
168
    if (scalar(@errors) == 0) {
169
        # Move holds
170
        MergeHolds($dbh, $ref_biblionumber, $biblionumber);
171
        my $error = DelBiblio($biblionumber);
172
        push @errors, $error if ($error);
173
    }
174
}
175
176
    # Parameters
171
    # Parameters
177
    $template->param(
172
    $template->param(
173
        all_records_same_source => $all_records_same_source,
178
        result => 1,
174
        result => 1,
179
        report_records => \@report_records,
175
        report_records => \@report_records,
180
        report_header => $report_header,
176
        report_header => $report_header,
181
        ref_biblionumber => scalar $input->param('ref_biblionumber')
177
        ref_record_path => scalar $input->param('ref_record'),
178
        ref_record_id => "$ref_record_source-$ref_record_num",
179
        ref_record_link => $sources->{$ref_record_source}->{get_link}($ref_record_num),
182
    );
180
    );
183
181
184
#-------------------------
182
#-------------------------
185
# Show records to merge
183
# Show records to merge
186
#-------------------------
184
#-------------------------
187
} else {
185
} else {
188
    my $ref_biblionumber = $input->param('ref_biblionumber');
186
    my $ref_record_path = $input->param('ref_record');
187
188
    if ($ref_record_path) {
189
        my ( $ref_record_source, $ref_record_num ) = split_record_path $ref_record_path;
189
190
190
    if ($ref_biblionumber) {
191
        my $framework = $input->param('frameworkcode');
191
        my $framework = $input->param('frameworkcode');
192
        $framework //= GetFrameworkCode($ref_biblionumber);
192
        $framework //= GetFrameworkCode($ref_record_num) if $ref_record_source eq 'catalog';
193
        $framework //= '';
193
194
194
        # Getting MARC Structure
195
        # Getting MARC Structure
195
        my $tagslib = GetMarcStructure(1, $framework);
196
        my $tagslib = GetMarcStructure(1, $framework);
Lines 198-216 if ($merge) { Link Here
198
199
199
        # Creating a loop for display
200
        # Creating a loop for display
200
        my @records;
201
        my @records;
201
        foreach my $biblionumber (@biblionumbers) {
202
        foreach my $record_path ( $input->param('record') ) {
202
            my $marcrecord = GetMarcBiblio($biblionumber);
203
            my ( $record_source, $record_num ) = split_record_path $record_path;
203
            my $frameworkcode = GetFrameworkCode($biblionumber);
204
            my $marcrecord = $sources->{$record_source}->{fetch}($record_num);
205
            # FIXME: We assume the default framework for import records.
206
            my $frameworkcode = $record_source eq 'catalog' ? GetFrameworkCode($record_num) : '';
204
            my $recordObj = new Koha::MetadataRecord({'record' => $marcrecord, schema => $marcflavour});
207
            my $recordObj = new Koha::MetadataRecord({'record' => $marcrecord, schema => $marcflavour});
205
            my $record = {
208
            my $record = {
206
                recordid => $biblionumber,
209
                record_path => $record_path,
210
                recordid => "$record_source-$record_num",
211
                record_source => $record_source,
212
                record_num => $record_num,
207
                record => $marcrecord,
213
                record => $marcrecord,
208
                frameworkcode => $frameworkcode,
214
                frameworkcode => $frameworkcode,
209
                display => $recordObj->createMergeHash($tagslib),
215
                display => $recordObj->createMergeHash($tagslib),
210
            };
216
            };
211
            if ($ref_biblionumber and $ref_biblionumber == $biblionumber) {
217
            if ($ref_record_path and $ref_record_path eq $record_path) {
212
                $record->{reference} = 1;
218
                $record->{reference} = 1;
213
                $template->param(ref_record => $record);
219
                $template->param(ref_record_path => $record);
214
                unshift @records, $record;
220
                unshift @records, $record;
215
            } else {
221
            } else {
216
                push @records, $record;
222
                push @records, $record;
Lines 221-227 if ($merge) { Link Here
221
227
222
        # Parameters
228
        # Parameters
223
        $template->param(
229
        $template->param(
224
            ref_biblionumber => $ref_biblionumber,
230
            ref_record_path => $ref_record_path,
231
            ref_recordid => "$ref_record_source-$ref_record_num",
225
            records => \@records,
232
            records => \@records,
226
            ref_record => $records[0],
233
            ref_record => $records[0],
227
            framework => $framework,
234
            framework => $framework,
Lines 230-240 if ($merge) { Link Here
230
        );
237
        );
231
    } else {
238
    } else {
232
        my @records;
239
        my @records;
233
        foreach my $biblionumber (@biblionumbers) {
240
        foreach my $record_path ( $input->multi_param('record') ) {
234
            my $frameworkcode = GetFrameworkCode($biblionumber);
241
            my ( $record_source, $record_num ) = split_record_path $record_path;
242
243
            my $marcrecord = $sources->{$record_source}->{fetch}($record_num);
244
            # FIXME: We assume the default framework for import records.
245
            my $frameworkcode = $record_source eq 'catalog' ? GetFrameworkCode($record_num) : '';
235
            my $record = {
246
            my $record = {
236
                biblionumber => $biblionumber,
247
                record_path => $record_path,
237
                data => GetBiblioData($biblionumber),
248
                recordid => "$record_path-$record_num",
249
                record_source => $record_source,
250
                record_num => $record_num,
251
                preview_link => $sources->{$record_source}->{get_preview_link}($record_num),
252
                data => TransformMarcToKoha( $marcrecord, $frameworkcode ),
238
                frameworkcode => $frameworkcode,
253
                frameworkcode => $frameworkcode,
239
            };
254
            };
240
            push @records, $record;
255
            push @records, $record;
Lines 266-269 if (@errors) { Link Here
266
}
281
}
267
282
268
output_html_with_http_headers $input, $cookie, $template->output;
283
output_html_with_http_headers $input, $cookie, $template->output;
269
exit;
284
285
sub _delete_catalog {
286
    my ( $biblionumber ) = @_;
287
    return DelBiblio($biblionumber);
288
}
289
290
sub _fetch_catalog {
291
    my ( $biblionumber ) = @_;
292
293
    return GetMarcBiblio( $biblionumber );
294
}
295
296
sub _get_link_catalog {
297
    my ( $biblionumber ) = @_;
298
299
    return "/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=$biblionumber";
300
}
301
302
sub _get_preview_link_catalog {
303
    my ( $biblionumber ) = @_;
304
305
    return "/cgi-bin/koha/catalogue/showmarc.pl?id=$biblionumber";
306
}
307
308
sub _merge_other_catalog {
309
    my ( $biblionumber, $ref_biblionumber ) = @_;
310
311
    my $dbh = C4::Context->dbh;
312
    my @errors;
313
314
    my @notmoveditems;
315
    my $itemnumbers = get_itemnumbers_of($biblionumber);
316
    foreach my $itemnumber (@{ $itemnumbers->{$biblionumber} }) {
317
        if ( !MoveItemFromBiblio( $itemnumber, $biblionumber, $ref_biblionumber ) ) {
318
            push @notmoveditems, $itemnumber;
319
        }
320
    }
321
322
    # If some items could not be moved :
323
    if (scalar(@notmoveditems) > 0) {
324
        my $itemlist = join(' ',@notmoveditems);
325
        push @errors, { code => "CANNOT_MOVE", value => $itemlist };
326
    }
327
328
    my $sth_subscription = $dbh->prepare("
329
        UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?
330
    ");
331
    my $sth_subscriptionhistory = $dbh->prepare("
332
        UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?
333
    ");
334
    my $sth_serial = $dbh->prepare("
335
        UPDATE serial SET biblionumber = ? WHERE biblionumber = ?
336
    ");
337
338
    # Moving subscriptions from the other record to the reference record
339
    my $subcount = CountSubscriptionFromBiblionumber($biblionumber);
340
    if ($subcount > 0) {
341
        $sth_subscription->execute($ref_biblionumber, $biblionumber);
342
        $sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber);
343
    }
344
345
    # Moving serials
346
    $sth_serial->execute($ref_biblionumber, $biblionumber);
347
348
    # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
349
    foreach my $myorder( GetOrdersByBiblionumber($biblionumber) ) {
350
        $myorder->{'biblionumber'} = $ref_biblionumber;
351
        ModOrder ($myorder);
352
        # TODO : add error control (in ModOrder?)
353
    }
354
355
    if (scalar(@errors) == 0) {
356
        MergeHolds($dbh, $ref_biblionumber, $biblionumber);
357
    }
358
359
    return @errors;
360
}
361
362
sub _update_catalog {
363
    my ( $record, $biblionumber, $frameworkcode ) = @_;
364
    ModBiblio( $record, $biblionumber, $frameworkcode );
365
}
366
367
sub _fetch_import_batch {
368
    my ( $import_recordid ) = @_;
369
    return C4::ImportBatch::GetRecordFromImportBiblio( $import_recordid );
370
}
371
372
sub _get_preview_link_import_batch {
373
    my ( $import_recordid ) = @_;
374
375
    return "/cgi-bin/koha/catalogue/showmarc.pl?importid=$import_recordid";
376
}
377
378
sub _update_import_batch {
379
    my ( $record, $import_recordid ) = @_;
380
    ModBiblioInBatch( $import_recordid, $record );
381
}
(-)a/koha-tmpl/intranet-tmpl/prog/css/merge-record.css (+61 lines)
Line 0 Link Here
1
.merge-record-fixed-contents {
2
    display: inline-block;
3
}
4
5
.merge-record-fixed-contents, .merge-record-subfield {
6
    padding: 2px;
7
}
8
9
.merge-record-unique-0, #tabs .merge-record-unique-0 {
10
    background-color: #005AC8;
11
    color: white;
12
}
13
14
.merge-record-unique-1, #tabs .merge-record-unique-1 {
15
    background-color: #AA0A3C;
16
    color: white;
17
}
18
19
.merge-record-unique-2, #tabs .merge-record-unique-2 {
20
    background-color: #F0F032;
21
}
22
23
.merge-record-unique-3, #tabs .merge-record-unique-3 {
24
    background-color: #00A0FA;
25
    color: white;
26
}
27
28
.merge-record-unique-4, #tabs .merge-record-unique-4 {
29
    background-color: #FA78FA;
30
}
31
32
.merge-record-unique-5, #tabs .merge-record-unique-5 {
33
    background-color: #14D2DC;
34
}
35
36
.merge-record-unique-6, #tabs .merge-record-unique-6 {
37
    background-color: #8214A0;
38
    color: white;
39
}
40
41
.merge-record-unique-7, #tabs .merge-record-unique-7 {
42
    background-color: #FA7850;
43
}
44
45
.merge-record-unique-8, #tabs .merge-record-unique-8 {
46
    background-color: #0AB45A;
47
    color: white;
48
}
49
50
.merge-record-unique-9, #tabs .merge-record-unique-9 {
51
    background-color: #006E82;
52
    color: white;
53
}
54
55
.merge-record-unique-10, #tabs .merge-record-unique-10 {
56
    background-color: #A0FA82;
57
}
58
59
.merge-record-unique-11, #tabs .merge-record-unique-11 {
60
    background-color: #F9E5BD;
61
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc (-1 / +1 lines)
Lines 9-15 function mergeAuth(authid, summary) { Link Here
9
        if (typeof alreadySelected.mergereference !== 'undefined') {
9
        if (typeof alreadySelected.mergereference !== 'undefined') {
10
            refstring = "&mergereference=" + alreadySelected.mergereference;
10
            refstring = "&mergereference=" + alreadySelected.mergereference;
11
        }
11
        }
12
        window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
12
        window.location.href = "/cgi-bin/koha/authorities/merge.pl?record=catalog/" + authid + "&record=catalog/" + alreadySelected.authid + refstring;
13
    } else {
13
    } else {
14
        $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
14
        $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
15
        showMergingInProgress();
15
        showMergingInProgress();
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc (-4 / +5 lines)
Lines 4-10 Link Here
4
            <ul id="ulrecord[% record.recordid %]">
4
            <ul id="ulrecord[% record.recordid %]">
5
                [% FOREACH field IN record.display %]
5
                [% FOREACH field IN record.display %]
6
                  [% IF field.tag != biblionumbertag %]
6
                  [% IF field.tag != biblionumbertag %]
7
                    <li id="k[% field.key %]">
7
                    <li id="k[% field.key %]" class="merge-record-field">
8
                        [% IF (tabrecord.reference) %]
8
                        [% IF (tabrecord.reference) %]
9
                            <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% record.recordid %]_[% field.key %]" />
9
                            <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% record.recordid %]_[% field.key %]" />
10
                        [% ELSE %]
10
                        [% ELSE %]
Lines 15-21 Link Here
15
                        <input type="hidden" name="tag_[% field.tag %]_indicator1_[% field.key %]" value="[% field.indicator1 %]" />
15
                        <input type="hidden" name="tag_[% field.tag %]_indicator1_[% field.key %]" value="[% field.indicator1 %]" />
16
                        <input type="hidden" name="tag_[% field.tag %]_indicator2_[% field.key %]" value="[% field.indicator2 %]" />
16
                        <input type="hidden" name="tag_[% field.tag %]_indicator2_[% field.key %]" value="[% field.indicator2 %]" />
17
                        [% IF ( field.value ) %]
17
                        [% IF ( field.value ) %]
18
                            / [% field.value %]
18
                            / <span class="merge-record-fixed-contents">[% field.value %]</span>
19
                            <input type="hidden" name="tag_[% field.tag %]_code_00_[% field.key %]" value="00" />
19
                            <input type="hidden" name="tag_[% field.tag %]_code_00_[% field.key %]" value="00" />
20
                            <input type="hidden" name="tag_[% field.tag %]_subfield_00_[% field.key %]" value="[% field.value %]" />
20
                            <input type="hidden" name="tag_[% field.tag %]_subfield_00_[% field.key %]" value="[% field.value %]" />
21
                        [% END %]
21
                        [% END %]
Lines 23-29 Link Here
23
                        [% IF ( field.subfield.size ) %]
23
                        [% IF ( field.subfield.size ) %]
24
                            <ul>
24
                            <ul>
25
                                [% FOREACH subfield IN field.subfield %]
25
                                [% FOREACH subfield IN field.subfield %]
26
                                    <li id="k[% subfield.subkey %]">
26
                                    <li id="k[% subfield.subkey %]" class="merge-record-subfield">
27
                                        [% IF (tabrecord.reference) %]
27
                                        [% IF (tabrecord.reference) %]
28
                                            <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% record.recordid %]_[% subfield.subkey %]" />
28
                                            <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% record.recordid %]_[% subfield.subkey %]" />
29
                                        [% ELSE %]
29
                                        [% ELSE %]
Lines 51-57 Link Here
51
        [% FOREACH record IN sourcerecords %]
51
        [% FOREACH record IN sourcerecords %]
52
            <li>
52
            <li>
53
                <a href="#tabrecord[% record.recordid %]">
53
                <a href="#tabrecord[% record.recordid %]">
54
                    [% record.recordid %]
54
                    [% IF record.record_source == 'batch' %]import[% END %]
55
                    #[% record.record_num %]
55
                    [% IF record.reference %](ref)[% END %]
56
                    [% IF record.reference %](ref)[% END %]
56
                </a>
57
                </a>
57
            </li>
58
            </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt (-1 / +1 lines)
Lines 69-75 Link Here
69
     } else {
69
     } else {
70
         var params = [];
70
         var params = [];
71
         $(checkboxes).each(function() {
71
         $(checkboxes).each(function() {
72
             params.push('biblionumber=' + $(this).val());
72
             params.push('record=catalog/' + $(this).val());
73
         });
73
         });
74
         var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
74
         var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
75
         location.href = url;
75
         location.href = url;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt (-12 / +13 lines)
Lines 2-7 Link Here
2
2
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
4
<title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
5
<link rel="stylesheet" href="[% interface %]/[% theme %]/css/merge-record.css">
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
6
<script type="text/javascript" src="[% interface %]/[% theme %]/js/merge-record.js"></script>
7
<script type="text/javascript" src="[% interface %]/[% theme %]/js/merge-record.js"></script>
7
[% INCLUDE 'merge-record-strings.inc' %]
8
[% INCLUDE 'merge-record-strings.inc' %]
Lines 111-118 $(document).ready(function(){ Link Here
111
112
112
    // Check all checkboxes in first tab, and uncheck all others to avoid
113
    // Check all checkboxes in first tab, and uncheck all others to avoid
113
    // inconsistencies from a page refresh.
114
    // inconsistencies from a page refresh.
114
    $('#tabs div#tabrecord[% ref_biblionumber %]').find('input[type="checkbox"]').prop('checked', true);
115
    $('#tabs div#tabrecord[% ref_recordid %]').find('input[type="checkbox"]').prop('checked', true);
115
    $('#tabs > div:not("#tabrecord[% ref_biblionumber %]")').find('input[type="checkbox"]').prop('checked', false);
116
    $('#tabs > div:not("#tabrecord[% ref_recordid %]")').find('input[type="checkbox"]').prop('checked', false);
116
117
117
    //Set focus to cataloging search
118
    //Set focus to cataloging search
118
    $("input[name=q]:eq(0)").focus();
119
    $("input[name=q]:eq(0)").focus();
Lines 150-161 $(document).ready(function(){ Link Here
150
       [% END %]
151
       [% END %]
151
152
152
    [% ELSE %]
153
    [% ELSE %]
153
        <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber %]">Click here to see the merged record.</a></p>
154
        <p>The merge was successful. <a href="[% ref_record_link %]">Click here to see the merged record.</a></p>
154
        <h3>Report</h3>
155
        <h3>Report</h3>
155
        <table>
156
        <table>
156
            <thead>
157
            <thead>
157
                <tr>
158
                <tr>
158
                    <th>Biblionumber</th>
159
                    <th>Record #</th>
159
                    [% FOREACH key IN report_header.keys.sort %]
160
                    [% FOREACH key IN report_header.keys.sort %]
160
                        [% tag = key.substr(0, 3) %]
161
                        [% tag = key.substr(0, 3) %]
161
                        [% code = key.substr(3, 1) %]
162
                        [% code = key.substr(3, 1) %]
Lines 172-178 $(document).ready(function(){ Link Here
172
                [% FOREACH record IN report_records %]
173
                [% FOREACH record IN report_records %]
173
                    <tr>
174
                    <tr>
174
                        <td>
175
                        <td>
175
                            [% record.biblionumber %]
176
                            [% record.record_num %]
176
                            [% IF loop.first %]
177
                            [% IF loop.first %]
177
                                (record kept)
178
                                (record kept)
178
                            [% END %]
179
                            [% END %]
Lines 205-220 $(document).ready(function(){ Link Here
205
        [% FOREACH record IN records %]
206
        [% FOREACH record IN records %]
206
            <li class="radio">
207
            <li class="radio">
207
                [% IF loop.first %]
208
                [% IF loop.first %]
208
                    <input type="radio" value="[% record.biblionumber %]" checked="checked" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
209
                    <input type="radio" value="[% record.record_path %]" checked="checked" id="ref_record[% record.recordid %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode %]')" />
209
                [% ELSE %]
210
                [% ELSE %]
210
                    <input type="radio" value="[% record.biblionumber %]" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
211
                    <input type="radio" value="[% record.record_path %]" id="ref_record[% record.recordid %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode %]')" />
211
                [% END %]
212
                [% END %]
212
                <label for="ref_biblionumber[% record.biblionumber %]">
213
                <label for="ref_record[% record.recordid %]">
213
                    [% record.data.title %]
214
                    [% record.data.title %]
214
                    [% FOREACH subtitle IN record.subtitles %]
215
                    [% FOREACH subtitle IN record.subtitles %]
215
                        [% subtitle.subfield %]
216
                        [% subtitle.subfield %]
216
                    [% END %]
217
                    [% END %]
217
                    ([% record.biblionumber %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber %]" class="previewData">View MARC</a>
218
                    ([% IF record.record_source == 'batch' %]import [% END %]#[% record.record_num %]) <a href="[% record.preview_link %]" class="previewData">View MARC</a>
218
                </label>
219
                </label>
219
            </li>
220
            </li>
220
        [% END %]
221
        [% END %]
Lines 239-245 $(document).ready(function(){ Link Here
239
    </ol>
240
    </ol>
240
241
241
    [% FOREACH record IN records %]
242
    [% FOREACH record IN records %]
242
        <input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
243
        <input type="hidden" name="record" value="[% record.record_path %]" />
243
    [% END %]
244
    [% END %]
244
    <fieldset class="action">
245
    <fieldset class="action">
245
        <input type="submit" value="Next" />
246
        <input type="submit" value="Next" />
Lines 278-286 $(document).ready(function(){ Link Here
278
[% PROCESS mergetarget %]
279
[% PROCESS mergetarget %]
279
</div> <!-- .yui-u -->
280
</div> <!-- .yui-u -->
280
281
281
<input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber %]" />
282
<input type="hidden" name="ref_record" value="[% ref_record_path %]" />
282
[% FOREACH record IN records %]
283
[% FOREACH record IN records %]
283
    <input type="hidden" name="biblionumber" value="[% record.recordid %]" />
284
    <input type="hidden" name="record" value="[% record.record_path %]" />
284
[% END %]
285
[% END %]
285
<input type="hidden" name="frameworkcode" value="[% framework %]" />
286
<input type="hidden" name="frameworkcode" value="[% framework %]" />
286
287
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-2 / +3 lines)
Lines 12-19 Link Here
12
            [% IF ( record.record_type == 'biblio' ) %]
12
            [% IF ( record.record_type == 'biblio' ) %]
13
                <td colspan="5">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
13
                <td colspan="5">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
14
            [% ELSIF ( record.record_type == 'auth' ) %]
14
            [% ELSIF ( record.record_type == 'auth' ) %]
15
                <td colspan="5">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a> |
15
                <td class="highlight" colspan="5">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a> |
16
        <a href="/cgi-bin/koha/authorities/merge.pl?mergereference=breeding&authid=[% record_lis.match_id %]&authid=[% record_lis.import_record_id %]">Merge</a>
16
                    <a href="/cgi-bin/koha/authorities/merge.pl?ref_record=batch-[% import_batch_id %]/[% record_lis.import_record_id %]&record=catalog/[% record_lis.match_id %]&record=batch-[% import_batch_id %]/[% record_lis.import_record_id %]">Merge</a>
17
                </td>
17
                </td>
18
            [% END %]
18
            [% END %]
19
        </tr>
19
        </tr>
Lines 125-130 $(document).ready(function(){ Link Here
125
            }
125
            }
126
            if (aData['diff_url']){
126
            if (aData['diff_url']){
127
                $('td:eq(5)', nRow).html(
127
                $('td:eq(5)', nRow).html(
128
                    (aData['merge_url'] ? '<a href="'+aData['merge_url']+'">Merge</a> ' : '') +
128
                    '<a href="'+aData['diff_url']+'">View</a>'
129
                    '<a href="'+aData['diff_url']+'">View</a>'
129
                );
130
                );
130
            }
131
            }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-1 / +1 lines)
Lines 207-213 $(document).ready(function(){ Link Here
207
        } else {
207
        } else {
208
            var params = [];
208
            var params = [];
209
            $(checkboxes).each(function() {
209
            $(checkboxes).each(function() {
210
                params.push('biblionumber=' + $(this).val());
210
                params.push('record=catalog/' + $(this).val());
211
            });
211
            });
212
            var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
212
            var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
213
            location.href = url;
213
            location.href = url;
(-)a/koha-tmpl/intranet-tmpl/prog/js/merge-record.js (+58 lines)
Lines 181-184 $(document).ready(function(){ Link Here
181
      }
181
      }
182
      rebuild_target($('#tabs'), $('#resultul'));
182
      rebuild_target($('#tabs'), $('#resultul'));
183
    });
183
    });
184
185
    // Keep track of all the class names added; easier than finding the right one to remove later.
186
    var record_class_names = '';
187
188
    // Start by marking subfield as unique to its record.
189
    $('.record').each( function(i) {
190
      var record_class = 'merge-record-unique-' + i;
191
      record_class_names += record_class + ' ';
192
193
      $(this).find('.merge-record-fixed-contents, .merge-record-subfield').addClass( record_class );
194
    } );
195
196
    // Mark the tabs the same color as the subfields.
197
    $(window).load( function() { $('#tabs a.ui-tabs-anchor').addClass( function(i) { return 'merge-record-unique-' + i } ) } );
198
199
    // We iterate through every subfield of every field of the first record, and check to see if it
200
    // exists in every other record.
201
    //
202
    // I'm sorry if this leaves you feeling... loopy.
203
    $('.record').eq(0).find('.merge-record-field').each( function() {
204
      var field = $(this).find('.field').text();
205
206
      $(this).find('.merge-record-fixed-contents, .merge-record-subfield').each( function() {
207
        var text = field + $(this).text().replace(/\s+/g, ' ');
208
        var $matching_subfields = $(this);
209
        var common_subfield = true;
210
211
        $('.record').slice(1).each( function() {
212
          var found = false;
213
          $(this).find('.merge-record-field').each( function() {
214
            var other_field = $(this).find('.field').text();
215
            $(this).find('.merge-record-fixed-contents, .merge-record-subfield').each( function() {
216
              var other_text = field + $(this).text().replace(/\s+/g, ' ');
217
218
              if (other_text == text) {
219
                // Little jQueryism to build up a custom set of elements that we can later remove
220
                // classes from all at once.
221
                $matching_subfields = $matching_subfields.add(this);
222
                found = true;
223
                return false;
224
              }
225
            } );
226
227
            if (found == true) return false;
228
          } );
229
230
          if (found == false) {
231
            common_subfield = false;
232
            return false;
233
          }
234
        } );
235
236
        if (common_subfield) {
237
          // If the subfield exists in all records, remove the "unique" class from all of them.
238
          $matching_subfields.removeClass(record_class_names);
239
        }
240
      } );
241
    } );
184
});
242
});
(-)a/tools/batch_records_ajax.pl (-2 / +6 lines)
Lines 78-83 foreach my $record (@$records) { Link Here
78
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
78
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
79
    my $match_citation = '';
79
    my $match_citation = '';
80
    my $match_id;
80
    my $match_id;
81
    my $script_name;
81
    if ( $#$match > -1 ) {
82
    if ( $#$match > -1 ) {
82
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
83
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
83
            $match_citation .= $match->[0]->{'title'}
84
            $match_citation .= $match->[0]->{'title'}
Lines 85-96 foreach my $record (@$records) { Link Here
85
            $match_citation .= ' ' . $match->[0]->{'author'}
86
            $match_citation .= ' ' . $match->[0]->{'author'}
86
              if defined( $match->[0]->{'author'} );
87
              if defined( $match->[0]->{'author'} );
87
            $match_id = $match->[0]->{'biblionumber'};
88
            $match_id = $match->[0]->{'biblionumber'};
89
            $script_name = 'cataloguing/merge.pl';
88
        }
90
        }
89
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
91
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
90
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
92
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
91
                $match_citation .= $match->[0]->{'authorized_heading'};
93
                $match_citation .= $match->[0]->{'authorized_heading'};
92
                $match_id = $match->[0]->{'candidate_match_id'};
94
                $match_id = $match->[0]->{'candidate_match_id'};
93
            }
95
            }
96
            # Uncomment this when support for merging authorities is ready
97
            #$script_name = 'authorities/merge.pl';
94
        }
98
        }
95
    }
99
    }
96
100
Lines 107-113 foreach my $record (@$records) { Link Here
107
          || q{},
111
          || q{},
108
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
112
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
109
        match_id => $match_id,
113
        match_id => $match_id,
110
        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef
114
        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef,
115
        merge_url => ($match_id && $script_name) ? "/cgi-bin/koha/$script_name?ref_record=batch-$record->{import_batch_id}/$record->{import_record_id}&record=catalog/$match_id&record=batch-$record->{import_batch_id}/$record->{import_record_id}" : undef
111
      };
116
      };
112
}
117
}
113
118
114
- 

Return to bug 14578