788 lines
42 KiB
Plaintext
788 lines
42 KiB
Plaintext
[% USE raw %]
|
|
[% USE Koha %]
|
|
[% USE Asset %]
|
|
[% USE KohaDates %]
|
|
[% USE TablesSettings %]
|
|
[% PROCESS 'i18n.inc' %]
|
|
[% SET footerjs = 1 %]
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
<title
|
|
>[% FILTER collapse %]
|
|
[% IF ( job_enqueued ) %]
|
|
[% t("Job enqueued") | html %]
|
|
›
|
|
[% END %]
|
|
[% IF ( import_batch_id ) %]
|
|
[% tx("Batch {batch_import_number}", { batch_import_number = import_batch_id }) | html %]
|
|
›
|
|
[% END %]
|
|
[% t("Manage staged MARC records") | html %]
|
|
› [% t("Cataloging") | html %] › [% t("Koha") | html %]
|
|
[% END %]</title
|
|
>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
[% Asset.css("css/humanmsg.css") | $raw %]
|
|
<style nonce="[% Koha.CSPNonce | $raw %]">
|
|
span.change-status {
|
|
font-style: italic;
|
|
color: #666;
|
|
display: none;
|
|
}
|
|
ul.matches li {
|
|
list-style-type: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body id="tools_manage-marc-import" class="tools">
|
|
[% WRAPPER 'header.inc' %]
|
|
[% INCLUDE 'cat-search.inc' %]
|
|
[% END %]
|
|
|
|
[% WRAPPER 'sub-header.inc' %]
|
|
[% WRAPPER breadcrumbs %]
|
|
[% WRAPPER breadcrumb_item %]
|
|
<a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
|
|
[% END %]
|
|
[% IF ( import_batch_id || job_enqueued ) %]
|
|
[% WRAPPER breadcrumb_item %]
|
|
<a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>
|
|
[% END %]
|
|
[% END %]
|
|
[% IF ( import_batch_id ) %]
|
|
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
|
<span>Batch [% import_batch_id | html %]</span>
|
|
[% END %]
|
|
[% ELSIF ( job_enqueued ) %]
|
|
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
|
[% t("Job enqueued") | html %]
|
|
[% END %]
|
|
[% ELSE %]
|
|
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
|
<span>Manage staged MARC records</span>
|
|
[% END %]
|
|
[% END %]
|
|
[% END #/ WRAPPER breadcrumbs %]
|
|
[% END #/ WRAPPER sub-header.inc %]
|
|
|
|
[% WRAPPER 'main-container.inc' aside='cat-menu' %]
|
|
<h1>Manage staged MARC records</h1>
|
|
[% IF ( import_batch_id ) %]
|
|
<h2>Batch [% import_batch_id | html %]</h2>
|
|
[% END %]
|
|
[% FOREACH message IN messages %]
|
|
[% SET div_class = '' %]
|
|
[% SET div_style = '' %]
|
|
[% IF message.type == 'success' %]
|
|
[% SET div_class="alert alert-info" %]
|
|
[% ELSIF message.type == 'warning' %]
|
|
[% SET div_class="alert alert-warning" %]
|
|
[% ELSIF message.type == 'error' %]
|
|
[% SET div_class="alert alert-warning" %]
|
|
[% SET div_style="margin:auto;" %]
|
|
[% END %]
|
|
<div class="[% div_class | html %]" style="[% div_style | html %]">
|
|
[% IF message.code == 'cannot_enqueue_job' %]
|
|
<span>Cannot enqueue this job.</span>
|
|
[% END %]
|
|
[% IF message.error %]
|
|
<span>(The error was: [% message.error | html %], see the Koha log file for more information).</span>
|
|
[% END %]
|
|
</div>
|
|
[% END %]
|
|
|
|
[% IF job_enqueued %]
|
|
<div class="alert alert-info">
|
|
<h1>The job has been enqueued!</h1>
|
|
<p>It will be processed as soon as possible.</p>
|
|
<p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]">View detail of the enqueued job</a> </p></div
|
|
>
|
|
[% ELSIF ( label_batch_msg ) %]
|
|
[% IF ( alert ) %]
|
|
[% SET div_class="alert" %]
|
|
[% ELSE %]
|
|
[% SET div_class="alert alert-info" %]
|
|
[% END %]
|
|
<div class="[% div_class | html %]">
|
|
<p
|
|
><strong>
|
|
[% IF ( label_batch_msg == "error" ) %]
|
|
<span>Error attempting to create label batch. Please ask your system administrator to check the log for more details.</span>
|
|
[% ELSE %]
|
|
<span>Label</span> <a href="/cgi-bin/koha/labels/label-edit-batch.pl?op=edit&element_id=[% label_batch_msg | uri %]">batch #[% label_batch_msg | html %]</a> created.
|
|
[% END %]
|
|
</strong></p
|
|
>
|
|
</div>
|
|
[% END %]
|
|
|
|
[% IF ( did_clean ) %]
|
|
<div class="alert alert-info">Cleaned import batch #[% import_batch_id | html %]</div>
|
|
[% END %]
|
|
|
|
[% IF ( did_delete ) %]
|
|
<div class="alert alert-info">Import batch deleted successfully</div>
|
|
[% END %]
|
|
|
|
[% UNLESS batch_list || batch_info || job_enqueued %]
|
|
<div class="alert alert-info">
|
|
<p>No records have been staged.</p>
|
|
<p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
|
|
</div>
|
|
[% END %]
|
|
|
|
[% IF ( batch_info ) %]
|
|
[% IF ( rematch_attempted ) %]
|
|
[% IF ( rematch_failed ) %]
|
|
<div class="alert alert-warning">Failed to apply different matching rule</div>
|
|
[% ELSE %]
|
|
<div class="alert alert-info">Applied different matching rule. Number of records matched now [% num_with_matches | html %] </div>
|
|
[% END %]
|
|
[% END %]
|
|
|
|
[% IF ( changed_overlay_action ) %]
|
|
<div class="alert alert-info">Changed action if matching record found</div>
|
|
[% END %]
|
|
|
|
[% IF ( changed_nomatch_action ) %]
|
|
<div class="alert alert-info">Changed action if no match found</div>
|
|
[% END %]
|
|
|
|
[% IF ( changed_item_action ) %]
|
|
<div class="alert alert-info">Changed item processing option</div>
|
|
[% END %]
|
|
|
|
[% UNLESS job_enqueued %]
|
|
<fieldset class="rows" id="staged-record-matching-rules">
|
|
<ol>
|
|
<li><span class="label">File name:</span> [% file_name | html %]</li>
|
|
<li><span class="label">Profile:</span> [% IF (profile) %][% profile | html %][% ELSE %](none)[% END %]</li>
|
|
<li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
|
|
<li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
|
|
<li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
|
|
<li
|
|
><span class="label">Status:</span>
|
|
[% IF ( import_status == 'cleaned' ) %]
|
|
<span>Cleaned</span>
|
|
[% ELSIF ( import_status == 'imported' ) %]
|
|
<span>Imported</span>
|
|
[% ELSIF ( import_status == 'importing' ) %]
|
|
<span>Importing</span>
|
|
[% ELSIF ( import_status == 'reverted' ) %]
|
|
<span>Reverted</span>
|
|
[% ELSIF ( import_status == 'reverting' ) %]
|
|
<span>Reverting</span>
|
|
[% ELSIF ( import_status == 'staged' ) %]
|
|
<span>Staged</span>
|
|
[% ELSE %]
|
|
[% import_status | html %]
|
|
[% END %]
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
<!-- /#staged-record-matching-rules -->
|
|
[% IF ( can_commit ) %]
|
|
<form method="post">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="op" value="cud-redo-matching" />
|
|
<input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
|
|
<input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
|
|
<fieldset class="rows">
|
|
<ol>
|
|
<li>
|
|
<label for="new_matcher_id">Matching rule applied:</label>
|
|
<select name="new_matcher_id" id="new_matcher_id">
|
|
<option value="">Do not look for matching records</option>
|
|
[% FOREACH available_matcher IN available_matchers %]
|
|
[% IF ( available_matcher.selected ) %]
|
|
<option value="[% available_matcher.matcher_id | html %]" selected="selected"> [% available_matcher.code | html %] ([% available_matcher.description | html %]) </option>
|
|
[% ELSE %]
|
|
<option value="[% available_matcher.matcher_id | html %]"> [% available_matcher.code | html %] ([% available_matcher.description | html %]) </option>
|
|
[% END %]
|
|
[% END %]
|
|
</select>
|
|
<span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
|
|
</li>
|
|
<li>
|
|
<label for="overlay_action">Action if matching record found:</label>
|
|
[% INCLUDE 'tools-overlay-action.inc' action=overlay_action %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
|
|
</li>
|
|
<li>
|
|
<label for="nomatch_action">Action if no match found:</label>
|
|
[% INCLUDE 'tools-nomatch-action.inc' action=nomatch_action %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
|
|
</li>
|
|
[% IF ( record_type == 'biblio' ) %]
|
|
<li>
|
|
<label for="item_action">Item processing:</label>
|
|
[% INCLUDE 'tools-item-action.inc' action=item_action %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
|
|
</li>
|
|
[% ELSE %]
|
|
<input type="hidden" name="item_action" value="ignore" />
|
|
[% END %]
|
|
</ol>
|
|
<fieldset class="action"><input type="submit" class="btn btn-secondary" value="Apply different matching rules" /></fieldset>
|
|
</fieldset>
|
|
</form>
|
|
<div>
|
|
<form method="post" id="import_batch_form">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="op" value="cud-commit-batch" />
|
|
<input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
|
|
[% IF ( record_type != 'auth' ) %]
|
|
<fieldset class="rows">
|
|
<ol>
|
|
<li>
|
|
<label for="frameworks">New record framework:</label>
|
|
<select name="framework" id="frameworks">
|
|
<option value="">Default</option>
|
|
[% FOREACH framework IN frameworks %]
|
|
<option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
|
|
[% END %]
|
|
</select>
|
|
<div class="hint">New bibliographic records will use this framework</div>
|
|
</li>
|
|
<li>
|
|
<label for="overlay_framework">Replacement record framework:</label>
|
|
<select name="overlay_framework" id="overlay_frameworks">
|
|
<option value="_USE_ORIG_">Keep original framework</option>
|
|
<option value="">Default</option>
|
|
[% FOREACH framework IN frameworks %]
|
|
<option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
|
|
[% END %]
|
|
</select>
|
|
<div class="hint">Replacement records will use this framework</div>
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
[% END %]
|
|
<fieldset class="action">
|
|
<input type="submit" class="btn btn-primary" name="mainformsubmit" value="Import this batch into the catalog" />
|
|
</fieldset>
|
|
</form>
|
|
<!-- /#import_batch_form -->
|
|
</div>
|
|
[% END %]
|
|
|
|
[% UNLESS can_commit %]
|
|
<fieldset class="rows">
|
|
<ol>
|
|
<li>
|
|
<span class="label">Matching rule applied:</span>
|
|
[% IF ( current_matcher_id ) %]
|
|
[% current_matcher_code | html %]
|
|
([% current_matcher_description | html %])
|
|
[% ELSE %]
|
|
<span>No matching rule in effect</span>
|
|
[% END %]
|
|
</li>
|
|
<li>
|
|
<span class="label">Action if matching record found:</span>
|
|
[% IF ( overlay_action == 'replace' ) %]
|
|
<span>Replace existing record with incoming record</span>
|
|
[% ELSIF ( overlay_action == 'create_new' ) %]
|
|
<span>Add incoming record</span>
|
|
[% ELSIF ( overlay_action == 'ignore' ) %]
|
|
<span>Ignore incoming record (its items may still be processed)</span>
|
|
[% ELSE %]
|
|
<span>[% overlay_action | html %]</span>
|
|
[% END %]
|
|
</li>
|
|
<li>
|
|
<span class="label">Action if no match found:</span>
|
|
[% IF ( nomatch_action == 'create_new' ) %]
|
|
Add incoming record
|
|
[% ELSIF ( nomatch_action == 'ignore' ) %]
|
|
Ignore incoming record (its items may still be processed)
|
|
[% ELSE %]
|
|
[% nomatch_action | html %]
|
|
[% END %]
|
|
</li>
|
|
[% IF ( record_type == 'biblio' ) %]
|
|
<li>
|
|
<span class="label">Item processing:</span>
|
|
[% IF ( item_action == 'always_add' ) %]
|
|
<span>Always add items</span>
|
|
[% ELSIF ( item_action == 'add_only_for_matches' ) %]
|
|
<span>Add items only if matching bib was found</span>
|
|
[% ELSIF ( item_action == 'add_only_for_new' ) %]
|
|
<span>Add items only if no matching bib was found</span>
|
|
[% ELSIF ( item_action == 'ignore' ) %]
|
|
<span>Ignore items</span>
|
|
[% ELSE %]
|
|
<span>[% item_action | html %]</span>
|
|
[% END %]
|
|
</li>
|
|
[% END %]
|
|
</ol>
|
|
</fieldset>
|
|
|
|
[% IF ( can_revert ) %]
|
|
<form method="post" id="revert_batch_form">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="op" value="cud-revert-batch" />
|
|
<input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
|
|
<fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
|
|
</form>
|
|
[% END # /IF can_revert %]
|
|
[% END #/UNLESS can_commit %]
|
|
[% END #/UNLESS job_enqueue %]
|
|
[% END # /IF batch_info %]
|
|
|
|
<br style="clear:both;" />
|
|
|
|
[% IF ( batch_list ) %]
|
|
[% IF ( pages ) %]
|
|
[% PROCESS pagination %]
|
|
[% END %]
|
|
<div class="page-section">
|
|
<table class="dataTable">
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>File name</th>
|
|
<th>Profile</th>
|
|
<th>Comments</th>
|
|
<th>Type</th>
|
|
<th>Status</th>
|
|
<th>Staged</th>
|
|
<th># Records</th>
|
|
<th># Items</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
[% FOREACH batch_lis IN batch_list %]
|
|
<tr>
|
|
<td>[% batch_lis.import_batch_id | html %]</td>
|
|
<td><a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
|
|
<td>[% batch_lis.profile | html %]</td>
|
|
<td>[% batch_lis.comments | html %]</td>
|
|
<td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
|
|
<td>
|
|
[% IF ( batch_lis.import_status == 'cleaned' ) %]
|
|
<span>Cleaned</span>
|
|
[% ELSIF ( batch_lis.import_status == 'imported' ) %]
|
|
<span>Imported</span>
|
|
[% ELSIF ( batch_lis.import_status == 'importing' ) %]
|
|
<span>Importing</span>
|
|
[% ELSIF ( batch_lis.import_status == 'reverted' ) %]
|
|
<span>Reverted</span>
|
|
[% ELSIF ( batch_lis.import_status == 'reverting' ) %]
|
|
<span>Reverting</span>
|
|
[% ELSIF ( batch_lis.import_status == 'staged' ) %]
|
|
<span>Staged</span>
|
|
[% ELSE %]
|
|
<span>[% batch_lis.import_status | html %]</span>
|
|
[% END %]
|
|
</td>
|
|
<td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
|
|
<td>[% batch_lis.num_records | html %]</td>
|
|
<td
|
|
>[% batch_lis.num_items | html %]
|
|
[% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
|
|
(<a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
|
|
[% END %]
|
|
</td>
|
|
<td class="actions">
|
|
[% IF ( batch_lis.can_clean ) %]
|
|
<form method="post" name="clean_batch_[% batch_lis.import_batch_id | html %]" id="clean_batch_[% batch_lis.import_batch_id | html %]" class="batch_form batch_clean">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
|
|
<input type="hidden" name="op" value="cud-clean-batch" />
|
|
<input type="hidden" name="import_status" value="[% batch_lis.import_status | html %]" />
|
|
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
|
|
</form>
|
|
[% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
|
|
<form
|
|
method="post"
|
|
action="/cgi-bin/koha/tools/manage-marc-import.pl"
|
|
name="delete_batch_[% batch_lis.import_batch_id | html %]"
|
|
id="delete_batch_[% batch_lis.import_batch_id | html %]"
|
|
class="batch_form batch_delete"
|
|
>
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
|
|
<input type="hidden" name="op" value="cud-delete-batch" />
|
|
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</button>
|
|
</form>
|
|
[% END %]
|
|
</td>
|
|
</tr>
|
|
[% END # /FOREACH batch_lis %]
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- /.page-section -->
|
|
|
|
[% IF ( pages ) %]
|
|
[% PROCESS pagination %]
|
|
[% END %]
|
|
[% END # /IF batch_lis %]
|
|
|
|
[% IF import_batch_id && !did_clean %]
|
|
<div class="page-section">
|
|
<table id="records-table">
|
|
<thead>
|
|
<tr>
|
|
<th data-colname="import_record_id">#</th>
|
|
<th data-colname="citation">Citation</th>
|
|
<th data-colname="status">Status</th>
|
|
<th data-colname="overlay_status">Match type</th>
|
|
<th data-colname="match_details">Match details</th>
|
|
<th data-colname="match_score_breakdown">Score breakdown</th>
|
|
<th data-colname="diff"><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
|
|
<th data-colname="matched">Record</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
|
|
<div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-xl">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title" id="marcPreviewLabel">MARC preview</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-default" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- /#marcPreview -->
|
|
[% END # /IF import_batch_id %]
|
|
[% END %]
|
|
[% MACRO jsinclude BLOCK %]
|
|
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
|
|
[% INCLUDE 'datatables.inc' %]
|
|
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
|
const interface = "[% interface | html %]";
|
|
const theme = "[% theme | html %]";
|
|
const import_batch_id = "[% import_batch_id | html %]";
|
|
const record_type = "[% record_type | html %]";
|
|
Koha.addPermissions({
|
|
CAN_user_editcatalogue_edit_catalogue: [% CAN_user_editcatalogue_edit_catalogue ? 1 : 0 | html %],
|
|
});
|
|
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'manage-marc-import', 'records-table', 'json' ) | $raw %];
|
|
</script>
|
|
<script nonce="[% Koha.CSPNonce | $raw %]">
|
|
$(document).ready(function () {
|
|
$("#staged-record-matching-rules select").change(function () {
|
|
var str = $(this).attr("id");
|
|
$("#reset_" + str)
|
|
.parent()
|
|
.show();
|
|
});
|
|
$("a.reset").click(function () {
|
|
var str = $(this).attr("id");
|
|
str = str.replace("reset_", "");
|
|
$("#" + str + " option[selected='selected']").attr("selected", "selected");
|
|
$(this).parent().hide();
|
|
});
|
|
|
|
if (import_batch_id) {
|
|
$("#records-table").kohaTable(
|
|
{
|
|
autoWidth: false,
|
|
searching: false,
|
|
processing: true,
|
|
serverSide: true,
|
|
ajax: {
|
|
url: "batch_records_ajax.pl",
|
|
data: function (d) {
|
|
d.import_batch_id = import_batch_id;
|
|
return d;
|
|
},
|
|
},
|
|
bKohaAjaxSVC: true,
|
|
pagingType: "full_numbers",
|
|
dom: '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
|
|
columns: [
|
|
{
|
|
data: "import_record_id",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "import_record_id");
|
|
},
|
|
},
|
|
{
|
|
data: "citation",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "citation");
|
|
},
|
|
},
|
|
{
|
|
data: "status",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "status");
|
|
},
|
|
},
|
|
{
|
|
data: "overlay_status",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "overlay_status");
|
|
},
|
|
},
|
|
{
|
|
data: null,
|
|
defaultContent: "",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "match_details");
|
|
},
|
|
},
|
|
{
|
|
data: null,
|
|
defaultContent: "",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "match_score_breakdown");
|
|
},
|
|
},
|
|
{
|
|
data: null,
|
|
defaultContent: "",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "diff");
|
|
},
|
|
},
|
|
{
|
|
data: "matched",
|
|
createdCell: function (td) {
|
|
$(td).attr("data-colname", "matched");
|
|
},
|
|
},
|
|
],
|
|
rowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
|
var record_details_url = record_type == "auth" ? "/cgi-bin/koha/authorities/detail.pl?authid=" : "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
|
|
var record_edit_url = record_type == "auth" ? "/cgi-bin/koha/authorities/authorities.pl?authid=" : "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
|
|
|
|
var additional_details = "";
|
|
if (aData["author"]) {
|
|
additional_details += " " + escape_str(aData["author"]) + " ";
|
|
}
|
|
|
|
if (aData["isbn"]) {
|
|
additional_details += " (" + escape_str(aData["isbn"]) + ") ";
|
|
}
|
|
|
|
if (aData["issn"]) {
|
|
additional_details += " (" + escape_str(aData["issn"]) + ") ";
|
|
}
|
|
|
|
$("td[data-colname='citation']", nRow).html(
|
|
'<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData["import_record_id"] + '&viewas=html" class="previewMARC">' + escape_str(aData["citation"]) + "</a> " + additional_details
|
|
);
|
|
|
|
$("td[data-colname='status']", nRow).html(
|
|
aData["status"] == "imported"
|
|
? _("Imported")
|
|
: aData["status"] == "ignored"
|
|
? _("Ignored")
|
|
: aData["status"] == "reverted"
|
|
? _("Reverted")
|
|
: aData["status"] == "staged"
|
|
? _("Staged")
|
|
: aData["status"] == "error"
|
|
? _("Error")
|
|
: aData["status"]
|
|
);
|
|
|
|
$("td[data-colname='overlay_status']", nRow).html(
|
|
aData["overlay_status"] == "no_match" ? _("No match") : aData["overlay_status"] == "match_applied" ? _("Match applied") : aData["overlay_status"] == "auto_match" ? _("Match found") : aData["overlay_status"]
|
|
);
|
|
|
|
if (aData["matches"].length > 0) {
|
|
var any_checked = 0;
|
|
$("td[data-colname='match_details']", nRow).html('<ul class="matches"></ul>');
|
|
$("td[data-colname='match_score_breakdown']", nRow).html('<ul class="matches"></ul>');
|
|
$("td[data-colname='diff']", nRow).html('<ul class="matches"></ul>');
|
|
var checked = "";
|
|
var disabled = "";
|
|
if (aData["status"] == "imported" || aData["status"] == "ignored") {
|
|
disabled = " disabled ";
|
|
}
|
|
aData["matches"].forEach(function (item, index) {
|
|
if (item.chosen == 1) {
|
|
checked = 'checked="checked"';
|
|
any_checked = 1;
|
|
}
|
|
var match_option = "";
|
|
match_option =
|
|
'<input type="radio" data-import_record_id="' +
|
|
aData["import_record_id"] +
|
|
'" class="chosen" name="import_record_id_' +
|
|
aData["import_record_id"] +
|
|
'_match" value="' +
|
|
item.candidate_match_id +
|
|
'" ' +
|
|
checked +
|
|
disabled +
|
|
"> ";
|
|
|
|
var diff_url = "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s";
|
|
var match_citation = "";
|
|
var matching_msg = "";
|
|
if (item.record_type == "auth") {
|
|
matching_msg = _("Matches authority %s (score=%s):%s");
|
|
if (item.authorized_heading) {
|
|
match_citation += item.authorized_heading;
|
|
}
|
|
} else {
|
|
matching_msg = _("Matches bibliographic record %s (score=%s):%s");
|
|
if (item.title) {
|
|
match_citation += item.title + " ";
|
|
}
|
|
if (item.author) {
|
|
match_citation += item.author;
|
|
}
|
|
}
|
|
$("td[data-colname='match_details'] ul", nRow).append(
|
|
'<li><label for="import_record_id_' +
|
|
aData["import_record_id"] +
|
|
"_match_" +
|
|
index +
|
|
'">' +
|
|
match_option +
|
|
matching_msg.format(item.candidate_match_id, item.score, '<a target="_blank" href="' + record_details_url + item.candidate_match_id + '">' + match_citation + "</a></label></li>")
|
|
);
|
|
var score_breakdown = "";
|
|
if (item.composite_scores && Object.keys(item.composite_scores).length > 0) {
|
|
score_breakdown = Object.entries(item.composite_scores)
|
|
.map(function (e) {
|
|
return e[0] + ":" + e[1];
|
|
})
|
|
.join(", ");
|
|
}
|
|
$("td[data-colname='match_score_breakdown'] ul", nRow).append("<li>" + (score_breakdown || item.score) + "</li>");
|
|
$("td[data-colname='diff'] ul", nRow).append('<li><a href="' + diff_url.format(import_batch_id, aData["import_record_id"], item.candidate_match_id, item.record_type) + '">' + _("View") + "</a></li>");
|
|
checked = "";
|
|
});
|
|
if (!any_checked) {
|
|
checked = 'checked="checked"';
|
|
}
|
|
$("td[data-colname='match_details'] ul", nRow).prepend(
|
|
'<li><label><input type="radio" data-import_record_id="' +
|
|
aData["import_record_id"] +
|
|
'" class="chosen" name="import_record_id_' +
|
|
aData["import_record_id"] +
|
|
'_match" value="none" ' +
|
|
checked +
|
|
disabled +
|
|
" > " +
|
|
_("Ignore matches") +
|
|
"</label></li>"
|
|
);
|
|
$("td[data-colname='match_score_breakdown'] ul", nRow).prepend("<li> </li>");
|
|
$("td[data-colname='diff'] ul", nRow).prepend("<li> </li>");
|
|
}
|
|
if (aData["diff_url"]) {
|
|
$("td[data-colname='diff']", nRow).html('<a href="' + aData["diff_url"] + '">' + _("View") + "</a>");
|
|
}
|
|
if (aData["matched"]) {
|
|
let buttons = '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url + aData["matched"] + '"><i class="fa-solid fa-eye"></i> ' + _("View") + "</a> ";
|
|
if (Koha.permissions.CAN_user_editcatalogue_edit_catalogue) {
|
|
buttons += '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url + aData["matched"] + '"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + "</a>";
|
|
}
|
|
$("td[data-colname='matched']", nRow).html(buttons);
|
|
}
|
|
},
|
|
},
|
|
table_settings
|
|
);
|
|
$("#revert_batch_form").on("submit", function () {
|
|
return confirm(_("Are you sure you want to undo the import of this batch into the catalog?"));
|
|
});
|
|
}
|
|
|
|
$("body").on("change", ".chosen", function (e) {
|
|
let apimethod = "DELETE";
|
|
let apidata = "";
|
|
if ($(this).val() != "none") {
|
|
apimethod = "PUT";
|
|
apidata = JSON.stringify({ candidate_match_id: $(this).val() });
|
|
}
|
|
$.ajax({
|
|
url: "/api/v1/import_batches/" + import_batch_id + "/records/" + $(this).data("import_record_id") + "/matches/chosen",
|
|
method: apimethod,
|
|
data: apidata,
|
|
contentType: "application/json",
|
|
}).fail(function () {
|
|
alert(_("Unable to update match choices"));
|
|
return false;
|
|
});
|
|
});
|
|
|
|
$("body").on("click", ".previewMARC", function (e) {
|
|
e.preventDefault();
|
|
var ltitle = $(this).text();
|
|
var page = $(this).attr("href");
|
|
$("#marcPreviewLabel").text(ltitle);
|
|
$("#marcPreview .modal-body").load(page + " table");
|
|
$("#marcPreview").modal("show");
|
|
});
|
|
$("#marcPreview").on("hidden.bs.modal", function () {
|
|
$("#marcPreviewLabel").html("");
|
|
$("#marcPreview .modal-body").html('<div id="loading"><img src="' + interface + "/" + theme + '/img/spinner-small.gif" alt="" /> ' + _("Loading") + "</div>");
|
|
});
|
|
$(".batch_form").on("submit", function () {
|
|
if ($(this).hasClass("batch_delete")) {
|
|
return confirm(_("Are you sure you want to permanently delete this batch?"));
|
|
} else {
|
|
if ($(this).find("input[name='import_status']").val() === "imported") {
|
|
return confirm(_("This batch contains imported records. Are you sure you wish to clear all the reservoir records? This cannot be undone."));
|
|
} else {
|
|
return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
[% IF job_enqueued %]
|
|
<script nonce="[% Koha.CSPNonce | $raw %]">
|
|
$(document).ready(function () {
|
|
setTimeout(
|
|
function () {
|
|
window.location.href = $("a.job_details").attr("href");
|
|
},
|
|
5000 // 5 secs to read
|
|
);
|
|
});
|
|
</script>
|
|
[% END %]
|
|
[% END %]
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|
|
[% BLOCK pagination %]
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination">
|
|
[% FOREACH page IN pages %]
|
|
[% IF ( page.current_page && page.page_number > 1 ) %]
|
|
<li class="page-item"
|
|
><a href="?offset=0" class="page-link"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li
|
|
>
|
|
<li class="page-item"
|
|
><a href="?offset=[% offset - results_per_page | uri %]" class="page-link"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li
|
|
>
|
|
[% END %]
|
|
[% END %]
|
|
[% FOREACH page IN pages %]
|
|
[% IF ( page.current_page ) %]
|
|
[% SET current_page = page.page_number %]
|
|
<li class="page-item active" aria-current="page"><span class="page-link">[% page.page_number | html %]</span></li>
|
|
[% ELSE %]
|
|
<li class="page-item"><a class="page-link" href="?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
|
|
[% END %]
|
|
[% END %]
|
|
[% IF ( current_page < pages.size() ) %]
|
|
<li class="page-item">
|
|
<a href="?offset=[% offset + results_per_page | uri %]" class="page-link">Next <i class="fa fa-fw fa-angle-right"></i></a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a href="?offset=[% ( results_per_page * ( pages.size - 1 ) ) | uri %]" class="page-link">Last <i class="fa fa-fw fa-angle-double-right"></i></a>
|
|
</li>
|
|
[% END %]
|
|
</ul>
|
|
</nav>
|
|
[% END %]
|