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

(-)a/Koha/Util/MARC.pm (-24 / +13 lines)
Lines 46-61 sub createMergeHash { Link Here
46
            if ( !defined($tagslib)
46
            if ( !defined($tagslib)
47
                || $tagslib->{$fieldtag}->{'@'}->{'tab'} >= 0 )
47
                || $tagslib->{$fieldtag}->{'@'}->{'tab'} >= 0 )
48
            {
48
            {
49
                push @array,
49
                push @array, {
50
                  {
50
                    tag   => $fieldtag,
51
                    field => [
51
                    key   => _createKey(),
52
                        {
52
                    value => $field->data(),
53
                            tag   => $fieldtag,
53
                };
54
                            key   => _createKey(),
55
                            value => $field->data(),
56
                        }
57
                    ]
58
                  };
59
            }
54
            }
60
        }
55
        }
61
        else {
56
        else {
Lines 65-76 sub createMergeHash { Link Here
65
                if ( !defined($tagslib)
60
                if ( !defined($tagslib)
66
                    || $tagslib->{$fieldtag}->{ @$subfield[0] }->{'tab'} >= 0 )
61
                    || $tagslib->{$fieldtag}->{ @$subfield[0] }->{'tab'} >= 0 )
67
                {
62
                {
68
                    push @subfield_array,
63
                    push @subfield_array, {
69
                      {
70
                        subtag => @$subfield[0],
64
                        subtag => @$subfield[0],
71
                        subkey => _createKey(),
65
                        subkey => _createKey(),
72
                        value  => @$subfield[1],
66
                        value  => @$subfield[1],
73
                      };
67
                    };
74
                }
68
                }
75
69
76
            }
70
            }
Lines 78-94 sub createMergeHash { Link Here
78
            if ( ( !defined($tagslib) || $tagslib->{$fieldtag}->{'tab'} >= 0 )
72
            if ( ( !defined($tagslib) || $tagslib->{$fieldtag}->{'tab'} >= 0 )
79
                && @subfield_array )
73
                && @subfield_array )
80
            {
74
            {
81
                push @array,
75
                push @array, {
82
                  {
76
                      tag        => $fieldtag,
83
                    field => [
77
                      key        => _createKey(),
84
                        {
78
                      indicator1 => $field->indicator(1),
85
                            tag        => $fieldtag,
79
                      indicator2 => $field->indicator(2),
86
                            key        => _createKey(),
80
                      subfield   => [@subfield_array],
87
                            indicator1 => $field->indicator(1),
88
                            indicator2 => $field->indicator(2),
89
                            subfield   => [@subfield_array],
90
                        }
91
                    ]
92
                  };
81
                  };
93
            }
82
            }
94
83
(-)a/cataloguing/merge.pl (-125 / +157 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
4
# Copyright 2009 BibLibre
3
# Copyright 2009 BibLibre
5
# Parts Copyright Catalyst IT 2011
4
# Parts Copyright Catalyst IT 2011
6
#
5
#
Lines 19-26 Link Here
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
20
22
use strict;
21
use Modern::Perl;
23
#use warnings; FIXME - Bug 2505
22
24
use CGI;
23
use CGI;
25
use C4::Output;
24
use C4::Output;
26
use C4::Auth;
25
use C4::Auth;
Lines 33-46 use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/; Link Here
33
use Koha::MetadataRecord;
32
use Koha::MetadataRecord;
34
33
35
my $input = new CGI;
34
my $input = new CGI;
36
my @biblionumber = $input->param('biblionumber');
35
my @biblionumbers = $input->param('biblionumber');
37
my $merge = $input->param('merge');
36
my $merge = $input->param('merge');
38
37
39
my @errors;
38
my @errors;
40
39
41
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42
    {
41
    {
43
        template_name   => "cataloguing/merge.tmpl",
42
        template_name   => "cataloguing/merge.tt",
44
        query           => $input,
43
        query           => $input,
45
        type            => "intranet",
44
        type            => "intranet",
46
        authnotrequired => 0,
45
        authnotrequired => 0,
Lines 54-81 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
54
if ($merge) {
53
if ($merge) {
55
54
56
    my $dbh = C4::Context->dbh;
55
    my $dbh = C4::Context->dbh;
57
    my $sth;
58
56
59
    # Creating a new record from the html code
57
    # Creating a new record from the html code
60
    my $record       = TransformHtmlToMarc( $input );
58
    my $record       = TransformHtmlToMarc( $input );
61
    my $tobiblio     =  $input->param('biblio1');
59
    my $ref_biblionumber = $input->param('ref_biblionumber');
62
    my $frombiblio   =  $input->param('biblio2');
60
    @biblionumbers = grep { $_ != $ref_biblionumber } @biblionumbers;
61
62
    # prepare report
63
    my @report_records;
64
    my $report_fields_str = $input->param('report_fields');
65
    $report_fields_str ||= C4::Context->preference('MergeReportFields');
66
    my @report_fields;
67
    foreach my $field_str (split /,/, $report_fields_str) {
68
        if ($field_str =~ /(\d{3})([0-9a-z]*)/) {
69
            my ($field, $subfields) = ($1, $2);
70
            push @report_fields, {
71
                tag => $field,
72
                subfields => [ split //, $subfields ]
73
            }
74
        }
75
    }
63
76
64
    # Rewriting the leader
77
    # Rewriting the leader
65
    $record->leader(GetMarcBiblio($tobiblio)->leader());
78
    $record->leader(GetMarcBiblio($ref_biblionumber)->leader());
66
79
67
    my $frameworkcode = $input->param('frameworkcode');
80
    my $frameworkcode = $input->param('frameworkcode');
68
    my @notmoveditems;
81
    my @notmoveditems;
69
82
70
    # Modifying the reference record
83
    # Modifying the reference record
71
    ModBiblio($record, $tobiblio, $frameworkcode);
84
    ModBiblio($record, $ref_biblionumber, $frameworkcode);
72
85
73
    # Moving items from the other record to the reference record
86
    # Moving items from the other record to the reference record
74
    # Also moving orders from the other record to the reference record, only if the order is linked to an item of the other record
87
    foreach my $biblionumber (@biblionumbers) {
75
    my $itemnumbers = get_itemnumbers_of($frombiblio);
88
        my $itemnumbers = get_itemnumbers_of($biblionumber);
76
    foreach my $itloop ($itemnumbers->{$frombiblio}) {
89
        foreach my $itemnumber (@{ $itemnumbers->{$biblionumber} }) {
77
    foreach my $itemnumber (@$itloop) {
90
        my $res = MoveItemFromBiblio($itemnumber, $biblionumber, $ref_biblionumber);
78
        my $res = MoveItemFromBiblio($itemnumber, $frombiblio, $tobiblio);
79
        if (not defined $res) {
91
        if (not defined $res) {
80
            push @notmoveditems, $itemnumber;
92
            push @notmoveditems, $itemnumber;
81
        }
93
        }
Lines 87-223 if ($merge) { Link Here
87
        push @errors, { code => "CANNOT_MOVE", value => $itemlist };
99
        push @errors, { code => "CANNOT_MOVE", value => $itemlist };
88
    }
100
    }
89
101
90
    # Moving subscriptions from the other record to the reference record
102
    my $sth_subscription = $dbh->prepare("
91
    my $subcount = CountSubscriptionFromBiblionumber($frombiblio);
103
        UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?
92
    if ($subcount > 0) {
104
    ");
93
    $sth = $dbh->prepare("UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?");
105
    my $sth_subscriptionhistory = $dbh->prepare("
94
    $sth->execute($tobiblio, $frombiblio);
106
        UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?
95
107
    ");
96
    $sth = $dbh->prepare("UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?");
108
    my $sth_serial = $dbh->prepare("
97
    $sth->execute($tobiblio, $frombiblio);
109
        UPDATE serial SET biblionumber = ? WHERE biblionumber = ?
98
110
    ");
111
112
    my $report_header = {};
113
    foreach my $biblionumber ($ref_biblionumber, @biblionumbers) {
114
        # build report
115
        my $marcrecord = GetMarcBiblio($biblionumber);
116
        my %report_record = (
117
            biblionumber => $biblionumber,
118
            fields => {},
119
        );
120
        foreach my $field (@report_fields) {
121
            my @marcfields = $marcrecord->field($field->{tag});
122
            foreach my $marcfield (@marcfields) {
123
                my $tag = $marcfield->tag();
124
                my %subfields;
125
                if (scalar @{$field->{subfields}}) {
126
                    foreach my $subfield (@{$field->{subfields}}) {
127
                        my @values = $marcfield->subfield($subfield);
128
                        $report_header->{ $tag . $subfield } = 1;
129
                        push @{ $report_record{fields}->{$tag . $subfield} }, @values;
130
                    }
131
                } elsif ($field->{tag} gt '009') {
132
                    my @marcsubfields = $marcfield->subfields();
133
                    foreach my $marcsubfield (@marcsubfields) {
134
                        my ($code, $value) = @$marcsubfield;
135
                        $report_header->{ $tag . $code } = 1;
136
                        push @{ $report_record{fields}->{ $tag . $code } }, $value;
137
                    }
138
                } else {
139
                    $report_header->{ $tag . '@' } = 1;
140
                    push @{ $report_record{fields}->{ $tag .'@' } }, $marcfield->data();
141
                }
142
            }
143
        }
144
        push @report_records, \%report_record;
99
    }
145
    }
100
146
101
    # Moving serials
147
    foreach my $biblionumber (@biblionumbers) {
102
    $sth = $dbh->prepare("UPDATE serial SET biblionumber = ? WHERE biblionumber = ?");
148
        # Moving subscriptions from the other record to the reference record
103
    $sth->execute($tobiblio, $frombiblio);
149
        my $subcount = CountSubscriptionFromBiblionumber($biblionumber);
150
        if ($subcount > 0) {
151
            $sth_subscription->execute($ref_biblionumber, $biblionumber);
152
            $sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber);
153
        }
104
154
105
    # TODO : Moving reserves
155
    # Moving serials
156
        $sth_serial->execute($ref_biblionumber, $biblionumber);
106
157
107
    # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
158
    # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
108
    my @allorders = GetOrdersByBiblionumber($frombiblio);
159
    my @allorders = GetOrdersByBiblionumber($biblionumber);
109
    my @tobiblioitem = GetBiblioItemByBiblioNumber ($tobiblio);
160
    my @tobiblioitem = GetBiblioItemByBiblioNumber ($ref_biblionumber);
110
    my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber };
161
    my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber };
111
    foreach my $myorder (@allorders) {
162
    foreach my $myorder (@allorders) {
112
        $myorder->{'biblionumber'} = $tobiblio;
163
        $myorder->{'biblionumber'} = $ref_biblionumber;
113
        ModOrder ($myorder);
164
        ModOrder ($myorder);
114
    # TODO : add error control (in ModOrder?)
165
    # TODO : add error control (in ModOrder?)
115
    }
166
    }
116
167
117
    # Deleting the other record
168
    # Deleting the other records
118
    if (scalar(@errors) == 0) {
169
    if (scalar(@errors) == 0) {
119
    # Move holds
170
        # Move holds
120
    MergeHolds($dbh,$tobiblio,$frombiblio);
171
        MergeHolds($dbh, $ref_biblionumber, $biblionumber);
121
    my $error = DelBiblio($frombiblio);
172
        my $error = DelBiblio($biblionumber);
122
    push @errors, $error if ($error);
173
        push @errors, $error if ($error);
123
    }
174
    }
175
}
124
176
125
    # Parameters
177
    # Parameters
126
    $template->param(
178
    $template->param(
127
    result => 1,
179
        result => 1,
128
    biblio1 => $input->param('biblio1')
180
        report_records => \@report_records,
181
        report_header => $report_header,
182
        ref_biblionumber => $input->param('ref_biblionumber')
129
    );
183
    );
130
184
131
#-------------------------
185
#-------------------------
132
# Show records to merge
186
# Show records to merge
133
#-------------------------
187
#-------------------------
134
} else {
188
} else {
135
    my $mergereference = $input->param('mergereference');
189
    my $ref_biblionumber = $input->param('ref_biblionumber');
136
    my $biblionumber = $input->param('biblionumber');
190
137
191
    if ($ref_biblionumber) {
138
    if (scalar(@biblionumber) != 2) {
192
        my $framework = $input->param('frameworkcode');
139
        push @errors, { code => "WRONG_COUNT", value => scalar(@biblionumber) };
193
        $framework //= GetFrameworkCode($ref_biblionumber);
140
    }
194
141
    else {
195
        # Getting MARC Structure
142
        my $data1 = GetBiblioData($biblionumber[0]);
196
        my $tagslib = GetMarcStructure(1, $framework);
143
        my $record1 = GetMarcBiblio($biblionumber[0]);
197
144
198
        my $marcflavour = lc(C4::Context->preference('marcflavour'));
145
        my $data2 = GetBiblioData($biblionumber[1]);
199
146
        my $record2 = GetMarcBiblio($biblionumber[1]);
200
        # Creating a loop for display
147
201
        my @records;
148
        # Checks if both records use the same framework
202
        foreach my $biblionumber (@biblionumbers) {
149
        my $frameworkcode1 = &GetFrameworkCode($biblionumber[0]);
203
            my $marcrecord = GetMarcBiblio($biblionumber);
150
        my $frameworkcode2 = &GetFrameworkCode($biblionumber[1]);
204
            my $frameworkcode = GetFrameworkCode($biblionumber);
151
205
            my $recordObj = new Koha::MetadataRecord({'record' => $marcrecord, schema => $marcflavour});
152
206
            my $record = {
153
        my $subtitle1 = GetRecordValue('subtitle', $record1, $frameworkcode1);
207
                biblionumber => $biblionumber,
154
        my $subtitle2 = GetRecordValue('subtitle', $record2, $frameworkcode1);
208
                record => $marcrecord,
155
209
                frameworkcode => $frameworkcode,
156
        if ($mergereference) {
210
                display => $recordObj->createMergeHash($tagslib),
157
211
            };
158
            my $framework;
212
            if ($ref_biblionumber and $ref_biblionumber == $biblionumber) {
159
            if ($frameworkcode1 ne $frameworkcode2) {
213
                $record->{reference} = 1;
160
                $framework = $input->param('frameworkcode')
214
                $template->param(ref_record => $record);
161
                  or push @errors, "Famework not selected.";
215
                unshift @records, $record;
162
            } else {
216
            } else {
163
                $framework = $frameworkcode1;
217
                push @records, $record;
164
            }
218
            }
165
166
            # Getting MARC Structure
167
            my $tagslib = GetMarcStructure(1, $framework);
168
169
            my $notreference = ($biblionumber[0] == $mergereference) ? $biblionumber[1] : $biblionumber[0];
170
171
            # Creating a loop for display
172
173
            my $recordObj1 = new Koha::MetadataRecord({ 'record' => GetMarcBiblio($mergereference), 'schema' => lc C4::Context->preference('marcflavour') });
174
            my $recordObj2 = new Koha::MetadataRecord({ 'record' => GetMarcBiblio($notreference), 'schema' => lc C4::Context->preference('marcflavour') });
175
176
            my @record1 = $recordObj1->createMergeHash($tagslib);
177
            my @record2 = $recordObj2->createMergeHash($tagslib);
178
179
            # Parameters
180
            $template->param(
181
                biblio1 => $mergereference,
182
                biblio2 => $notreference,
183
                mergereference => $mergereference,
184
                record1 => @record1,
185
                record2 => @record2,
186
                framework => $framework,
187
            );
188
        }
219
        }
189
        else {
190
220
221
        my ($biblionumbertag) = GetMarcFromKohaField('biblio.biblionumber');
222
223
        # Parameters
224
        $template->param(
225
            ref_biblionumber => $ref_biblionumber,
226
            records => \@records,
227
            ref_record => $records[0],
228
            framework => $framework,
229
            biblionumbertag => $biblionumbertag,
230
            MergeReportFields => C4::Context->preference('MergeReportFields'),
231
        );
232
    } else {
233
        my @records;
234
        foreach my $biblionumber (@biblionumbers) {
235
            my $frameworkcode = GetFrameworkCode($biblionumber);
236
            my $record = {
237
                biblionumber => $biblionumber,
238
                data => GetBiblioData($biblionumber),
239
                frameworkcode => $frameworkcode,
240
            };
241
            push @records, $record;
242
        }
191
        # Ask the user to choose which record will be the kept
243
        # Ask the user to choose which record will be the kept
192
            $template->param(
244
        $template->param(
193
                choosereference => 1,
245
            choosereference => 1,
194
                biblio1 => $biblionumber[0],
246
            records => \@records,
195
                biblio2 => $biblionumber[1],
247
        );
196
                title1 => $data1->{'title'},
248
197
                subtitle1 => $subtitle1,
249
        my $frameworks = getframeworks;
198
                title2 => $data2->{'title'},
250
        my @frameworkselect;
199
                subtitle2 => $subtitle2
251
        foreach my $thisframeworkcode ( keys %$frameworks ) {
252
            my %row = (
253
                value         => $thisframeworkcode,
254
                frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
200
            );
255
            );
201
            if ($frameworkcode1 ne $frameworkcode2) {
256
            push @frameworkselect, \%row;
202
                my $frameworks = getframeworks;
203
                my @frameworkselect;
204
                foreach my $thisframeworkcode ( keys %$frameworks ) {
205
                    my %row = (
206
                        value         => $thisframeworkcode,
207
                        frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
208
                    );
209
                    if ($frameworkcode1 eq $thisframeworkcode){
210
                        $row{'selected'} = 1;
211
                        }
212
                    push @frameworkselect, \%row;
213
                }
214
                $template->param(
215
                    frameworkselect => \@frameworkselect,
216
                    frameworkcode1 => $frameworkcode1,
217
                    frameworkcode2 => $frameworkcode2,
218
                );
219
            }
220
        }
257
        }
258
        $template->param(
259
            frameworkselect => \@frameworkselect,
260
        );
221
    }
261
    }
222
}
262
}
223
263
Lines 228-238 if (@errors) { Link Here
228
268
229
output_html_with_http_headers $input, $cookie, $template->output;
269
output_html_with_http_headers $input, $cookie, $template->output;
230
exit;
270
exit;
231
232
=head1 FUNCTIONS
233
234
=cut
235
236
# ------------------------
237
# Functions
238
# ------------------------
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 427-429 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MergeReportFields','','Displayed fields for deleted MARC records after merge',NULL,'Free');
(-)a/installer/data/mysql/updatedatabase.pl (+14 lines)
Lines 7017-7022 if ( CheckVersion($DBversion) ) { Link Here
7017
    SetVersion($DBversion);
7017
    SetVersion($DBversion);
7018
}
7018
}
7019
7019
7020
7021
7022
7023
$DBversion = "3.13.00.XXX";
7024
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7025
    $dbh->do("
7026
        INSERT INTO systempreferences (variable,value,explanation,options,type)
7027
        VALUES('MergeReportFields','','Displayed fields for deleted MARC records after merge',NULL,'Free');
7028
    ");
7029
    print "Upgrade to $DBversion done (Add system preference 'MergeReportFields')\n";
7030
    SetVersion($DBversion);
7031
}
7032
7033
7020
=head1 FUNCTIONS
7034
=head1 FUNCTIONS
7021
7035
7022
=head2 TableExists($table)
7036
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc (-199 / +223 lines)
Lines 1-227 Link Here
1
[% BLOCK sourcetab %]
1
[% BLOCK sourcetab %]
2
    <div id="tabrecord[% recordnumber %]">
2
    <div id="tabrecord[% record.biblionumber %]">
3
    [% IF ( records ) %]
4
5
        <div class="record">
3
        <div class="record">
6
        <ul id="ulrecord[% recordnumber %]">
4
            <ul id="ulrecord[% record.biblionumber %]">
7
        [% FOREACH record IN records %]
5
                [% FOREACH field IN record.display %]
8
            [% FOREACH fiel IN record.field %]
6
                  [% IF field.tag != biblionumbertag %]
9
            <li id="k[% fiel.key %]">
7
                    <li id="k[% field.key %]">
10
                [% IF (defaultrecord) %]
8
                        [% IF (tabrecord.reference) %]
11
                    <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% recordnumber %]_[% fiel.key %]" />
9
                            <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% record.biblionumber %]_[% field.key %]" />
12
                [% ELSE %]
13
                    <input type="checkbox" class="fieldpick" id="rec_[% recordnumber %]_[% fiel.key %]" />
14
                [% END %]
15
                <span class="field">[% fiel.tag %]</span>
16
17
                <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
18
                <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
19
                [% IF ( fiel.value ) %] / [% fiel.value %]
20
                <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
21
                <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
22
                [% END %]
23
24
                [% IF ( fiel.subfield ) %]
25
                <ul>
26
                    [% FOREACH subfiel IN fiel.subfield %]
27
                    <li id="k[% subfiel.subkey %]">
28
                        [% IF (defaultrecord) %]
29
                            <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% recordnumber %]_[% subfiel.subkey %]" />
30
                        [% ELSE %]
10
                        [% ELSE %]
31
                            <input type="checkbox" class="subfieldpick" id="rec_[% recordnumber %]_[% subfiel.subkey %]" />
11
                            <input type="checkbox" class="fieldpick" id="rec_[% record.biblionumber %]_[% field.key %]" />
12
                        [% END %]
13
                        <label for="rec_[% record.biblionumber %]_[% field.key %]"><span class="field">[% field.tag %]</span></label>
14
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 %]" />
17
                        [% IF ( field.value ) %]
18
                            / [% field.value %]
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 %]" />
21
                        [% END %]
22
23
                        [% IF ( field.subfield.size ) %]
24
                            <ul>
25
                                [% FOREACH subfield IN field.subfield %]
26
                                    <li id="k[% subfield.subkey %]">
27
                                        [% IF (tabrecord.reference) %]
28
                                            <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% record.biblionumber %]_[% subfield.subkey %]" />
29
                                        [% ELSE %]
30
                                            <input type="checkbox" class="subfieldpick" id="rec_[% record.biblionumber %]_[% subfield.subkey %]" />
31
                                        [% END %]
32
                                        <label for="rec_[% record.biblionumber %]_[% subfield.subkey %]"><span class="subfield">[% subfield.subtag %]</span> / [% subfield.value %]</label>
33
                                        <input type="hidden" name="tag_[% field.tag %]_code_[% subfield.subtag %]_[% field.key %]_[% subfield.subkey %]" value="[% subfield.subtag %]" />
34
                                        <input type="hidden" name="tag_[% field.tag %]_subfield_[% subfield.subtag %]_[% subfield.key %]_[% subfield.subkey %]" value="[% subfield.value |html%]" />
35
                                    </li>
36
                                [% END %]
37
                            </ul>
32
                        [% END %]
38
                        [% END %]
33
                        <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
34
                    <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
35
                    <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
36
                    </li>
39
                    </li>
37
                    [% END %]
40
                  [% END %]
38
                </ul>
39
                [% END %]
41
                [% END %]
40
            [% END %]
42
            </ul>
41
            </li>
42
        [% END %]
43
        </ul>
44
        </div><!-- /div.record -->
43
        </div><!-- /div.record -->
45
    [% END %]
44
    </div><!-- /div#tabrecordXXX -->
46
    </div><!-- /div#tabrecord[% recordnumber %] -->
47
[% END %]
45
[% END %]
46
48
[% BLOCK mergejs %]
47
[% BLOCK mergejs %]
49
    // Creating tabs
48
  // Creating tabs
50
    $("#tabs").tabs();
49
  $("#tabs").tabs();
51
50
52
    // Toggle a field / subfield
51
  // Toggle a field / subfield
53
    function toggleField(pField) {
52
  function toggleField(pField) {
54
53
      // Getting the key of the clicked checkbox
55
    // Getting the key of the clicked checkbox
54
      var ckid   = $(pField).attr("id");
56
    var ckid   = $(pField).attr("id");
55
      var tab    = ckid.split('_');
57
    var tab    = ckid.split('_');
56
      var source = tab[1]; // From which record the click came from
58
    var source = tab[1]; // From which record the click came from
57
      var key    = tab[2];
59
    var key    = tab[2];
58
      var type   = $(pField).attr("class");
60
    var type   = $(pField).attr("class");
59
61
60
      // Getting field/subfield
62
    // Getting field/subfield
61
      var field;
63
    var field;
62
      var subfield;
64
    var subfield;
63
      if (type == "subfieldpick") {
65
    if (type == "subfieldpick") {
64
          field = $(pField).parent().parent().parent().find("span.field").text();
66
65
          subfield = $(pField).parent().find("span.subfield").text();
67
            field = $(pField).parent().parent().parent().find("span.field").text();
66
      } else {
68
            subfield = $(pField).parent().find("span.subfield").text();
67
          field = $(pField).parent().find("span.field").text();
69
    } else {
68
      }
70
69
71
            field = $(pField).parent().find("span.field").text();
70
      // If the field has just been checked
72
    }
71
      if (pField.checked) {
73
72
          // We check for repeatability
74
    // If the field has just been checked
73
          var canbeadded = true;
75
    if (pField.checked) {
74
          if (type == "subfieldpick") {
76
75
              var repeatable = 1;
77
        // We check for repeatability
76
              var alreadyexists = 0;
78
        var canbeadded = true;
77
              if (tagslib[field] && tagslib[field][subfield]) {
79
        if (type == "subfieldpick") {
78
                  // Note : we can't use the dot notation here (tagslib.021)
80
        var repeatable = 1;
79
                  // because the key is a number
81
        var alreadyexists = 0;
80
                  repeatable = tagslib[field][subfield].repeatable;
82
        if (tagslib[field] && tagslib[field][subfield]) {
81
                  if (repeatable == 0) {
83
            repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
82
                      canbeadded = false;
84
            // TODO : Checking for subfields
83
                      $("#resultul span.field:contains(" + field + ")")
85
        }
84
                      .each(function() {
86
        } else {
85
                          if ($(this).parent()
87
        if (tagslib[field]) {
86
                              .find("span.subfield:contains(" + subfield + ")")
88
            repeatable = tagslib[field].repeatable;
87
                              .length == 0)
89
            alreadyexists = $("#resultul span.field:contains(" + field + ")");
88
                          {
90
            if (repeatable == 0 && alreadyexists.length != 0) {
89
                              canbeadded = true;
91
            canbeadded = false;
90
                          }
92
            }
91
                      });
93
        }
92
                  }
94
        }
93
              }
95
        // If the field is not repeatable, we check if it already exists in the result table
94
          } else {
96
        if (canbeadded == false) {
95
              if (tagslib[field]) {
97
        alert(_("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it."));
96
                  repeatable = tagslib[field].repeatable;
98
        pField.checked = 0;
97
                  alreadyexists = $("#resultul span.field:contains(" + field + ")");
99
        } else {
98
                  if (repeatable == 0 && alreadyexists.length != 0) {
100
99
                      canbeadded = false;
101
        // Cloning the field or subfield we picked
100
                  }
102
        var clone = $(pField).parent().clone();
101
              }
103
102
          }
104
        // Removing the checkboxes from it
103
          // If the field is not repeatable, we check if it already exists in the result table
105
        $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
104
          if (canbeadded == false) {
106
            $(this).remove();
105
              var field_or_subfield = (type == "subfieldpick") ? _("subfield") : _("field");
107
        });
106
              alert(_("The " + field_or_subfield + " is non-repeatable and already exists in the destination record. Therefore, you cannot add it."));
108
107
              pField.checked = 0;
109
108
          } else {
110
        // If we are a subfield
109
              // Cloning the field or subfield we picked
111
        if (type == "subfieldpick") {
110
              var clone = $(pField).parent().clone();
112
            // then we need to find who is our parent field...
111
113
            fieldkey = $(pField).parent().parent().parent().attr("id");
112
              // Removing the checkboxes from it
114
113
              $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
115
            // Find where to add the subfield
114
                  $(this).remove();
116
115
              });
117
            // First, check if the field is not already in the destination record
116
              $(clone).find('label').each(function() {
118
            if ($("#resultul li#" + fieldkey).length > 0) {
117
                  $(this).replaceWith($(this).contents());
119
            // If so, we add our field to it
118
              });
120
            $("#resultul li#" + fieldkey + " ul").append(clone);
119
121
            } else {
120
              // If we are a subfield
122
            // If not, we add the subfield to the first matching field
121
              if (type == "subfieldpick") {
123
            var where = 0;
122
                  // then we need to find who is our parent field...
124
            $("#resultul li span.field").each(function() {
123
                  fieldkey = $(pField).parent().parent().parent().attr("id");
125
                if (where == 0 && $(this).text() == field) {
124
126
                where = this;
125
                  // Find where to add the subfield
127
                }
126
128
            });
127
                  // First, check if the field is not already in the destination record
129
128
                  if ($("#resultul li#" + fieldkey).length > 0) {
130
            // If there is no matching field in the destination record
129
                      // If so, we add our field to it
131
            if (where == 0) {
130
                      $("#resultul li#" + fieldkey + " ul").append(clone);
132
131
                  } else {
133
                // TODO:
132
                      // If not, we add the subfield to the first matching field
134
                // We select the whole field and removing non-selected subfields, instead of...
133
                      var where = 0;
135
134
                      $("#resultul li span.field").each(function() {
136
                // Alerting the user
135
                          if (where == 0 && $(this).text() == field) {
137
                alert(_("This subfield cannot be added: there is no") + " " + field + " " + _("field in the destination record."));
136
                              where = this;
138
                pField.checked = false;
137
                          }
139
138
                      });
140
            } else {
139
141
                $(where).nextAll("ul").append(clone);
140
                      // If there is no matching field in the destination record
142
            }
141
                      if (where == 0) {
143
142
                          // TODO:
144
            }
143
                          // We select the whole field and removing non-selected subfields, instead of...
145
144
146
145
                          // Alerting the user
147
146
                          alert(_("This subfield cannot be added: there is no " + field + " field in the destination record."));
148
        } else {
147
                          pField.checked = false;
149
            // If we are a field
148
150
            var where = 0;
149
                      } else {
151
            // Find where to add the field
150
                          $(where).nextAll("ul").append(clone);
152
            $("#resultul li span.field").each(function() {
151
                      }
153
            if (where == 0 && $(this).text() > field) {
152
                  }
154
                where = this;
153
              } else {
155
            }
154
                  // If we are a field
156
            });
155
                  var where = 0;
157
156
                  // Find where to add the field
158
            $(where).parent().before(clone);
157
                  $("#resultul li span.field").each(function() {
159
        }
158
                      if (where == 0 && $(this).text() > field) {
160
        }
159
                          where = this;
161
    } else {
160
                      }
162
161
                  });
163
        // Else, we remove it from the results tab
162
                  if (where) {
164
        $("ul#resultul li#k" + key).remove();
163
                      $(where).parent().before(clone);
165
    }
164
                  } else {
166
}
165
                      $("#resultul").append(clone);
167
166
                  }
168
167
              }
169
    // When a field is checked / unchecked
168
          }
170
    $('input.fieldpick').click(function() {
169
      } else {
171
    toggleField(this);
170
          // Else, we remove it from the results tab
172
    // (un)check all subfields
171
          $("ul#resultul li#k" + key).remove();
173
    var ischecked = this.checked;
172
      }
174
    $(this).parent().find("input.subfieldpick").each(function() {
173
  }
175
        this.checked = ischecked;
174
176
    });
175
  // Check all checkboxes in first tab, and uncheck all others to avoid
177
    });
