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' %]
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">
36 <div class="main container-fluid">
38 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
40 <h1>Merging records</h1>
42 [% IF ( errors.size ) %]
43 [% FOREACH error IN errors %]
44 <div class="dialog alert">
45 [% IF error.code == 'CANNOT_MOVE' %]
46 The following items could not be moved from the old record to the new one: [% error.value | html %]
51 Therefore, the record to be merged has not been deleted.
56 <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber | uri %]">View the merged record.</a></p>
62 [% FOREACH key IN report_header.keys.sort %]
63 [% tag = key.substr(0, 3) %]
64 [% code = key.substr(3, 1) %]
68 [% header = tag _ '$' _ code %]
70 <th>[% header | html %]</th>
75 [% FOREACH record IN report_records %]
78 [% record.biblionumber | html %]
83 [% FOREACH key IN report_header.keys.sort %]
85 [% values = record.fields.$key %]
87 [% FOREACH value IN record.fields.$key %]
89 [% UNLESS loop.last %]<br />[% END %]
102 [% IF ( choosereference ) %]
103 <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>
104 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
105 <fieldset class="rows">
106 <legend>Merge reference</legend>
108 [% FOREACH record IN records %]
111 <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
113 <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
115 <label for="ref_biblionumber[% record.biblionumber | html %]">
116 [% INCLUDE 'biblio-title.inc' biblio=record.data %]
117 ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
123 <label for="frameworkcode">Using framework:</label>
124 <select name="frameworkcode" id="frameworkcode">
125 <option value="">Default</option>
126 [% FOREACH framework IN frameworks %]
127 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
133 [% FOREACH record IN records %]
134 <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
136 <fieldset class="action">
137 <input type="submit" value="Next" />
142 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
143 <div class="modal-dialog">
144 <div class="modal-content">
145 <div class="modal-header">
146 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
147 <h3 id="dataPreviewLabel">Preview</h3>
149 <div class="modal-body">
150 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
152 <div class="modal-footer">
153 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
160 [% IF ( errors.size ) %]
161 <div class="dialog alert">
162 [% FOREACH error IN errors %]
163 <p>[% error | html %]</p>
167 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
169 <div class="col-sm-6">
170 [% PROCESS mergesource sourcerecords=records %]
172 <div class="col-sm-6">
173 [% PROCESS mergetarget %]
174 </div> <!-- .col-sm-6 -->
176 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
177 [% FOREACH record IN records %]
178 <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
180 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
182 <fieldset class="action">
183 <input type="submit" name="merge" value="Merge" />
184 <label for="report_fields">Fields to display in report:</label>
185 <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
186 <span class="hint">(Example: "001,245ab,600")</span>
196 [% MACRO jsinclude BLOCK %]
197 [% Asset.js("js/merge-record.js") | $raw %]
199 [% UNLESS (result) %]
200 [% IF (choosereference) %]
201 function changeFramework(fw) {
202 $("#frameworkcode").val(fw);
204 $(document).ready(function(){
205 $(".previewData").on("click", function(e){
207 var ltitle = $(this).text();
208 var page = $(this).attr("href");
209 $("#dataPreviewLabel").text(ltitle);
210 $("#dataPreview .modal-body").load(page + " div");
211 $('#dataPreview').modal({show:true});
213 $("#dataPreview").on("hidden.bs.modal", function(){
214 $("#dataPreviewLabel").html("");
215 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
219 function check_mandatory () {
224 for (tag in tagslib) {
225 if (tag == '000' || tag == '001')
227 if (tagslib[tag].mandatory == 1) {
228 if ($("#resultul span.field:contains("+ tag +")").length == 0) {
229 missing.fields.push(tag);
232 for (subfieldcode in tagslib[tag]) {
233 if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
234 || subfieldcode == 'repeatable' || subfieldcode == 'tab'
235 || subfieldcode == '@') {
238 if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
239 var fields = $("#resultul span.field:contains("+ tag +")");
240 $(fields).each(function() {
241 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
242 if (subfields.length == 0) {
243 missing.subfields.push( {
245 'subfieldcode': subfieldcode
255 // When submiting the form
256 function mergeformsubmit() {
257 var missing = check_mandatory();
260 if (missing.fields.length > 0) {
261 alert_msg += _("Following required fields are missing:") + "\n";
262 for (var i in missing.fields) {
263 alert_msg += "\t- " + missing.fields[i] + "\n";
268 if (missing.subfields.length > 0) {
269 alert_msg += _("Following required subfields are missing:") + "\n";
270 for (var i in missing.subfields) {
271 var subfield = missing.subfields[i];
272 alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
285 $(document).ready(function(){
287 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
289 rebuild_target($("#tabs"), $("#resultul"));
295 // Check all checkboxes in first tab, and uncheck all others to avoid
296 // inconsistencies from a page refresh.
297 $('#tabs div#tabrecord[% ref_biblionumber | html %]').find('input[type="checkbox"]').prop('checked', true);
298 $('#tabs > div:not("#tabrecord[% ref_biblionumber | html %]")').find('input[type="checkbox"]').prop('checked', false);
300 //Set focus to cataloging search
301 $("input[name=q]:eq(0)").focus();
309 [% INCLUDE 'intranet-bottom.inc' %]