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' %]
11 [% Asset.css("css/humanmsg.css") | $raw %]
13 #jobpanel,#jobstatus,#jobfailed { display : none; }
14 span.change-status { font-style:italic; color:#666; display:none; }
18 <body id="tools_manage-marc-import" class="tools">
19 [% INCLUDE 'header.inc' %]
20 [% INCLUDE 'cat-search.inc' %]
22 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23 [% IF ( import_batch_id ) %]
25 <a href="[% script_name | url %]">Manage staged MARC records</a>
26 › Batch [% import_batch_id | html %]
28 › Manage staged MARC records
32 <div class="main container-fluid">
34 <div class="col-sm-10 col-sm-push-2">
36 <h1>Manage staged MARC records
37 [% IF ( import_batch_id ) %]
38 › Batch [% import_batch_id | html %]
42 [% IF ( label_batch_msg ) %]
46 <div class="dialog message">
48 <b><p>[% label_batch_msg | html %]</p></b>
52 [% IF ( did_clean ) %]
53 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
56 [% IF ( did_delete ) %]
57 <div class="dialog message">Import batch deleted successfully</div>
60 [% UNLESS ( batch_list ) %]
61 [% UNLESS ( batch_info ) %]
62 <div class="dialog message">
63 <p>No records have been staged.</p>
64 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
69 [% IF ( batch_info ) %]
70 [% IF ( can_commit ) %]
71 <form action="[% script_name | html %]" method="post">
72 <input type="hidden" name="op" value="redo-matching" />
73 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
74 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
77 [% IF ( rematch_attempted ) %]
78 [% IF ( rematch_failed ) %]
79 <div class="dialog alert">Failed to apply different matching rule</div>
81 <div class="dialog message">Applied different matching rule. Number of records matched now
82 [% num_with_matches | html %]
87 [% IF ( changed_overlay_action ) %]
88 <div class="dialog message">Changed action if matching record found</div>
91 [% IF ( changed_nomatch_action ) %]
92 <div class="dialog message">Changed action if no match found</div>
95 [% IF ( changed_item_action ) %]
96 <div class="dialog message">Changed item processing option</div>
99 <fieldset class="rows" id="staged-record-matching-rules">
101 <li><span class="label">File name:</span> [% file_name | html %]</li>
102 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
103 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
104 <li><span class="label">Staged:</span> [% upload_timestamp | html %]</li>
105 <li><span class="label">Status:</span>
106 [% IF ( import_status == 'cleaned' ) %]
108 [% ELSIF ( import_status == 'imported' ) %]
110 [% ELSIF ( import_status == 'importing' ) %]
112 [% ELSIF ( import_status == 'reverted' ) %]
114 [% ELSIF ( import_status == 'reverting' ) %]
116 [% ELSIF ( import_status == 'staged' ) %]
119 [% import_status | html %]
123 [% IF ( can_commit ) %]
124 <label for="new_matcher_id">Matching rule applied:</label>
125 <select name="new_matcher_id" id="new_matcher_id">
126 <option value="">Do not look for matching records</option>
127 [% FOREACH available_matcher IN available_matchers %]
128 [% IF ( available_matcher.selected ) %]
129 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
130 [% available_matcher.code | html %] ([% available_matcher.description | html %])
133 <option value="[% available_matcher.matcher_id | html %]">
134 [% available_matcher.code | html %] ([% available_matcher.description | html %])
139 <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
141 <span class="label">Matching rule applied</span>
142 [% IF ( current_matcher_id ) %]
143 [% current_matcher_code | html %] ([% current_matcher_description | html %])
145 No matching rule in effect
150 [% IF ( can_commit ) %]
151 <label for="overlay_action">Action if matching record found:</label>
152 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
154 <span class="label">Action if matching record found:</span>
155 [% IF ( overlay_action == 'replace' ) %]
156 Replace existing record with incoming record
157 [% ELSIF ( overlay_action == 'create_new' ) %]
159 [% ELSIF ( overlay_action == 'ignore' ) %]
160 Ignore incoming record (its items may still be processed)
162 [% overlay_action | html %]
167 [% IF ( can_commit ) %]
168 <label for="nomatch_action">Action if no match found:</label>
169 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
171 <span class="label">Action if no match found:</span>
172 [% IF ( nomatch_action == 'create_new' ) %]
174 [% ELSIF ( nomatch_action == 'ignore' ) %]
175 Ignore incoming record (its items may still be processed)
177 [% nomatch_action | html %]
181 [% IF ( record_type == 'biblio' ) %]
183 [% IF ( can_commit ) %]
184 <label for="item_action">Item processing:</label>
185 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
187 <span class="label">Item processing:</span>
188 [% IF ( item_action == 'always_add' ) %]
190 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
191 Add items only if matching bib was found
192 [% ELSIF ( item_action == 'add_only_for_new' ) %]
193 Add items only if no matching bib was found
194 [% ELSIF ( item_action == 'ignore' ) %]
197 [% item_action | html %]
203 [% IF ( can_commit ) %]
204 <fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset>
207 </fieldset> <!-- /#staged-record-matching-rules -->
210 [% IF ( can_commit ) %]
211 <form action="[% script_name | html %]" method="post" id="import_batch_form">
212 <input type="hidden" name="op" value="commit-batch" />
213 <input type="hidden" name="runinbackground" value="" />
214 <input type="hidden" name="completedJobID" value="" />
215 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
216 <fieldset class="action">
217 [% IF ( record_type != 'auth' ) %]
218 Add new bibliographic records into this framework:
219 <select name="framework" id="frameworks">
220 <option value="">Default</option>
221 [% FOREACH framework IN frameworks %]
222 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
227 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
229 </form> <!-- /#import_batch_form -->
231 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
232 <div id="jobfailed"></div>
234 [% END # /IF can_commit %]
235 [% IF ( can_revert ) %]
236 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
237 <input type="hidden" name="op" value="revert-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"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
244 <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
245 <div id="jobfailed"></div>
247 [% END # /IF can_revert %]
250 [% IF ( did_commit ) %]
251 <div class="dialog message">Completed import of records</div>
254 <td>Number of records added</td>
255 <td>[% num_added | html %]</td>
258 <td>Number of records updated</td>
259 <td>[% num_updated | html %]</td>
262 <td>Number of records ignored</td>
263 <td>[% num_ignored | html %]</td>
265 [% IF ( record_type == 'biblio' ) %]
267 <td>Number of items added</td>
268 <td>[% num_items_added | html %]</td>
271 <td>Number of items replaced</td>
272 <td>[% num_items_replaced | html %]</td>
275 <td>Number of items ignored because of duplicate barcode</td>
276 <td>[% num_items_errored | html %]</td>
280 [% END #/ IF did_commit %]
282 [% IF ( did_revert ) %]
283 <div class="dialog message">Success: Import reversed</div>
286 <td>Number of records deleted</td>
287 <td>[% num_deleted | html %]</td>
289 [% IF ( record_type == 'biblio' ) %]
291 <td>Number of items deleted</td>
292 <td>[% num_items_deleted | html %]</td>
295 <td>Number of records not deleted due to items on loan</td>
296 <td>[% num_errors | html %]</td>
300 <td>Number of records changed back</td>
301 <td>[% num_reverted | html %]</td>
304 <td>Number of records ignored</td>
305 <td>[% num_ignored | html %]</td>
308 [% END # /IF did_revert%]
310 [% END # /IF batch_info %]
312 <br style="clear:both;" />
314 [% IF ( batch_list ) %]
316 [% PROCESS pagination %]
331 [% FOREACH batch_lis IN batch_list %]
333 <td>[% batch_lis.import_batch_id | html %]</td>
334 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
335 <td>[% batch_lis.comments | html %]</td>
336 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
338 [% IF ( batch_lis.import_status == 'cleaned' ) %]
340 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
342 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
344 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
346 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
348 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
351 [% batch_lis.import_status | html %]
354 <td>[% batch_lis.upload_timestamp | html %]</td>
355 <td>[% batch_lis.num_records | html %]</td>
356 <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>
358 [% IF ( batch_lis.can_clean ) %]
359 <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">
360 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
361 <input type="hidden" name="op" value="clean-batch" />
362 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
364 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
365 <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">
366 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
367 <input type="hidden" name="op" value="delete-batch" />
368 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
373 [% END # /FOREACH batch_lis %]
377 [% PROCESS pagination %]
379 [% END # /IF batch_lis %]
381 [% IF import_batch_id %]
382 <table id="records-table">
389 <th>Match details</th>
390 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
396 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
397 <div class="modal-dialog modal-wide">
398 <div class="modal-content">
399 <div class="modal-header">
400 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
401 <h3 id="marcPreviewLabel">MARC preview</h3>
403 <div class="modal-body">
404 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
406 <div class="modal-footer">
407 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
411 </div> <!-- /#marcPreview -->
412 [% END # /IF import_batch_id %]
415 </div> <!-- /.col-sm-10.col-sm-push-2 -->
416 <div class="col-sm-2 col-sm-pull-10">
418 [% INCLUDE 'tools-menu.inc' %]
420 </div> <!-- .col-sm-2.col-sm-pull-10 -->
421 </div> <!-- /.row -->
423 [% MACRO jsinclude BLOCK %]
424 [% Asset.js("js/tools-menu.js") | $raw %]
425 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
426 [% Asset.js("js/background-job-progressbar.js") | $raw %]
427 [% INCLUDE 'datatables.inc' %]
429 $(document).ready(function() {
430 $("#staged-record-matching-rules select").change(function() {
431 var str = $(this).attr("id");
432 $("#reset_" + str).parent().show();
434 $("a.reset").click(function() {
435 var str = $(this).attr("id");
436 str = str.replace("reset_", "")
437 $("#" + str + " option[selected='selected']").attr("selected", "selected");
438 $(this).parent().hide();
441 [% IF import_batch_id %]
442 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
447 "sAjaxSource": 'batch_records_ajax.pl',
448 "sPaginationType": "full_numbers",
449 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
451 { "mDataProp": "import_record_id" },
452 { "mDataProp": "citation" },
453 { "mDataProp": "status" },
454 { "mDataProp": "overlay_status" },
455 { "mDataProp": "match_citation" },
456 { "mDataProp": "diff_url" },
457 { "mDataProp": "matched" }
459 "fnServerData": function(sSource, aoData, fnCallback) {
460 aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
467 'success': function(json) {
472 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
473 [% IF(record_type == 'auth') %]
474 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
476 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
479 var additional_details = "";
480 if( aData['author'] ){
481 additional_details += " " + aData['author'] + " ";
485 additional_details += " (" + aData['isbn'] + ") ";
489 additional_details += " (" + aData['issn'] + ") ";
492 $('td:eq(1)', nRow).html(
493 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
496 $('td:eq(2)', nRow).html(
497 aData['status'] == 'imported' ? _("Imported") :
498 aData['status'] == 'ignored' ? _("Ignored") :
499 aData['status'] == 'reverted' ? _("Reverted") :
500 aData['status'] == 'staged' ? _("Staged") :
501 aData['status'] == 'error' ? _("Error") :
505 $('td:eq(3)', nRow).html(
506 aData['overlay_status'] == 'no_match' ? _("No match") :
507 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
508 aData['overlay_status'] == 'auto_match' ? _("Match found") :
509 aData['overlay_status']
512 if (aData['match_id']) {
513 [% IF(record_type == 'auth') -%]
514 var matching_msg = _("Matches authority %s (score=%s):%s");
516 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
518 $('td:eq(4)', nRow).html(
519 matching_msg.format(aData['match_id'], aData['score'],
520 '<a target="_blank" href="' + record_details_url
521 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
524 if (aData['diff_url']) {
525 $('td:eq(5)', nRow).html(
526 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
529 $('td:eq(6)', nRow).html(
530 '<a target="_blank" href="' + record_details_url
531 + aData['matched'] + '">' + aData['matched'] + '</a>'
535 $("#import_batch_form").on("submit", function() {
536 return submitBackgroundJob(document.getElementById("import_batch_form"));
538 $("#revert_batch_form").on("submit", function() {
539 return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
543 $("body").on("click", ".previewMARC", function(e) {
545 var ltitle = $(this).text();
546 var page = $(this).attr("href");
547 $("#marcPreviewLabel").text(ltitle);
548 $("#marcPreview .modal-body").load(page + " table");
549 $('#marcPreview').modal({ show: true });
551 $("#marcPreview").on("hidden.bs.modal", function() {
552 $("#marcPreviewLabel").html("");
553 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
555 $(".batch_form").on("submit", function() {
556 if ($(this).hasClass("batch_delete")) {
557 return confirm(_("Are you sure you want to permanently delete this batch?"));
559 return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone."));
566 [% INCLUDE 'intranet-bottom.inc' %]
567 [% BLOCK pagination %]
569 <ul class="pagination">
570 [% FOREACH page IN pages %]
571 [% IF ( page.current_page && page.page_number > 1 ) %]
572 <li><a href="[% page.script_name | url %]?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
573 <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>
576 [% FOREACH page IN pages %]
577 [% IF ( page.current_page ) %]
578 [% SET current_page = page.page_number %]
579 <li class="active"><span class="current">[% page.page_number | html %]</span></li>
581 <li><a class="nav" href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
584 [% IF ( current_page < pages.size() ) %]
586 <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>
589 <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>