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