3 [% PROCESS 'i18n.inc' %]
5 [% PROCESS 'merge-record.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>[% FILTER collapse %]
8 [% t("Merging records") | html %] ›
9 [% t("Cataloging") | html %] ›
10 [% t("Koha") | html %]
12 [% INCLUDE 'doc-head-close.inc' %]
14 div.record ul, div.record li { float:none; display:block; }
15 div#result { margin-top: 1em; }
16 /* We use this style "against" the li ui-tabs-nav style automatically applied */
17 #dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }
21 <body id="cat_merge" class="cat">
22 [% WRAPPER 'header.inc' %]
23 [% INCLUDE 'cataloging-search.inc' %]
26 [% WRAPPER 'sub-header.inc' %]
27 [% WRAPPER breadcrumbs %]
28 [% WRAPPER breadcrumb_item %]
29 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
31 [% WRAPPER breadcrumb_item bc_active= 1 %]
32 <span>Merging records</span>
34 [% END #/ WRAPPER breadcrumbs %]
35 [% END #/ WRAPPER sub-header.inc %]
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 <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>
58 <div class="page-section">
64 [% FOREACH key IN report_header.keys.sort %]
65 [% tag = key.substr(0, 3) %]
66 [% code = key.substr(3, 1) %]
70 [% header = tag _ '$' _ code %]
72 <th>[% header | html %]</th>
77 [% FOREACH record IN report_records %]
80 [% record.biblionumber | html %]
82 <span>(record kept)</span>
85 [% FOREACH key IN report_header.keys.sort %]
87 [% values = record.fields.$key %]
89 [% FOREACH value IN record.fields.$key %]
91 [% UNLESS loop.last %]<br />[% END %]
100 </div> <!-- /.page-section -->
105 [% IF ( choosereference ) %]
106 <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>
107 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
108 <fieldset class="rows">
109 <legend>Merge reference</legend>
111 [% FOREACH record IN records %]
114 <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
116 <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
118 <label for="ref_biblionumber[% record.biblionumber | html %]">
119 [% INCLUDE 'biblio-title.inc' biblio=record.data %]
120 ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
126 <label for="frameworkcode">Using framework:</label>
127 <select name="frameworkcode" id="frameworkcode">
128 <option value="">Default</option>
129 [% FOREACH framework IN frameworks %]
130 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
136 [% FOREACH record IN records %]
137 <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
140 <fieldset class="action">
141 <input type="submit" class="btn btn-primary" value="Next" />
145 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
146 <div class="modal-dialog">
147 <div class="modal-content">
148 <div class="modal-header">
149 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
150 <h3 id="dataPreviewLabel">Preview</h3>
152 <div class="modal-body">
153 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
155 <div class="modal-footer">
156 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
163 [% IF ( errors.size ) %]
164 <div class="dialog alert">
165 [% FOREACH error IN errors %]
166 <p>[% error | html %]</p>
170 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
172 <div class="col-sm-6">
173 [% PROCESS mergesource sourcerecords=records %]
175 <div class="col-sm-6">
176 [% PROCESS mergetarget %]
177 </div> <!-- .col-sm-6 -->
179 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
180 [% FOREACH record IN records %]
181 <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
183 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
185 <fieldset class="action">
186 <input type="submit" name="merge" class="btn btn-primary" value="Merge" />
187 <label for="report_fields">Fields to display in report:</label>
188 <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
189 <span class="hint">(Example: "001,245ab,600")</span>
199 [% MACRO jsinclude BLOCK %]
200 [% Asset.js("js/merge-record.js") | $raw %]
202 [% UNLESS (result) %]
203 [% IF (choosereference) %]
204 function changeFramework(fw) {
205 $("#frameworkcode").val(fw);
207 $(document).ready(function(){
208 $(".previewData").on("click", function(e){
210 var ltitle = $(this).text();
211 var page = $(this).attr("href");
212 $("#dataPreviewLabel").text(ltitle);
213 $("#dataPreview .modal-body").load(page + " div");
214 $('#dataPreview').modal({show:true});
216 $("#dataPreview").on("hidden.bs.modal", function(){
217 $("#dataPreviewLabel").html("");
218 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
222 function check_mandatory () {
227 for (tag in tagslib) {
228 if (tag == '000' || tag == '001')
230 if (tagslib[tag].mandatory == 1) {
231 if ($("#resultul span.field:contains("+ tag +")").length == 0) {
232 missing.fields.push(tag);
235 for (subfieldcode in tagslib[tag]) {
236 if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
237 || subfieldcode == 'repeatable' || subfieldcode == 'tab'
238 || subfieldcode == '@') {
241 if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
242 var fields = $("#resultul span.field:contains("+ tag +")");
243 $(fields).each(function() {
244 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
245 if (subfields.length == 0) {
246 missing.subfields.push( {
248 'subfieldcode': subfieldcode
258 // When submiting the form
259 function mergeformsubmit() {
260 var missing = check_mandatory();
263 if (missing.fields.length > 0) {
264 alert_msg += _("Following required fields are missing:") + "\n";
265 for (var i in missing.fields) {
266 alert_msg += "\t- " + missing.fields[i] + "\n";
271 if (missing.subfields.length > 0) {
272 alert_msg += _("Following required subfields are missing:") + "\n";
273 for (var i in missing.subfields) {
274 var subfield = missing.subfields[i];
275 alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
288 $(document).ready(function(){
290 $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
292 rebuild_target($("#tabs"), $("#resultul"));
295 if( $("#tabs .tab-pane.active").length < 1 ){
296 $("#tabs a:first").tab("show");
299 // Uncheck all checkboxes in both tabs, then check all checkboxes in first tab
300 // to avoid inconsistencies from a page refresh.
301 $("#tabs input[type='checkbox']").prop("checked", false);
302 $("#tabrecord[% ref_biblionumber | html %]_panel input[type='checkbox']").prop("checked", true );
304 //Set focus to cataloging search
305 $("input[name=q]:eq(0)").focus();
313 [% INCLUDE 'intranet-bottom.inc' %]