1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha › Cataloging › Merging records</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <style type="text/css">
5 div.record ul, div.record li { float:none; display:block; }
6 div#result { margin-top: 1em; }
7 /* We use this style "against" the li ui-tabs-nav style automatically applied */
9 <script type="text/javascript">
12 // When submiting the form
13 function mergeformsubmit() {
14 $("ul#ulrecord1").remove();
15 $("ul#ulrecord2").remove();
19 $(document).ready(function(){
21 $("#tabs > ul").tabs();
23 // Getting marc structure via ajax
25 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
30 // Toggle a field / subfield
31 function toggleField(pField) {
33 // Getting the key of the clicked checkbox
34 var ckid = $(pField).attr("id");
35 var tab = ckid.split('_');
36 var source = tab[1]; // From which record the click came from
38 var type = $(pField).attr("class");
40 // Getting field/subfield
43 if (type == "subfieldpick") {
45 field = $(pField).parent().parent().parent().find("span.field").text();
46 subfield = $(pField).parent().find("span.subfield").text();
49 field = $(pField).parent().find("span.field").text();
52 // If the field has just been checked
55 // We check for repeatability
56 var canbeadded = true;
57 if (type == "subfieldpick") {
59 var alreadyexists = 0;
60 if (tagslib[field] && tagslib[field][subfield]) {
61 repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
62 // TODO : Checking for subfields
66 repeatable = tagslib[field].repeatable;
67 alreadyexists = $("#resultul span.field:contains(" + field + ")");
68 if (repeatable == 0 && alreadyexists.length != 0) {
73 // If the field is not repeatable, we check if it already exists in the result table
74 if (canbeadded == false) {
75 alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
79 // Cloning the field or subfield we picked
80 var clone = $(pField).parent().clone();
82 // Removing the checkboxes from it
83 $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
88 // If we are a subfield
89 if (type == "subfieldpick") {
90 // then we need to find who is our parent field...
91 fieldkey = $(pField).parent().parent().parent().attr("id");
93 // Find where to add the subfield
95 // First, check if the field is not already in the destination record
96 if ($("#resultul li#" + fieldkey).length > 0) {
97 // If so, we add our field to it
98 $("#resultul li#" + fieldkey + " ul").append(clone);
100 // If not, we add the subfield to the first matching field
102 $("#resultul li span.field").each(function() {
103 if (where == 0 && $(this).text() == field) {
108 // If there is no matching field in the destination record
112 // We select the whole field and removing non-selected subfields, instead of...
115 alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
116 pField.checked = false;
119 $(where).nextAll("ul").append(clone);
129 // Find where to add the field
130 $("#resultul li span.field").each(function() {
131 if (where == 0 && $(this).text() > field) {
136 $(where).parent().before(clone);
141 // Else, we remove it from the results tab
142 $("ul#resultul li#k" + key).remove();
147 // When a field is checked / unchecked
148 $('input.fieldpick').click(function() {
150 // (un)check all subfields
151 var ischecked = this.checked;
152 $(this).parent().find("input.subfieldpick").each(function() {
153 this.checked = ischecked;
157 // When a field or subfield is checked / unchecked
158 $("input.subfieldpick").click(function() {
164 function changeFramework(fw) {
165 $("#Frameworks").val(fw);
172 [% INCLUDE 'header.inc' %]
173 [% INCLUDE 'cataloging-search.inc' %]
174 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a> › [% IF ( biblionumber ) %]Editing <em>[% title |html %]</em> (Record Number [% biblionumber %])[% ELSE %]Add MARC Record[% END %]</div>
176 <div id="doc" class="yui-t7">
182 <h1>Merging records</h1>
185 [% FOREACH error IN errors %]
186 <div class="dialog alert">[% error.error %].<br />Therefore, the record to be merged has not been deleted.</div>
190 <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]"</script>
191 <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]">Click here to see the merged record.</a></p>
196 [% IF ( choosereference ) %]
197 <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>
198 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
199 <fieldset class="rows">
200 <legend>Merge reference</legend>
203 <td style="border-width: 0px; text-align: left">
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>
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>
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">
218 <option value="[% frameworkcodeloo.value %]">
220 [% frameworkcodeloo.frameworktext %]
229 <input type="hidden" name="biblionumber" value="[% biblio1 %]" />
230 <input type="hidden" name="biblionumber" value="[% biblio2 %]" />
231 <fieldset class="action"><input type="submit" value="Next" /></fieldset>
236 [% FOREACH error IN errors %]
237 <div class="error">[% error.error %]</div>
240 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
243 <div class="yui-u first">
244 <div id="tabs" class="toptabs">
245 <h2>Source records</h2>
247 <li><a href="#tabrecord1">[% biblio1 %]</a></li>
248 <li><a href="#tabrecord2">[% biblio2 %]</a></li>
250 <div id="tabrecord1">
255 [% FOREACH record IN record1 %]
256 [% FOREACH fiel IN record.field %]
257 <li id="k[% fiel.key %]">
258 <input type="checkbox" checked="checked" class="fieldpick" id="rec_1_[% fiel.key %]" />
259 <span class="field">[% fiel.tag %]</span>
261 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
262 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
263 [% IF ( fiel.value ) %] / [% fiel.value %]
264 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
265 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
268 [% IF ( fiel.subfield ) %]
270 [% FOREACH subfiel IN fiel.subfield %]
271 <li id="k[% subfiel.subkey %]">
272 <input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_[% subfiel.subkey %]" />
273 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
274 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
275 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
284 </div><!-- /div.record -->
286 </div><!-- /div#tabrecord1 -->
287 <div id="tabrecord2">
292 [% FOREACH record IN record2 %]
293 [% FOREACH fiel IN record.field %]
294 <li id="k[% fiel.key %]">
295 <input type="checkbox" class="fieldpick" id="rec_2_[% fiel.key %]" />
296 <span class="field">[% fiel.tag %]</span>
298 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
299 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
300 [% IF ( fiel.value ) %] / [% fiel.value %]
301 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
302 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
305 [% IF ( fiel.subfield ) %]
307 [% FOREACH subfiel IN fiel.subfield %]
308 <li id="k[% subfiel.subkey %]">
309 <input type="checkbox" class="subfieldpick" id="rec_2_[% subfiel.subkey %]" />
310 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
311 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
312 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
328 </div><!-- /div#tabrecord2 -->
329 </div> <!-- // #tabs -->
333 <h2>Destination record</h2>
334 <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
336 [% FOREACH record IN record1 %]
337 [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]"><span class="field">[% fiel.tag %]</span>
338 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
339 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
340 [% IF ( fiel.value ) %] /
342 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
343 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
346 [% IF ( fiel.subfield ) %]
348 [% FOREACH subfiel IN fiel.subfield %]
349 <li id="k[% subfiel.subkey %]">
350 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
351 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
352 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
364 </div> <!-- // #result -->
365 </div> <!-- .yui-u -->
367 <input type="hidden" name="biblio1" value="[% biblio1 %]" />
368 <input type="hidden" name="biblio2" value="[% biblio2 %]" />
369 <input type="hidden" name="mergereference" value="[% mergereference %]" />
370 <input type="hidden" name="frameworkcode" value="[% framework %]" />
372 <fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
383 [% INCLUDE 'intranet-bottom.inc' %]