8d536b8ecf
Give the user the ability to merge two records, one being kept and the other deleted. Selection of the records to merge can be done from virtualshelves.
345 lines
13 KiB
Cheetah
345 lines
13 KiB
Cheetah
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
|
|
<title>Koha › Cataloging › Merging records</title>
|
|
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
|
|
<style type="text/css">
|
|
div.record ul, div.record li { float:none; display:block; }
|
|
/* We use this style "against" the li ui-tabs-nav style automatically applied */
|
|
</style>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
|
|
// When submiting the form
|
|
function mergeformsubmit() {
|
|
$("ul#ulrecord1").remove();
|
|
$("ul#ulrecord2").remove();
|
|
}
|
|
|
|
|
|
$(document).ready(function(){
|
|
// Creating tabs
|
|
$("#tabs").tabs();
|
|
|
|
// Getting marc structure via ajax
|
|
tagslib = [];
|
|
$.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "<!-- TMPL_VAR name="framework" -->" }, function(json) {
|
|
tagslib = json;
|
|
});
|
|
|
|
|
|
// Toggle a field / subfield
|
|
function toggleField(pField) {
|
|
|
|
// Getting the key of the clicked checkbox
|
|
var ckid = $(pField).attr("id");
|
|
var tab = ckid.split('_');
|
|
var source = tab[1]; // From which record the click came from
|
|
var key = tab[2];
|
|
var type = $(pField).attr("class");
|
|
|
|
// Getting field/subfield
|
|
var field;
|
|
var subfield;
|
|
if (type == "subfieldpick") {
|
|
|
|
field = $(pField).parent().parent().parent().find("span.field").text();
|
|
subfield = $(pField).parent().find("span.subfield").text();
|
|
} else {
|
|
|
|
field = $(pField).parent().find("span.field").text();
|
|
}
|
|
|
|
// If the field has just been checked
|
|
if (pField.checked) {
|
|
|
|
// We check for repeatability
|
|
var canbeadded = true;
|
|
if (type == "subfieldpick") {
|
|
var repeatable = 1;
|
|
var alreadyexists = 0;
|
|
if (tagslib[field] && tagslib[field][subfield]) {
|
|
repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
|
|
// TODO : Checking for subfields
|
|
}
|
|
} else {
|
|
if (tagslib[field]) {
|
|
repeatable = tagslib[field].repeatable;
|
|
alreadyexists = $("#resultul span.field:contains(" + field + ")");
|
|
if (repeatable == 0 && alreadyexists.length != 0) {
|
|
canbeadded = false;
|
|
}
|
|
}
|
|
}
|
|
// If the field is not repeatable, we check if it already exists in the result table
|
|
if (canbeadded == false) {
|
|
alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
|
|
pField.checked = 0;
|
|
} else {
|
|
|
|
// Cloning the field or subfield we picked
|
|
var clone = $(pField).parent().clone();
|
|
|
|
// Removing the checkboxes from it
|
|
$(clone).find("input.subfieldpick, input.fieldpick").each(function() {
|
|
$(this).remove();
|
|
});
|
|
|
|
|
|
// If we are a subfield
|
|
if (type == "subfieldpick") {
|
|
// then we need to find who is our parent field...
|
|
fieldkey = $(pField).parent().parent().parent().attr("id");
|
|
|
|
// Find where to add the subfield
|
|
|
|
// First, check if the field is not already in the destination record
|
|
if ($("#resultul li#" + fieldkey).length > 0) {
|
|
// If so, we add our field to it
|
|
$("#resultul li#" + fieldkey + " ul").append(clone);
|
|
} else {
|
|
// If not, we add the subfield to the first matching field
|
|
var where = 0;
|
|
$("#resultul li span.field").each(function() {
|
|
if (where == 0 && $(this).text() == field) {
|
|
where = this;
|
|
}
|
|
});
|
|
|
|
// If there is no matching field in the destination record
|
|
if (where == 0) {
|
|
|
|
// TODO:
|
|
// We select the whole field and removing non-selected subfields, instead of...
|
|
|
|
// Alerting the user
|
|
alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
|
|
pField.checked = false;
|
|
|
|
} else {
|
|
$(where).nextAll("ul").append(clone);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
// If we are a field
|
|
var where = 0;
|
|
// Find where to add the field
|
|
$("#resultul li span.field").each(function() {
|
|
if (where == 0 && $(this).text() > field) {
|
|
where = this;
|
|
}
|
|
});
|
|
|
|
$(where).parent().before(clone);
|
|
}
|
|
}
|
|
} else {
|
|
|
|
// Else, we remove it from the results tab
|
|
$("ul#resultul li#k" + key).remove();
|
|
}
|
|
}
|
|
|
|
|
|
// When a field is checked / unchecked
|
|
$('input.fieldpick').click(function() {
|
|
toggleField(this);
|
|
// (un)check all subfields
|
|
var ischecked = this.checked;
|
|
$(this).parent().find("input.subfieldpick").each(function() {
|
|
this.checked = ischecked;
|
|
});
|
|
});
|
|
|
|
// When a field or subfield is checked / unchecked
|
|
$("input.subfieldpick").click(function() {
|
|
toggleField(this);
|
|
});
|
|
|
|
});
|
|
|
|
//]]>
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<!-- TMPL_INCLUDE NAME="header.inc" -->
|
|
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a> › <!-- TMPL_IF NAME="biblionumber" -->Editing <em><!-- TMPL_VAR NAME="title" escape="html" --></em> (Record Number <!-- TMPL_VAR name="biblionumber" -->)<!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></div>
|
|
|
|
<div id="doc" class="yui-t7">
|
|
|
|
<div id="bd">
|
|
<div id="yui-main">
|
|
<div class="yui-g">
|
|
|
|
|
|
<h1>Merging records</h1>
|
|
<!-- TMPL_IF name="result" -->
|
|
<!-- TMPL_IF name="errors" -->
|
|
<!-- TMPL_LOOP name="errors" -->
|
|
<div class="error"><!-- TMPL_VAR name="error" -->.<br />Therefore, the record to be merged has not been deleted.</div>
|
|
<!-- /TMPL_LOOP -->
|
|
|
|
<!-- TMPL_ELSE -->
|
|
<script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->"</script>
|
|
<p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->">Click here to see the merged record.</a></p>
|
|
<!-- /TMPL_IF -->
|
|
|
|
<!-- TMPL_ELSE -->
|
|
|
|
<!-- TMPL_IF NAME="choosereference" -->
|
|
<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>
|
|
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
|
|
<fieldset>
|
|
<legend>Merge reference</legend>
|
|
<input type="radio" value="<!-- TMPL_VAR NAME="biblio1" -->" checked="checked" id="mergereference1" name="mergereference" /><label for="mergereference1"><!-- TMPL_VAR NAME="title1" --> (<!-- TMPL_VAR NAME="biblio1" -->)</label><br />
|
|
<input type="radio" value="<!-- TMPL_VAR NAME="biblio2" -->" id="mergereference2" name="mergereference" /><label for="mergereference2"><!-- TMPL_VAR NAME="title2" --> (<!-- TMPL_VAR NAME="biblio2" -->)</label><br />
|
|
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio1" -->" />
|
|
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio2" -->" />
|
|
<input type="submit" />
|
|
</fieldset>
|
|
</form>
|
|
<!-- TMPL_ELSE -->
|
|
<!-- TMPL_IF name="errors" -->
|
|
<!-- TMPL_LOOP name="errors" -->
|
|
<div class="error"><!-- TMPL_VAR name="error" --></div>
|
|
<!-- /TMPL_LOOP -->
|
|
<!-- TMPL_ELSE -->
|
|
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
|
|
|
|
<div id="tabs" class="yui-u first">
|
|
<h2>Source records</h2>
|
|
<ul>
|
|
<li><a href="#tabrecord1"><!-- TMPL_VAR name="biblio1" --></a></li>
|
|
<li><a href="#tabrecord2"><!-- TMPL_VAR name="biblio2" --></a></li>
|
|
</ul>
|
|
<div id="tabrecord1">
|
|
<!-- TMPL_IF name="record1" -->
|
|
<br />
|
|
<div class="record">
|
|
<ul id="ulrecord1">
|
|
<!-- TMPL_LOOP NAME="record1" -->
|
|
<!-- TMPL_LOOP NAME="field" -->
|
|
<li id="k<!-- TMPL_VAR name="key" -->">
|
|
<input type="checkbox" checked="checked" class="fieldpick" id="rec_1_<!-- TMPL_VAR name="key" -->" />
|
|
<span class="field"><!-- TMPL_VAR NAME="tag" --></span>
|
|
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
|
|
<!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
<!-- /TMPL_IF -->
|
|
|
|
<!-- TMPL_IF NAME="subfield" -->
|
|
<ul>
|
|
<!-- TMPL_LOOP NAME="subfield" -->
|
|
<li id="k<!-- TMPL_VAR name="subkey" -->">
|
|
<input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_<!-- TMPL_VAR name="subkey" -->" />
|
|
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
</ul>
|
|
<!-- /TMPL_IF -->
|
|
<!-- /TMPL_LOOP -->
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div id="tabrecord2">
|
|
<!-- TMPL_IF name="record2" -->
|
|
<br />
|
|
<div class="record">
|
|
<ul id="ulrecord2">
|
|
<!-- TMPL_LOOP NAME="record2" -->
|
|
<!-- TMPL_LOOP NAME="field" -->
|
|
<li id="k<!-- TMPL_VAR name="key" -->">
|
|
<input type="checkbox" class="fieldpick" id="rec_2_<!-- TMPL_VAR name="key" -->" />
|
|
<span class="field"><!-- TMPL_VAR NAME="tag" --></span>
|
|
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
|
|
<!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
<!-- /TMPL_IF -->
|
|
|
|
<!-- TMPL_IF NAME="subfield" -->
|
|
<ul>
|
|
<!-- TMPL_LOOP NAME="subfield" -->
|
|
<li id="k<!-- TMPL_VAR name="subkey" -->">
|
|
<input type="checkbox" class="subfieldpick" id="rec_2_<!-- TMPL_VAR name="subkey" -->" />
|
|
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
</ul>
|
|
<!-- /TMPL_IF -->
|
|
<!-- /TMPL_LOOP -->
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- /TMPL_IF -->
|
|
</div>
|
|
</div> <!-- // #tabs -->
|
|
|
|
<div id="result" class="yui-u">
|
|
<h2>Destination record</h2>
|
|
<br /><br />
|
|
<ul id="resultul">
|
|
<!-- TMPL_LOOP NAME="record1" -->
|
|
<!-- TMPL_LOOP NAME="field" --><li id="k<!-- TMPL_VAR name="key" -->"><span class="field"><!-- TMPL_VAR NAME="tag" --></span>
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
|
|
<!-- TMPL_IF NAME="value" --> /
|
|
<!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
<!-- /TMPL_IF -->
|
|
|
|
<!-- TMPL_IF NAME="subfield" -->
|
|
<ul>
|
|
<!-- TMPL_LOOP NAME="subfield" -->
|
|
<li id="k<!-- TMPL_VAR name="subkey" -->">
|
|
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
|
|
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
</ul>
|
|
<!-- /TMPL_IF -->
|
|
|
|
<!-- /TMPL_LOOP -->
|
|
</li>
|
|
<!-- /TMPL_LOOP -->
|
|
|
|
</ul>
|
|
|
|
<input type="hidden" name="biblio1" value="<!-- TMPL_VAR name="biblio1" -->" />
|
|
<input type="hidden" name="biblio2" value="<!-- TMPL_VAR name="biblio2" -->" />
|
|
<input type="hidden" name="mergereference" value="<!-- TMPL_VAR name="mergereference" -->" />
|
|
|
|
<p><input type="submit" name="merge" value="merge" /></p>
|
|
|
|
</div> <!-- // #result -->
|
|
</form>
|
|
<!-- /TMPL_IF -->
|
|
<!-- /TMPL_IF -->
|
|
<!-- /TMPL_IF -->
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|