5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Tools › Manage staged MARC records
7 [% IF ( import_batch_id ) %]
8 › Batch [% import_batch_id | html %]
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; }
19 <body id="tools_manage-marc-import" class="tools">
20 [% INCLUDE 'header.inc' %]
21 [% INCLUDE 'cat-search.inc' %]
23 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
24 [% IF ( import_batch_id ) %]
26 <a href="[% script_name | url %]">Manage staged MARC records</a>
27 › Batch [% import_batch_id | html %]
29 › Manage staged MARC records
33 <div class="main container-fluid">
35 <div class="col-sm-10 col-sm-push-2">
37 <h1>Manage staged MARC records
38 [% IF ( import_batch_id ) %]
39 › Batch [% import_batch_id | html %]
43 [% IF ( label_batch_msg ) %]
47 <div class="dialog message">
50 [% IF ( label_batch_msg == "error" ) %]
51 Error attempting to create label batch. Please ask your system administrator to check the log for more details.
53 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.
59 [% IF ( did_clean ) %]
60 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
63 [% IF ( did_delete ) %]
64 <div class="dialog message">Import batch deleted successfully</div>
67 [% UNLESS ( batch_list ) %]
68 [% UNLESS ( batch_info ) %]
69 <div class="dialog message">
70 <p>No records have been staged.</p>
71 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
76 [% IF ( batch_info ) %]
77 [% IF ( can_commit ) %]
78 <form action="[% script_name | html %]" method="post">
79 <input type="hidden" name="op" value="redo-matching" />
80 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
81 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
84 [% IF ( rematch_attempted ) %]
85 [% IF ( rematch_failed ) %]
86 <div class="dialog alert">Failed to apply different matching rule</div>
88 <div class="dialog message">Applied different matching rule. Number of records matched now
89 [% num_with_matches | html %]
94 [% IF ( changed_overlay_action ) %]
95 <div class="dialog message">Changed action if matching record found</div>
98 [% IF ( changed_nomatch_action ) %]
99 <div class="dialog message">Changed action if no match found</div>
102 [% IF ( changed_item_action ) %]
103 <div class="dialog message">Changed item processing option</div>
106 <fieldset class="rows" id="staged-record-matching-rules">
108 <li><span class="label">File name:</span> [% file_name | html %]</li>
109 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
110 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
111 <li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
112 <li><span class="label">Status:</span>
113 [% IF ( import_status == 'cleaned' ) %]
115 [% ELSIF ( import_status == 'imported' ) %]
117 [% ELSIF ( import_status == 'importing' ) %]
119 [% ELSIF ( import_status == 'reverted' ) %]
121 [% ELSIF ( import_status == 'reverting' ) %]
123 [% ELSIF ( import_status == 'staged' ) %]
126 [% import_status | html %]
130 [% IF ( can_commit ) %]
131 <label for="new_matcher_id">Matching rule applied:</label>
132 <select name="new_matcher_id" id="new_matcher_id">
133 <option value="">Do not look for matching records</option>
134 [% FOREACH available_matcher IN available_matchers %]
135 [% IF ( available_matcher.selected ) %]
136 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
137 [% available_matcher.code | html %] ([% available_matcher.description | html %])
140 <option value="[% available_matcher.matcher_id | html %]">
141 [% available_matcher.code | html %] ([% available_matcher.description | html %])
146 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
148 <span class="label">Matching rule applied</span>
149 [% IF ( current_matcher_id ) %]
150 [% current_matcher_code | html %] ([% current_matcher_description | html %])
152 No matching rule in effect
157 [% IF ( can_commit ) %]
158 <label for="overlay_action">Action if matching record found:</label>
159 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
161 <span class="label">Action if matching record found:</span>
162 [% IF ( overlay_action == 'replace' ) %]
163 Replace existing record with incoming record
164 [% ELSIF ( overlay_action == 'create_new' ) %]
166 [% ELSIF ( overlay_action == 'ignore' ) %]
167 Ignore incoming record (its items may still be processed)
169 [% overlay_action | html %]
174 [% IF ( can_commit ) %]
175 <label for="nomatch_action">Action if no match found:</label>
176 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
178 <span class="label">Action if no match found:</span>
179 [% IF ( nomatch_action == 'create_new' ) %]
181 [% ELSIF ( nomatch_action == 'ignore' ) %]
182 Ignore incoming record (its items may still be processed)
184 [% nomatch_action | html %]
188 [% IF ( record_type == 'biblio' ) %]
190 [% IF ( can_commit ) %]
191 <label for="item_action">Item processing:</label>
192 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
194 <span class="label">Item processing:</span>
195 [% IF ( item_action == 'always_add' ) %]
197 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
198 Add items only if matching bib was found
199 [% ELSIF ( item_action == 'add_only_for_new' ) %]
200 Add items only if no matching bib was found
201 [% ELSIF ( item_action == 'ignore' ) %]
204 [% item_action | html %]
210 [% IF ( can_commit ) %]
211 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
214 </fieldset> <!-- /#staged-record-matching-rules -->
217 [% IF ( can_commit ) %]
218 <form action="[% script_name | html %]" method="post" id="import_batch_form">
219 <input type="hidden" name="op" value="commit-batch" />
220 <input type="hidden" name="runinbackground" value="" />
221 <input type="hidden" name="completedJobID" value="" />
222 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
223 <fieldset class="action">
224 [% IF ( record_type != 'auth' ) %]
225 Add new bibliographic records into this framework:
226 <select name="framework" id="frameworks">
227 <option value="">Default</option>
228 [% FOREACH framework IN frameworks %]
229 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
234 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
236 </form> <!-- /#import_batch_form -->
238 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
239 <div id="jobfailed"></div>
241 [% END # /IF can_commit %]
242 [% IF ( can_revert ) %]
243 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
244 <input type="hidden" name="op" value="revert-batch" />
245 <input type="hidden" name="runinbackground" value="" />
246 <input type="hidden" name="completedJobID" value="" />
247 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
248 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
251 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
252 <div id="jobfailed"></div>
254 [% END # /IF can_revert %]
257 [% IF ( did_commit ) %]
258 <div class="dialog message">Completed import of records</div>
261 <td>Number of records added</td>
262 <td>[% num_added | html %]</td>
265 <td>Number of records updated</td>
266 <td>[% num_updated | html %]</td>
269 <td>Number of records ignored</td>
270 <td>[% num_ignored | html %]</td>
272 [% IF ( record_type == 'biblio' ) %]
274 <td>Number of items added</td>
275 <td>[% num_items_added | html %]</td>
278 <td>Number of items replaced</td>
279 <td>[% num_items_replaced | html %]</td>
282 <td>Number of items ignored because of duplicate barcode</td>
283 <td>[% num_items_errored | html %]</td>
287 [% END #/ IF did_commit %]
289 [% IF ( did_revert ) %]
290 <div class="dialog message">Success: Import reversed</div>
293 <td>Number of records deleted</td>
294 <td>[% num_deleted | html %]</td>
296 [% IF ( record_type == 'biblio' ) %]
298 <td>Number of items deleted</td>
299 <td>[% num_items_deleted | html %]</td>
302 <td>Number of records not deleted due to items on loan</td>
303 <td>[% num_errors | html %]</td>
307 <td>Number of records changed back</td>
308 <td>[% num_reverted | html %]</td>
311 <td>Number of records ignored</td>
312 <td>[% num_ignored | html %]</td>
315 [% END # /IF did_revert%]
317 [% END # /IF batch_info %]
319 <br style="clear:both;" />
321 [% IF ( batch_list ) %]
323 [% PROCESS pagination %]
338 [% FOREACH batch_lis IN batch_list %]
340 <td>[% batch_lis.import_batch_id | html %]</td>
341 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></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' ) %]
349 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
351 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
353 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
355 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
358 [% batch_lis.import_status | html %]
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="[% batch_lis.script_name | url %]?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" 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">
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 %]
388 [% PROCESS pagination %]
390 [% END # /IF batch_lis %]
392 [% IF import_batch_id %]
393 <table id="records-table">
400 <th>Match details</th>
401 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
407 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
408 <div class="modal-dialog modal-wide">
409 <div class="modal-content">
410 <div class="modal-header">
411 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
412 <h3 id="marcPreviewLabel">MARC preview</h3>
414 <div class="modal-body">
415 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
417 <div class="modal-footer">
418 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
422 </div> <!-- /#marcPreview -->
423 [% END # /IF import_batch_id %]
426 </div> <!-- /.col-sm-10.col-sm-push-2 -->
427 <div class="col-sm-2 col-sm-pull-10">
429 [% INCLUDE 'tools-menu.inc' %]
431 </div> <!-- .col-sm-2.col-sm-pull-10 -->
432 </div> <!-- /.row -->
434 [% MACRO jsinclude BLOCK %]
435 [% Asset.js("js/tools-menu.js") | $raw %]
436 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
437 [% Asset.js("js/background-job-progressbar.js") | $raw %]
438 [% INCLUDE 'datatables.inc' %]
440 $(document).ready(function() {
441 $("#staged-record-matching-rules select").change(function() {
442 var str = $(this).attr("id");
443 $("#reset_" + str).parent().show();
445 $("a.reset").click(function() {
446 var str = $(this).attr("id");
447 str = str.replace("reset_", "")
448 $("#" + str + " option[selected='selected']").attr("selected", "selected");
449 $(this).parent().hide();
452 [% IF import_batch_id %]
453 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
458 "sAjaxSource": 'batch_records_ajax.pl',
459 "sPaginationType": "full_numbers",
460 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
462 { "mDataProp": "import_record_id" },
463 { "mDataProp": "citation" },
464 { "mDataProp": "status" },
465 { "mDataProp": "overlay_status" },
466 { "mDataProp": "match_citation" },
467 { "mDataProp": "diff_url" },
468 { "mDataProp": "matched" }
470 "fnServerData": function(sSource, aoData, fnCallback) {
471 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
478 'success': function(json) {
483 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
484 [% IF(record_type == 'auth') %]
485 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
487 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
490 var additional_details = "";
491 if( aData['author'] ){
492 additional_details += " " + aData['author'] + " ";
496 additional_details += " (" + aData['isbn'] + ") ";
500 additional_details += " (" + aData['issn'] + ") ";
503 $('td:eq(1)', nRow).html(
504 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
507 $('td:eq(2)', nRow).html(
508 aData['status'] == 'imported' ? _("Imported") :
509 aData['status'] == 'ignored' ? _("Ignored") :
510 aData['status'] == 'reverted' ? _("Reverted") :
511 aData['status'] == 'staged' ? _("Staged") :
512 aData['status'] == 'error' ? _("Error") :
516 $('td:eq(3)', nRow).html(
517 aData['overlay_status'] == 'no_match' ? _("No match") :
518 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
519 aData['overlay_status'] == 'auto_match' ? _("Match found") :
520 aData['overlay_status']
523 if (aData['match_id']) {
524 [% IF(record_type == 'auth') -%]
525 var matching_msg = _("Matches authority %s (score=%s):%s");
527 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
529 $('td:eq(4)', nRow).html(
530 matching_msg.format(aData['match_id'], aData['score'],
531 '<a target="_blank" href="' + record_details_url
532 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
535 if (aData['diff_url']) {
536 $('td:eq(5)', nRow).html(
537 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
540 $('td:eq(6)', nRow).html(
541 '<a target="_blank" href="' + record_details_url
542 + aData['matched'] + '">' + aData['matched'] + '</a>'
546 $("#import_batch_form").on("submit", function() {
547 return submitBackgroundJob(document.getElementById("import_batch_form"));
549 $("#revert_batch_form").on("submit", function() {
550 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
554 $("body").on("click", ".previewMARC", function(e) {
556 var ltitle = $(this).text();
557 var page = $(this).attr("href");
558 $("#marcPreviewLabel").text(ltitle);
559 $("#marcPreview .modal-body").load(page + " table");
560 $('#marcPreview').modal({ show: true });
562 $("#marcPreview").on("hidden.bs.modal", function() {
563 $("#marcPreviewLabel").html("");
564 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
566 $(".batch_form").on("submit", function() {
567 if ($(this).hasClass("batch_delete")) {
568 return confirm(_("Are you sure you want to permanently delete this batch?"));
570 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
577 [% INCLUDE 'intranet-bottom.inc' %]
578 [% BLOCK pagination %]
580 <ul class="pagination">
581 [% FOREACH page IN pages %]
582 [% IF ( page.current_page && page.page_number > 1 ) %]
583 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
584 <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>
587 [% FOREACH page IN pages %]
588 [% IF ( page.current_page ) %]
589 [% SET current_page = page.page_number %]
590 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
592 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
595 [% IF ( current_page < pages.size() ) %]
597 <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>
600 <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>