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' %]
12 #jobpanel,#jobstatus,#jobfailed { display : none; }
13 span.change-status { font-style:italic; color:#666; display:none; }
17 <body id="tools_manage-marc-import" class="tools">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'cat-search.inc' %]
21 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
22 [% IF ( import_batch_id ) %]
24 <a href="[% script_name | url %]">Manage staged MARC records</a>
25 › Batch [% import_batch_id | html %]
27 › Manage staged MARC records
31 <div class="main container-fluid">
33 <div class="col-sm-10 col-sm-push-2">
35 <h1>Manage staged MARC records
36 [% IF ( import_batch_id ) %]
37 › Batch [% import_batch_id | html %]
41 [% IF ( label_batch_msg ) %]
45 <div class="dialog message">
47 <b><p>[% label_batch_msg | html %]</p></b>
51 [% IF ( did_clean ) %]
52 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
55 [% IF ( did_delete ) %]
56 <div class="dialog message">Import batch deleted successfully</div>
59 [% UNLESS ( batch_list ) %]
60 [% UNLESS ( batch_info ) %]
61 <div class="dialog message">
62 <p>No records have been staged.</p>
63 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
68 [% IF ( batch_info ) %]
69 [% IF ( can_commit ) %]
70 <form action="[% script_name | html %]" method="post">
71 <input type="hidden" name="op" value="redo-matching" />
72 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
73 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
76 [% IF ( rematch_attempted ) %]
77 [% IF ( rematch_failed ) %]
78 <div class="dialog alert">Failed to apply different matching rule</div>
80 <div class="dialog message">Applied different matching rule. Number of records matched now
81 [% num_with_matches | html %]
86 [% IF ( changed_overlay_action ) %]
87 <div class="dialog message">Changed action if matching record found</div>
90 [% IF ( changed_nomatch_action ) %]
91 <div class="dialog message">Changed action if no match found</div>
94 [% IF ( changed_item_action ) %]
95 <div class="dialog message">Changed item processing option</div>
98 <fieldset class="rows" id="staged-record-matching-rules">
100 <li><span class="label">File name:</span> [% file_name | html %]</li>
101 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
102 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
103 <li><span class="label">Staged:</span> [% upload_timestamp | html %]</li>
104 <li><span class="label">Status:</span>
105 [% IF ( import_status == 'cleaned' ) %]
107 [% ELSIF ( import_status == 'imported' ) %]
109 [% ELSIF ( import_status == 'importing' ) %]
111 [% ELSIF ( import_status == 'reverted' ) %]
113 [% ELSIF ( import_status == 'reverting' ) %]
115 [% ELSIF ( import_status == 'staged' ) %]
118 [% import_status | html %]
122 [% IF ( can_commit ) %]
123 <label for="new_matcher_id">Matching rule applied:</label>
124 <select name="new_matcher_id" id="new_matcher_id">
125 <option value="">Do not look for matching records</option>
126 [% FOREACH available_matcher IN available_matchers %]
127 [% IF ( available_matcher.selected ) %]
128 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
129 [% available_matcher.code | html %] ([% available_matcher.description | html %])
132 <option value="[% available_matcher.matcher_id | html %]">
133 [% available_matcher.code | html %] ([% available_matcher.description | html %])
138 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
140 <span class="label">Matching rule applied</span>
141 [% IF ( current_matcher_id ) %]
142 [% current_matcher_code | html %] ([% current_matcher_description | html %])
144 No matching rule in effect
149 [% IF ( can_commit ) %]
150 <label for="overlay_action">Action if matching record found:</label>
151 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
153 <span class="label">Action if matching record found:</span>
154 [% IF ( overlay_action == 'replace' ) %]
155 Replace existing record with incoming record
156 [% ELSIF ( overlay_action == 'create_new' ) %]
158 [% ELSIF ( overlay_action == 'ignore' ) %]
159 Ignore incoming record (its items may still be processed)
161 [% overlay_action | html %]
166 [% IF ( can_commit ) %]
167 <label for="nomatch_action">Action if no match found:</label>
168 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
170 <span class="label">Action if no match found:</span>
171 [% IF ( nomatch_action == 'create_new' ) %]
173 [% ELSIF ( nomatch_action == 'ignore' ) %]
174 Ignore incoming record (its items may still be processed)
176 [% nomatch_action | html %]
180 [% IF ( record_type == 'biblio' ) %]
182 [% IF ( can_commit ) %]
183 <label for="item_action">Item processing:</label>
184 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
186 <span class="label">Item processing:</span>
187 [% IF ( item_action == 'always_add' ) %]
189 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
190 Add items only if matching bib was found
191 [% ELSIF ( item_action == 'add_only_for_new' ) %]
192 Add items only if no matching bib was found
193 [% ELSIF ( item_action == 'ignore' ) %]
196 [% item_action | html %]
202 [% IF ( can_commit ) %]
203 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
206 </fieldset> <!-- /#staged-record-matching-rules -->
209 [% IF ( can_commit ) %]
210 <form action="[% script_name | html %]" method="post" id="import_batch_form">
211 <input type="hidden" name="op" value="commit-batch" />
212 <input type="hidden" name="runinbackground" value="" />
213 <input type="hidden" name="completedJobID" value="" />
214 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
215 <fieldset class="action">
216 [% IF ( record_type != 'auth' ) %]
217 Add new bibliographic records into this framework:
218 <select name="framework" id="frameworks">
219 <option value="">Default</option>
220 [% FOREACH framework IN frameworks %]
221 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
226 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
228 </form> <!-- /#import_batch_form -->
230 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
231 <div id="jobfailed"></div>
233 [% END # /IF can_commit %]
234 [% IF ( can_revert ) %]
235 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
236 <input type="hidden" name="op" value="revert-batch" />
237 <input type="hidden" name="runinbackground" value="" />
238 <input type="hidden" name="completedJobID" value="" />
239 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
240 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
243 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
244 <div id="jobfailed"></div>
246 [% END # /IF can_revert %]
249 [% IF ( did_commit ) %]
250 <div class="dialog message">Completed import of records</div>
253 <td>Number of records added</td>
254 <td>[% num_added | html %]</td>
257 <td>Number of records updated</td>
258 <td>[% num_updated | html %]</td>
261 <td>Number of records ignored</td>
262 <td>[% num_ignored | html %]</td>
264 [% IF ( record_type == 'biblio' ) %]
266 <td>Number of items added</td>
267 <td>[% num_items_added | html %]</td>
270 <td>Number of items replaced</td>
271 <td>[% num_items_replaced | html %]</td>
274 <td>Number of items ignored because of duplicate barcode</td>
275 <td>[% num_items_errored | html %]</td>
279 [% END #/ IF did_commit %]
281 [% IF ( did_revert ) %]
282 <div class="dialog message">Success: Import reversed</div>
285 <td>Number of records deleted</td>
286 <td>[% num_deleted | html %]</td>
288 [% IF ( record_type == 'biblio' ) %]
290 <td>Number of items deleted</td>
291 <td>[% num_items_deleted | html %]</td>
294 <td>Number of records not deleted due to items on loan</td>
295 <td>[% num_errors | html %]</td>
299 <td>Number of records changed back</td>
300 <td>[% num_reverted | html %]</td>
303 <td>Number of records ignored</td>
304 <td>[% num_ignored | html %]</td>
307 [% END # /IF did_revert%]
309 [% END # /IF batch_info %]
311 <br style="clear:both;" />
313 [% IF ( batch_list ) %]
315 [% PROCESS pagination %]
330 [% FOREACH batch_lis IN batch_list %]
332 <td>[% batch_lis.import_batch_id | html %]</td>
333 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
334 <td>[% batch_lis.comments | html %]</td>
335 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
337 [% IF ( batch_lis.import_status == 'cleaned' ) %]
339 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
341 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
343 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
345 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
347 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
350 [% batch_lis.import_status | html %]
353 <td>[% batch_lis.upload_timestamp | html %]</td>
354 <td>[% batch_lis.num_records | html %]</td>
355 <td>[% batch_lis.num_items | html %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">(Create label batch)</a>[% END %]</td>
357 [% IF ( batch_lis.can_clean ) %]
358 <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">
359 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
360 <input type="hidden" name="op" value="clean-batch" />
361 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
363 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
364 <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">
365 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
366 <input type="hidden" name="op" value="delete-batch" />
367 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
372 [% END # /FOREACH batch_lis %]
376 [% PROCESS pagination %]
378 [% END # /IF batch_lis %]
380 [% IF import_batch_id %]
381 <table id="records-table">
388 <th>Match details</th>
389 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
395 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
396 <div class="modal-dialog">
397 <div class="modal-content">
398 <div class="modal-header">
399 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
400 <h3 id="marcPreviewLabel">MARC preview</h3>
402 <div class="modal-body">
403 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
405 <div class="modal-footer">
406 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
410 </div> <!-- /#marcPreview -->
411 [% END # /IF import_batch_id %]
414 </div> <!-- /.col-sm-10.col-sm-push-2 -->
415 <div class="col-sm-2 col-sm-pull-10">
417 [% INCLUDE 'tools-menu.inc' %]
419 </div> <!-- .col-sm-2.col-sm-pull-10 -->
420 </div> <!-- /.row -->
422 [% MACRO jsinclude BLOCK %]
423 [% Asset.js("js/tools-menu.js") | $raw %]
424 [% Asset.js("js/background-job-progressbar.js") | $raw %]
425 [% INCLUDE 'datatables.inc' %]
427 $(document).ready(function() {
428 $("#staged-record-matching-rules select").change(function() {
429 var str = $(this).attr("id");
430 $("#reset_" + str).parent().show();
432 $("a.reset").click(function() {
433 var str = $(this).attr("id");
434 str = str.replace("reset_", "")
435 $("#" + str + " option[selected='selected']").attr("selected", "selected");
436 $(this).parent().hide();
439 [% IF import_batch_id %]
440 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
445 "sAjaxSource": 'batch_records_ajax.pl',
446 "sPaginationType": "full_numbers",
447 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
449 { "mDataProp": "import_record_id" },
450 { "mDataProp": "citation" },
451 { "mDataProp": "status" },
452 { "mDataProp": "overlay_status" },
453 { "mDataProp": "match_citation" },
454 { "mDataProp": "diff_url" },
455 { "mDataProp": "matched" }
457 "fnServerData": function(sSource, aoData, fnCallback) {
458 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
465 'success': function(json) {
470 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
471 [% IF(record_type == 'auth') %]
472 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
474 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
477 $('td:eq(1)', nRow).html(
478 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
481 $('td:eq(2)', nRow).html(
482 aData['status'] == 'imported' ? _("Imported") :
483 aData['status'] == 'ignored' ? _("Ignored") :
484 aData['status'] == 'reverted' ? _("Reverted") :
485 aData['status'] == 'staged' ? _("Staged") :
486 aData['status'] == 'error' ? _("Error") :
490 $('td:eq(3)', nRow).html(
491 aData['overlay_status'] == 'no_match' ? _("No match") :
492 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
493 aData['overlay_status'] == 'auto_match' ? _("Match found") :
494 aData['overlay_status']
497 if (aData['match_id']) {
498 [% IF(record_type == 'auth') -%]
499 var matching_msg = _("Matches authority %s (score=%s):%s");
501 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
503 $('td:eq(4)', nRow).html(
504 matching_msg.format(aData['match_id'], aData['score'],
505 '<a target="_blank" href="' + record_details_url
506 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
509 if (aData['diff_url']) {
510 $('td:eq(5)', nRow).html(
511 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
514 $('td:eq(6)', nRow).html(
515 '<a target="_blank" href="' + record_details_url
516 + aData['matched'] + '">' + aData['matched'] + '</a>'
520 $("#import_batch_form").on("submit", function() {
521 return submitBackgroundJob(document.getElementById("import_batch_form"));
523 $("#revert_batch_form").on("submit", function() {
524 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
528 $("body").on("click", ".previewMARC", function(e) {
530 var ltitle = $(this).text();
531 var page = $(this).attr("href");
532 $("#marcPreviewLabel").text(ltitle);
533 $("#marcPreview .modal-body").load(page + " table");
534 $('#marcPreview').modal({ show: true });
536 $("#marcPreview").on("hidden.bs.modal", function() {
537 $("#marcPreviewLabel").html("");
538 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
540 $(".batch_form").on("submit", function() {
541 if ($(this).hasClass("batch_delete")) {
542 return confirm(_("Are you sure you want to permanently delete this batch?"));
544 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
551 [% INCLUDE 'intranet-bottom.inc' %]
552 [% BLOCK pagination %]
554 <ul class="pagination">
555 [% FOREACH page IN pages %]
556 [% IF ( page.current_page && page.page_number > 1 ) %]
557 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
558 <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>
561 [% FOREACH page IN pages %]
562 [% IF ( page.current_page ) %]
563 [% SET current_page = page.page_number %]
564 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
566 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
569 [% IF ( current_page < pages.size() ) %]
571 <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>
574 <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>