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

(-)a/cataloguing/merge.pl (-57 / +79 lines)
Lines 26-31 use C4::Auth; Link Here
26
use C4::Items;
26
use C4::Items;
27
use C4::Biblio;
27
use C4::Biblio;
28
use C4::Serials;
28
use C4::Serials;
29
use C4::Koha;
29
30
30
my $input = new CGI;
31
my $input = new CGI;
31
my @biblionumber = $input->param('biblionumber');
32
my @biblionumber = $input->param('biblionumber');
Lines 59-65 if ($merge) { Link Here
59
    # Rewriting the leader
60
    # Rewriting the leader
60
    $record->leader(GetMarcBiblio($tobiblio)->leader());
61
    $record->leader(GetMarcBiblio($tobiblio)->leader());
61
62
62
    my $frameworkcode = &GetFrameworkCode($tobiblio);
63
    my $frameworkcode = $input->param('frameworkcode');
63
    my @notmoveditems;
64
    my @notmoveditems;
64
65
65
    # Modifying the reference record
66
    # Modifying the reference record
Lines 104-180 if ($merge) { Link Here
104
	push @errors, $error if ($error); 
105
	push @errors, $error if ($error); 
105
    }
106
    }
106
107
107
    # Errors
108
    my @errors_loop  = map{{error => $_}}@errors;
109
110
    # Parameters
108
    # Parameters
111
    $template->param(
109
    $template->param(
112
	errors  => \@errors_loop,
113
	result => 1,
110
	result => 1,
114
	biblio1 => $input->param('biblio1')
111
	biblio1 => $input->param('biblio1')
115
    );
112
    );