176
  // inconsistencies from a page refresh.
178
177
  $('#tabs div#tabrecord[% ref_biblionumber %]').find('input[type="checkbox"]').attr('checked', true);
179
    // When a field or subfield is checked / unchecked
178
  $('#tabs > div:not("#tabrecord[% ref_biblionumber %]")').find('input[type="checkbox"]').removeAttr('checked');
180
    $("input.subfieldpick").click(function() {
179
181
    toggleField(this);
180
  // When a field is checked / unchecked
182
    });
181
  $('input.fieldpick').click(function() {
182
      toggleField(this);
183
      // (un)check all subfields
184
      var ischecked = this.checked;
185
      $(this).parent().find("input.subfieldpick").each(function() {
186
          this.checked = ischecked;
187
      });
188
  });
189
190
  // When a field or subfield is checked / unchecked
191
  $("input.subfieldpick").click(function() {
192
      toggleField(this);
193
  });
183
[% END %]
194
[% END %]
195
184
[% BLOCK mergesource %]
196
[% BLOCK mergesource %]
185
<div id="tabs" class="toptabs">
197
<div id="tabs" class="toptabs">
186
<h2>Source records</h2>
198
<h2>Source records</h2>
187
    <ul>
199
    <ul>
188
    <li><a href="#tabrecord1">[% recordid1 %]</a></li>
