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