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