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