200
        [% FOREACH record IN sourcerecords %]
189
    <li><a href="#tabrecord2">[% recordid2 %]</a></li>
201
            <li>
202
                <a href="#tabrecord[% record.biblionumber %]">
203
                    [% record.biblionumber %]
204
                    [% IF record.reference %](ref)[% END %]
205
                </a>
206
            </li>
207
        [% END %]
190
    </ul>
208
    </ul>
191
    [% PROCESS sourcetab records=record1 recordnumber=1 defaultrecord=1 %]
209
    [% IF ( sourcerecords.size ) %]
192
    [% PROCESS sourcetab records=record2 recordnumber=2 defaultrecord=0 %]
210
        [% FOREACH record IN sourcerecords %]
211
            [% PROCESS sourcetab tabrecord=record %]
212
        [% END %]
213
    [% END %]
193
</div> <!-- // #tabs -->
214
</div> <!-- // #tabs -->
194
[% END %]
215
[% END %]
216
195
[% BLOCK mergetarget %]
217
[% BLOCK mergetarget %]
196
<div id="result">
218
<div id="result">
197
    <h2>Destination record</h2>
219
    <h2>Destination record</h2>
198
    <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
220
    <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
199
        <ul id="resultul">
221
        <ul id="resultul">
200
        [% FOREACH record IN record1 %]
