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 <span>No matching rule in effect</span>
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 <span>Replace existing record with incoming record</span>
182 [% ELSIF ( overlay_action == 'create_new' ) %]
183 <span>Add incoming record</span>
184 [% ELSIF ( overlay_action == 'ignore' ) %]
185 <span>Ignore incoming record (its items may still be processed)</span>
187 <span>[% overlay_action | html %]</span>
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' ) %]
214 <span>Always add items</span>
215 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
216 <span>Add items only if matching bib was found</span>
217 [% ELSIF ( item_action == 'add_only_for_new' ) %]
218 <span>Add items only if no matching bib was found</span>
219 [% ELSIF ( item_action == 'ignore' ) %]
220 <span>Ignore items</span>
222 <span>[% item_action | html %]</span>
227 <input type ="hidden" name="item_action" value="ignore">
230 [% IF ( can_commit ) %]
231 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
234 </fieldset> <!-- /#staged-record-matching-rules -->
237 [% IF ( can_commit ) %]
238 <form action="[% script_name | html %]" method="post" id="import_batch_form">
239 <input type="hidden" name="op" value="commit-batch" />
240 <input type="hidden" name="runinbackground" value="" />
241 <input type="hidden" name="completedJobID" value="" />
242 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
243 <fieldset class="action">
244 [% IF ( record_type != 'auth' ) %]
245 Add new bibliographic records into this framework:
246 <select name="framework" id="frameworks">
247 <option value="">Default</option>
248 [% FOREACH framework IN frameworks %]
249 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
254 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
256 </form> <!-- /#import_batch_form -->
258 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
259 <div id="jobfailed"></div>
261 [% END # /IF can_commit %]
262 [% IF ( can_revert ) %]
263 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
264 <input type="hidden" name="op" value="revert-batch" />
265 <input type="hidden" name="runinbackground" value="" />
266 <input type="hidden" name="completedJobID" value="" />
267 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
268 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
271 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
272 <div id="jobfailed"></div>
274 [% END # /IF can_revert %]
277 [% IF ( did_commit ) %]
278 <div class="dialog message">Completed import of records</div>
281 <td>Number of records added</td>
282 <td>[% num_added | html %]</td>
285 <td>Number of records updated</td>
286 <td>[% num_updated | html %]</td>
289 <td>Number of records ignored</td>
290 <td>[% num_ignored | html %]</td>
292 [% IF ( record_type == 'biblio' ) %]
294 <td>Number of items added</td>
295 <td>[% num_items_added | html %]</td>
298 <td>Number of items replaced</td>
299 <td>[% num_items_replaced | html %]</td>
302 <td>Number of items ignored because of duplicate barcode</td>
303 <td>[% num_items_errored | html %]</td>
307 [% END #/ IF did_commit %]
309 [% IF ( did_revert ) %]
310 <div class="dialog message">Success: Import reversed</div>
313 <td>Number of records deleted</td>
314 <td>[% num_deleted | html %]</td>
316 [% IF ( record_type == 'biblio' ) %]
318 <td>Number of items deleted</td>
319 <td>[% num_items_deleted | html %]</td>
322 <td>Number of records not deleted due to items on loan</td>
323 <td>[% num_errors | html %]</td>
327 <td>Number of records changed back</td>
328 <td>[% num_reverted | html %]</td>
331 <td>Number of records ignored</td>
332 <td>[% num_ignored | html %]</td>
335 [% END # /IF did_revert%]
337 [% END # /IF batch_info %]
339 <br style="clear:both;" />
341 [% IF ( batch_list ) %]
343 [% PROCESS pagination %]
359 [% FOREACH batch_lis IN batch_list %]
361 <td>[% batch_lis.import_batch_id | html %]</td>
362 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
363 <td>[% batch_lis.profile | html %]</td>
364 <td>[% batch_lis.comments | html %]</td>
365 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
367 [% IF ( batch_lis.import_status == 'cleaned' ) %]
369 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
370 <span>Imported</span>
371 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
372 <span>Importing</span>
373 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
374 <span>Reverted</span>
375 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
376 <span>Reverting</span>
377 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
380 <span>[% batch_lis.import_status | html %]</span>
383 <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
384 <td>[% batch_lis.num_records | html %]</td>
385 <td>[% batch_lis.num_items | html %]
386 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
387 (<a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
391 [% IF ( batch_lis.can_clean ) %]
392 <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">
393 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
394 <input type="hidden" name="op" value="clean-batch" />
395 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
397 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
398 <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">
399 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
400 <input type="hidden" name="op" value="delete-batch" />
401 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
406 [% END # /FOREACH batch_lis %]
410 [% PROCESS pagination %]
412 [% END # /IF batch_lis %]
414 [% IF import_batch_id && !did_clean %]
415 <table id="records-table">
422 <th>Match details</th>
423 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
429 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
430 <div class="modal-dialog modal-wide">
431 <div class="modal-content">
432 <div class="modal-header">
433 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
434 <h3 id="marcPreviewLabel">MARC preview</h3>
436 <div class="modal-body">
437 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
439 <div class="modal-footer">
440 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
444 </div> <!-- /#marcPreview -->
445 [% END # /IF import_batch_id %]
448 </div> <!-- /.col-sm-10.col-sm-push-2 -->
449 <div class="col-sm-2 col-sm-pull-10">
451 [% INCLUDE 'tools-menu.inc' %]
453 </div> <!-- .col-sm-2.col-sm-pull-10 -->
454 </div> <!-- /.row -->
456 [% MACRO jsinclude BLOCK %]
457 [% Asset.js("js/tools-menu.js") | $raw %]
458 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
459 [% Asset.js("js/background-job-progressbar.js") | $raw %]
460 [% INCLUDE 'datatables.inc' %]
462 $(document).ready(function() {
463 $("#staged-record-matching-rules select").change(function() {
464 var str = $(this).attr("id");
465 $("#reset_" + str).parent().show();
467 $("a.reset").click(function() {
468 var str = $(this).attr("id");
469 str = str.replace("reset_", "")
470 $("#" + str + " option[selected='selected']").attr("selected", "selected");
471 $(this).parent().hide();
474 [% IF import_batch_id %]
475 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
480 "sAjaxSource": 'batch_records_ajax.pl',
481 "sPaginationType": "full_numbers",
482 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
484 { "mDataProp": "import_record_id" },
485 { "mDataProp": "citation" },
486 { "mDataProp": "status" },
487 { "mDataProp": "overlay_status" },
488 { "mDataProp": "match_citation" },
489 { "mDataProp": "diff_url" },
490 { "mDataProp": "matched" }
492 "fnServerData": function(sSource, aoData, fnCallback) {
493 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
500 'success': function(json) {
505 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
506 [% IF(record_type == 'auth') %]
507 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
509 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
511 [% IF(record_type == 'auth') %]
512 var record_edit_url = "/cgi-bin/koha/authorities/authorities.pl?authid=";
514 var record_edit_url = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
517 var additional_details = "";
518 if( aData['author'] ){
519 additional_details += " " + aData['author'] + " ";
523 additional_details += " (" + aData['isbn'] + ") ";
527 additional_details += " (" + aData['issn'] + ") ";
530 $('td:eq(1)', nRow).html(
531 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
534 $('td:eq(2)', nRow).html(
535 aData['status'] == 'imported' ? _("Imported") :
536 aData['status'] == 'ignored' ? _("Ignored") :
537 aData['status'] == 'reverted' ? _("Reverted") :
538 aData['status'] == 'staged' ? _("Staged") :
539 aData['status'] == 'error' ? _("Error") :
543 $('td:eq(3)', nRow).html(
544 aData['overlay_status'] == 'no_match' ? _("No match") :
545 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
546 aData['overlay_status'] == 'auto_match' ? _("Match found") :
547 aData['overlay_status']
550 if (aData['match_id']) {
551 [% IF(record_type == 'auth') -%]
552 var matching_msg = _("Matches authority %s (score=%s):%s");
554 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
556 $('td:eq(4)', nRow).html(
557 matching_msg.format(aData['match_id'], aData['score'],
558 '<a target="_blank" href="' + record_details_url
559 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
562 if (aData['diff_url']) {
563 $('td:eq(5)', nRow).html(
564 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
567 if (aData['matched']) {
568 $('td:eq(6)', nRow).html(
569 '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url
570 + aData['matched'] + '"><i class="fa fa-eye"></i> ' + _("View") + '</a> '
571 [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
572 + '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url
573 + aData['matched'] + '"><i class="fa fa-pencil"></i> ' + _("Edit") + '</a>'
579 $("#import_batch_form").on("submit", function() {
580 return submitBackgroundJob(document.getElementById("import_batch_form"));
582 $("#revert_batch_form").on("submit", function() {
583 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
587 $("body").on("click", ".previewMARC", function(e) {
589 var ltitle = $(this).text();
590 var page = $(this).attr("href");
591 $("#marcPreviewLabel").text(ltitle);
592 $("#marcPreview .modal-body").load(page + " table");
593 $('#marcPreview').modal({ show: true });
595 $("#marcPreview").on("hidden.bs.modal", function() {
596 $("#marcPreviewLabel").html("");
597 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
599 $(".batch_form").on("submit", function() {
600 if ($(this).hasClass("batch_delete")) {
601 return confirm(_("Are you sure you want to permanently delete this batch?"));
603 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
610 [% INCLUDE 'intranet-bottom.inc' %]
611 [% BLOCK pagination %]
613 <ul class="pagination">
614 [% FOREACH page IN pages %]
615 [% IF ( page.current_page && page.page_number > 1 ) %]
616 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
617 <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>
620 [% FOREACH page IN pages %]
621 [% IF ( page.current_page ) %]
622 [% SET current_page = page.page_number %]
623 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
625 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
628 [% IF ( current_page < pages.size() ) %]
630 <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>
633 <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>