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() {
168 [% INCLUDE 'header.inc' %]
169 [% INCLUDE 'cataloging-search.inc' %]
170 <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>
172 <div id="doc" class="yui-t7">
178 <h1>Merging records</h1>
181 [% FOREACH error IN errors %]
182 <div class="dialog alert">[% error.error %].<br />Therefore, the record to be merged has not been deleted.</div>
186 <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]"</script>
187 <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]">Click here to see the merged record.</a></p>
192 [% IF ( choosereference ) %]
193 <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>
194 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
195 <fieldset class="rows">
196 <legend>Merge reference</legend>
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>
199 <li class="radio"><input type="radio" value="[% biblio2 %]" id="mergereference2" name="mergereference" /><label style="float:none" for="mergereference2">[% title2 %] ([% biblio2 %])</label></li>
201 <input type="hidden" name="biblionumber" value="[% biblio1 %]" />
202 <input type="hidden" name="biblionumber" value="[% biblio2 %]" />
203 <fieldset class="action"><input type="submit" value="Next" /></fieldset>
208 [% FOREACH error IN errors %]
209 <div class="error">[% error.error %]</div>
212 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
215 <div class="yui-u first">
216 <div id="tabs" class="toptabs">
217 <h2>Source records</h2>
219 <li><a href="#tabrecord1">[% biblio1 %]</a></li>
220 <li><a href="#tabrecord2">[% biblio2 %]</a></li>
222 <div id="tabrecord1">
227 [% FOREACH record IN record1 %]
228 [% FOREACH fiel IN record.field %]
229 <li id="k[% fiel.key %]">
230 <input type="checkbox" checked="checked" class="fieldpick" id="rec_1_[% fiel.key %]" />
231 <span class="field">[% fiel.tag %]</span>
233 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
234 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
235 [% IF ( fiel.value ) %] / [% fiel.value %]
236 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
237 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
240 [% IF ( fiel.subfield ) %]
242 [% FOREACH subfiel IN fiel.subfield %]
243 <li id="k[% subfiel.subkey %]">
244 <input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_[% subfiel.subkey %]" />
245 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
246 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
247 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
256 </div><!-- /div.record -->
258 </div><!-- /div#tabrecord1 -->
259 <div id="tabrecord2">
264 [% FOREACH record IN record2 %]
265 [% FOREACH fiel IN record.field %]
266 <li id="k[% fiel.key %]">
267 <input type="checkbox" class="fieldpick" id="rec_2_[% fiel.key %]" />
268 <span class="field">[% fiel.tag %]</span>
270 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
271 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
272 [% IF ( fiel.value ) %] / [% fiel.value %]
273 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
274 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
277 [% IF ( fiel.subfield ) %]
279 [% FOREACH subfiel IN fiel.subfield %]
280 <li id="k[% subfiel.subkey %]">
281 <input type="checkbox" class="subfieldpick" id="rec_2_[% subfiel.subkey %]" />
282 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
283 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
284 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
300 </div><!-- /div#tabrecord2 -->
301 </div> <!-- // #tabs -->
305 <h2>Destination record</h2>
306 <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
308 [% FOREACH record IN record1 %]
309 [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]"><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 ) %] /
314 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
315 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
318 [% IF ( fiel.subfield ) %]
320 [% FOREACH subfiel IN fiel.subfield %]
321 <li id="k[% 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%]" />
336 <input type="hidden" name="biblio1" value="[% biblio1 %]" />
337 <input type="hidden" name="biblio2" value="[% biblio2 %]" />
338 <input type="hidden" name="mergereference" value="[% mergereference %]" />
341 </div> <!-- // #result -->
342 </div> <!-- .yui-u -->
343 <fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
354 [% INCLUDE 'intranet-bottom.inc' %]