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