Bug 18063: Remove dead code from tools/manage-marc-import.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / manage-marc-import.tt
blob2f0d0834fba0a0f59d398cd4d3646f3728794499
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
3 [% IF ( import_batch_id ) %]
4  &rsaquo; Batch [% import_batch_id %]
5 [% END %]
6 </title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
9 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
10 [% INCLUDE 'datatables.inc' %]
11 <script type="text/javascript">
12 //<![CDATA[
13 $(document).ready(function(){
14   $("#staged-record-matching-rules select").change(function(){
15       var str = $(this).attr("id");
16       $("#reset_"+str).parent().show();
17   });
18   $("a.reset").click(function(){
19       var str = $(this).attr("id");
20       str = str.replace("reset_","")
21       $("#"+str+" option[selected='selected']").attr("selected","selected");
22       $(this).parent().hide();
23   });
25   [% IF import_batch_id %]
26       $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
27           "bAutoWidth": false,
28           "bFilter": false,
29           "bProcessing": true,
30           "bServerSide": true,
31           "sAjaxSource": 'batch_records_ajax.pl',
32           "sPaginationType": "full_numbers",
33           "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
34           "aoColumns": [
35               { "mDataProp": "import_record_id" },
36               { "mDataProp": "citation" },
37               { "mDataProp": "status" },
38               { "mDataProp": "overlay_status" },
39               { "mDataProp": "match_citation" },
40               { "mDataProp": "diff_url" },
41               { "mDataProp": "matched" }
42           ],
43           "fnServerData": function ( sSource, aoData, fnCallback ) {
44               aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
46               $.ajax({
47                   'dataType': 'json',
48                   'type': 'POST',
49                   'url': sSource,
50                   'data': aoData,
51                   'success': function(json){
52                       fnCallback(json);
53                   }
54               });
55           },
56           "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
57             [% IF ( record_type == 'auth' ) %]
58                 var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
59             [% ELSE %]
60                 var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
61             [% END %]
63             $('td:eq(1)', nRow).html(
64                 '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
65             );
67             $('td:eq(2)', nRow).html(
68                 aData['status'] == 'imported' ? _("Imported") :
69                 aData['status'] == 'ignored'  ? _("Ignored")  :
70                 aData['status'] == 'reverted' ? _("Reverted") :
71                 aData['status'] == 'staged'   ? _("Staged")   :
72                 aData['status'] == 'error'    ? _("Error")    :
73                 aData['status']
74             );
76             $('td:eq(3)', nRow).html(
77                 aData['overlay_status'] == 'no_match'      ? _("No match")       :
78                 aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
79                 aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
80                 aData['overlay_status']
81             );
83             if ( aData['match_id'] ) {
84                 [% IF ( record_type == 'auth' ) -%]
85                 var matching_msg = _("Matches authority %s (score=%s):%s");
86                 [%- ELSE -%]
87                 var matching_msg = _("Matches biblio %s (score=%s):%s");
88                 [%- END %]
89                 $('td:eq(4)', nRow).html(
90                     matching_msg.format(aData['match_id'], aData['score'],
91                     '<a target="_blank" href="' + record_details_url
92                     + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
93                 );
94             }
95             if (aData['diff_url']){
96                 $('td:eq(5)', nRow).html(
97                     '<a href="'+aData['diff_url']+'">View</a>'
98                 );
99             }
100             $('td:eq(6)', nRow).html(
101                 '<a target="_blank" href="' + record_details_url
102                     + aData['matched'] + '">' + aData['matched'] + '</a>'
103             );
104           },
105       }));
106         $("#import_batch_form").on("submit",function(){
107             return submitBackgroundJob( document.getElementById("import_batch_form") );
108         });
109         $("#revert_batch_form").on("submit",function(){
110             return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) &&   submitBackgroundJob( document.getElementById("revert_batch_form") );
111         });
112     [% END %]
113     $("body").on("click",".previewMARC", function(e){
114         e.preventDefault();
115         var ltitle = $(this).text();
116         var page = $(this).attr("href");
117         $("#marcPreviewLabel").text(ltitle);
118         $("#marcPreview .modal-body").load(page + " table");
119         $('#marcPreview').modal({show:true});
120     });
121     $("#marcPreview").on("hidden", function(){
122         $("#marcPreviewLabel").html("");
123         $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
124     });
125     $(".batch_form").on("submit",function(){
126         if( $(this).hasClass("batch_delete") ){
127             return confirm( _("Are you sure you want to permanently delete this batch?") );
128         } else {
129             return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
130         }
131     });
134 //]]>
135 </script>
136 <style type="text/css">
137     #jobpanel,#jobstatus,#jobfailed { display : none; }
138 </style>
139 </head>
140 <body id="tools_manage-marc-import" class="tools">
141 [% INCLUDE 'header.inc' %]
142 [% INCLUDE 'cat-search.inc' %]
144 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> 
145 [% IF ( import_batch_id ) %]
146  &rsaquo;
147  <a href="[% script_name %]">Manage staged MARC records</a>
148  &rsaquo; Batch [% import_batch_id %]
149 [% ELSE %]
150  &rsaquo; Manage staged MARC records
151 [% END %]
152 </div>
154 <div id="doc3" class="yui-t2">
155    
156    <div id="bd">
157         <div id="yui-main">
158         <div class="yui-b">
160 <h1>Manage staged MARC records
161 [% IF ( import_batch_id ) %]
162  &rsaquo; Batch [% import_batch_id %]
163 [% END %]
164 </h1>
165 [% IF ( label_batch_msg ) %]
166 [% IF ( alert ) %]
167 <div class="alert">
168 [% ELSE %]
169 <div class="dialog message">
170 [% END %]
171 <b><p>[% label_batch_msg %]</p></b>
172 </div>
173 [% END %]
175 [% IF ( did_clean ) %]
176   <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div>
177 [% END %]
179 [% IF ( did_delete ) %]
180   <div class="dialog message">Import batch deleted successfully</div>
181 [% END %]
183 [% UNLESS ( batch_list ) %]
184    [% UNLESS ( batch_info ) %]
185    <div class="dialog message">
186      <p>No records have been staged.</p>
187      <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
188    </div>
189    [% END %]
190 [% END %]
192 [% IF ( batch_info ) %]
194 [% IF ( can_commit ) %]
195 <form action="[% script_name %]" method="post">
196 <input type="hidden" name="op" value="redo-matching" />
197 <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
198 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id %]" />
199 [% END %]
201   [% IF ( rematch_attempted ) %]
202     [% IF ( rematch_failed ) %]
203       <div class="dialog alert">Failed to apply different matching rule</div>
204     [% ELSE %]
205       <div class="dialog message">Applied different matching rule.  Number of records matched now
206        [% num_with_matches %]
207       </div>
208     [% END %]
209   [% END %]
210   [% IF ( changed_overlay_action ) %]
211       <div class="dialog message">Changed action if matching record found</div>
212   [% END %]
213   [% IF ( changed_nomatch_action ) %]
214       <div class="dialog message">Changed action if no match found</div>
215   [% END %]
216   [% IF ( changed_item_action ) %]
217       <div class="dialog message">Changed item processing option</div>
218   [% END %]
220 <fieldset class="rows" id="staged-record-matching-rules">
221   <ol>
222     <li><span class="label">File name:</span> [% file_name %]</li>
223     <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments %][% ELSE %](none)[% END %]</li>
224     <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
225     <li><span class="label">Staged:</span> [% upload_timestamp %]</li>
226     <li><span class="label">Status:</span>
227       [% IF ( import_status == 'cleaned' ) %]
228          Cleaned
229       [% ELSIF ( import_status == 'imported' ) %]
230         Imported
231       [% ELSIF ( import_status == 'importing' ) %]
232         Importing
233       [% ELSIF ( import_status == 'reverted' ) %]
234          Reverted
235       [% ELSIF ( import_status == 'reverting' ) %]
236          Reverting
237       [% ELSIF ( import_status == 'staged' ) %]
238           Staged
239       [% ELSE %]
240           [% import_status %]
241       [% END %]
242       </li>
243     <li>
244 [% IF ( can_commit ) %]<label for="new_matcher_id">Matching rule applied:</label><select name="new_matcher_id" id="new_matcher_id">
245        <option value="">Do not look for matching records</option> 
246        [% FOREACH available_matcher IN available_matchers %]
247           [% IF ( available_matcher.selected ) %]
248           <option value="[% available_matcher.matcher_id %]" selected="selected">
249              [% available_matcher.code %] ([% available_matcher.description %])
250           </option>
251           [% ELSE %]
252           <option value="[% available_matcher.matcher_id %]">
253             [% available_matcher.code %] ([% available_matcher.description %])
254           </option>
255           [% END %]
256        [% END %]
257     </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 ) %]
258   [% current_matcher_code %] ([% current_matcher_description %])
259 [% ELSE %]
260   No matching rule in effect
261 [% END %][% END %]
262     </li>
263     <li>
264         [% IF ( can_commit ) %]
265             <label for="overlay_action">Action if matching record found:</label>
266             [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
267         [% ELSE %]
268             <span class="label">Action if matching record found:</span>
269             [% IF ( overlay_action == 'replace' ) %]
270                 Replace existing record with incoming record
271             [% ELSIF ( overlay_action == 'create_new' ) %]
272                 Add incoming record
273             [% ELSIF ( overlay_action == 'ignore' ) %]
274                 Ignore incoming record (its items may still be processed)
275             [% ELSE %]
276                 [% overlay_action %]
277             [% END %]
278         [% END %]</li>
279      
280     <li>
281         [% IF ( can_commit ) %]
282             <label for="nomatch_action">Action if no match found:</label>
283             [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
284         [% ELSE %]
285             <span class="label">Action if no match found:</span>
286             [% IF ( nomatch_action == 'create_new' ) %]
287                 Add incoming record
288             [% ELSIF ( nomatch_action == 'ignore' ) %]
289                 Ignore incoming record (its items may still be processed)
290             [% ELSE %]
291                 [% nomatch_action %]
292             [% END %]
293         [% END %]
294     </li>
296     [% IF ( record_type == 'biblio' ) %]
297     <li>
298         [% IF ( can_commit ) %]
299             <label for="item_action">Item processing:</label>
300             [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
301         [% ELSE %]
302             <span class="label">Item processing:</span>
303             [% IF ( item_action == 'always_add' ) %]
304                 Always add items
305             [% ELSIF ( item_action == 'add_only_for_matches' ) %]
306                 Add items only if matching bib was found
307             [% ELSIF ( item_action == 'add_only_for_new' ) %]
308                 Add items only if no matching bib was found
309             [% ELSIF ( item_action == 'ignore' ) %]
310                 Ignore items
311             [% ELSE %]
312                 [% item_action %]
313             [% END %]
314         [% END %]
315     </li>
316     [% END %]
317   </ol>
318 [% IF ( can_commit ) %]<fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset></form>[% END %]
319 </fieldset>
322 <div>
323   [% IF ( can_commit ) %]
324   <form action="[% script_name %]" method="post" id="import_batch_form">
325     <input type="hidden" name="op" value="commit-batch" />
326     <input type="hidden" name="runinbackground" value="" />
327     <input type="hidden" name="completedJobID" value="" />
328     <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
329     <fieldset class="action">
330     <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
331     <br/>
332     [% IF ( record_type != 'auth' ) %]
333     Add new bibliographic records into this framework:
334     <select name="framework" id="frameworks">
335       <option value="">Default</option>
336       [% FOREACH framework IN frameworks %]
337           <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
338       [% END %]
339     </select>
340     [% END %]
341     </fieldset>
342   </form>
343   <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
344      <div id="jobfailed"></div></div>
345   [% END %]
346   [% IF ( can_revert ) %]
347   <form action="[% script_name %]" method="post" id="revert_batch_form">
348     <input type="hidden" name="op" value="revert-batch" />
349     <input type="hidden" name="runinbackground" value="" />
350     <input type="hidden" name="completedJobID" value="" />
351     <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
352     <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
353   </form>
354   <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
355      <div id="jobfailed"></div></div>
356   [% END %]
357 </div>
358   [% IF ( did_commit ) %]
359   <div class="dialog message">Completed import of records</div>
360   <table>
361   <tr><td>Number of records added</td><td>[% num_added %]</td></tr>
362   <tr><td>Number of records updated</td><td>[% num_updated %]</td></tr>
363   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
364   [% IF ( record_type == 'biblio' ) %]
365       <tr><td>Number of items added</td><td>[% num_items_added %]</td></tr>
366       <tr><td>Number of items replaced</td><td>[% num_items_replaced %]</td></tr>
367       <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored %]</td></tr>
368   [% END %]
369   </table>
370   [% END %]
371   [% IF ( did_revert ) %]
372   <div class="dialog message">Success: Import reversed</div>
373   <table>
374   <tr><td>Number of records deleted</td><td>[% num_deleted %]</td></tr>
375   [% IF ( record_type == 'biblio' ) %]
376     <tr><td>Number of items deleted</td><td>[% num_items_deleted %]</td></tr>
377     <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors %]</td></tr>
378   [% END %]
379   <tr><td>Number of records changed back</td><td>[% num_reverted %]</td></tr>
380   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
381   </table>
382   [% END %]
383 [% END %]
384 <br style="clear:both;" />
386 [% IF ( batch_list ) %]
387   [% IF ( pages ) %]
388 <div class="pages">
389 Page 
390     [% FOREACH page IN pages %]
391       [% IF ( page.current_page ) %]
392       <span class="current">[% page.page_number %]</span>
393       [% ELSE %]
394       <a class="nav" href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
395       [% END %]
396     [% END %]
397 </div>
398   [% END %]
399 <table>
400   <tr>
401     <th>#</th>
402     <th>File name</th>
403     <th>Comments</th>
404     <th>Type</th>
405     <th>Status</th>
406     <th>Staged</th>
407     <th># Records</th>
408     <th># Items</th>
409     <th>Action</th>
410   </tr>
411   [% FOREACH batch_lis IN batch_list %]
412     <tr>
413     <td>[% batch_lis.import_batch_id %]</td>
414     <td><a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]">[% batch_lis.file_name %]</a></td>
415     <td>[% batch_lis.comments %]</td>
416     <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
417     <td>
418       [% IF ( batch_lis.import_status == 'cleaned' ) %]
419          Cleaned
420       [% ELSIF ( batch_lis.import_status == 'imported' ) %]
421         Imported
422       [% ELSIF ( batch_lis.import_status == 'importing' ) %]
423         Importing
424       [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
425          Reverted
426       [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
427          Reverting
428       [% ELSIF ( batch_lis.import_status == 'staged' ) %]
429           Staged
430       [% ELSE %]
431           [% batch_lis.import_status %]
432       [% END %]
433     </td>
434     <td>[% batch_lis.upload_timestamp %]</td>
435     <td>[% batch_lis.num_records %]</td>
436     <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;op=create_labels">(Create label batch)</a>[% END %]</td>
437     <td class="actions">
438         [% IF ( batch_lis.can_clean ) %]
439           <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" >
440             <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
441             <input type="hidden" name="op" value="clean-batch" />
442             <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
443           </form>
444         [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
445           <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">
446             <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
447             <input type="hidden" name="op" value="delete-batch" />
448             <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
449           </form>
450         [% END %]
451     </td>
452   </tr>
453   [% END %]
454 </table>
455   [% IF ( pages ) %]
456 <div class="pages">
457 Page 
458     [% FOREACH page IN pages %]
459       [% IF ( page.current_page ) %]
460       <span class="current">[% page.page_number %]</span>
461       [% ELSE %]
462       <a class="nav" href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
463       [% END %]
464     [% END %]
465 </div>
466   [% END %]
467 [% END %]
469 [% IF import_batch_id %]
470     <table id="records-table">
471         <thead>
472             <tr>
473                 <th>#</th>
474                 <th>Citation</th>
475                 <th>Status</th>
476                 <th>Match type</th>
477                 <th>Match details</th>
478                 <th><abbr title="Differences between the original biblio and the imported" lang="en">Diff</abbr></th>
479                 <th>Record</th>
480             </tr>
481         </thead>
482     </table>
484     <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
485         <div class="modal-dialog">
486         <div class="modal-content">
487         <div class="modal-header">
488             <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
489             <h3 id="marcPreviewLabel">MARC preview</h3>
490         </div>
491         <div class="modal-body">
492             <div id="loading"> <img src="[% interface %]/[% theme %]/img/spinner-small.gif" alt="" /> Loading </div>
493         </div>
494         <div class="modal-footer">
495             <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
496         </div>
497         </div>
498         </div>
499     </div>
500 [% END %]
502 </div>
503 </div>
504 <div class="yui-b">
505 [% INCLUDE 'tools-menu.inc' %]
506 </div>
507 </div>
508 [% INCLUDE 'intranet-bottom.inc' %]