4 [% PROCESS 'merge-record.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Merging records › Cataloging › Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
10 div.record ul, div.record li { float:none; display:block; }
11 div#result { margin-top: 1em; }
12 /* We use this style "against" the li ui-tabs-nav style automatically applied */
13 #dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }
17 <body id="cat_merge" class="cat">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'cataloging-search.inc' %]
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
24 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
27 <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
30 <a href="#" aria-current="page">
37 <div class="main container-fluid">
39 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
41 <h1>Merging records</h1>
43 [% IF ( errors.size ) %]
44 [% FOREACH error IN errors %]
45 <div class="dialog alert">
46 [% IF error.code == 'CANNOT_MOVE' %]
47 The following items could not be moved from the old record to the new one: [% error.value | html %]
52 Therefore, the record to be merged has not been deleted.
57 <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber | uri %]">View the merged record.</a></p>
63 [% FOREACH key IN report_header.keys.sort %]
64 [% tag = key.substr(0, 3) %]
65 [% code = key.substr(3, 1) %]
69 [% header = tag _ '$' _ code %]
71 <th>[% header | html %]</th>
76 [% FOREACH record IN report_records %]
79 [% record.biblionumber | html %]
81 <span>(record kept)</span>
84 [% FOREACH key IN report_header.keys.sort %]
86 [% values = record.fields.$key %]
88 [% FOREACH value IN record.fields.$key %]
90 [% UNLESS loop.last %]<br />[% END %]
103 [% IF ( choosereference ) %]
104 <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>
105 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
106 <fieldset class="rows">
107 <legend>Merge reference</legend>
109 [% FOREACH record IN records %]
112 <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
114 <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
116 <label for="ref_biblionumber[% record.biblionumber | html %]">
117 [% INCLUDE 'biblio-title.inc' biblio=record.data %]
118 ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
124 <label for="frameworkcode">Using framework:</label>
125 <select name="frameworkcode" id="frameworkcode">
126 <option value="">Default</option>
127 [% FOREACH framework IN frameworks %]
128 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
134 [% FOREACH record IN records %]
135 <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
137 <fieldset class="action">
138 <input type="submit" value="Next" />
143 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
144 <div class="modal-dialog">
145 <div class="modal-content">
146 <div class="modal-header">
147 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
148 <h3 id="dataPreviewLabel">Preview</h3>
150 <div class="modal-body">
151 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
153 <div class="modal-footer">
154 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
161 [% IF ( errors.size ) %]
162 <div class="dialog alert">
163 [% FOREACH error IN errors %]
164 <p>[% error | html %]</p>
168 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
170 <div class="col-sm-6">
171 [% PROCESS mergesource sourcerecords=records %]
173 <div class="col-sm-6">
174 [% PROCESS mergetarget %]
175 </div> <!-- .col-sm-6 -->
177 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
178 [% FOREACH record IN records %]
179 <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
181 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
183 <fieldset class="action">
184 <input type="submit" name="merge" value="Merge" />
185 <label for="report_fields">Fields to display in report:</label>
186 <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
187 <span class="hint">(Example: "001,245ab,600")</span>
197 [% MACRO jsinclude BLOCK %]
198 [% Asset.js("js/merge-record.js") | $raw %]
200 [% UNLESS (result) %]
201 [% IF (choosereference) %]
202 function changeFramework(fw) {
203 $("#frameworkcode").val(fw);
205 $(document).ready(function(){
206 $(".previewData").on("click", function(e){
208 var ltitle = $(this).text();
209 var page = $(this).attr("href");
210 $("#dataPreviewLabel").text(ltitle);
211 $("#dataPreview .modal-body").load(page + " div");
212 $('#dataPreview').modal({show:true});
214 $("#dataPreview").on("hidden.bs.modal", function(){
215 $("#dataPreviewLabel").html("");
216 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
220 function check_mandatory () {
225 for (tag in tagslib) {
226 if (tag == '000' || tag == '001')
228 if (tagslib[tag].mandatory == 1) {
229 if ($("#resultul span.field:contains("+ tag +")").length == 0) {
230 missing.fields.push(tag);
233 for (subfieldcode in tagslib[tag]) {
234 if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
235 || subfieldcode == 'repeatable' || subfieldcode == 'tab'
236 || subfieldcode == '@') {
239 if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
240 var fields = $("#resultul span.field:contains("+ tag +")");
241 $(fields).each(function() {
242 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
243 if (subfields.length == 0) {
244 missing.subfields.push( {
246 'subfieldcode': subfieldcode
256 // When submiting the form
257 function mergeformsubmit() {
258 var missing = check_mandatory();
261 if (missing.fields.length > 0) {
262 alert_msg += _("Following required fields are missing:") + "\n";
263 for (var i in missing.fields) {
264 alert_msg += "\t- " + missing.fields[i] + "\n";
269 if (missing.subfields.length > 0) {
270 alert_msg += _("Following required subfields are missing:") + "\n";
271 for (var i in missing.subfields) {
272 var subfield = missing.subfields[i];
273 alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
286 $(document).ready(function(){
288 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
290 rebuild_target($("#tabs"), $("#resultul"));
293 if( $(".tab-pane.active").length < 1 ){
294 $("#tabs a:first").tab("show");
297 // Uncheck all checkboxes in both tabs, then check all checkboxes in first tab
298 // to avoid inconsistencies from a page refresh.
299 $("#tabs input[type='checkbox']").prop("checked", false);
300 $("#tabrecord[% ref_biblionumber | html %] input[type='checkbox']").prop("checked", true );
302 //Set focus to cataloging search
303 $("input[name=q]:eq(0)").focus();
311 [% INCLUDE 'intranet-bottom.inc' %]