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 [% WRAPPER 'header.inc' %]
19 [% INCLUDE 'cataloging-search.inc' %]
22 [% WRAPPER 'sub-header.inc' %]
23 [% WRAPPER breadcrumbs %]
24 [% WRAPPER breadcrumb_item %]
25 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
27 [% WRAPPER breadcrumb_item bc_active= 1 %]
28 <span>Merging records</span>
30 [% END #/ WRAPPER breadcrumbs %]
31 [% END #/ WRAPPER sub-header.inc %]
33 <div class="main container-fluid">
35 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
37 <h1>Merging records</h1>
39 [% IF ( errors.size ) %]
40 [% FOREACH error IN errors %]
41 <div class="dialog alert">
42 [% IF error.code == 'CANNOT_MOVE' %]
43 The following items could not be moved from the old record to the new one: [% error.value | html %]
48 Therefore, the record to be merged has not been deleted.
53 <div class="dialog message">The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber | uri %]">View the merged record.</a></div>
54 <div class="page-section">
60 [% FOREACH key IN report_header.keys.sort %]
61 [% tag = key.substr(0, 3) %]
62 [% code = key.substr(3, 1) %]
66 [% header = tag _ '$' _ code %]
68 <th>[% header | html %]</th>
73 [% FOREACH record IN report_records %]
76 [% record.biblionumber | html %]
78 <span>(record kept)</span>
81 [% FOREACH key IN report_header.keys.sort %]
83 [% values = record.fields.$key %]
85 [% FOREACH value IN record.fields.$key %]
87 [% UNLESS loop.last %]<br />[% END %]
96 </div> <!-- /.page-section -->
101 [% IF ( choosereference ) %]
102 <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>
103 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
104 <fieldset class="rows">
105 <legend>Merge reference</legend>
107 [% FOREACH record IN records %]
110 <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
112 <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
114 <label for="ref_biblionumber[% record.biblionumber | html %]">
115 [% INCLUDE 'biblio-title.inc' biblio=record.data %]
116 ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
122 <label for="frameworkcode">Using framework:</label>
123 <select name="frameworkcode" id="frameworkcode">
124 <option value="">Default</option>
125 [% FOREACH framework IN frameworks %]
126 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
132 [% FOREACH record IN records %]
133 <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
136 <fieldset class="action">
137 <input type="submit" class="btn btn-primary" value="Next" />
141 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
142 <div class="modal-dialog">
143 <div class="modal-content">
144 <div class="modal-header">
145 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
146 <h3 id="dataPreviewLabel">Preview</h3>
148 <div class="modal-body">
149 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
151 <div class="modal-footer">
152 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
159 [% IF ( errors.size ) %]
160 <div class="dialog alert">
161 [% FOREACH error IN errors %]
162 <p>[% error | html %]</p>
166 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
168 <div class="col-sm-6">
169 [% PROCESS mergesource sourcerecords=records %]
171 <div class="col-sm-6">
172 [% PROCESS mergetarget %]
173 </div> <!-- .col-sm-6 -->
175 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
176 [% FOREACH record IN records %]
177 <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
179 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
181 <fieldset class="action">
182 <input type="submit" name="merge" class="btn btn-primary" value="Merge" />
183 <label for="report_fields">Fields to display in report:</label>
184 <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
185 <span class="hint">(Example: "001,245ab,600")</span>
195 [% MACRO jsinclude BLOCK %]
196 [% Asset.js("js/merge-record.js") | $raw %]
198 [% UNLESS (result) %]
199 [% IF (choosereference) %]
200 function changeFramework(fw) {
201 $("#frameworkcode").val(fw);
203 $(document).ready(function(){
204 $(".previewData").on("click", function(e){
206 var ltitle = $(this).text();
207 var page = $(this).attr("href");
208 $("#dataPreviewLabel").text(ltitle);
209 $("#dataPreview .modal-body").load(page + " div");
210 $('#dataPreview').modal({show:true});
212 $("#dataPreview").on("hidden.bs.modal", function(){
213 $("#dataPreviewLabel").html("");
214 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
218 function check_mandatory () {
223 for (tag in tagslib) {
224 if (tag == '000' || tag == '001')
226 if (tagslib[tag].mandatory == 1) {
227 if ($("#resultul span.field:contains("+ tag +")").length == 0) {
228 missing.fields.push(tag);
231 for (subfieldcode in tagslib[tag]) {
232 if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
233 || subfieldcode == 'repeatable' || subfieldcode == 'tab'
234 || subfieldcode == '@') {
237 if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
238 var fields = $("#resultul span.field:contains("+ tag +")");
239 $(fields).each(function() {
240 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
241 if (subfields.length == 0) {
242 missing.subfields.push( {
244 'subfieldcode': subfieldcode
254 // When submiting the form
255 function mergeformsubmit() {
256 var missing = check_mandatory();
259 if (missing.fields.length > 0) {
260 alert_msg += _("Following required fields are missing:") + "\n";
261 for (var i in missing.fields) {
262 alert_msg += "\t- " + missing.fields[i] + "\n";
267 if (missing.subfields.length > 0) {
268 alert_msg += _("Following required subfields are missing:") + "\n";
269 for (var i in missing.subfields) {
270 var subfield = missing.subfields[i];
271 alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
284 $(document).ready(function(){
286 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
288 rebuild_target($("#tabs"), $("#resultul"));
291 if( $("#tabs .tab-pane.active").length < 1 ){
292 $("#tabs a:first").tab("show");
295 // Uncheck all checkboxes in both tabs, then check all checkboxes in first tab
296 // to avoid inconsistencies from a page refresh.
297 $("#tabs input[type='checkbox']").prop("checked", false);
298 $("#tabrecord[% ref_biblionumber | html %]_panel input[type='checkbox']").prop("checked", true );
300 //Set focus to cataloging search
301 $("input[name=q]:eq(0)").focus();
309 [% INCLUDE 'intranet-bottom.inc' %]