3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha › Tools › Manage staged MARC records
5 [% IF ( import_batch_id ) %]
6 › Batch [% import_batch_id %]
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("css/datatables.css") %]
11 <style type="text/css">
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 %]">Manage staged MARC records</a>
24 › Batch [% import_batch_id %]
26 › Manage staged MARC records
30 <div id="doc3" class="yui-t2">
36 <h1>Manage staged MARC records
37 [% IF ( import_batch_id ) %]
38 › Batch [% import_batch_id %]
41 [% IF ( label_batch_msg ) %]
45 <div class="dialog message">
47 <b><p>[% label_batch_msg %]</p></b>
51 [% IF ( did_clean ) %]
52 <div class="dialog message">Cleaned import batch #[% import_batch_id %]</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 ) %]
70 [% IF ( can_commit ) %]
71 <form action="[% script_name %]" method="post">
72 <input type="hidden" name="op" value="redo-matching" />
73 <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
74 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id %]" />
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 %]
86 [% IF ( changed_overlay_action ) %]
87 <div class="dialog message">Changed action if matching record found</div>
89 [% IF ( changed_nomatch_action ) %]
90 <div class="dialog message">Changed action if no match found</div>
92 [% IF ( changed_item_action ) %]
93 <div class="dialog message">Changed item processing option</div>
96 <fieldset class="rows" id="staged-record-matching-rules">
98 <li><span class="label">File name:</span> [% file_name %]</li>
99 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments %][% ELSE %](none)[% END %]</li>
100 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
101 <li><span class="label">Staged:</span> [% upload_timestamp %]</li>
102 <li><span class="label">Status:</span>
103 [% IF ( import_status == 'cleaned' ) %]
105 [% ELSIF ( import_status == 'imported' ) %]
107 [% ELSIF ( import_status == 'importing' ) %]
109 [% ELSIF ( import_status == 'reverted' ) %]
111 [% ELSIF ( import_status == 'reverting' ) %]
113 [% ELSIF ( import_status == 'staged' ) %]
120 [% IF ( can_commit ) %]<label for="new_matcher_id">Matching rule applied:</label><select name="new_matcher_id" id="new_matcher_id">
121 <option value="">Do not look for matching records</option>
122 [% FOREACH available_matcher IN available_matchers %]
123 [% IF ( available_matcher.selected ) %]
124 <option value="[% available_matcher.matcher_id %]" selected="selected">
125 [% available_matcher.code %] ([% available_matcher.description %])
128 <option value="[% available_matcher.matcher_id %]">
129 [% available_matcher.code %] ([% available_matcher.description %])
133 </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 ) %]
134 [% current_matcher_code %] ([% current_matcher_description %])
136 No matching rule in effect
140 [% IF ( can_commit ) %]
141 <label for="overlay_action">Action if matching record found:</label>
142 [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
144 <span class="label">Action if matching record found:</span>
145 [% IF ( overlay_action == 'replace' ) %]
146 Replace existing record with incoming record
147 [% ELSIF ( overlay_action == 'create_new' ) %]
149 [% ELSIF ( overlay_action == 'ignore' ) %]
150 Ignore incoming record (its items may still be processed)
157 [% IF ( can_commit ) %]
158 <label for="nomatch_action">Action if no match found:</label>
159 [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
161 <span class="label">Action if no match found:</span>
162 [% IF ( nomatch_action == 'create_new' ) %]
164 [% ELSIF ( nomatch_action == 'ignore' ) %]
165 Ignore incoming record (its items may still be processed)
172 [% IF ( record_type == 'biblio' ) %]
174 [% IF ( can_commit ) %]
175 <label for="item_action">Item processing:</label>
176 [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
178 <span class="label">Item processing:</span>
179 [% IF ( item_action == 'always_add' ) %]
181 [% ELSIF ( item_action == 'add_only_for_matches' ) %]
182 Add items only if matching bib was found
183 [% ELSIF ( item_action == 'add_only_for_new' ) %]
184 Add items only if no matching bib was found
185 [% ELSIF ( item_action == 'ignore' ) %]
194 [% IF ( can_commit ) %]<fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset></form>[% END %]
199 [% IF ( can_commit ) %]
200 <form action="[% script_name %]" method="post" id="import_batch_form">
201 <input type="hidden" name="op" value="commit-batch" />
202 <input type="hidden" name="runinbackground" value="" />
203 <input type="hidden" name="completedJobID" value="" />
204 <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
205 <fieldset class="action">
206 [% IF ( record_type != 'auth' ) %]
207 Add new bibliographic records into this framework:
208 <select name="framework" id="frameworks">
209 <option value="">Default</option>
210 [% FOREACH framework IN frameworks %]
211 <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
216 <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
219 <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
220 <div id="jobfailed"></div></div>
222 [% IF ( can_revert ) %]
223 <form action="[% script_name %]" method="post" id="revert_batch_form">
224 <input type="hidden" name="op" value="revert-batch" />
225 <input type="hidden" name="runinbackground" value="" />
226 <input type="hidden" name="completedJobID" value="" />
227 <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
228 <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
230 <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
231 <div id="jobfailed"></div></div>
234 [% IF ( did_commit ) %]
235 <div class="dialog message">Completed import of records</div>
237 <tr><td>Number of records added</td><td>[% num_added %]</td></tr>
238 <tr><td>Number of records updated</td><td>[% num_updated %]</td></tr>
239 <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
240 [% IF ( record_type == 'biblio' ) %]
241 <tr><td>Number of items added</td><td>[% num_items_added %]</td></tr>
242 <tr><td>Number of items replaced</td><td>[% num_items_replaced %]</td></tr>
243 <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored %]</td></tr>
247 [% IF ( did_revert ) %]
248 <div class="dialog message">Success: Import reversed</div>
250 <tr><td>Number of records deleted</td><td>[% num_deleted %]</td></tr>
251 [% IF ( record_type == 'biblio' ) %]
252 <tr><td>Number of items deleted</td><td>[% num_items_deleted %]</td></tr>
253 <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors %]</td></tr>
255 <tr><td>Number of records changed back</td><td>[% num_reverted %]</td></tr>
256 <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
260 <br style="clear:both;" />
262 [% IF ( batch_list ) %]
265 [% FOREACH page IN pages %]
266 [% IF ( page.current_page ) %]
267 <span class="current">[% page.page_number %]</span>
269 <a href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
286 [% FOREACH batch_lis IN batch_list %]
288 <td>[% batch_lis.import_batch_id %]</td>
289 <td><a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]">[% batch_lis.file_name %]</a></td>
290 <td>[% batch_lis.comments %]</td>
291 <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
293 [% IF ( batch_lis.import_status == 'cleaned' ) %]
295 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
297 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
299 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
301 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
303 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
306 [% batch_lis.import_status %]
309 <td>[% batch_lis.upload_timestamp %]</td>
310 <td>[% batch_lis.num_records %]</td>
311 <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&op=create_labels">(Create label batch)</a>[% END %]</td>
313 [% IF ( batch_lis.can_clean ) %]
314 <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" class="batch_form batch_clean" >
315 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
316 <input type="hidden" name="op" value="clean-batch" />
317 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
319 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
320 <form method="post" action="/cgi-bin/koha/tools/manage-marc-import.pl" name="delete_batch_[% batch_lis.import_batch_id %]" id="delete_batch_[% batch_lis.import_batch_id %]" class="batch_form batch_delete">
321 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
322 <input type="hidden" name="op" value="delete-batch" />
323 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
332 [% FOREACH page IN pages %]
333 [% IF ( page.current_page ) %]
334 <span class="current">[% page.page_number %]</span>
336 <a href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
343 [% IF import_batch_id %]
344 <table id="records-table">
351 <th>Match details</th>
352 <th><abbr title="Differences between the original biblio and the imported">Diff</abbr></th>
358 <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
359 <div class="modal-dialog">
360 <div class="modal-content">
361 <div class="modal-header">
362 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
363 <h3 id="marcPreviewLabel">MARC preview</h3>
365 <div class="modal-body">
366 <div id="loading"> <img src="[% interface %]/[% theme %]/img/spinner-small.gif" alt="" /> Loading </div>
368 <div class="modal-footer">
369 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
379 [% INCLUDE 'tools-menu.inc' %]
383 [% MACRO jsinclude BLOCK %]
384 [% Asset.js("js/tools-menu.js") %]
385 [% Asset.js("js/background-job-progressbar.js") %]
386 [% INCLUDE 'datatables.inc' %]
387 <script type="text/javascript">
388 $(document).ready(function(){
389 $("#staged-record-matching-rules select").change(function(){
390 var str = $(this).attr("id");
391 $("#reset_"+str).parent().show();
393 $("a.reset").click(function(){
394 var str = $(this).attr("id");
395 str = str.replace("reset_","")
396 $("#"+str+" option[selected='selected']").attr("selected","selected");
397 $(this).parent().hide();
400 [% IF import_batch_id %]
401 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
406 "sAjaxSource": 'batch_records_ajax.pl',
407 "sPaginationType": "full_numbers",
408 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
410 { "mDataProp": "import_record_id" },
411 { "mDataProp": "citation" },
412 { "mDataProp": "status" },
413 { "mDataProp": "overlay_status" },
414 { "mDataProp": "match_citation" },
415 { "mDataProp": "diff_url" },
416 { "mDataProp": "matched" }
418 "fnServerData": function ( sSource, aoData, fnCallback ) {
419 aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
426 'success': function(json){
431 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
432 [% IF ( record_type == 'auth' ) %]
433 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
435 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
438 $('td:eq(1)', nRow).html(
439 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
442 $('td:eq(2)', nRow).html(
443 aData['status'] == 'imported' ? _("Imported") :
444 aData['status'] == 'ignored' ? _("Ignored") :
445 aData['status'] == 'reverted' ? _("Reverted") :
446 aData['status'] == 'staged' ? _("Staged") :
447 aData['status'] == 'error' ? _("Error") :
451 $('td:eq(3)', nRow).html(
452 aData['overlay_status'] == 'no_match' ? _("No match") :
453 aData['overlay_status'] == 'match_applied' ? _("Match applied") :
454 aData['overlay_status'] == 'auto_match' ? _("Match found") :
455 aData['overlay_status']
458 if ( aData['match_id'] ) {
459 [% IF ( record_type == 'auth' ) -%]
460 var matching_msg = _("Matches authority %s (score=%s):%s");
462 var matching_msg = _("Matches biblio %s (score=%s):%s");
464 $('td:eq(4)', nRow).html(
465 matching_msg.format(aData['match_id'], aData['score'],
466 '<a target="_blank" href="' + record_details_url
467 + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
470 if (aData['diff_url']){
471 $('td:eq(5)', nRow).html(
472 '<a href="'+aData['diff_url']+'">' + _("View") + '</a>'
475 $('td:eq(6)', nRow).html(
476 '<a target="_blank" href="' + record_details_url
477 + aData['matched'] + '">' + aData['matched'] + '</a>'
481 $("#import_batch_form").on("submit",function(){
482 return submitBackgroundJob( document.getElementById("import_batch_form") );
484 $("#revert_batch_form").on("submit",function(){
485 return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) && submitBackgroundJob( document.getElementById("revert_batch_form") );
488 $("body").on("click",".previewMARC", function(e){
490 var ltitle = $(this).text();
491 var page = $(this).attr("href");
492 $("#marcPreviewLabel").text(ltitle);
493 $("#marcPreview .modal-body").load(page + " table");
494 $('#marcPreview').modal({show:true});
496 $("#marcPreview").on("hidden", function(){
497 $("#marcPreviewLabel").html("");
498 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
500 $(".batch_form").on("submit",function(){
501 if( $(this).hasClass("batch_delete") ){
502 return confirm( _("Are you sure you want to permanently delete this batch?") );
504 return confirm( _("Clear all reservoir records staged in this batch? This cannot be undone.") );
511 [% INCLUDE 'intranet-bottom.inc' %]