5 [% INCLUDE 'doc-head-open.inc' %]
7 [% IF ( import_batch_id ) %]
8 Batch [% import_batch_id | html %] › [% END %]
9 Manage staged MARC records › Tools › 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; }
19 <body id="tools_manage-marc-import" class="tools">
20 [% INCLUDE 'header.inc' %]
21 [% INCLUDE 'cat-search.inc' %]
23 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
26 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
29 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
31 [% IF ( import_batch_id ) %]
33 <a href="[% script_name | url %]">Manage staged MARC records</a>
36 <a href="#" aria-current="page">
37 Batch [% import_batch_id | html %]
42 <a href="#" aria-current="page">
43 Manage staged MARC records
50 <div class="main container-fluid">
52 <div class="col-sm-10 col-sm-push-2">
54 <h1>Manage staged MARC records
55 [% IF ( import_batch_id ) %]
56 › Batch [% import_batch_id | html %]
60 [% IF ( label_batch_msg ) %]
64 <div class="dialog message">
67 [% IF ( label_batch_msg == "error" ) %]
68 Error attempting to create label batch. Please ask your system administrator to check the log for more details.
70 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.
76 [% IF ( did_clean ) %]
77 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
80 [% IF ( did_delete ) %]
81 <div class="dialog message">Import batch deleted successfully</div>
84 [% UNLESS ( batch_list ) %]
85 [% UNLESS ( batch_info ) %]
86 <div class="dialog message">
87 <p>No records have been staged.</p>
88 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
93 [% IF ( batch_info ) %]
94 [% IF ( can_commit ) %]
95 <form action="[% script_name | html %]" method="post">
96 <input type="hidden" name="op" value="redo-matching" />
97 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
98 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
101 [% IF ( rematch_attempted ) %]
102 [% IF ( rematch_failed ) %]
103 <div class="dialog alert">Failed to apply different matching rule</div>
105 <div class="dialog message">Applied different matching rule. Number of records matched now
106 [% num_with_matches | html %]
111 [% IF ( changed_overlay_action ) %]
112 <div class="dialog message">Changed action if matching record found</div>
115 [% IF ( changed_nomatch_action ) %]
116 <div class="dialog message">Changed action if no match found</div>
119 [% IF ( changed_item_action ) %]
120 <div class="dialog message">Changed item processing option</div>
123 <fieldset class="rows" id="staged-record-matching-rules">
125 <li><span class="label">File name:</span> [% file_name | html %]</li>
126 <li><span class="label">Profile:</span> [% IF (profile) %][% profile | html %][% ELSE %](none)[% END %]</li>
127 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
128 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
129 <li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
130 <li><span class="label">Status:</span>
131 [% IF ( import_status == 'cleaned' ) %]
133 [% ELSIF ( import_status == 'imported' ) %]
135 [% ELSIF ( import_status == 'importing' ) %]
137 [% ELSIF ( import_status == 'reverted' ) %]
139 [% ELSIF ( import_status == 'reverting' ) %]
141 [% ELSIF ( import_status == 'staged' ) %]
144 [% import_status | html %]
148 [% IF ( can_commit ) %]
149 <label for="new_matcher_id">Matching rule applied:</label>
150 <select name="new_matcher_id" id="new_matcher_id">
151 <option value="">Do not look for matching records</option>
152 [% FOREACH available_matcher IN available_matchers %]
153 [% IF ( available_matcher.selected ) %]
154 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
155 [% available_matcher.code | html %] ([% available_matcher.description | html %])
158 <option value="[% available_matcher.matcher_id | html %]">
159 [% available_matcher.code | html %] ([% available_matcher.description | html %])
164 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
166 <span class="label">Matching rule applied</span>
167 [% IF ( current_matcher_id ) %]
168 [% current_matcher_code | html %] ([% current_matcher_description | html %])
170 No matching rule in effect
175 [% IF ( can_commit ) %]
176 <label for="overlay_action">Action if matching record found:</label>
177 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
179 <span class="label">Action if matching record found:</span>
180 [% IF ( overlay_action == 'replace' ) %]
181 Replace existing record with incoming record
182 [% ELSIF ( overlay_action == 'create_new' ) %]
184 [% ELSIF ( overlay_action == 'ignore' ) %]
185 Ignore incoming record (its items may still be processed)
187 [% overlay_action | html %]
192 [% IF ( can_commit ) %]
193 <label for="nomatch_action">Action if no match found:</label>
194 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
196 <span class="label">Action if no match found:</span>
197 [% IF ( nomatch_action == 'create_new' ) %]
199 [% ELSIF ( nomatch_action == 'ignore' ) %]
200 Ignore incoming record (its items may still be processed)
202 [% nomatch_action | html %]
206 [% IF ( record_type == 'biblio' ) %]
208 [% IF ( can_commit ) %]
209 <label for="item_action">Item processing:</label>
210 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
212 <span class="label">Item processing:</span>
213 [% IF ( item_action == 'always_add' ) %]
215 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
216 Add items only if matching bib was found
217 [% ELSIF ( item_action == 'add_only_for_new' ) %]
218 Add items only if no matching bib was found
219 [% ELSIF ( item_action == 'ignore' ) %]
222 [% item_action | html %]
228 [% IF ( can_commit ) %]
229 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
232 </fieldset> <!-- /#staged-record-matching-rules -->
235 [% IF ( can_commit ) %]
236 <form action="[% script_name | html %]" method="post" id="import_batch_form">
237 <input type="hidden" name="op" value="commit-batch" />
238 <input type="hidden" name="runinbackground" value="" />
239 <input type="hidden" name="completedJobID" value="" />
240 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
241 <fieldset class="action">
242 [% IF ( record_type != 'auth' ) %]
243 Add new bibliographic records into this framework:
244 <select name="framework" id="frameworks">
245 <option value="">Default</option>
246 [% FOREACH framework IN frameworks %]
247 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
252 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
254 </form> <!-- /#import_batch_form -->
256 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
257 <div id="jobfailed"></div>
259 [% END # /IF can_commit %]
260 [% IF ( can_revert ) %]
261 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
262 <input type="hidden" name="op" value="revert-batch" />
263 <input type="hidden" name="runinbackground" value="" />
264 <input type="hidden" name="completedJobID" value="" />
265 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
266 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
269 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
270 <div id="jobfailed"></div>
272 [% END # /IF can_revert %]
275 [% IF ( did_commit ) %]
276 <div class="dialog message">Completed import of records</div>
279 <td>Number of records added</td>
280 <td>[% num_added | html %]</td>
283 <td>Number of records updated</td>
284 <td>[% num_updated | html %]</td>
287 <td>Number of records ignored</td>
288 <td>[% num_ignored | html %]</td>
290 [% IF ( record_type == 'biblio' ) %]
292 <td>Number of items added</td>
293 <td>[% num_items_added | html %]</td>
296 <td>Number of items replaced</td>
297 <td>[% num_items_replaced | html %]</td>
300 <td>Number of items ignored because of duplicate barcode</td>
301 <td>[% num_items_errored | html %]</td>
305 [% END #/ IF did_commit %]
307 [% IF ( did_revert ) %]
308 <div class="dialog message">Success: Import reversed</div>
311 <td>Number of records deleted</td>
312 <td>[% num_deleted | html %]</td>
314 [% IF ( record_type == 'biblio' ) %]
316 <td>Number of items deleted</td>
317 <td>[% num_items_deleted | html %]</td>
320 <td>Number of records not deleted due to items on loan</td>
321 <td>[% num_errors | html %]</td>
325 <td>Number of records changed back</td>
326 <td>[% num_reverted | html %]</td>
329 <td>Number of records ignored</td>
330 <td>[% num_ignored | html %]</td>
333 [% END # /IF did_revert%]
335 [% END # /IF batch_info %]
337 <br style="clear:both;" />
339 [% IF ( batch_list ) %]
341 [% PROCESS pagination %]
357 [% FOREACH batch_lis IN batch_list %]
359 <td>[% batch_lis.import_batch_id | html %]</td>
360 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
361 <td>[% batch_lis.profile | html %]</td>
362 <td>[% batch_lis.comments | html %]</td>
363 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
365 [% IF ( batch_lis.import_status == 'cleaned' ) %]
367 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
369 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
371 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
373 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
375 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
378 [% batch_lis.import_status | html %]
381 <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
382 <td>[% batch_lis.num_records | html %]</td>
383 <td>[% batch_lis.num_items | html %]
384 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
385 (<a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
389 [% IF ( batch_lis.can_clean ) %]
390 <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">
391 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
392 <input type="hidden" name="op" value="clean-batch" />
393 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
395 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
396 <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">
397 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
398 <input type="hidden" name="op" value="delete-batch" />
399 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
404 [% END # /FOREACH batch_lis %]
408 [% PROCESS pagination %]
410 [% END # /IF batch_lis %]
412 [% IF import_batch_id && !did_clean %]
413 <table id="records-table">
420 <th>Match details</th>
421 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
427 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
428 <div class="modal-dialog modal-wide">
429 <div class="modal-content">
430 <div class="modal-header">
431 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
432 <h3 id="marcPreviewLabel">MARC preview</h3>
434 <div class="modal-body">
435 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
437 <div class="modal-footer">
438 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
442 </div> <!-- /#marcPreview -->
443 [% END # /IF import_batch_id %]
446 </div> <!-- /.col-sm-10.col-sm-push-2 -->
447 <div class="col-sm-2 col-sm-pull-10">
449 [% INCLUDE 'tools-menu.inc' %]
451 </div> <!-- .col-sm-2.col-sm-pull-10 -->
452 </div> <!-- /.row -->
454 [% MACRO jsinclude BLOCK %]
455 [% Asset.js("js/tools-menu.js") | $raw %]
456 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
457 [% Asset.js("js/background-job-progressbar.js") | $raw %]
458 [% INCLUDE 'datatables.inc' %]
460 $(document).ready(function() {
461 $("#staged-record-matching-rules select").change(function() {
462 var str = $(this).attr("id");
463 $("#reset_" + str).parent().show();
465 $("a.reset").click(function() {
466 var str = $(this).attr("id");
467 str = str.replace("reset_", "")
468 $("#" + str + " option[selected='selected']").attr("selected", "selected");
469 $(this).parent().hide();
472 [% IF import_batch_id %]
473 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
478 "sAjaxSource": 'batch_records_ajax.pl',
479 "sPaginationType": "full_numbers",
480 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
482 { "mDataProp": "import_record_id" },
483 { "mDataProp": "citation" },
484 { "mDataProp": "status" },
485 { "mDataProp": "overlay_status" },
486 { "mDataProp": "match_citation" },
487 { "mDataProp": "diff_url" },
488 { "mDataProp": "matched" }
490 "fnServerData": function(sSource, aoData, fnCallback) {
491 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
498 'success': function(json) {
503 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
504 [% IF(record_type == 'auth') %]
505 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
507 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
510 var additional_details = "";
511 if( aData['author'] ){
512 additional_details += " " + aData['author'] + " ";
516 additional_details += " (" + aData['isbn'] + ") ";
520 additional_details += " (" + aData['issn'] + ") ";
523 $('td:eq(1)', nRow).html(
524 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
527 $('td:eq(2)', nRow).html(
528 aData['status'] == 'imported' ? _("Imported") :
529 aData['status'] == 'ignored' ? _("Ignored") :
530 aData['status'] == 'reverted' ? _("Reverted") :
531 aData['status'] == 'staged' ? _("Staged") :
532 aData['status'] == 'error' ? _("Error") :
536 $('td:eq(3)', nRow).html(
537 aData['overlay_status'] == 'no_match' ? _("No match") :
538 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
539 aData['overlay_status'] == 'auto_match' ? _("Match found") :
540 aData['overlay_status']
543 if (aData['match_id']) {
544 [% IF(record_type == 'auth') -%]
545 var matching_msg = _("Matches authority %s (score=%s):%s");
547 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
549 $('td:eq(4)', nRow).html(
550 matching_msg.format(aData['match_id'], aData['score'],
551 '<a target="_blank" href="' + record_details_url
552 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
555 if (aData['diff_url']) {
556 $('td:eq(5)', nRow).html(
557 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
560 $('td:eq(6)', nRow).html(
561 '<a target="_blank" href="' + record_details_url
562 + aData['matched'] + '">' + aData['matched'] + '</a>'
566 $("#import_batch_form").on("submit", function() {
567 return submitBackgroundJob(document.getElementById("import_batch_form"));
569 $("#revert_batch_form").on("submit", function() {
570 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
574 $("body").on("click", ".previewMARC", function(e) {
576 var ltitle = $(this).text();
577 var page = $(this).attr("href");
578 $("#marcPreviewLabel").text(ltitle);
579 $("#marcPreview .modal-body").load(page + " table");
580 $('#marcPreview').modal({ show: true });
582 $("#marcPreview").on("hidden.bs.modal", function() {
583 $("#marcPreviewLabel").html("");
584 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
586 $(".batch_form").on("submit", function() {
587 if ($(this).hasClass("batch_delete")) {
588 return confirm(_("Are you sure you want to permanently delete this batch?"));
590 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
597 [% INCLUDE 'intranet-bottom.inc' %]
598 [% BLOCK pagination %]
600 <ul class="pagination">
601 [% FOREACH page IN pages %]
602 [% IF ( page.current_page && page.page_number > 1 ) %]
603 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
604 <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>
607 [% FOREACH page IN pages %]
608 [% IF ( page.current_page ) %]
609 [% SET current_page = page.page_number %]
610 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
612 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
615 [% IF ( current_page < pages.size() ) %]
617 <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>
620 <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>