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