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">Profile:</span> [% IF (profile) %][% profile | html %][% ELSE %](none)[% END %]</li>
110 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
111 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
112 <li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
113 <li><span class="label">Status:</span>
114 [% IF ( import_status == 'cleaned' ) %]
116 [% ELSIF ( import_status == 'imported' ) %]
118 [% ELSIF ( import_status == 'importing' ) %]
120 [% ELSIF ( import_status == 'reverted' ) %]
122 [% ELSIF ( import_status == 'reverting' ) %]
124 [% ELSIF ( import_status == 'staged' ) %]
127 [% import_status | html %]
131 [% IF ( can_commit ) %]
132 <label for="new_matcher_id">Matching rule applied:</label>
133 <select name="new_matcher_id" id="new_matcher_id">
134 <option value="">Do not look for matching records</option>
135 [% FOREACH available_matcher IN available_matchers %]
136 [% IF ( available_matcher.selected ) %]
137 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
138 [% available_matcher.code | html %] ([% available_matcher.description | html %])
141 <option value="[% available_matcher.matcher_id | html %]">
142 [% available_matcher.code | html %] ([% available_matcher.description | html %])
147 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
149 <span class="label">Matching rule applied</span>
150 [% IF ( current_matcher_id ) %]
151 [% current_matcher_code | html %] ([% current_matcher_description | html %])
153 No matching rule in effect
158 [% IF ( can_commit ) %]
159 <label for="overlay_action">Action if matching record found:</label>
160 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
162 <span class="label">Action if matching record found:</span>
163 [% IF ( overlay_action == 'replace' ) %]
164 Replace existing record with incoming record
165 [% ELSIF ( overlay_action == 'create_new' ) %]
167 [% ELSIF ( overlay_action == 'ignore' ) %]
168 Ignore incoming record (its items may still be processed)
170 [% overlay_action | html %]
175 [% IF ( can_commit ) %]
176 <label for="nomatch_action">Action if no match found:</label>
177 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
179 <span class="label">Action if no match found:</span>
180 [% IF ( nomatch_action == 'create_new' ) %]
182 [% ELSIF ( nomatch_action == 'ignore' ) %]
183 Ignore incoming record (its items may still be processed)
185 [% nomatch_action | html %]
189 [% IF ( record_type == 'biblio' ) %]
191 [% IF ( can_commit ) %]
192 <label for="item_action">Item processing:</label>
193 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
195 <span class="label">Item processing:</span>
196 [% IF ( item_action == 'always_add' ) %]
198 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
199 Add items only if matching bib was found
200 [% ELSIF ( item_action == 'add_only_for_new' ) %]
201 Add items only if no matching bib was found
202 [% ELSIF ( item_action == 'ignore' ) %]
205 [% item_action | html %]
211 [% IF ( can_commit ) %]
212 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
215 </fieldset> <!-- /#staged-record-matching-rules -->
218 [% IF ( can_commit ) %]
219 <form action="[% script_name | html %]" method="post" id="import_batch_form">
220 <input type="hidden" name="op" value="commit-batch" />
221 <input type="hidden" name="runinbackground" value="" />
222 <input type="hidden" name="completedJobID" value="" />
223 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
224 <fieldset class="action">
225 [% IF ( record_type != 'auth' ) %]
226 Add new bibliographic records into this framework:
227 <select name="framework" id="frameworks">
228 <option value="">Default</option>
229 [% FOREACH framework IN frameworks %]
230 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
235 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
237 </form> <!-- /#import_batch_form -->
239 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
240 <div id="jobfailed"></div>
242 [% END # /IF can_commit %]
243 [% IF ( can_revert ) %]
244 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
245 <input type="hidden" name="op" value="revert-batch" />
246 <input type="hidden" name="runinbackground" value="" />
247 <input type="hidden" name="completedJobID" value="" />
248 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
249 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
252 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
253 <div id="jobfailed"></div>
255 [% END # /IF can_revert %]
258 [% IF ( did_commit ) %]
259 <div class="dialog message">Completed import of records</div>
262 <td>Number of records added</td>
263 <td>[% num_added | html %]</td>
266 <td>Number of records updated</td>
267 <td>[% num_updated | html %]</td>
270 <td>Number of records ignored</td>
271 <td>[% num_ignored | html %]</td>
273 [% IF ( record_type == 'biblio' ) %]
275 <td>Number of items added</td>
276 <td>[% num_items_added | html %]</td>
279 <td>Number of items replaced</td>
280 <td>[% num_items_replaced | html %]</td>
283 <td>Number of items ignored because of duplicate barcode</td>
284 <td>[% num_items_errored | html %]</td>
288 [% END #/ IF did_commit %]
290 [% IF ( did_revert ) %]
291 <div class="dialog message">Success: Import reversed</div>
294 <td>Number of records deleted</td>
295 <td>[% num_deleted | html %]</td>
297 [% IF ( record_type == 'biblio' ) %]
299 <td>Number of items deleted</td>
300 <td>[% num_items_deleted | html %]</td>
303 <td>Number of records not deleted due to items on loan</td>
304 <td>[% num_errors | html %]</td>
308 <td>Number of records changed back</td>
309 <td>[% num_reverted | html %]</td>
312 <td>Number of records ignored</td>
313 <td>[% num_ignored | html %]</td>
316 [% END # /IF did_revert%]
318 [% END # /IF batch_info %]
320 <br style="clear:both;" />
322 [% IF ( batch_list ) %]
324 [% PROCESS pagination %]
340 [% FOREACH batch_lis IN batch_list %]
342 <td>[% batch_lis.import_batch_id | html %]</td>
343 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
344 <td>[% batch_lis.profile | html %]</td>
345 <td>[% batch_lis.comments | html %]</td>
346 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
348 [% IF ( batch_lis.import_status == 'cleaned' ) %]
350 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
352 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
354 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
356 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
358 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
361 [% batch_lis.import_status | html %]
364 <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
365 <td>[% batch_lis.num_records | html %]</td>
366 <td>[% batch_lis.num_items | html %]
367 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
368 (<a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&op=create_labels">Create label batch</a>)
372 [% IF ( batch_lis.can_clean ) %]
373 <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">
374 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
375 <input type="hidden" name="op" value="clean-batch" />
376 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
378 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
379 <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">
380 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
381 <input type="hidden" name="op" value="delete-batch" />
382 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
387 [% END # /FOREACH batch_lis %]
391 [% PROCESS pagination %]
393 [% END # /IF batch_lis %]
395 [% IF import_batch_id && !did_clean %]
396 <table id="records-table">
403 <th>Match details</th>
404 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
410 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
411 <div class="modal-dialog modal-wide">
412 <div class="modal-content">
413 <div class="modal-header">
414 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
415 <h3 id="marcPreviewLabel">MARC preview</h3>
417 <div class="modal-body">
418 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
420 <div class="modal-footer">
421 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
425 </div> <!-- /#marcPreview -->
426 [% END # /IF import_batch_id %]
429 </div> <!-- /.col-sm-10.col-sm-push-2 -->
430 <div class="col-sm-2 col-sm-pull-10">
432 [% INCLUDE 'tools-menu.inc' %]
434 </div> <!-- .col-sm-2.col-sm-pull-10 -->
435 </div> <!-- /.row -->
437 [% MACRO jsinclude BLOCK %]
438 [% Asset.js("js/tools-menu.js") | $raw %]
439 [% Asset.js("lib/jquery/plugins/humanmsg.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 var additional_details = "";
494 if( aData['author'] ){
495 additional_details += " " + aData['author'] + " ";
499 additional_details += " (" + aData['isbn'] + ") ";
503 additional_details += " (" + aData['issn'] + ") ";
506 $('td:eq(1)', nRow).html(
507 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
510 $('td:eq(2)', nRow).html(
511 aData['status'] == 'imported' ? _("Imported") :
512 aData['status'] == 'ignored' ? _("Ignored") :
513 aData['status'] == 'reverted' ? _("Reverted") :
514 aData['status'] == 'staged' ? _("Staged") :
515 aData['status'] == 'error' ? _("Error") :
519 $('td:eq(3)', nRow).html(
520 aData['overlay_status'] == 'no_match' ? _("No match") :
521 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
522 aData['overlay_status'] == 'auto_match' ? _("Match found") :
523 aData['overlay_status']
526 if (aData['match_id']) {
527 [% IF(record_type == 'auth') -%]
528 var matching_msg = _("Matches authority %s (score=%s):%s");
530 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
532 $('td:eq(4)', nRow).html(
533 matching_msg.format(aData['match_id'], aData['score'],
534 '<a target="_blank" href="' + record_details_url
535 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
538 if (aData['diff_url']) {
539 $('td:eq(5)', nRow).html(
540 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
543 $('td:eq(6)', nRow).html(
544 '<a target="_blank" href="' + record_details_url
545 + aData['matched'] + '">' + aData['matched'] + '</a>'
549 $("#import_batch_form").on("submit", function() {
550 return submitBackgroundJob(document.getElementById("import_batch_form"));
552 $("#revert_batch_form").on("submit", function() {
553 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
557 $("body").on("click", ".previewMARC", function(e) {
559 var ltitle = $(this).text();
560 var page = $(this).attr("href");
561 $("#marcPreviewLabel").text(ltitle);
562 $("#marcPreview .modal-body").load(page + " table");
563 $('#marcPreview').modal({ show: true });
565 $("#marcPreview").on("hidden.bs.modal", function() {
566 $("#marcPreviewLabel").html("");
567 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
569 $(".batch_form").on("submit", function() {
570 if ($(this).hasClass("batch_delete")) {
571 return confirm(_("Are you sure you want to permanently delete this batch?"));
573 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
580 [% INCLUDE 'intranet-bottom.inc' %]
581 [% BLOCK pagination %]
583 <ul class="pagination">
584 [% FOREACH page IN pages %]
585 [% IF ( page.current_page && page.page_number > 1 ) %]
586 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
587 <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>
590 [% FOREACH page IN pages %]
591 [% IF ( page.current_page ) %]
592 [% SET current_page = page.page_number %]
593 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
595 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
598 [% IF ( current_page < pages.size() ) %]
600 <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>
603 <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>