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