4 [% PROCESS 'merge-record.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Cataloging › Merging records</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' %]
20 <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>
22 <div class="main container-fluid">
24 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
26 <h1>Merging records</h1>
28 [% IF ( errors.size ) %]
29 [% FOREACH error IN errors %]
30 <div class="dialog alert">
31 [% IF error.code == 'CANNOT_MOVE' %]
32 The following items could not be moved from the old record to the new one: [% error.value | html %]
37 Therefore, the record to be merged has not been deleted.
42 <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber | uri %]">Click here to see the merged record.</a></p>
48 [% FOREACH key IN report_header.keys.sort %]
49 [% tag = key.substr(0, 3) %]
50 [% code = key.substr(3, 1) %]
54 [% header = tag _ '$' _ code %]
56 <th>[% header | html %]</th>
61 [% FOREACH record IN report_records %]
64 [% record.biblionumber | html %]
69 [% FOREACH key IN report_header.keys.sort %]
71 [% values = record.fields.$key %]
73 [% FOREACH value IN record.fields.$key %]
75 [% UNLESS loop.last %]<br />[% END %]
88 [% IF ( choosereference ) %]
89 <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>
90 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
91 <fieldset class="rows">
92 <legend>Merge reference</legend>
94 [% FOREACH record IN records %]
97 <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
99 <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
101 <label for="ref_biblionumber[% record.biblionumber | html %]">
102 [% INCLUDE 'biblio-title.inc' biblio=record.data %]
103 ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
109 <label for="frameworkcode">Using framework:</label>
110 <select name="frameworkcode" id="frameworkcode">
111 <option value="">Default</option>
112 [% FOREACH framework IN frameworks %]
113 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
119 [% FOREACH record IN records %]
120 <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
122 <fieldset class="action">
123 <input type="submit" value="Next" />
128 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
129 <div class="modal-dialog">
130 <div class="modal-content">
131 <div class="modal-header">
132 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
133 <h3 id="dataPreviewLabel">Preview</h3>
135 <div class="modal-body">
136 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
138 <div class="modal-footer">
139 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
146 [% IF ( errors.size ) %]
147 <div class="dialog alert">
148 [% FOREACH error IN errors %]
149 <p>[% error | html %]</p>
153 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
155 <div class="col-sm-6">
156 [% PROCESS mergesource sourcerecords=records %]
158 <div class="col-sm-6">
159 [% PROCESS mergetarget %]
160 </div> <!-- .col-sm-6 -->
162 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
163 [% FOREACH record IN records %]
164 <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
166 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
168 <fieldset class="action">
169 <input type="submit" name="merge" value="Merge" />
170 <label for="report_fields">Fields to display in report:</label>
171 <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
172 <span class="hint">(Example: "001,245ab,600")</span>
182 [% MACRO jsinclude BLOCK %]
183 [% Asset.js("js/merge-record.js") | $raw %]
184 [% INCLUDE 'merge-record-strings.inc' %]
186 [% UNLESS (result) %]
187 [% IF (choosereference) %]
188 function changeFramework(fw) {
189 $("#frameworkcode").val(fw);
191 $(document).ready(function(){
192 $(".previewData").on("click", function(e){
194 var ltitle = $(this).text();
195 var page = $(this).attr("href");
196 $("#dataPreviewLabel").text(ltitle);
197 $("#dataPreview .modal-body").load(page + " div");
198 $('#dataPreview').modal({show:true});
200 $("#dataPreview").on("hidden.bs.modal", function(){
201 $("#dataPreviewLabel").html("");
202 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
206 function check_mandatory () {
211 for (tag in tagslib) {
212 if (tag == '000' || tag == '001')
214 if (tagslib[tag].mandatory == 1) {
215 if ($("#resultul span.field:contains("+ tag +")").length == 0) {
216 missing.fields.push(tag);
219 for (subfieldcode in tagslib[tag]) {
220 if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
221 || subfieldcode == 'repeatable' || subfieldcode == 'tab'
222 || subfieldcode == '@') {
225 if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
226 var fields = $("#resultul span.field:contains("+ tag +")");
227 $(fields).each(function() {
228 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
229 if (subfields.length == 0) {
230 missing.subfields.push( {
232 'subfieldcode': subfieldcode
242 // When submiting the form
243 function mergeformsubmit() {
244 var missing = check_mandatory();
247 if (missing.fields.length > 0) {
248 alert_msg += _("Following required fields are missing:") + "\n";
249 for (var i in missing.fields) {
250 alert_msg += "\t- " + missing.fields[i] + "\n";
255 if (missing.subfields.length > 0) {
256 alert_msg += _("Following required subfields are missing:") + "\n";
257 for (var i in missing.subfields) {
258 var subfield = missing.subfields[i];
259 alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
272 $(document).ready(function(){
274 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
276 rebuild_target($("#tabs"), $("#resultul"));
282 // Check all checkboxes in first tab, and uncheck all others to avoid
283 // inconsistencies from a page refresh.
284 $('#tabs div#tabrecord[% ref_biblionumber | html %]').find('input[type="checkbox"]').prop('checked', true);
285 $('#tabs > div:not("#tabrecord[% ref_biblionumber | html %]")').find('input[type="checkbox"]').prop('checked', false);
287 //Set focus to cataloging search
288 $("input[name=q]:eq(0)").focus();
296 [% INCLUDE 'intranet-bottom.inc' %]