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; }
16 <body id="tools_manage-marc-import" class="tools">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'cat-search.inc' %]
20 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
21 [% IF ( import_batch_id ) %]
23 <a href="[% script_name | url %]">Manage staged MARC records</a>
24 › Batch [% import_batch_id | html %]
26 › Manage staged MARC records
30 <div class="main container-fluid">
32 <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 %]
40 [% IF ( label_batch_msg ) %]
44 <div class="dialog message">
46 <b><p>[% label_batch_msg | html %]</p></b>
50 [% IF ( did_clean ) %]
51 <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
54 [% IF ( did_delete ) %]
55 <div class="dialog message">Import batch deleted successfully</div>
58 [% UNLESS ( batch_list ) %]
59 [% UNLESS ( batch_info ) %]
60 <div class="dialog message">
61 <p>No records have been staged.</p>
62 <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
67 [% 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 %]
85 [% IF ( changed_overlay_action ) %]
86 <div class="dialog message">Changed action if matching record found</div>
88 [% IF ( changed_nomatch_action ) %]
89 <div class="dialog message">Changed action if no match found</div>
91 [% IF ( changed_item_action ) %]
92 <div class="dialog message">Changed item processing option</div>
95 <fieldset class="rows" id="staged-record-matching-rules">
97 <li><span class="label">File name:</span> [% file_name | html %]</li>
98 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
99 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
100 <li><span class="label">Staged:</span> [% upload_timestamp | html %]</li>
101 <li><span class="label">Status:</span>
102 [% IF ( import_status == 'cleaned' ) %]
104 [% ELSIF ( import_status == 'imported' ) %]
106 [% ELSIF ( import_status == 'importing' ) %]
108 [% ELSIF ( import_status == 'reverted' ) %]
110 [% ELSIF ( import_status == 'reverting' ) %]
112 [% ELSIF ( import_status == 'staged' ) %]
115 [% import_status | html %]
119 [% IF ( can_commit ) %]<label for="new_matcher_id">Matching rule applied:</label><select name="new_matcher_id" id="new_matcher_id">
120 <option value="">Do not look for matching records</option>
121 [% FOREACH available_matcher IN available_matchers %]
122 [% IF ( available_matcher.selected ) %]
123 <option value="[% available_matcher.matcher_id | html %]" selected="selected">
124 [% available_matcher.code | html %] ([% available_matcher.description | html %])
127 <option value="[% available_matcher.matcher_id | html %]">
128 [% available_matcher.code | html %] ([% available_matcher.description | html %])
132 </select> <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>[% ELSE %]<span class="label">Matching rule applied</span>[% IF ( current_matcher_id ) %]
133 [% current_matcher_code | html %] ([% current_matcher_description | html %])
135 No matching rule in effect
139 [% IF ( can_commit ) %]
140 <label for="overlay_action">Action if matching record found:</label>
141 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
143 <span class="label">Action if matching record found:</span>
144 [% IF ( overlay_action == 'replace' ) %]
145 Replace existing record with incoming record
146 [% ELSIF ( overlay_action == 'create_new' ) %]
148 [% ELSIF ( overlay_action == 'ignore' ) %]
149 Ignore incoming record (its items may still be processed)
151 [% overlay_action | html %]
156 [% IF ( can_commit ) %]
157 <label for="nomatch_action">Action if no match found:</label>
158 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
160 <span class="label">Action if no match found:</span>
161 [% IF ( nomatch_action == 'create_new' ) %]
163 [% ELSIF ( nomatch_action == 'ignore' ) %]
164 Ignore incoming record (its items may still be processed)
166 [% nomatch_action | html %]
171 [% IF ( record_type == 'biblio' ) %]
173 [% IF ( can_commit ) %]
174 <label for="item_action">Item processing:</label>
175 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
177 <span class="label">Item processing:</span>
178 [% IF ( item_action == 'always_add' ) %]
180 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
181 Add items only if matching bib was found
182 [% ELSIF ( item_action == 'add_only_for_new' ) %]
183 Add items only if no matching bib was found
184 [% ELSIF ( item_action == 'ignore' ) %]
187 [% item_action | html %]
193 [% IF ( can_commit ) %]<fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset></form>[% END %]
198 [% IF ( can_commit ) %]
199 <form action="[% script_name | html %]" method="post" id="import_batch_form">
200 <input type="hidden" name="op" value="commit-batch" />
201 <input type="hidden" name="runinbackground" value="" />
202 <input type="hidden" name="completedJobID" value="" />
203 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
204 <fieldset class="action">
205 [% IF ( record_type != 'auth' ) %]
206 Add new bibliographic records into this framework:
207 <select name="framework" id="frameworks">
208 <option value="">Default</option>
209 [% FOREACH framework IN frameworks %]
210 <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
215 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
218 <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
219 <div id="jobfailed"></div></div>
221 [% IF ( can_revert ) %]
222 <form action="[% script_name | html %]" method="post" id="revert_batch_form">
223 <input type="hidden" name="op" value="revert-batch" />
224 <input type="hidden" name="runinbackground" value="" />
225 <input type="hidden" name="completedJobID" value="" />
226 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
227 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
229 <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
230 <div id="jobfailed"></div></div>
233 [% IF ( did_commit ) %]
234 <div class="dialog message">Completed import of records</div>
236 <tr><td>Number of records added</td><td>[% num_added | html %]</td></tr>
237 <tr><td>Number of records updated</td><td>[% num_updated | html %]</td></tr>
238 <tr><td>Number of records ignored</td><td>[% num_ignored | html %]</td></tr>
239 [% IF ( record_type == 'biblio' ) %]
240 <tr><td>Number of items added</td><td>[% num_items_added | html %]</td></tr>
241 <tr><td>Number of items replaced</td><td>[% num_items_replaced | html %]</td></tr>
242 <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored | html %]</td></tr>
246 [% IF ( did_revert ) %]
247 <div class="dialog message">Success: Import reversed</div>
249 <tr><td>Number of records deleted</td><td>[% num_deleted | html %]</td></tr>
250 [% IF ( record_type == 'biblio' ) %]
251 <tr><td>Number of items deleted</td><td>[% num_items_deleted | html %]</td></tr>
252 <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors | html %]</td></tr>
254 <tr><td>Number of records changed back</td><td>[% num_reverted | html %]</td></tr>
255 <tr><td>Number of records ignored</td><td>[% num_ignored | html %]</td></tr>
259 <br style="clear:both;" />
261 [% IF ( batch_list ) %]
264 [% FOREACH page IN pages %]
265 [% IF ( page.current_page ) %]
266 <span class="current">[% page.page_number | html %]</span>
268 <a href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a>
285 [% FOREACH batch_lis IN batch_list %]
287 <td>[% batch_lis.import_batch_id | html %]</td>
288 <td><a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
289 <td>[% batch_lis.comments | html %]</td>
290 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
292 [% IF ( batch_lis.import_status == 'cleaned' ) %]
294 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
296 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
298 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
300 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
302 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
305 [% batch_lis.import_status | html %]
308 <td>[% batch_lis.upload_timestamp | html %]</td>
309 <td>[% batch_lis.num_records | html %]</td>
310 <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>
312 [% IF ( batch_lis.can_clean ) %]
313 <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" >
314 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
315 <input type="hidden" name="op" value="clean-batch" />
316 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
318 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
319 <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">
320 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
321 <input type="hidden" name="op" value="delete-batch" />
322 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
331 [% FOREACH page IN pages %]
332 [% IF ( page.current_page ) %]
333 <span class="current">[% page.page_number | html %]</span>
335 <a href="[% page.script_name | url %]?offset=[% page.offset | uri %]">[% page.page_number | html %]</a>
342 [% IF import_batch_id %]
343 <table id="records-table">
350 <th>Match details</th>
351 <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
357 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
358 <div class="modal-dialog">
359 <div class="modal-content">
360 <div class="modal-header">
361 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
362 <h3 id="marcPreviewLabel">MARC preview</h3>
364 <div class="modal-body">
365 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
367 <div class="modal-footer">
368 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
376 </div> <!-- /.col-sm-10.col-sm-push-2 -->
378 <div class="col-sm-2 col-sm-pull-10">
380 [% INCLUDE 'tools-menu.inc' %]
382 </div> <!-- .col-sm-2.col-sm-pull-10 -->
383 </div> <!-- /.row -->
385 [% MACRO jsinclude BLOCK %]
386 [% Asset.js("js/tools-menu.js") | $raw %]
387 [% Asset.js("js/background-job-progressbar.js") | $raw %]
388 [% INCLUDE 'datatables.inc' %]
390 $(document).ready(function(){
391 $("#staged-record-matching-rules select").change(function(){
392 var str = $(this).attr("id");
393 $("#reset_"+str).parent().show();
395 $("a.reset").click(function(){
396 var str = $(this).attr("id");
397 str = str.replace("reset_","")
398 $("#"+str+" option[selected='selected']").attr("selected","selected");
399 $(this).parent().hide();
402 [% IF import_batch_id %]
403 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
408 "sAjaxSource": 'batch_records_ajax.pl',
409 "sPaginationType": "full_numbers",
410 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
412 { "mDataProp": "import_record_id" },
413 { "mDataProp": "citation" },
414 { "mDataProp": "status" },
415 { "mDataProp": "overlay_status" },
416 { "mDataProp": "match_citation" },
417 { "mDataProp": "diff_url" },
418 { "mDataProp": "matched" }
420 "fnServerData": function ( sSource, aoData, fnCallback ) {
421 aoData.push( { "name": "import_batch_id", "value": [% import_batch_id | html %] } );
428 'success': function(json){
433 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
434 [% IF ( record_type == 'auth' ) %]
435 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
437 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
440 $('td:eq(1)', nRow).html(
441 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
444 $('td:eq(2)', nRow).html(
445 aData['status'] == 'imported' ? _("Imported") :
446 aData['status'] == 'ignored' ? _("Ignored") :
447 aData['status'] == 'reverted' ? _("Reverted") :
448 aData['status'] == 'staged' ? _("Staged") :
449 aData['status'] == 'error' ? _("Error") :
453 $('td:eq(3)', nRow).html(
454 aData['overlay_status'] == 'no_match' ? _("No match") :
455 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
456 aData['overlay_status'] == 'auto_match' ? _("Match found") :
457 aData['overlay_status']
460 if ( aData['match_id'] ) {
461 [% IF ( record_type == 'auth' ) -%]
462 var matching_msg = _("Matches authority %s (score=%s):%s");
464 var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
466 $('td:eq(4)', nRow).html(
467 matching_msg.format(aData['match_id'], aData['score'],
468 '<a target="_blank" href="' + record_details_url
469 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
472 if (aData['diff_url']){
473 $('td:eq(5)', nRow).html(
474 '<a href="'+aData['diff_url']+'">' + _("View") + '</a>'
477 $('td:eq(6)', nRow).html(
478 '<a target="_blank" href="' + record_details_url
479 + aData['matched'] + '">' + aData['matched'] + '</a>'
483 $("#import_batch_form").on("submit",function(){
484 return submitBackgroundJob( document.getElementById("import_batch_form") );
486 $("#revert_batch_form").on("submit",function(){
487 return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) && submitBackgroundJob( document.getElementById("revert_batch_form") );
490 $("body").on("click",".previewMARC", function(e){
492 var ltitle = $(this).text();
493 var page = $(this).attr("href");
494 $("#marcPreviewLabel").text(ltitle);
495 $("#marcPreview .modal-body").load(page + " table");
496 $('#marcPreview').modal({show:true});
498 $("#marcPreview").on("hidden.bs.modal", function(){
499 $("#marcPreviewLabel").html("");
500 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
502 $(".batch_form").on("submit",function(){
503 if( $(this).hasClass("batch_delete") ){
504 return confirm( _("Are you sure you want to permanently delete this batch?") );
506 return confirm( _("Clear all reservoir records staged in this batch? This cannot be undone.") );
513 [% INCLUDE 'intranet-bottom.inc' %]