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