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>
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" />
230 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
231 <div id="jobfailed"></div>
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>
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>
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>
311 <br style="clear:both;" />
313 [% IF ( batch_list ) %]
316 [% FOREACH page IN pages %]
317 [% IF ( page.current_page ) %]
318 <span class="current">[% page.page_number | html %]</span>
320 <a href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a>
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 | html %]</td>
362 <td>[% batch_lis.num_records | html %]</td>
363 <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>
365 [% IF ( batch_lis.can_clean ) %]
366 <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">
367 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
368 <input type="hidden" name="op" value="clean-batch" />
369 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
371 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
372 <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">
373 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
374 <input type="hidden" name="op" value="delete-batch" />
375 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
385 [% FOREACH page IN pages %]
386 [% IF ( page.current_page ) %]
387 <span class="current">[% page.page_number | html %]</span>
389 <a href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a>
396 [% IF import_batch_id %]
397 <table id="records-table">
404 <th>Match details</th>
405 <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">
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>
430 </div> <!-- /.col-sm-10.col-sm-push-2 -->
431 <div class="col-sm-2 col-sm-pull-10">
433 [% INCLUDE 'tools-menu.inc' %]
435 </div> <!-- .col-sm-2.col-sm-pull-10 -->
436 </div> <!-- /.row -->
438 [% MACRO jsinclude BLOCK %]
439 [% Asset.js("js/tools-menu.js") | $raw %]
440 [% Asset.js("js/background-job-progressbar.js") | $raw %]
441 [% INCLUDE 'datatables.inc' %]
443 $(document).ready(function() {
444 $("#staged-record-matching-rules select").change(function() {
445 var str = $(this).attr("id");
446 $("#reset_" + str).parent().show();
448 $("a.reset").click(function() {
449 var str = $(this).attr("id");
450 str = str.replace("reset_", "")
451 $("#" + str + " option[selected='selected']").attr("selected", "selected");
452 $(this).parent().hide();
455 [% IF import_batch_id %]
456 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
461 "sAjaxSource": 'batch_records_ajax.pl',
462 "sPaginationType": "full_numbers",
463 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
465 { "mDataProp": "import_record_id" },
466 { "mDataProp": "citation" },
467 { "mDataProp": "status" },
468 { "mDataProp": "overlay_status" },
469 { "mDataProp": "match_citation" },
470 { "mDataProp": "diff_url" },
471 { "mDataProp": "matched" }
473 "fnServerData": function(sSource, aoData, fnCallback) {
474 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
481 'success': function(json) {
486 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
487 [% IF(record_type == 'auth') %]
488 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
490 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
493 $('td:eq(1)', nRow).html(
494 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
497 $('td:eq(2)', nRow).html(
498 aData['status'] == 'imported' ? _("Imported") :
499 aData['status'] == 'ignored' ? _("Ignored") :
500 aData['status'] == 'reverted' ? _("Reverted") :
501 aData['status'] == 'staged' ? _("Staged") :
502 aData['status'] == 'error' ? _("Error") :
506 $('td:eq(3)', nRow).html(
507 aData['overlay_status'] == 'no_match' ? _("No match") :
508 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
509 aData['overlay_status'] == 'auto_match' ? _("Match found") :
510 aData['overlay_status']
513 if (aData['match_id']) {
514 [% IF(record_type == 'auth') -%]
515 var matching_msg = _("Matches authority %s (score=%s):%s");
517 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
519 $('td:eq(4)', nRow).html(
520 matching_msg.format(aData['match_id'], aData['score'],
521 '<a target="_blank" href="' + record_details_url
522 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
525 if (aData['diff_url']) {
526 $('td:eq(5)', nRow).html(
527 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
530 $('td:eq(6)', nRow).html(
531 '<a target="_blank" href="' + record_details_url
532 + aData['matched'] + '">' + aData['matched'] + '</a>'
536 $("#import_batch_form").on("submit", function() {
537 return submitBackgroundJob(document.getElementById("import_batch_form"));
539 $("#revert_batch_form").on("submit", function() {
540 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
544 $("body").on("click", ".previewMARC", function(e) {
546 var ltitle = $(this).text();
547 var page = $(this).attr("href");
548 $("#marcPreviewLabel").text(ltitle);
549 $("#marcPreview .modal-body").load(page + " table");
550 $('#marcPreview').modal({ show: true });
552 $("#marcPreview").on("hidden.bs.modal", function() {
553 $("#marcPreviewLabel").html("");
554 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
556 $(".batch_form").on("submit", function() {
557 if ($(this).hasClass("batch_delete")) {
558 return confirm(_("Are you sure you want to permanently delete this batch?"));
560 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
567 [% INCLUDE 'intranet-bottom.inc' %]