222
          [% FOREACH field IN ref_record.display %]
201
            [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]">
223
            [% IF field.tag != biblionumbertag %]
202
                <span class="field">[% fiel.tag %]</span>
224
              <li id="k[% field.key %]">
203
                <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
225
                <span class="field">[% field.tag %]</span>
204
                <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
226
                <input type="hidden" name="tag_[% field.tag %]_indicator1_[% field.key %]" value="[% field.indicator1 %]" />
205
                [% IF ( fiel.value ) %] /
227
                <input type="hidden" name="tag_[% field.tag %]_indicator2_[% field.key %]" value="[% field.indicator2 %]" />
206
                    [% fiel.value %]
228
                [% IF ( field.value ) %]
207
                    <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
229
                  / [% field.value %]
208
                    <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
230
                  <input type="hidden" name="tag_[% field.tag %]_code_00_[% field.key %]" value="00" />
231
                  <input type="hidden" name="tag_[% field.tag %]_subfield_00_[% field.key %]" value="[% field.value |html%]" />
209
                [% END %]
232
                [% END %]
210
233
211
                [% IF ( fiel.subfield ) %]
234
                [% IF ( field.subfield ) %]
212
                    <ul>
235
                  <ul>
213
                        [% FOREACH subfiel IN fiel.subfield %]
