1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha › Cataloging › Merging records</title>
3 [% INCLUDE 'greybox.inc' %]
4 [% INCLUDE 'doc-head-close.inc' %]
5 <style type="text/css">
6 div.record ul, div.record li { float:none; display:block; }
7 div#result { margin-top: 1em; }
8 /* We use this style "against" the li ui-tabs-nav style automatically applied */
10 <script type="text/javascript">
13 // When submiting the form
14 function mergeformsubmit() {
15 $("ul#ulrecord1").remove();
16 $("ul#ulrecord2").remove();
20 $(document).ready(function(){
24 // Getting marc structure via ajax
26 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
31 // Toggle a field / subfield
32 function toggleField(pField) {
34 // Getting the key of the clicked checkbox
35 var ckid = $(pField).attr("id");
36 var tab = ckid.split('_');
37 var source = tab[1]; // From which record the click came from
39 var type = $(pField).attr("class");
41 // Getting field/subfield
44 if (type == "subfieldpick") {
46 field = $(pField).parent().parent().parent().find("span.field").text();
47 subfield = $(pField).parent().find("span.subfield").text();
50 field = $(pField).parent().find("span.field").text();
53 // If the field has just been checked
56 // We check for repeatability
57 var canbeadded = true;
58 if (type == "subfieldpick") {
60 var alreadyexists = 0;
61 if (tagslib[field] && tagslib[field][subfield]) {
62 repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
63 // TODO : Checking for subfields
67 repeatable = tagslib[field].repeatable;
68 alreadyexists = $("#resultul span.field:contains(" + field + ")");
69 if (repeatable == 0 && alreadyexists.length != 0) {
74 // If the field is not repeatable, we check if it already exists in the result table
75 if (canbeadded == false) {
76 alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
80 // Cloning the field or subfield we picked
81 var clone = $(pField).parent().clone();
83 // Removing the checkboxes from it
84 $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
89 // If we are a subfield
90 if (type == "subfieldpick") {
91 // then we need to find who is our parent field...
92 fieldkey = $(pField).parent().parent().parent().attr("id");
94 // Find where to add the subfield
96 // First, check if the field is not already in the destination record
97 if ($("#resultul li#" + fieldkey).length > 0) {
98 // If so, we add our field to it
99 $("#resultul li#" + fieldkey + " ul").append(clone);
101 // If not, we add the subfield to the first matching field
103 $("#resultul li span.field").each(function() {
104 if (where == 0 && $(this).text() == field) {
109 // If there is no matching field in the destination record
113 // We select the whole field and removing non-selected subfields, instead of...
116 alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
117 pField.checked = false;
120 $(where).nextAll("ul").append(clone);
130 // Find where to add the field
131 $("#resultul li span.field").each(function() {
132 if (where == 0 && $(this).text() > field) {
137 $(where).parent().before(clone);
142 // Else, we remove it from the results tab
143 $("ul#resultul li#k" + key).remove();
148 // When a field is checked / unchecked
149 $('input.fieldpick').click(function() {
151 // (un)check all subfields
152 var ischecked = this.checked;
153 $(this).parent().find("input.subfieldpick").each(function() {
154 this.checked = ischecked;
158 // When a field or subfield is checked / unchecked
159 $("input.subfieldpick").click(function() {
165 function changeFramework(fw) {
166 $("#Frameworks").val(fw);
172 <body id="cat_merge" class="cat">
173 [% INCLUDE 'header.inc' %]
174 [% INCLUDE 'cataloging-search.inc' %]
175 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a> › Merging records</div>
177 <div id="doc" class="yui-t7">
183 <h1>Merging records</h1>
187 [% FOREACH error IN errors %]
188 <div class="dialog alert">
190 [% IF error.code == 'CANNOT_MOVE' %]
191 The following items could not be moved from the old record to the new one: [% error.value %]
196 <br />Therefore, the record to be merged has not been deleted.</div>
200 <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]"</script>
201 <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]">Click here to see the merged record.</a></p>
206 [% IF ( choosereference ) %]
207 <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>
208 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
209 <fieldset class="rows">
210 <legend>Merge reference</legend>
212 <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>
213 <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>
215 [% IF frameworkselect %]
216 <li><label for="frameworkcode">Using framework:</label>
217 <select name="frameworkcode" id="frameworkcode">
218 <option value="Default">Default</option>
219 [% FOREACH frameworkcodeloo IN frameworkselect %]
220 [% IF ( frameworkcodeloo.selected ) %]
221 <option value="[% frameworkcodeloo.value %]" selected="selected">
223 <option value="[% frameworkcodeloo.value %]">
225 [% frameworkcodeloo.frameworktext %]
232 <input type="hidden" name="biblionumber" value="[% biblio1 %]" />
233 <input type="hidden" name="biblionumber" value="[% biblio2 %]" />
234 <fieldset class="action"><input type="submit" value="Next" /></fieldset>
239 <div class="dialog alert">
240 [% FOREACH error IN errors %]
242 [% IF error.code == 'WRONG_COUNT' %]
243 Number of records provided for merging: [% error.value %]. Currently only 2 records can be merged at a time.
252 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
255 <div class="yui-u first">
256 <div id="tabs" class="toptabs">
257 <h2>Source records</h2>
259 <li><a href="#tabrecord1">[% biblio1 %]</a></li>
260 <li><a href="#tabrecord2">[% biblio2 %]</a></li>
262 <div id="tabrecord1">
267 [% FOREACH record IN record1 %]
268 [% FOREACH fiel IN record.field %]
269 <li id="k[% fiel.key %]">
270 <input type="checkbox" checked="checked" class="fieldpick" id="rec_1_[% fiel.key %]" />
271 <span class="field">[% fiel.tag %]</span>
273 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
274 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
275 [% IF ( fiel.value ) %] / [% fiel.value %]
276 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
277 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
280 [% IF ( fiel.subfield ) %]
282 [% FOREACH subfiel IN fiel.subfield %]
283 <li id="k[% subfiel.subkey %]">
284 <input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_[% subfiel.subkey %]" />
285 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
286 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
287 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
296 </div><!-- /div.record -->
298 </div><!-- /div#tabrecord1 -->
299 <div id="tabrecord2">
304 [% FOREACH record IN record2 %]
305 [% FOREACH fiel IN record.field %]
306 <li id="k[% fiel.key %]">
307 <input type="checkbox" class="fieldpick" id="rec_2_[% fiel.key %]" />
308 <span class="field">[% fiel.tag %]</span>
310 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
311 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
312 [% IF ( fiel.value ) %] / [% fiel.value %]
313 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
314 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
317 [% IF ( fiel.subfield ) %]
319 [% FOREACH subfiel IN fiel.subfield %]
320 <li id="k[% subfiel.subkey %]">
321 <input type="checkbox" class="subfieldpick" id="rec_2_[% subfiel.subkey %]" />
322 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
323 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
324 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
340 </div><!-- /div#tabrecord2 -->
341 </div> <!-- // #tabs -->
345 <h2>Destination record</h2>
346 <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
348 [% FOREACH record IN record1 %]
349 [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]"><span class="field">[% fiel.tag %]</span>
350 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
351 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
352 [% IF ( fiel.value ) %] /
354 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
355 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
358 [% IF ( fiel.subfield ) %]
360 [% FOREACH subfiel IN fiel.subfield %]
361 <li id="k[% subfiel.subkey %]">
362 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
363 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
364 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
376 </div> <!-- // #result -->
377 </div> <!-- .yui-u -->
379 <input type="hidden" name="biblio1" value="[% biblio1 %]" />
380 <input type="hidden" name="biblio2" value="[% biblio2 %]" />
381 <input type="hidden" name="mergereference" value="[% mergereference %]" />
382 <input type="hidden" name="frameworkcode" value="[% framework %]" />
384 <fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
395 [% INCLUDE 'intranet-bottom.inc' %]