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