236
                    [% FOREACH subfield IN field.subfield %]
214
                            <li id="k[% subfiel.subkey %]">
237
                      <li id="k[% subfield.subkey %]">
215
                                <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
238
                        <span class="subfield">[% subfield.subtag %]</span> / [% subfield.value %]
216
                                <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
239
                        <input type="hidden" name="tag_[% field.tag %]_code_[% subfield.subtag %]_[% field.key %]_[% subfield.subkey %]" value="[% subfield.subtag %]" />
217
                                <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
240
                        <input type="hidden" name="tag_[% field.tag %]_subfield_[% subfield.subtag %]_[% field.key %]_[% subfield.subkey %]" value="[% subfield.value |html%]" />
218
                            </li>
241
                      </li>
219
                        [% END %]
242
                    [% END %]
220
                    </ul>
243
                  </ul>
221
                [% END %]
244
                [% END %]
222
            </li>[% END %]
245
              </li>
223
        [% END %]
246
            [% END %]
247
          [% END %]
224
        </ul>
248
        </ul>
225
    </div>
249
</div>
226
</div> <!-- // #result -->
250
</div> <!-- // #result -->
227
[% END %]
251
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+9 lines)
Lines 176-178 Cataloging: Link Here
176
            - pref: NotesBlacklist
176
            - pref: NotesBlacklist
