5 [% INCLUDE 'doc-head-open.inc' %]
7 [% IF ( import_batch_id ) %]
8 Batch [% import_batch_id | html %] › [% END %]
9 Manage staged MARC records › Cataloging › Koha
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/humanmsg.css") | $raw %]
14 #jobpanel,#jobstatus,#jobfailed { display : none; }
15 span.change-status { font-style:italic; color:#666; display:none; }
16 ul.matches li { list-style-type:none; }
20 <body id="tools_manage-marc-import" class="tools">
21 [% WRAPPER 'header.inc' %]
22 [% INCLUDE 'cat-search.inc' %]
25 [% WRAPPER 'sub-header.inc' %]
26 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
29 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
34 [% IF ( import_batch_id ) %]
36 <a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>
39 <a href="#" aria-current="page">
40 Batch [% import_batch_id | html %]
45 <a href="#" aria-current="page">
46 Manage staged MARC records
54 <div class="main container-fluid">
56 <div class="col-sm-10 col-sm-push-2">
58 <h1>Manage staged MARC records
59 [% IF ( import_batch_id ) %]
60 › Batch [% import_batch_id | html %]
63 [% FOREACH message IN messages %]
64 [% IF message.type == 'success' %]
65 <div class="dialog message">
66 [% ELSIF message.type == 'warning' %]
67 <div class="dialog alert">
68 [% ELSIF message.type == 'error' %]
69 <div class="dialog alert" style="margin:auto;">
71 [% IF message.code == 'cannot_enqueue_job' %]
72 <span>Cannot enqueue this job.</span>
74 [% IF message.error %]
75 <span>(The error was: [% message.error | html %], see the Koha log file for more information).</span>
81 <div class="dialog message">
82 <p>The job has been enqueued! It will be processed as soon as possible.</p>
83 <p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
86 [% ELSIF ( label_batch_msg ) %]
90 <div class="dialog message">
93 [% IF ( label_batch_msg == "error" ) %]
94 <span>Error attempting to create label batch. Please ask your system administrator to check the log for more details.</span>
96 <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.
102 [% IF ( did_clean ) %]
103 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
106 [% IF ( did_delete ) %]
107 <div class="dialog message">Import batch deleted successfully</div>
110 [% UNLESS batch_list || batch_info || job_enqueued %]
111 <div class="dialog message">
112 <p>No records have been staged.</p>
113 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
117 [% IF ( batch_info ) %]
118 [% IF ( can_commit ) %]
120 <input type="hidden" name="op" value="redo-matching" />
121 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
122 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
125 [% IF ( rematch_attempted ) %]
126 [% IF ( rematch_failed ) %]
127 <div class="dialog alert">Failed to apply different matching rule</div>
129 <div class="dialog message">Applied different matching rule. Number of records matched now
130 [% num_with_matches | html %]
135 [% IF ( changed_overlay_action ) %]
136 <div class="dialog message">Changed action if matching record found</div>
139 [% IF ( changed_nomatch_action ) %]
140 <div class="dialog message">Changed action if no match found</div>
143 [% IF ( changed_item_action ) %]
144 <div class="dialog message">Changed item processing option</div>
147 [% UNLESS job_enqueued %]
148 <fieldset class="rows" id="staged-record-matching-rules">
150 <li><span class="label">File name:</span> [% file_name | html %]</li>
151 <li><span class="label">Profile:</span> [% IF (profile) %][% profile | html %][% ELSE %](none)[% END %]</li>
152 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
153 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
154 <li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
155 <li><span class="label">Status:</span>
156 [% IF ( import_status == 'cleaned' ) %]
158 [% ELSIF ( import_status == 'imported' ) %]
159 <span>Imported</span>
160 [% ELSIF ( import_status == 'importing' ) %]
161 <span>Importing</span>
162 [% ELSIF ( import_status == 'reverted' ) %]
163 <span>Reverted</span>
164 [% ELSIF ( import_status == 'reverting' ) %]
165 <span>Reverting</span>
166 [% ELSIF ( import_status == 'staged' ) %]
169 [% import_status | html %]
173 [% IF ( can_commit ) %]
174 <label for="new_matcher_id">Matching rule applied:</label>
175 <select name="new_matcher_id" id="new_matcher_id">
176 <option value="">Do not look for matching records</option>
177 [% FOREACH available_matcher IN available_matchers %]
178 [% IF ( available_matcher.selected ) %]
179 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
180 [% available_matcher.code | html %] ([% available_matcher.description | html %])
183 <option value="[% available_matcher.matcher_id | html %]">
184 [% available_matcher.code | html %] ([% available_matcher.description | html %])
189 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
191 <span class="label">Matching rule applied:</span>
192 [% IF ( current_matcher_id ) %]
193 [% current_matcher_code | html %] ([% current_matcher_description | html %])
195 <span>No matching rule in effect</span>
200 [% IF ( can_commit ) %]
201 <label for="overlay_action">Action if matching record found:</label>
202 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
204 <span class="label">Action if matching record found:</span>
205 [% IF ( overlay_action == 'replace' ) %]
206 <span>Replace existing record with incoming record</span>
207 [% ELSIF ( overlay_action == 'create_new' ) %]
208 <span>Add incoming record</span>
209 [% ELSIF ( overlay_action == 'ignore' ) %]
210 <span>Ignore incoming record (its items may still be processed)</span>
212 <span>[% overlay_action | html %]</span>
217 [% IF ( can_commit ) %]
218 <label for="nomatch_action">Action if no match found:</label>
219 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
221 <span class="label">Action if no match found:</span>
222 [% IF ( nomatch_action == 'create_new' ) %]
224 [% ELSIF ( nomatch_action == 'ignore' ) %]
225 Ignore incoming record (its items may still be processed)
227 [% nomatch_action | html %]
231 [% IF ( record_type == 'biblio' ) %]
233 [% IF ( can_commit ) %]
234 <label for="item_action">Item processing:</label>
235 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
237 <span class="label">Item processing:</span>
238 [% IF ( item_action == 'always_add' ) %]
239 <span>Always add items</span>
240 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
241 <span>Add items only if matching bib was found</span>
242 [% ELSIF ( item_action == 'add_only_for_new' ) %]
243 <span>Add items only if no matching bib was found</span>
244 [% ELSIF ( item_action == 'ignore' ) %]
245 <span>Ignore items</span>
247 <span>[% item_action | html %]</span>
252 <input type ="hidden" name="item_action" value="ignore">
255 [% IF ( can_commit ) %]
256 <fieldset class="action"><input type="submit" class="btn btn-primary" value="Apply different matching rules" /></fieldset>
259 </fieldset> <!-- /#staged-record-matching-rules -->
262 [% IF ( can_commit ) %]
263 <form method="post" id="import_batch_form">
264 <input type="hidden" name="op" value="commit-batch" />
265 <input type="hidden" name="runinbackground" value="" />
266 <input type="hidden" name="completedJobID" value="" />
267 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
268 <fieldset class="action">
269 [% IF ( record_type != 'auth' ) %]
270 Add new bibliographic records into this framework:
271 <select name="framework" id="frameworks">
272 <option value="">Default</option>
273 [% FOREACH framework IN frameworks %]
274 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
278 When replacing records use this framework:
279 <select name="overlay_framework" id="overlay_frameworks">
280 <option value="_USE_ORIG_">Keep original framework</option>
281 <option value="">Default</option>
282 [% FOREACH framework IN frameworks %]
283 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
288 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
290 </form> <!-- /#import_batch_form -->
292 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
293 <div id="jobfailed"></div>
295 [% END # /IF can_commit %]
296 [% IF ( can_revert ) %]
297 <form method="post" id="revert_batch_form">
298 <input type="hidden" name="op" value="revert-batch" />
299 <input type="hidden" name="runinbackground" value="" />
300 <input type="hidden" name="completedJobID" value="" />
301 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
302 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
305 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
306 <div id="jobfailed"></div>
308 [% END # /IF can_revert %]
312 [% END # /IF batch_info %]
314 <br style="clear:both;" />
316 [% IF ( batch_list ) %]
318 [% PROCESS pagination %]
320 <div class="page-section">
321 <table class="dataTable">
337 [% FOREACH batch_lis IN batch_list %]
339 <td>[% batch_lis.import_batch_id | html %]</td>
340 <td><a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
341 <td>[% batch_lis.profile | html %]</td>
342 <td>[% batch_lis.comments | html %]</td>
343 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
345 [% IF ( batch_lis.import_status == 'cleaned' ) %]
347 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
348 <span>Imported</span>
349 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
350 <span>Importing</span>
351 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
352 <span>Reverted</span>
353 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
354 <span>Reverting</span>
355 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
358 <span>[% batch_lis.import_status | html %]</span>
361 <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
362 <td>[% batch_lis.num_records | html %]</td>
363 <td>[% batch_lis.num_items | html %]
364 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
365 (<a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
369 [% IF ( batch_lis.can_clean ) %]
370 <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">
371 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
372 <input type="hidden" name="op" value="clean-batch" />
373 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
375 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
376 <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">
377 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
378 <input type="hidden" name="op" value="delete-batch" />
379 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
384 [% END # /FOREACH batch_lis %]
387 </div> <!-- /.page-section -->
390 [% PROCESS pagination %]
392 [% END # /IF batch_lis %]
394 [% IF import_batch_id && !did_clean %]
395 <div class="page-section">
396 <table id="records-table">
403 <th>Match details</th>
404 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
411 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
412 <div class="modal-dialog modal-wide">
413 <div class="modal-content">
414 <div class="modal-header">
415 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
416 <h3 id="marcPreviewLabel">MARC preview</h3>
418 <div class="modal-body">
419 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
421 <div class="modal-footer">
422 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
426 </div> <!-- /#marcPreview -->
427 [% END # /IF import_batch_id %]
430 </div> <!-- /.col-sm-10.col-sm-push-2 -->
431 <div class="col-sm-2 col-sm-pull-10">
433 [% INCLUDE 'cat-menu.inc' %]
435 </div> <!-- .col-sm-2.col-sm-pull-10 -->
436 </div> <!-- /.row -->
438 [% MACRO jsinclude BLOCK %]
439 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
440 [% INCLUDE 'datatables.inc' %]
442 $(document).ready(function() {
443 $("#staged-record-matching-rules select").change(function() {
444 var str = $(this).attr("id");
445 $("#reset_" + str).parent().show();
447 $("a.reset").click(function() {
448 var str = $(this).attr("id");
449 str = str.replace("reset_", "")
450 $("#" + str + " option[selected='selected']").attr("selected", "selected");
451 $(this).parent().hide();
454 [% IF import_batch_id %]
455 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
460 "sAjaxSource": 'batch_records_ajax.pl',
461 "sPaginationType": "full_numbers",
462 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
464 { "mDataProp": "import_record_id" },
465 { "mDataProp": "citation" },
466 { "mDataProp": "status" },
467 { "mDataProp": "overlay_status" },
468 { "mDataProp": null, "sDefaultContent": "" },
469 { "mDataProp": null, "sDefaultContent": "" },
470 { "mDataProp": "matched" }
472 "fnServerData": function(sSource, aoData, fnCallback) {
473 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
480 'success': function(json) {
485 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
486 [% IF(record_type == 'auth') %]
487 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
489 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
491 [% IF(record_type == 'auth') %]
492 var record_edit_url = "/cgi-bin/koha/authorities/authorities.pl?authid=";
494 var record_edit_url = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
497 var additional_details = "";
498 if( aData['author'] ){
499 additional_details += " " + aData['author'] + " ";
503 additional_details += " (" + aData['isbn'] + ") ";
507 additional_details += " (" + aData['issn'] + ") ";
510 $('td:eq(1)', nRow).html(
511 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
514 $('td:eq(2)', nRow).html(
515 aData['status'] == 'imported' ? _("Imported") :
516 aData['status'] == 'ignored' ? _("Ignored") :
517 aData['status'] == 'reverted' ? _("Reverted") :
518 aData['status'] == 'staged' ? _("Staged") :
519 aData['status'] == 'error' ? _("Error") :
523 $('td:eq(3)', nRow).html(
524 aData['overlay_status'] == 'no_match' ? _("No match") :
525 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
526 aData['overlay_status'] == 'auto_match' ? _("Match found") :
527 aData['overlay_status']
530 if ( aData['matches'].length > 0 ) {
533 $('td:eq(4)', nRow).html('<ul class="matches"></ul>');
534 $('td:eq(5)', nRow).html('<ul class="matches"></ul>');
537 if( aData['status'] == "imported" || aData['status'] == "ignored" ){
538 disabled = ' disabled ';
540 aData['matches'].forEach(function(item,index){
541 if( item.chosen == 1 ){
542 checked = 'checked="checked"';
545 [% IF(item.record_type == 'auth') -%]
546 var matching_msg = _("Matches authority %s (score=%s):%s");
548 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
550 var match_option = "";
551 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 + '> ';
553 var diff_url = '/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s';
554 var match_citation = '';
555 if( item.title ){ match_citation += item.title + ' ' }
556 if( item.author ){ match_citation += item.author }
557 $('td:eq(4) ul', nRow).append('<li><label for="import_record_id_'+aData['import_record_id']+'_match_'+index+'">'+match_option+
558 matching_msg.format(item.candidate_match_id, item.score,
559 '<a target="_blank" href="' + record_details_url
560 + item.candidate_match_id + '">' + match_citation + '</a></label></li>')
562 $('td:eq(5) ul', nRow).append('<li><a href="'
563 + diff_url.format( [% import_batch_id | html %], aData['import_record_id'], item.candidate_match_id, item.record_type) + '">' + _("View") + '</a></li>');
566 if( !any_checked ){ checked = 'checked="checked"'; }
567 $('td:eq(4) 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>');
568 $('td:eq(5) ul', nRow).prepend('<li> </li>');
570 if (aData['diff_url']) {
571 $('td:eq(5)', nRow).html(
572 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
575 if (aData['matched']) {
576 $('td:eq(6)', nRow).html(
577 '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url
578 + aData['matched'] + '"><i class="fa fa-eye"></i> ' + _("View") + '</a> '
579 [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
580 + '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url
581 + aData['matched'] + '"><i class="fa fa-pencil"></i> ' + _("Edit") + '</a>'
587 $("#import_batch_form").on("submit", function() {
588 return submitBackgroundJob(document.getElementById("import_batch_form"));
590 $("#revert_batch_form").on("submit", function() {
591 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
595 $("body").on("change", ".chosen", function(e) {
596 let apimethod = "DELETE";
598 if( $(this).val() != 'none' ){
600 apidata = JSON.stringify({ candidate_match_id: $(this).val() });
603 url: '/api/v1/import_batches/[% import_batch_id | html %]/records/'+$(this).data('import_record_id')+'/matches/chosen',
606 contentType: 'application/json'
607 }).fail(function(){ alert(_("Unable to update match choices")); return false; });
610 $("body").on("click", ".previewMARC", function(e) {
612 var ltitle = $(this).text();
613 var page = $(this).attr("href");
614 $("#marcPreviewLabel").text(ltitle);
615 $("#marcPreview .modal-body").load(page + " table");
616 $('#marcPreview').modal({ show: true });
618 $("#marcPreview").on("hidden.bs.modal", function() {
619 $("#marcPreviewLabel").html("");
620 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
622 $(".batch_form").on("submit", function() {
623 if ($(this).hasClass("batch_delete")) {
624 return confirm(_("Are you sure you want to permanently delete this batch?"));
626 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
629 [% IF job_enqueued %]
631 function() { window.location.href=$('a.job_details').attr('href'); },
632 5000, // 5 secs to read
639 [% INCLUDE 'intranet-bottom.inc' %]
640 [% BLOCK pagination %]
642 <ul class="pagination">
643 [% FOREACH page IN pages %]
644 [% IF ( page.current_page && page.page_number > 1 ) %]
645 <li><a href="?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
646 <li><a href="?offset=[% offset - results_per_page | uri %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
649 [% FOREACH page IN pages %]
650 [% IF ( page.current_page ) %]
651 [% SET current_page = page.page_number %]
652 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
654 <li><a class="nav" href="?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
657 [% IF ( current_page < pages.size() ) %]
659 <a href="?offset=[% offset + results_per_page | uri %]" class="nav">Next <i class="fa fa-fw fa-angle-right"></i></a>
662 <a href="?offset=[% ( results_per_page * ( pages.size - 1 ) ) | uri %]" class="nav">Last <i class="fa fa-fw fa-angle-double-right"></i></a>