0098751f5e9c5dd0da7e66018b4314ce1b016650
[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                     [% IF ( record_type == 'auth' ) -%]
92                     _("Matches authority ")
93                     [%- ELSE -%]
94                     _("Matches biblio ")
95                     [%- END %]
96                     + aData['match_id']
97                     + " (" + _("score") + "="
98                     + aData['score']
99                     + '):' + '<a target="_blank" href="' + record_details_url
100                     + aData['match_id'] + '">' + aData['match_citation'] + '</a>'
101                 );
102             }
103
104             $('td:eq(5)', nRow).html(
105                 '<a target="_blank" href="' + record_details_url
106                     + aData['matched'] + '">' + aData['matched'] + '</a>'
107             );
108           },
109       });
110     [% END %]
111 });
112
113 function show_marc( id ) {
114     var page = "/cgi-bin/koha/catalogue/showmarc.pl?importid=" + id;
115
116     var $dialog = $('<div></div>')
117         .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
118         .dialog({
119             autoOpen: false,
120             modal: true,
121             height: 625,
122             width: 500,
123             title: _("MARC Preview")
124         });
125
126     $dialog.dialog('open');
127 }
128 //]]>
129 </script>
130 <style type="text/css">
131         #jobpanel,#jobstatus,#jobfailed { display : none; }
132         #jobstatus { margin:.4em; }
133     #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>
134 </head>
135 <body id="tools_manage-marc-import" class="tools">
136 [% INCLUDE 'header.inc' %]
137 [% INCLUDE 'cat-search.inc' %]
138
139 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> 
140 [% IF ( import_batch_id ) %]
141  &rsaquo;
142  <a href="[% script_name %]">Manage staged MARC records</a>
143  &rsaquo; Batch [% import_batch_id %]
144 [% ELSE %]
145  &rsaquo; Manage staged MARC records
146 [% END %]
147 </div>
148
149 <div id="doc3" class="yui-t2">
150    
151    <div id="bd">
152         <div id="yui-main">
153         <div class="yui-b">
154
155 <h1>Manage staged MARC records
156 [% IF ( import_batch_id ) %]
157  &rsaquo; Batch [% import_batch_id %]
158 [% END %]
159 </h1>
160 [% IF ( label_batch_msg ) %]
161 [% IF ( alert ) %]
162 <div class="alert">
163 [% ELSE %]
164 <div class="dialog">
165 [% END %]
166 <b><p>[% label_batch_msg %]</p></b>
167 </div>
168 [% END %]
169
170 [% IF ( did_clean ) %]
171   <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div>
172 [% END %]
173
174 [% UNLESS ( batch_list ) %]
175    [% UNLESS ( batch_info ) %]
176    <div class="dialog message">
177      <p>No records have been staged.</p>
178      <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
179    </div>
180    [% END %]
181 [% END %]
182
183 [% IF ( batch_info ) %]
184
185 [% IF ( can_commit ) %]
186 <form action="[% script_name %]" method="post">
187 <input type="hidden" name="op" value="redo-matching" />
188 <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
189 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id %]" />
190 [% END %]
191
192   [% IF ( rematch_attempted ) %]
193     [% IF ( rematch_failed ) %]
194       <div class="dialog alert">Failed to apply different matching rule</div>
195     [% ELSE %]
196       <div class="dialog message">Applied different matching rule.  Number of records matched now
197        [% num_with_matches %]
198       </div>
199     [% END %]
200   [% END %]
201   [% IF ( changed_overlay_action ) %]
202       <div class="dialog message">Changed action if matching record found</div>
203   [% END %]
204   [% IF ( changed_nomatch_action ) %]
205       <div class="dialog message">Changed action if no match found</div>
206   [% END %]
207   [% IF ( changed_item_action ) %]
208       <div class="dialog message">Changed item processing option</div>
209   [% END %]
210
211 <fieldset class="rows" id="staged-record-matching-rules">
212   <ol>
213     <li><span class="label">File name:</span> [% file_name %]</li>
214     <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments %][% ELSE %](none)[% END %]</li>
215     <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
216     <li><span class="label">Staged:</span> [% upload_timestamp %]</li>
217     <li><span class="label">Status:</span>
218       [% IF ( import_status == 'cleaned' ) %]
219          Cleaned
220       [% ELSIF ( import_status == 'imported' ) %]
221         Imported
222       [% ELSIF ( import_status == 'importing' ) %]
223         Importing
224       [% ELSIF ( import_status == 'reverted' ) %]
225          Reverted
226       [% ELSIF ( import_status == 'reverting' ) %]
227          Reverting
228       [% ELSIF ( import_status == 'staged' ) %]
229           Staged
230       [% ELSE %]
231           [% import_status %]
232       [% END %]
233       </li>
234     <li>
235 [% IF ( can_commit ) %]<label for="new_matcher_id">Matching rule applied:</label><select name="new_matcher_id" id="new_matcher_id">
236        <option value="">Do not look for matching records</option> 
237        [% FOREACH available_matcher IN available_matchers %]
238           [% IF ( available_matcher.selected ) %]
239           <option value="[% available_matcher.matcher_id %]" selected="selected">
240              [% available_matcher.code %] ([% available_matcher.description %])
241           </option>
242           [% ELSE %]
243           <option value="[% available_matcher.matcher_id %]">
244             [% available_matcher.code %] ([% available_matcher.description %])
245           </option>
246           [% END %]
247        [% END %]
248     </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 ) %]
249   [% current_matcher_code %] ([% current_matcher_description %])
250 [% ELSE %]
251   No matching rule in effect
252 [% END %][% END %]
253     </li>
254     <li>
255         [% IF ( can_commit ) %]
256             <label for="overlay_action">Action if matching record found:</label>
257             [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
258         [% ELSE %]
259             <span class="label">Action if matching record found:</span>
260             [% IF ( overlay_action == 'replace' ) %]
261                 Replace existing record with incoming record
262             [% ELSIF ( overlay_action == 'create_new' ) %]
263                 Add incoming record
264             [% ELSIF ( overlay_action == 'ignore' ) %]
265                 Ignore incoming record (its items may still be processed)
266             [% ELSE %]
267                 [% overlay_action %]
268             [% END %]
269         [% END %]</li>
270      
271     <li>
272         [% IF ( can_commit ) %]
273             <label for="nomatch_action">Action if no match found:</label>
274             [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
275         [% ELSE %]
276             <span class="label">Action if no match found:</span>
277             [% IF ( nomatch_action == 'create_new' ) %]
278                 Add incoming record
279             [% ELSIF ( nomatch_action == 'ignore' ) %]
280                 Ignore incoming record (its items may still be processed)
281             [% ELSE %]
282                 [% nomatch_action %]
283             [% END %]
284         [% END %]
285     </li>
286     
287     <li>
288         [% IF ( can_commit ) %]
289             <label for="item_action">Item processing:</label>
290             [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
291         [% ELSE %]
292             <span class="label">Item processing:</span>
293             [% IF ( item_action == 'always_add' ) %]
294                 Always add items
295             [% ELSIF ( item_action == 'add_only_for_matches' ) %]
296                 Add items only if matching bib was found
297             [% ELSIF ( item_action == 'add_only_for_new' ) %]
298                 Add items only if no matching bib was found
299             [% ELSIF ( item_action == 'ignore' ) %]
300                 Ignore items
301             [% ELSE %]
302                 [% item_action %]
303             [% END %]
304         [% END %]
305     </li>
306   </ol>
307 [% IF ( can_commit ) %]<fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset></form>[% END %]
308 </fieldset>
309
310
311 <div>
312   [% IF ( can_commit ) %]
313   <form action="[% script_name %]" method="post">
314     <input type="hidden" name="op" value="commit-batch" />
315     <input type="hidden" name="runinbackground" value="" />
316     <input type="hidden" name="completedJobID" value="" />
317     <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
318     <fieldset class="action">
319     <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" onclick="return submitBackgroundJob(this.form);" />
320     <br/>
321     [% IF ( record_type != 'auth' ) %]
322     Add new bibliographic records into this framework:
323     <select name="framework" id="frameworks">
324       <option value="">Default</option>
325       [% FOREACH framework IN frameworks %]
326           <option value="[% framework.value %]">[% framework.label %]</option>
327       [% END %]
328     </select>
329     [% END %]
330     </fieldset>
331   </form>
332   <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
333      <div id="jobfailed"></div></div>
334   [% END %]
335   [% IF ( can_revert ) %]
336   <form action="[% script_name %]" method="post">
337     <input type="hidden" name="op" value="revert-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"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" onclick="return submitBackgroundJob(this.form);" /></fieldset>
342   </form>
343   <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
344      <div id="jobfailed"></div></div>
345   [% END %]
346 </div>
347   [% IF ( did_commit ) %]
348   <div class="dialog message">Completed import of records</div>
349   <table>
350   <tr><td>Number of records added</td><td>[% num_added %]</td></tr>
351   <tr><td>Number of records updated</td><td>[% num_updated %]</td></tr>
352   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
353   <tr><td>Number of items added</td><td>[% num_items_added %]</td></tr>
354   <tr><td>Number of items replaced</td><td>[% num_items_replaced %]</td></tr>
355   <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored %]</td></tr>
356   </table>
357   [% END %]
358   [% IF ( did_revert ) %]
359   <div class="dialog message">Success: Import reversed</div>
360   <table>
361   <tr><td>Number of records deleted</td><td>[% num_deleted %]</td></tr>
362   <tr><td>Number of items deleted</td><td>[% num_items_deleted %]</td></tr>
363   <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors %]</td></tr>
364   <tr><td>Number of records changed back</td><td>[% num_reverted %]</td></tr>
365   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
366   </table>
367   [% END %]
368 [% END %]
369 <br style="clear:both;" />
370
371 [% IF ( batch_list ) %]
372   [% IF ( pages ) %]
373 <div class="pages">
374 Page 
375     [% FOREACH page IN pages %]
376       [% IF ( page.current_page ) %]
377       <span class="current">[% page.page_number %]</span>
378       [% ELSE %]
379       <a class="nav" href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
380       [% END %]
381     [% END %]
382 </div>
383   [% END %]
384 <table>
385   <tr>
386     <th>#</th>
387     <th>File name</th>
388     <th>Comments</th>
389     <th>Type</th>
390     <th>Status</th>
391     <th>Staged</th>
392     <th># Records</th>
393     <th># Items</th>
394     <th>Action</th>
395   </tr>
396   [% FOREACH batch_lis IN batch_list %]
397   [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
398     <td>[% batch_lis.import_batch_id %]</td>
399     <td><a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]">[% batch_lis.file_name %]</a></td>
400     <td>[% batch_lis.comments %]</td>
401     <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
402     <td>
403       [% IF ( batch_lis.import_status == 'cleaned' ) %]
404          Cleaned
405       [% ELSIF ( batch_lis.import_status == 'imported' ) %]
406         Imported
407       [% ELSIF ( batch_lis.import_status == 'importing' ) %]
408         Importing
409       [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
410          Reverted
411       [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
412          Reverting
413       [% ELSIF ( batch_lis.import_status == 'staged' ) %]
414           Staged
415       [% ELSE %]
416           [% batch_lis.import_status %]
417       [% END %]
418     </td>
419     <td>[% batch_lis.upload_timestamp %]</td>
420     <td>[% batch_lis.num_records %]</td>
421     <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>
422     <td>[% IF ( batch_lis.can_clean ) %]
423           <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" >
424             <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
425             <input type="hidden" name="op" value="clean-batch" />
426             <input type="submit" class="button" value="Clean" onclick="return confirm(MSG_CONFIRM_CLEAN);" />
427           </form>
428         [% END %]
429     </td>
430   </tr>
431   [% END %]
432 </table>
433   [% IF ( pages ) %]
434 <div class="pages">
435 Page 
436     [% FOREACH page IN pages %]
437       [% IF ( page.current_page ) %]
438       <span class="current">[% page.page_number %]</span>
439       [% ELSE %]
440       <a class="nav" href="[% page.script_name %]?offset=[% page.offset %]">[% page.page_number %]</a>
441       [% END %]
442     [% END %]
443 </div>
444   [% END %]
445 [% END %]
446
447 [% IF import_batch_id %]
448     <table id="records-table">
449         <thead>
450             <tr>
451                 <th>#</th>
452                 <th>Citation</th>
453                 <th>Status</th>
454                 <th>Match type</th>
455                 <th>Match details</th>
456                 <th>Record</th>
457             </tr>
458         </thead>
459     </table>
460 [% END %]
461
462 </div>
463 </div>
464 <div class="yui-b">
465 [% INCLUDE 'tools-menu.inc' %]
466 </div>
467 </div>
468 [% INCLUDE 'intranet-bottom.inc' %]