177
              class: multi
177
              class: multi
178
            - note fields in title notes separator (OPAC record details) and in the description separator (Staff client record details). The fields should appear separated with commas and according with the Koha MARC format (eg 3.. for UNIMARC, 5.. for MARC21)
178
            - note fields in title notes separator (OPAC record details) and in the description separator (Staff client record details). The fields should appear separated with commas and according with the Koha MARC format (eg 3.. for UNIMARC, 5.. for MARC21)
179
        -
180
            - pref: MergeReportFields
181
            - "fields to display for deleted records after merge"
182
            - "<br />example: '001,245ab,600'"
183
            - "displays:"
184
            - "<ul>"
185
            - "<li>value of 001</li>"
186
            - "<li>subfields a and b of fields 245</li>"
187
            - "<li>all subfields of fields 600</li>"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt (-57 / +176 lines)
Lines 10-21 div#result { margin-top: 1em; } Link Here
10
</style>
10
</style>
11
<script type="text/javascript">
11
<script type="text/javascript">
12
//<![CDATA[
12
//<![CDATA[
13
[% UNLESS (result) %]
14
  [% IF (choosereference) %]
15
    function changeFramework(fw) {
16
        $("#frameworkcode").val(fw);
17
    }
18
  [% ELSE %]
19
    function check_mandatory () {
20
        var missing = {
21
            'fields': [],
22
            'subfields': []
23
        };
24
        for (tag in tagslib) {
25
            if (tag == '000' || tag == '001')
26
                continue;
27
            if (tagslib[tag].mandatory == 1) {
28
                if ($("#resultul span.field:contains("+ tag +")").length == 0) {
29
                    missing.fields.push(tag);
30
                }
31
            }
32
            for (subfieldcode in tagslib[tag]) {
33
                if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
34
                || subfieldcode == 'repeatable' || subfieldcode == 'tab') {
35
                    continue;
36
                }
37
                if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
38
                    var fields = $("#resultul span.field:contains("+ tag +")");
39
                    $(fields).each(function() {
40
                        var subfields = $(this).parent().find("span.subfield:contains("+ subfieldcode +")");
41
                        if (subfields.length == 0) {
42
                            missing.subfields.push( {
43
                                'tag': tag,
44
                                'subfieldcode': subfieldcode
45
                            } );
46
                        }
47
                    });
48
                }
49
            }
