4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › Tools › Manage staged MARC records
6 [% IF ( import_batch_id ) %]
7 › Batch [% import_batch_id | html %]
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("css/humanmsg.css") | $raw %]
13 #jobpanel,#jobstatus,#jobfailed { display : none; }
14 span.change-status { font-style:italic; color:#666; display:none; }
18 <body id="tools_manage-marc-import" class="tools">
19 [% INCLUDE 'header.inc' %]
20 [% INCLUDE 'cat-search.inc' %]
22 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23 [% IF ( import_batch_id ) %]
25 <a href="[% script_name | url %]">Manage staged MARC records</a>
26 › Batch [% import_batch_id | html %]
28 › Manage staged MARC records
32 <div class="main container-fluid">
34 <div class="col-sm-10 col-sm-push-2">
36 <h1>Manage staged MARC records
37 [% IF ( import_batch_id ) %]
38 › Batch [% import_batch_id | html %]
42 [% IF ( label_batch_msg ) %]
46 <div class="dialog message">
49 [% IF ( label_batch_msg == "error" ) %]
50 Error attempting to create label batch. Please ask your system administrator to check the log for more details.
52 Label <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.
58 [% IF ( did_clean ) %]
59 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
62 [% IF ( did_delete ) %]
63 <div class="dialog message">Import batch deleted successfully</div>
66 [% UNLESS ( batch_list ) %]
67 [% UNLESS ( batch_info ) %]
68 <div class="dialog message">
69 <p>No records have been staged.</p>
70 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
75 [% IF ( batch_info ) %]
76 [% IF ( can_commit ) %]
77 <form action="[% script_name | html %]" method="post">
78 <input type="hidden" name="op" value="redo-matching" />
79 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
80 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
83 [% IF ( rematch_attempted ) %]
84 [% IF ( rematch_failed ) %]
85 <div class="dialog alert">Failed to apply different matching rule</div>
87 <div class="dialog message">Applied different matching rule. Number of records matched now
88 [% num_with_matches | html %]
93 [% IF ( changed_overlay_action ) %]
94 <div class="dialog message">Changed action if matching record found</div>
97 [% IF ( changed_nomatch_action ) %]
98 <div class="dialog message">Changed action if no match found</div>
101 [% IF ( changed_item_action ) %]
102 <div class="dialog message">Changed item processing option</div>
105 <fieldset class="rows" id="staged-record-matching-rules">
107 <li><span class="label">File name:</span> [% file_name | html %]</li>
108 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
109 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
110 <li><span class="label">Staged:</span> [% upload_timestamp | html %]</li>
111 <li><span class="label">Status:</span>
112 [% IF ( import_status == 'cleaned' ) %]
114 [% ELSIF ( import_status == 'imported' ) %]
116 [% ELSIF ( import_status == 'importing' ) %]
118 [% ELSIF ( import_status == 'reverted' ) %]
120 [% ELSIF ( import_status == 'reverting' ) %]
122 [% ELSIF ( import_status == 'staged' ) %]
125 [% import_status | html %]
129 [% IF ( can_commit ) %]
130 <label for="new_matcher_id">Matching rule applied:</label>
131 <select name="new_matcher_id" id="new_matcher_id">
132 <option value="">Do not look for matching records</option>
133 [% FOREACH available_matcher IN available_matchers %]
134 [% IF ( available_matcher.selected ) %]
135 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
136 [% available_matcher.code | html %] ([% available_matcher.description | html %])
139 <option value="[% available_matcher.matcher_id | html %]">
140 [% available_matcher.code | html %] ([% available_matcher.description | html %])
145 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
147 <span class="label">Matching rule applied</span>
148 [% IF ( current_matcher_id ) %]
149 [% current_matcher_code | html %] ([% current_matcher_description | html %])
151 No matching rule in effect
156 [% IF ( can_commit ) %]
157 <label for="overlay_action">Action if matching record found:</label>
158 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
160 <span class="label">Action if matching record found:</span>
161 [% IF ( overlay_action == 'replace' ) %]
162 Replace existing record with incoming record
163 [% ELSIF ( overlay_action == 'create_new' ) %]
165 [% ELSIF ( overlay_action == 'ignore' ) %]
166 Ignore incoming record (its items may still be processed)
168 [% overlay_action | html %]
173 [% IF ( can_commit ) %]
174 <label for="nomatch_action">Action if no match found:</label>
175 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
177 <span class="label">Action if no match found:</span>
178 [% IF ( nomatch_action == 'create_new' ) %]
180 [% ELSIF ( nomatch_action == 'ignore' ) %]
181 Ignore incoming record (its items may still be processed)
183 [% nomatch_action | html %]
187 [% IF ( record_type == 'biblio' ) %]
189 [% IF ( can_commit ) %]
190 <label for="item_action">Item processing:</label>
191 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
193 <span class="label">Item processing:</span>
194 [% IF ( item_action == 'always_add' ) %]
196 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
197 Add items only if matching bib was found
198 [% ELSIF ( item_action == 'add_only_for_new' ) %]
199 Add items only if no matching bib was found
200 [% ELSIF ( item_action == 'ignore' ) %]
203 [% item_action | html %]
209 [% IF ( can_commit ) %]
210 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
213 </fieldset> <!-- /#staged-record-matching-rules -->
216 [% IF ( can_commit ) %]
217 <form action="[% script_name | html %]" method="post" id="import_batch_form">
218 <input type="hidden" name="op" value="commit-batch" />
219 <input type="hidden" name="runinbackground" value="" />
220 <input type="hidden" name="completedJobID" value="" />
221 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
222 <fieldset class="action">
223 [% IF ( record_type != 'auth' ) %]
224 Add new bibliographic records into this framework:
225 <select name="framework" id="frameworks">
226 <option value="">Default</option>
227 [% FOREACH framework IN frameworks %]
228 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
233 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
235 </form> <!-- /#import_batch_form -->
237 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
238 <div id="jobfailed"></div>
240 [% END # /IF can_commit %]
241 [% IF ( can_revert ) %]
242 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
243 <input type="hidden" name="op" value="revert-batch" />
244 <input type="hidden" name="runinbackground" value="" />
245 <input type="hidden" name="completedJobID" value="" />
246 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
247 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
250 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
251 <div id="jobfailed"></div>
253 [% END # /IF can_revert %]
256 [% IF ( did_commit ) %]
257 <div class="dialog message">Completed import of records</div>
260 <td>Number of records added</td>
261 <td>[% num_added | html %]</td>
264 <td>Number of records updated</td>
265 <td>[% num_updated | html %]</td>
268 <td>Number of records ignored</td>
269 <td>[% num_ignored | html %]</td>
271 [% IF ( record_type == 'biblio' ) %]
273 <td>Number of items added</td>
274 <td>[% num_items_added | html %]</td>
277 <td>Number of items replaced</td>
278 <td>[% num_items_replaced | html %]</td>
281 <td>Number of items ignored because of duplicate barcode</td>
282 <td>[% num_items_errored | html %]</td>
286 [% END #/ IF did_commit %]
288 [% IF ( did_revert ) %]
289 <div class="dialog message">Success: Import reversed</div>
292 <td>Number of records deleted</td>
293 <td>[% num_deleted | html %]</td>
295 [% IF ( record_type == 'biblio' ) %]
297 <td>Number of items deleted</td>
298 <td>[% num_items_deleted | html %]</td>
301 <td>Number of records not deleted due to items on loan</td>
302 <td>[% num_errors | html %]</td>
306 <td>Number of records changed back</td>
307 <td>[% num_reverted | html %]</td>
310 <td>Number of records ignored</td>
311 <td>[% num_ignored | html %]</td>
314 [% END # /IF did_revert%]
316 [% END # /IF batch_info %]
318 <br style="clear:both;" />
320 [% IF ( batch_list ) %]
322 [% PROCESS pagination %]
337 [% FOREACH batch_lis IN batch_list %]
339 <td>[% batch_lis.import_batch_id | html %]</td>
340 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
341 <td>[% batch_lis.comments | html %]</td>
342 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
344 [% IF ( batch_lis.import_status == 'cleaned' ) %]
346 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
348 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
350 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
352 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
354 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
357 [% batch_lis.import_status | html %]
360 <td>[% batch_lis.upload_timestamp | html %]</td>
361 <td>[% batch_lis.num_records | html %]</td>
362 <td>[% batch_lis.num_items | html %]
363 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
364 (<a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
368 [% IF ( batch_lis.can_clean ) %]
369 <form method="post" action="[% batch_lis.script_name | html %]" name="clean_batch_[% batch_lis.import_batch_id | html %]" id="clean_batch_[% batch_lis.import_batch_id | html %]" class="batch_form batch_clean">
370 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
371 <input type="hidden" name="op" value="clean-batch" />
372 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
374 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
375 <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">
376 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
377 <input type="hidden" name="op" value="delete-batch" />
378 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
383 [% END # /FOREACH batch_lis %]
387 [% PROCESS pagination %]
389 [% END # /IF batch_lis %]
391 [% IF import_batch_id %]
392 <table id="records-table">
399 <th>Match details</th>
400 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
406 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
407 <div class="modal-dialog modal-wide">
408 <div class="modal-content">
409 <div class="modal-header">
410 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
411 <h3 id="marcPreviewLabel">MARC preview</h3>
413 <div class="modal-body">
414 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
416 <div class="modal-footer">
417 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
421 </div> <!-- /#marcPreview -->
422 [% END # /IF import_batch_id %]
425 </div> <!-- /.col-sm-10.col-sm-push-2 -->
426 <div class="col-sm-2 col-sm-pull-10">
428 [% INCLUDE 'tools-menu.inc' %]
430 </div> <!-- .col-sm-2.col-sm-pull-10 -->
431 </div> <!-- /.row -->
433 [% MACRO jsinclude BLOCK %]
434 [% Asset.js("js/tools-menu.js") | $raw %]
435 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
436 [% Asset.js("js/background-job-progressbar.js") | $raw %]
437 [% INCLUDE 'datatables.inc' %]
439 $(document).ready(function() {
440 $("#staged-record-matching-rules select").change(function() {
441 var str = $(this).attr("id");
442 $("#reset_" + str).parent().show();
444 $("a.reset").click(function() {
445 var str = $(this).attr("id");
446 str = str.replace("reset_", "")
447 $("#" + str + " option[selected='selected']").attr("selected", "selected");
448 $(this).parent().hide();
451 [% IF import_batch_id %]
452 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
457 "sAjaxSource": 'batch_records_ajax.pl',
458 "sPaginationType": "full_numbers",
459 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
461 { "mDataProp": "import_record_id" },
462 { "mDataProp": "citation" },
463 { "mDataProp": "status" },
464 { "mDataProp": "overlay_status" },
465 { "mDataProp": "match_citation" },
466 { "mDataProp": "diff_url" },
467 { "mDataProp": "matched" }
469 "fnServerData": function(sSource, aoData, fnCallback) {
470 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
477 'success': function(json) {
482 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
483 [% IF(record_type == 'auth') %]
484 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
486 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
489 var additional_details = "";
490 if( aData['author'] ){
491 additional_details += " " + aData['author'] + " ";
495 additional_details += " (" + aData['isbn'] + ") ";
499 additional_details += " (" + aData['issn'] + ") ";
502 $('td:eq(1)', nRow).html(
503 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
506 $('td:eq(2)', nRow).html(
507 aData['status'] == 'imported' ? _("Imported") :
508 aData['status'] == 'ignored' ? _("Ignored") :
509 aData['status'] == 'reverted' ? _("Reverted") :
510 aData['status'] == 'staged' ? _("Staged") :
511 aData['status'] == 'error' ? _("Error") :
515 $('td:eq(3)', nRow).html(
516 aData['overlay_status'] == 'no_match' ? _("No match") :
517 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
518 aData['overlay_status'] == 'auto_match' ? _("Match found") :
519 aData['overlay_status']
522 if (aData['match_id']) {
523 [% IF(record_type == 'auth') -%]
524 var matching_msg = _("Matches authority %s (score=%s):%s");
526 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
528 $('td:eq(4)', nRow).html(
529 matching_msg.format(aData['match_id'], aData['score'],
530 '<a target="_blank" href="' + record_details_url
531 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
534 if (aData['diff_url']) {
535 $('td:eq(5)', nRow).html(
536 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
539 $('td:eq(6)', nRow).html(
540 '<a target="_blank" href="' + record_details_url
541 + aData['matched'] + '">' + aData['matched'] + '</a>'
545 $("#import_batch_form").on("submit", function() {
546 return submitBackgroundJob(document.getElementById("import_batch_form"));
548 $("#revert_batch_form").on("submit", function() {
549 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
553 $("body").on("click", ".previewMARC", function(e) {
555 var ltitle = $(this).text();
556 var page = $(this).attr("href");
557 $("#marcPreviewLabel").text(ltitle);
558 $("#marcPreview .modal-body").load(page + " table");
559 $('#marcPreview').modal({ show: true });
561 $("#marcPreview").on("hidden.bs.modal", function() {
562 $("#marcPreviewLabel").html("");
563 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
565 $(".batch_form").on("submit", function() {
566 if ($(this).hasClass("batch_delete")) {
567 return confirm(_("Are you sure you want to permanently delete this batch?"));
569 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
576 [% INCLUDE 'intranet-bottom.inc' %]
577 [% BLOCK pagination %]
579 <ul class="pagination">
580 [% FOREACH page IN pages %]
581 [% IF ( page.current_page && page.page_number > 1 ) %]
582 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
583 <li><a href="[% page.script_name | url %]?offset=[% offset - results_per_page | uri %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
586 [% FOREACH page IN pages %]
587 [% IF ( page.current_page ) %]
588 [% SET current_page = page.page_number %]
589 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
591 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
594 [% IF ( current_page < pages.size() ) %]
596 <a href="[% page.script_name | url %]?offset=[% offset + results_per_page | uri %]" class="nav">Next <i class="fa fa-fw fa-angle-right"></i></a>
599 <a href="[% page.script_name | url %]?offset=[% ( results_per_page * ( pages.size - 1 ) ) | uri %]" class="nav">Last <i class="fa fa-fw fa-angle-double-right"></i></a>