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