50
        }
51
        return missing;
52
    }
13
53
14
    // When submiting the form
54
    // When submiting the form
15
    function mergeformsubmit() {
55
    function mergeformsubmit() {
16
	    $("ul#ulrecord1").remove();
56
        var missing = check_mandatory();
17
	    $("ul#ulrecord2").remove();
57
        var alert_msg = '';
18
}
58
        var error = 0;
59
        if (missing.fields.length > 0) {
60
            alert_msg += _("Following required fields are missing:") + "\n";
61
            for (var i in missing.fields) {
62
                alert_msg += "\t- " + missing.fields[i] + "\n";
63
                error ++;
64
            }
65
            alert_msg += "\n";
66
        }
67
        if (missing.subfields.length > 0) {
68
            alert_msg += _("Following required subfields are missing:") + "\n";
69
            for (var i in missing.subfields) {
70
                var subfield = missing.subfields[i];
71
                alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
72
                error ++;
73
            }
74
        }
75
76
        if (error != 0) {
77
            alert(alert_msg);
78
            return false;
79
        } else {
80
            $("#tabs").remove();
81
        }
82
    }
19
83
20
$(document).ready(function(){
84
$(document).ready(function(){
21
    // Getting marc structure via ajax
85
    // Getting marc structure via ajax
Lines 26-35 $(document).ready(function(){ Link Here
26
    [% PROCESS mergejs %]
90
    [% PROCESS mergejs %]
27
});
91
});
28
92
29
93
  [% END %]
30
function changeFramework(fw) {
94
[% END %]
31
    $("#Frameworks").val(fw);
32
}
33
95
34
//]]>
96
//]]>
35
</script>
97
</script>
Lines 47-69 function changeFramework(fw) { Link Here
47
109
48
<h1>Merging records</h1>
110
<h1>Merging records</h1>
49
[% IF ( result ) %]
111
[% IF ( result ) %]
50
    [% IF ( errors ) %]
112
    [% IF ( errors.size ) %]
51
113
       [% FOREACH error IN errors %]
52
	[% FOREACH error IN errors %]
114
           <div class="dialog alert">
53
	    <div class="dialog alert">
54
55
                [% IF error.code == 'CANNOT_MOVE' %]
115
                [% IF error.code == 'CANNOT_MOVE' %]
56
                    The following items could not be moved from the old record to the new one: [% error.value %]
116
                    The following items could not be moved from the old record to the new one: [% error.value %]
57
                [% ELSE %]
117
                [% ELSE %]
58
                    [% error %]
118
                    [% error %]
59
                [% END %]
119
                [% END %]
60
120
                <br />
61
            <br />Therefore, the record to be merged has not been deleted.</div>
121
                Therefore, the record to be merged has not been deleted.
62
	[% END %]
122
            </div>
123
       [% END %]
63
124
64
    [% ELSE %]
125
    [% ELSE %]
65
        <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]"</script>
126
        <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>
66
        <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]">Click here to see the merged record.</a></p>
127
        <h3>Report</h3>
128
        <table>
129
            <thead>
130
                <tr>
131
                    <th>Biblionumber</th>
132
                    [% FOREACH key IN report_header.keys.sort %]
133
                        [% tag = key.substr(0, 3) %]
134
                        [% code = key.substr(3, 1) %]
135
                        [% IF code == '@' %]
136
                            [% header = tag %]
137
                        [% ELSE %]
138
                            [% header = tag _ '$' _ code %]
139
                        [% END %]
140
                        <th>[% header %]</th>
141
                    [% END %]
142
                </tr>
143
            </thead>
144
            <tbody>
145
                [% FOREACH record IN report_records %]
146
                    <tr>
147
                        <td>
148
                            [% record.biblionumber %]
149
                            [% IF loop.first %]
150
                                (record kept)
151
                            [% END %]
152
                        </td>
153
                        [% FOREACH key IN report_header.keys.sort %]
154
                            <td>
155
                                [% values = record.fields.$key %]
156
                                [% IF values %]
157
                                    [% FOREACH value IN record.fields.$key %]
158
                                        [% value %]
159
                                        [% UNLESS loop.last %]<br />[% END %]
160
                                    [% END %]
161
                                [% END %]
162
                            </td>
163
                        [% END %]
164
                    </tr>
165
                [% END %]
166
            </tbody>
167
        </table>
67
    [% END %]
168
    [% END %]
68
169
69
[% ELSE %]
170
[% ELSE %]
Lines 72-135 function changeFramework(fw) { Link Here
72
<p>Please choose which record will be the reference for the merge. The record chosen as reference will be kept, and the other will be deleted.</p>
173
<p>Please choose which record will be the reference for the merge. The record chosen as reference will be kept, and the other will be deleted.</p>
73
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
174
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
74
    <fieldset class="rows">
175
    <fieldset class="rows">
75
	<legend>Merge reference</legend>
176
    <legend>Merge reference</legend>
76
	<ol>
177
    <ol>
77
	<li class="radio"><input type="radio" value="[% biblio1 %]" checked="checked" id="mergereference1" name="mergereference" onclick="changeFramework('[% frameworkcode1 %]')" /><label for="mergereference1">[% title1 %] [% FOREACH subtitl1 IN subtitle1 %] [% subtitl1.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblio1 %]" title="MARC" rel="gb_page_center[600,500]">[% biblio1 %]</a>)</label></li>
178
        [% FOREACH record IN records %]
78
	<li class="radio"><input type="radio" value="[% biblio2 %]" id="mergereference2" name="mergereference" onclick="changeFramework('[% frameworkcode2 %]')" /><label for="mergereference2">[% title2 %] [% FOREACH subtitl2 IN subtitle2 %] [% subtitl2.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblio2 %]" title="MARC" rel="gb_page_center[600,500]">[% biblio2 %]</a>)</label></li>
179
            <li class="radio">
79
180
                [% IF loop.first %]
80
    [% IF frameworkselect %]
181
                    <input type="radio" value="[% record.biblionumber %]" checked="checked" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
81
          <li><label for="frameworkcode">Using framework:</label>
182
                [% ELSE %]
82
                      <select name="frameworkcode" id="frameworkcode">
183
                    <input type="radio" value="[% record.biblionumber %]" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
83
                                      <option value="Default">Default</option>
184
                [% END %]
84
                                      [% FOREACH frameworkcodeloo IN frameworkselect %]
185
                <label for="ref_biblionumber[% record.biblionumber %]">
85
                                          [% IF ( frameworkcodeloo.selected ) %]
186
                    [% record.data.title %]
86
                                              <option value="[% frameworkcodeloo.value %]" selected="selected">
187
                    [% FOREACH subtitle IN record.subtitles %]
87
                                          [% ELSE %]
188
                        [% subtitle.subfield %]
88
                                              <option value="[% frameworkcodeloo.value %]">
189
                    [% END %]
89
                                          [% END %]
190
                    (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">[% record.biblionumber %]</a>)
90
                                           [% frameworkcodeloo.frameworktext %]
191
                </label>
91
                                           </option>
192
            </li>
92
                                      [% END %]
193
        [% END %]
93
                      </select></li>
194
94
    [% END %]
195
        [% IF frameworkselect.size %]
95
</ol>
196
            <li>
197
                <label for="frameworkcode">Using framework:</label>
198
                <select name="frameworkcode" id="frameworkcode">
199
                    <option value="">Default</option>
200
                    [% FOREACH frameworkcode IN frameworkselect %]
201
                        [% IF ( frameworkcode.selected ) %]
202
                            <option value="[% frameworkcode.value %]" selected="selected">
203
                        [% ELSE %]
204
                            <option value="[% frameworkcode.value %]">
205
                        [% END %]
206
                            [% frameworkcode.frameworktext %]
207
                        </option>
208
                    [% END %]
209
                </select>
210
            </li>
211
        [% END %]
212
    </ol>
96
213
97
	<input type="hidden" name="biblionumber" value="[% biblio1 %]" />
214
    [% FOREACH record IN records %]
98
	<input type="hidden" name="biblionumber" value="[% biblio2 %]" />
215
        <input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
99
	<fieldset class="action"><input type="submit" value="Next" /></fieldset>
216
    [% END %]
217
    <fieldset class="action">
218
        <input type="submit" value="Next" />
219
    </fieldset>
100
    </fieldset>
220
    </fieldset>
101
</form>
221
</form>
102
[% ELSE %]
222
[% ELSE %]
103
[% IF ( errors ) %]
223
[% IF ( errors.size ) %]
104
    <div class="dialog alert">
224
    <div class="dialog alert">
105
	[% FOREACH error IN errors %]
225
        [% FOREACH error IN errors %]
106
	    <p>
226
            <p>[% error %]</p>
107
                [% IF error.code == 'WRONG_COUNT' %]
227
        [% END %]
108
                    Number of records provided for merging: [% error.value %]. Currently only 2 records can be merged at a time.
109
                [% ELSE %]
110
                    [% error %]
111
                [% END %]
112
113
            </p>
114
	[% END %]
115
    </div>
228
    </div>
116
[% ELSE %]
229
[% ELSE %]
117
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
230
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
118
231
119
<div class="yui-g">
232
<div class="yui-g">
120
<div class="yui-u first">
233
<div class="yui-u first">
121
[% PROCESS mergesource recordid1=biblio1 recordid2=biblio2 %]
234
[% PROCESS mergesource sourcerecords=records %]
122
</div>
235
</div>
123
<div class="yui-u">
236
<div class="yui-u">
124
[% PROCESS mergetarget %]
237
[% PROCESS mergetarget %]
125
</div> <!-- .yui-u -->
238
</div> <!-- .yui-u -->
126
239
127
<input type="hidden" name="biblio1" value="[% biblio1 %]" />
240
<input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber %]" />
128
<input type="hidden" name="biblio2" value="[% biblio2 %]" />
241
[% FOREACH record IN records %]
129
<input type="hidden" name="mergereference" value="[% mergereference %]" />
242
    <input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
243
[% END %]
130
<input type="hidden" name="frameworkcode" value="[% framework %]" />
244
<input type="hidden" name="frameworkcode" value="[% framework %]" />
131
245
132
<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
246
<fieldset class="action">
247
    <input type="submit" name="merge" value="Merge" />
248
    <label for="report_fields">Fields to display in report:</label>
249
    <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields %]" />
250
    <span class="hint">(Example: "001,245ab,600")
251
</fieldset>
133
</div>
252
</div>
134
</form>
253
</form>
135
[% END %]
254
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-9 / +12 lines)
Lines 101-114 $(document).ready(function(){ Link Here
101
     * This function checks if the adequate number of records are checked for merging
101
     * This function checks if the adequate number of records are checked for merging
102
     */
102
     */
103
    function MergeItems() {
103
    function MergeItems() {
104
	var checkboxes = $("input:checkbox:checked");
104
        var checkboxes = $("input:checkbox:checked");
105
        var nbCheckbox = checkboxes.length;
105
        if (checkboxes.length > 0) {
106
	if (nbCheckbox != 2) {
106
            var params = [];
107
	    alert(_("Two records must be selected for merging."));
107
            $(checkboxes).each(function() {
108
	} else {
108
                params.push('biblionumber=' + $(this).val());
109
	    location.href='/cgi-bin/koha/cataloguing/merge.pl?biblionumber=' + checkboxes[0].value + '&amp;biblionumber=' + checkboxes[1].value;
109
            });
110
	}
110
            var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
111
	return false;
111
            location.href = url;
112
        } else {
113
            alert(_("You must select at least one record"));
114
        }
115
        return false;
112
    }
116
    }
113
117
114
    /**
118
    /**
115
- 

Return to bug 8064