116
113
117
118
#-------------------------
114
#-------------------------
119
# Show records to merge
115
# Show records to merge
120
#-------------------------
116
#-------------------------
121
} else {
117
} else {
122
123
    my $mergereference = $input->param('mergereference');
118
    my $mergereference = $input->param('mergereference');
124
    my $biblionumber = $input->param('biblionumber');
119
    my $biblionumber = $input->param('biblionumber');
125
120
126
    my $data1 = GetBiblioData($biblionumber[0]);
121
    if (scalar(@biblionumber) != 2) {
127
    my $data2 = GetBiblioData($biblionumber[1]);
122
        push @errors, "An unexpected number of records was provided for merging. Currently only two records at a time can be merged.";
128
123
    }
129
    # Ask the user to choose which record will be the kept
124
    else {
130
    if (not $mergereference) {
125
        my $data1 = GetBiblioData($biblionumber[0]);
131
	$template->param(
126
        my $data2 = GetBiblioData($biblionumber[1]);
132
	    choosereference => 1,	
127
133
	    biblio1 => $biblionumber[0],
128
        # Checks if both records use the same framework
134
	    biblio2 => $biblionumber[1],
129
        my $frameworkcode1 = &GetFrameworkCode($biblionumber[0]);
135
	    title1 => $data1->{'title'},
130
        my $frameworkcode2 = &GetFrameworkCode($biblionumber[1]);
136
	    title2 => $data2->{'title'}
131
137
	    );
132
        if ($mergereference) {
138
    } else {
133
139
134
            my $framework;
140
	if (scalar(@biblionumber) != 2) {
135
            if ($frameworkcode1 ne $frameworkcode2) {
141
	    push @errors, "An unexpected number of records was provided for merging. Currently only two records at a time can be merged.";
136
                $framework = $input->param('frameworkcode')
142
	}
137
                  or push @errors, "Famework not selected.";
143
138
            } else {
144
	# Checks if both records use the same framework
139
                $framework = $frameworkcode1;	
145
	my $frameworkcode1 = &GetFrameworkCode($biblionumber[0]);
140
            }
146
	my $frameworkcode2 = &GetFrameworkCode($biblionumber[1]);
141
147
	my $framework;
142
            # Getting MARC Structure
148
	if ($frameworkcode1 ne $frameworkcode2) {
143
            my $tagslib = GetMarcStructure(1, $framework);
149
	    push @errors, "The records selected for merging are using different frameworks. Currently merging is only available for records using the same framework.";
144
150
	} else {
145
            my $notreference = ($biblionumber[0] == $mergereference) ? $biblionumber[1] : $biblionumber[0];
151
	    $framework = $frameworkcode1;	
146
152
	}
147
            # Creating a loop for display
153
148
            my @record1 = _createMarcHash(GetMarcBiblio($mergereference), $tagslib);
154
	# Getting MARC Structure
149
            my @record2 = _createMarcHash(GetMarcBiblio($notreference), $tagslib);
155
	my $tagslib = GetMarcStructure(1, $framework);
150
156
151
            # Parameters
157
	my $notreference = ($biblionumber[0] == $mergereference) ? $biblionumber[1] : $biblionumber[0];
152
            $template->param(
158
153
                biblio1 => $mergereference,
159
	# Creating a loop for display
154
                biblio2 => $notreference,
160
	my @record1 = _createMarcHash(GetMarcBiblio($mergereference), $tagslib);
155
                mergereference => $mergereference,
161
	my @record2 = _createMarcHash(GetMarcBiblio($notreference), $tagslib);
156
                record1 => @record1,
162
157
                record2 => @record2,
163
	# Errors
158
                framework => $framework,
164
	my @errors_loop  = map{{error => $_}}@errors;
159
            );
165
160
        }
166
	# Parameters
161
        else {
167
	$template->param(
162
168
	    errors  => \@errors_loop,
163
        # Ask the user to choose which record will be the kept
169
	    biblio1 => $mergereference,
164
            $template->param(
170
	    biblio2 => $notreference,
165
                choosereference => 1,	
171
	    mergereference => $mergereference,
166
                biblio1 => $biblionumber[0],
172
	    record1 => @record1,
167
                biblio2 => $biblionumber[1],
173
	    record2 => @record2,
168
                title1 => $data1->{'title'},
174
	    framework => $framework
169
                title2 => $data2->{'title'}
175
	    );
170
            );
171
            if ($frameworkcode1 ne $frameworkcode2) {
172
                my $frameworks = getframeworks;
173
                my @frameworkselect;
174
                foreach my $thisframeworkcode ( keys %$frameworks ) {
175
                    my %row = (
176
                        value         => $thisframeworkcode,
177
                        frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
178
                    );
179
                    if ($frameworkcode1 eq $thisframeworkcode){
180
                        $row{'selected'} = 1;
181
                        }
182
                    push @frameworkselect, \%row;
183
                }
184
                $template->param(
185
                    frameworkselect => \@frameworkselect,
186
                    frameworkcode1 => $frameworkcode1,
187
                    frameworkcode2 => $frameworkcode2,
188
                );
189
            }
190
        }
176
    }
191
    }
177
}
192
}
193
194
if (@errors) {
195
    # Errors
196
    my @errors_loop  = map{{error => $_}}@errors;
197
    $template->param( errors  => \@errors_loop );
198
}
199
178
output_html_with_http_headers $input, $cookie, $template->output;
200
output_html_with_http_headers $input, $cookie, $template->output;
179
exit;
201
exit;
180
202
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt (-6 / +34 lines)
Lines 161-166 $(document).ready(function(){ Link Here
161
161
162
});
162
});
163
163
164
function changeFramework(fw) {
165
    $("#Frameworks").val(fw);
166
}
167
164
//]]>
168
//]]>
165
</script>
169
</script>
166
</head>
170
</head>
Lines 194-203 $(document).ready(function(){ Link Here
194
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
198
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
195
    <fieldset class="rows">
199
    <fieldset class="rows">
196
	<legend>Merge reference</legend>
200
	<legend>Merge reference</legend>
201
    <table>
202
      <tr>
203
        <td style="border-width: 0px; text-align: left">
197
	<ol>
204
	<ol>
198
	<li class="radio"><input type="radio" value="[% biblio1 %]" checked="checked" id="mergereference1" name="mergereference" /><label style="float:none" for="mergereference1">[% title1 %] ([% biblio1 %])</label></li>
205
	<li class="radio"><input type="radio" value="[% biblio1 %]" checked="checked" id="mergereference1" name="mergereference" onclick="changeFramework('[% frameworkcode1 %]')" /><label style="float:none" for="mergereference1">[% title1 %] ([% biblio1 %])</label></li>
199
	<li class="radio"><input type="radio" value="[% biblio2 %]" id="mergereference2" name="mergereference" /><label style="float:none" for="mergereference2">[% title2 %] ([% biblio2 %])</label></li>
206
	<li class="radio"><input type="radio" value="[% biblio2 %]" id="mergereference2" name="mergereference" onclick="changeFramework('[% frameworkcode2 %]')" /><label style="float:none" for="mergereference2">[% title2 %] ([% biblio2 %])</label></li>
200
</ol>
207
</ol>
208
        </td>
209
        <td style="border-width: 0px">
210
    [% IF frameworkselect %]
211
          <label style="float:none" for="frameworkcode">Framework:</label><br>
212
            <select name="frameworkcode" id="Frameworks">
213
                            <option value="Default">Default</option>
214
                            [% FOREACH frameworkcodeloo IN frameworkselect %]
215
                                [% IF ( frameworkcodeloo.selected ) %]
216
                                    <option value="[% frameworkcodeloo.value %]" selected="selected">
217
                                [% ELSE %]
218
                                    <option value="[% frameworkcodeloo.value %]">
219
                                [% END %]
220
                                 [% frameworkcodeloo.frameworktext %]                              
221
                                 </option>
222
                            [% END %]
223
            </select>
224
    [% END %]
225
        </td>
226
      </tr>
227
    </table>
228
201
	<input type="hidden" name="biblionumber" value="[% biblio1 %]" />
229
	<input type="hidden" name="biblionumber" value="[% biblio1 %]" />
202
	<input type="hidden" name="biblionumber" value="[% biblio2 %]" />
230
	<input type="hidden" name="biblionumber" value="[% biblio2 %]" />
203
	<fieldset class="action"><input type="submit" value="Next" /></fieldset>
231
	<fieldset class="action"><input type="submit" value="Next" /></fieldset>
Lines 332-345 $(document).ready(function(){ Link Here
332
		[% END %]
360
		[% END %]
333
361
334
	    </ul>
362
	    </ul>
363
</div>
364
</div> <!-- // #result -->
365
</div> <!-- .yui-u -->
335
366
336
<input type="hidden" name="biblio1" value="[% biblio1 %]" />
367
<input type="hidden" name="biblio1" value="[% biblio1 %]" />
337
<input type="hidden" name="biblio2" value="[% biblio2 %]" />
368
<input type="hidden" name="biblio2" value="[% biblio2 %]" />
338
<input type="hidden" name="mergereference" value="[% mergereference %]" />
369
<input type="hidden" name="mergereference" value="[% mergereference %]" />
370
<input type="hidden" name="frameworkcode" value="[% framework %]" />
339
371
340
</div>
341
</div> <!-- // #result -->
342
</div> <!-- .yui-u -->
343
<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
372
<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
344
</div>
373
</div>
345
</form>
374
</form>
346
- 

Return to bug 6210