Bug 15869: Change framework on overlay
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / manage-marc-import.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>
7     [% IF ( import_batch_id ) %]
8         Batch [% import_batch_id | html %] &rsaquo; [% END %]
9     Manage staged MARC records &rsaquo; Cataloging &rsaquo; Koha
10 </title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/humanmsg.css") | $raw %]
13 <style>
14     #jobpanel,#jobstatus,#jobfailed { display : none; }
15     span.change-status { font-style:italic; color:#666; display:none; }
16     ul.matches li { list-style-type:none; }
17 </style>
18 </head>
19
20 <body id="tools_manage-marc-import" class="tools">
21     [% WRAPPER 'header.inc' %]
22     [% INCLUDE 'cat-search.inc' %]
23 [% END %]
24
25     [% WRAPPER 'sub-header.inc' %]
26     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27         <ol>
28             <li>
29                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30             </li>
31             <li>
32                 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
33             </li>
34             [% IF ( import_batch_id ) %]
35                 <li>
36                     <a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>
37                 </li>
38                 <li>
39                     <a href="#" aria-current="page">
40                         Batch [% import_batch_id | html %]
41                     </a>
42                 </li>
43             [% ELSE %]
44                 <li>
45                     <a href="#" aria-current="page">
46                         Manage staged MARC records
47                     </a>
48                 </li>
49             [% END %]
50         </ol>
51     </nav>
52     [% END %]
53
54     <div class="main container-fluid">
55         <div class="row">
56             <div class="col-sm-10 col-sm-push-2">
57                 <main>
58                     <h1>Manage staged MARC records
59                         [% IF ( import_batch_id ) %]
60                             &rsaquo; Batch [% import_batch_id | html %]
61                         [% END %]
62                     </h1>
63                     [% FOREACH message IN messages %]
64                       [% IF message.type == 'success' %]
65                         <div class="dialog message">
66                       [% ELSIF message.type == 'warning' %]
67                         <div class="dialog alert">
68                       [% ELSIF message.type == 'error' %]
69                         <div class="dialog alert" style="margin:auto;">
70                       [% END %]
71                       [% IF message.code == 'cannot_enqueue_job' %]
72                           <span>Cannot enqueue this job.</span>
73                       [% END %]
74                       [% IF message.error %]
75                         <span>(The error was: [% message.error | html %], see the Koha log file for more information).</span>
76                       [% END %]
77                       </div>
78                     [% END %]
79
80                     [% IF job_enqueued %]
81                         <div class="dialog message">
82                           <p>The job has been enqueued! It will be processed as soon as possible.</p>
83                           <p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
84                         </div>
85
86                     [% ELSIF ( label_batch_msg ) %]
87                         [% IF ( alert ) %]
88                             <div class="alert">
89                         [% ELSE %]
90                             <div class="dialog message">
91                         [% END %]
92                             <p><strong>
93                                 [% IF ( label_batch_msg == "error" ) %]
94                                     <span>Error attempting to create label batch. Please ask your system administrator to check the log for more details.</span>
95                                 [% ELSE %]
96                                     <span>Label</span> <a href="/cgi-bin/koha/labels/label-edit-batch.pl?op=edit&element_id=[% label_batch_msg | uri %]" >batch #[% label_batch_msg | html %]</a> created.
97                                 [% END %]
98                             </strong></p>
99                         </div>
100                     [% END %]
101
102                     [% IF ( did_clean ) %]
103                         <div class="dialog message">Cleaned import batch #[% import_batch_id | html %]</div>
104                     [% END %]
105
106                     [% IF ( did_delete ) %]
107                         <div class="dialog message">Import batch deleted successfully</div>
108                     [% END %]
109
110                     [% UNLESS batch_list || batch_info || job_enqueued %]
111                         <div class="dialog message">
112                             <p>No records have been staged.</p>
113                             <p><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a>.</p>
114                         </div>
115                     [% END %]
116
117                     [% IF ( batch_info ) %]
118                         [% IF ( can_commit ) %]
119                             <form method="post">
120                                 <input type="hidden" name="op" value="redo-matching" />
121                                 <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
122                                 <input type="hidden" name="current_matcher_id" value="[% current_matcher_id | html %]" />
123                         [% END %]
124
125                         [% IF ( rematch_attempted ) %]
126                             [% IF ( rematch_failed ) %]
127                                 <div class="dialog alert">Failed to apply different matching rule</div>
128                             [% ELSE %]
129                                 <div class="dialog message">Applied different matching rule. Number of records matched now
130                                     [% num_with_matches | html %]
131                                 </div>
132                             [% END %]
133                         [% END %]
134
135                         [% IF ( changed_overlay_action ) %]
136                             <div class="dialog message">Changed action if matching record found</div>
137                         [% END %]
138
139                         [% IF ( changed_nomatch_action ) %]
140                             <div class="dialog message">Changed action if no match found</div>
141                         [% END %]
142
143                         [% IF ( changed_item_action ) %]
144                             <div class="dialog message">Changed item processing option</div>
145                         [% END %]
146
147                         [% UNLESS job_enqueued %]
148                         <fieldset class="rows" id="staged-record-matching-rules">
149                             <ol>
150                                 <li><span class="label">File name:</span> [% file_name | html %]</li>
151                                 <li><span class="label">Profile:</span> [% IF (profile) %][% profile | html %][% ELSE %](none)[% END %]</li>
152                                 <li><span class="label">Comments:</span> [% IF ( comments ) %][% comments | html %][% ELSE %](none)[% END %]</li>
153                                 <li><span class="label">Type:</span> [% IF ( record_type == 'auth' ) %]Authority records[% ELSE %]Bibliographic records[% END %]</li>
154                                 <li><span class="label">Staged:</span> [% upload_timestamp | $KohaDates with_hours=1 %]</li>
155                                 <li><span class="label">Status:</span>
156                                     [% IF ( import_status == 'cleaned' ) %]
157                                         <span>Cleaned</span>
158                                     [% ELSIF ( import_status == 'imported' ) %]
159                                         <span>Imported</span>
160                                     [% ELSIF ( import_status == 'importing' ) %]
161                                         <span>Importing</span>
162                                     [% ELSIF ( import_status == 'reverted' ) %]
163                                         <span>Reverted</span>
164                                     [% ELSIF ( import_status == 'reverting' ) %]
165                                         <span>Reverting</span>
166                                     [% ELSIF ( import_status == 'staged' ) %]
167                                         <span>Staged</span>
168                                     [% ELSE %]
169                                         [% import_status | html %]
170                                     [% END %]
171                                 </li>
172                                 <li>
173                                     [% IF ( can_commit ) %]
174                                         <label for="new_matcher_id">Matching rule applied:</label>
175                                         <select name="new_matcher_id" id="new_matcher_id">
176                                             <option value="">Do not look for matching records</option>
177                                             [% FOREACH available_matcher IN available_matchers %]
178                                                 [% IF ( available_matcher.selected ) %]
179                                                     <option value="[% available_matcher.matcher_id | html %]" selected="selected">
180                                                         [% available_matcher.code | html %] ([% available_matcher.description | html %])
181                                                     </option>
182                                                 [% ELSE %]
183                                                     <option value="[% available_matcher.matcher_id | html %]">
184                                                         [% available_matcher.code | html %] ([% available_matcher.description | html %])
185                                                     </option>
186                                                 [% END %]
187                                             [% END %]
188                                         </select>
189                                         <span class="change-status">Changed. <a href="#" class="reset" id="reset_new_matcher_id">Reset</a></span>
190                                     [% ELSE %]
191                                         <span class="label">Matching rule applied:</span>
192                                         [% IF ( current_matcher_id ) %]
193                                             [% current_matcher_code | html %] ([% current_matcher_description | html %])
194                                         [% ELSE %]
195                                             <span>No matching rule in effect</span>
196                                         [% END %]
197                                     [% END %]
198                                 </li>
199                                 <li>
200                                     [% IF ( can_commit ) %]
201                                         <label for="overlay_action">Action if matching record found:</label>
202                                         [% INCLUDE 'tools-overlay-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_overlay_action">Reset</a></span>
203                                     [% ELSE %]
204                                         <span class="label">Action if matching record found:</span>
205                                         [% IF ( overlay_action == 'replace' ) %]
206                                             <span>Replace existing record with incoming record</span>
207                                         [% ELSIF ( overlay_action == 'create_new' ) %]
208                                             <span>Add incoming record</span>
209                                         [% ELSIF ( overlay_action == 'ignore' ) %]
210                                             <span>Ignore incoming record (its items may still be processed)</span>
211                                         [% ELSE %]
212                                             <span>[% overlay_action | html %]</span>
213                                         [% END %]
214                                     [% END %]
215                                 </li>
216                                 <li>
217                                     [% IF ( can_commit ) %]
218                                         <label for="nomatch_action">Action if no match found:</label>
219                                         [% INCLUDE 'tools-nomatch-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_nomatch_action">Reset</a></span>
220                                     [% ELSE %]
221                                         <span class="label">Action if no match found:</span>
222                                         [% IF ( nomatch_action == 'create_new' ) %]
223                                             Add incoming record
224                                         [% ELSIF ( nomatch_action == 'ignore' ) %]
225                                             Ignore incoming record (its items may still be processed)
226                                         [% ELSE %]
227                                             [% nomatch_action | html %]
228                                         [% END %]
229                                     [% END %]
230                                 </li>
231                                 [% IF ( record_type == 'biblio' ) %]
232                                     <li>
233                                         [% IF ( can_commit ) %]
234                                             <label for="item_action">Item processing:</label>
235                                             [% INCLUDE 'tools-item-action.inc' %] <span class="change-status">Changed. <a href="#" class="reset" id="reset_item_action">Reset</a></span>
236                                         [% ELSE %]
237                                             <span class="label">Item processing:</span>
238                                             [% IF ( item_action == 'always_add' ) %]
239                                                 <span>Always add items</span>
240                                             [% ELSIF ( item_action == 'add_only_for_matches' ) %]
241                                                 <span>Add items only if matching bib was found</span>
242                                             [% ELSIF ( item_action == 'add_only_for_new' ) %]
243                                                 <span>Add items only if no matching bib was found</span>
244                                             [% ELSIF ( item_action == 'ignore' ) %]
245                                                 <span>Ignore items</span>
246                                             [% ELSE %]
247                                                 <span>[% item_action | html %]</span>
248                                             [% END %]
249                                         [% END %]
250                                     </li>
251                                 [% ELSE %]
252                                     <input type ="hidden" name="item_action" value="ignore">
253                                 [% END %]
254                             </ol>
255                             [% IF ( can_commit ) %]
256                                     <fieldset class="action"><input type="submit" class="btn btn-primary" value="Apply different matching rules" /></fieldset>
257                                 </form>
258                             [% END %]
259                         </fieldset> <!-- /#staged-record-matching-rules -->
260
261                         <div>
262                             [% IF ( can_commit ) %]
263                                 <form method="post" id="import_batch_form">
264                                     <input type="hidden" name="op" value="commit-batch" />
265                                     <input type="hidden" name="runinbackground" value="" />
266                                     <input type="hidden" name="completedJobID" value="" />
267                                     <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
268                                     <fieldset class="action">
269                                         [% IF ( record_type != 'auth' ) %]
270                                             Add new bibliographic records into this framework:
271                                             <select name="framework" id="frameworks">
272                                                 <option value="">Default</option>
273                                                 [% FOREACH framework IN frameworks %]
274                                                     <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
275                                                 [% END %]
276                                             </select>
277                                             <br/>
278                                             When replacing records use this framework:
279                                             <select name="overlay_framework" id="overlay_frameworks">
280                                                 <option value="_USE_ORIG_">Keep original framework</option>
281                                                 <option value="">Default</option>
282                                                 [% FOREACH framework IN frameworks %]
283                                                     <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
284                                                 [% END %]
285                                             </select>
286                                         [% END %]
287                                         <br />
288                                         <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
289                                     </fieldset>
290                                 </form> <!-- /#import_batch_form -->
291                                 <div id="jobpanel">
292                                     <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
293                                     <div id="jobfailed"></div>
294                                 </div>
295                             [% END # /IF can_commit %]
296                             [% IF ( can_revert ) %]
297                                 <form method="post" id="revert_batch_form">
298                                     <input type="hidden" name="op" value="revert-batch" />
299                                     <input type="hidden" name="runinbackground" value="" />
300                                     <input type="hidden" name="completedJobID" value="" />
301                                     <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
302                                     <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
303                                 </form>
304                                 <div id="jobpanel">
305                                     <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
306                                     <div id="jobfailed"></div>
307                                 </div>
308                             [% END # /IF can_revert %]
309                         </div>
310                         [% END %]
311
312                     [% END # /IF batch_info %]
313
314                     <br style="clear:both;" />
315
316                     [% IF ( batch_list ) %]
317                         [% IF ( pages ) %]
318                             [% PROCESS pagination %]
319                         [% END %]
320                         <div class="page-section">
321                             <table class="dataTable">
322                                 <thead>
323                                     <tr>
324                                         <th>#</th>
325                                         <th>File name</th>
326                                         <th>Profile</th>
327                                         <th>Comments</th>
328                                         <th>Type</th>
329                                         <th>Status</th>
330                                         <th>Staged</th>
331                                         <th># Records</th>
332                                         <th># Items</th>
333                                         <th>Action</th>
334                                     </tr>
335                                 </thead>
336                                 <tbody>
337                                     [% FOREACH batch_lis IN batch_list %]
338                                         <tr>
339                                             <td>[% batch_lis.import_batch_id | html %]</td>
340                                             <td><a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
341                                             <td>[% batch_lis.profile | html %]</td>
342                                             <td>[% batch_lis.comments | html %]</td>
343                                             <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
344                                             <td>
345                                                 [% IF ( batch_lis.import_status == 'cleaned' ) %]
346                                                     <span>Cleaned</span>
347                                                 [% ELSIF ( batch_lis.import_status == 'imported' ) %]
348                                                     <span>Imported</span>
349                                                 [% ELSIF ( batch_lis.import_status == 'importing' ) %]
350                                                     <span>Importing</span>
351                                                 [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
352                                                     <span>Reverted</span>
353                                                 [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
354                                                     <span>Reverting</span>
355                                                 [% ELSIF ( batch_lis.import_status == 'staged' ) %]
356                                                     <span>Staged</span>
357                                                 [% ELSE %]
358                                                     <span>[% batch_lis.import_status | html %]</span>
359                                                 [% END %]
360                                             </td>
361                                             <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
362                                             <td>[% batch_lis.num_records | html %]</td>
363                                             <td>[% batch_lis.num_items | html %]
364                                                 [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
365                                                     (<a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]&amp;op=create_labels">Create label batch</a>)
366                                                 [% END %]
367                                             </td>
368                                             <td class="actions">
369                                                 [% IF ( batch_lis.can_clean ) %]
370                                                     <form method="post" name="clean_batch_[% batch_lis.import_batch_id | html %]" id="clean_batch_[% batch_lis.import_batch_id | html %]" class="batch_form batch_clean">
371                                                         <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
372                                                         <input type="hidden" name="op" value="clean-batch" />
373                                                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
374                                                     </form>
375                                                 [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
376                                                     <form method="post" action="/cgi-bin/koha/tools/manage-marc-import.pl" name="delete_batch_[% batch_lis.import_batch_id | html %]" id="delete_batch_[% batch_lis.import_batch_id | html %]" class="batch_form batch_delete">
377                                                         <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
378                                                         <input type="hidden" name="op" value="delete-batch" />
379                                                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
380                                                     </form>
381                                                 [% END %]
382                                             </td>
383                                         </tr>
384                                     [% END # /FOREACH batch_lis %]
385                                 </tbody>
386                             </table>
387                         </div> <!-- /.page-section -->
388
389                         [% IF ( pages ) %]
390                             [% PROCESS pagination %]
391                         [% END %]
392                     [% END # /IF batch_lis %]
393
394                     [% IF import_batch_id && !did_clean %]
395                     <div class="page-section">
396                         <table id="records-table">
397                             <thead>
398                                 <tr>
399                                     <th>#</th>
400                                     <th>Citation</th>
401                                     <th>Status</th>
402                                     <th>Match type</th>
403                                     <th>Match details</th>
404                                     <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
405                                     <th>Record</th>
406                                 </tr>
407                             </thead>
408                         </table>
409                     </div>
410
411                         <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
412                             <div class="modal-dialog modal-wide">
413                                 <div class="modal-content">
414                                     <div class="modal-header">
415                                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
416                                         <h3 id="marcPreviewLabel">MARC preview</h3>
417                                     </div>
418                                     <div class="modal-body">
419                                         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
420                                     </div>
421                                     <div class="modal-footer">
422                                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
423                                     </div>
424                                 </div>
425                             </div>
426                         </div> <!-- /#marcPreview -->
427                     [% END # /IF import_batch_id %]
428                 </main>
429
430             </div> <!-- /.col-sm-10.col-sm-push-2 -->
431             <div class="col-sm-2 col-sm-pull-10">
432                 <aside>
433                     [% INCLUDE 'cat-menu.inc' %]
434                 </aside>
435             </div> <!-- .col-sm-2.col-sm-pull-10 -->
436         </div> <!-- /.row -->
437
438 [% MACRO jsinclude BLOCK %]
439     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
440     [% INCLUDE 'datatables.inc' %]
441     <script>
442         $(document).ready(function() {
443             $("#staged-record-matching-rules select").change(function() {
444                 var str = $(this).attr("id");
445                 $("#reset_" + str).parent().show();
446             });
447             $("a.reset").click(function() {
448                 var str = $(this).attr("id");
449                 str = str.replace("reset_", "")
450                 $("#" + str + " option[selected='selected']").attr("selected", "selected");
451                 $(this).parent().hide();
452             });
453
454             [% IF import_batch_id %]
455                 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
456                     "bAutoWidth": false,
457                     "bFilter": false,
458                     "bProcessing": true,
459                     "bServerSide": true,
460                     "sAjaxSource": 'batch_records_ajax.pl',
461                     "sPaginationType": "full_numbers",
462                     "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
463                     "aoColumns": [
464                         { "mDataProp": "import_record_id" },
465                         { "mDataProp": "citation" },
466                         { "mDataProp": "status" },
467                         { "mDataProp": "overlay_status" },
468                         { "mDataProp": null, "sDefaultContent": "" },
469                         { "mDataProp": null, "sDefaultContent": "" },
470                         { "mDataProp": "matched" }
471                     ],
472                     "fnServerData": function(sSource, aoData, fnCallback) {
473                         aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
474
475                         $.ajax({
476                             'dataType': 'json',
477                             'type': 'POST',
478                             'url': sSource,
479                             'data': aoData,
480                             'success': function(json) {
481                                 fnCallback(json);
482                             }
483                         });
484                     },
485                     "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
486                         [% IF(record_type == 'auth') %]
487                             var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
488                         [% ELSE %]
489                             var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
490                         [% END %]
491                         [% IF(record_type == 'auth') %]
492                             var record_edit_url = "/cgi-bin/koha/authorities/authorities.pl?authid=";
493                         [% ELSE %]
494                             var record_edit_url = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
495                         [% END %]
496
497                         var additional_details = "";
498                         if( aData['author'] ){
499                             additional_details += " " + aData['author'] + " ";
500                         }
501
502                         if( aData['isbn'] ){
503                             additional_details += " (" + aData['isbn'] + ") ";
504                         }
505
506                         if( aData['issn'] ){
507                             additional_details += " (" + aData['issn'] + ") ";
508                         }
509
510                         $('td:eq(1)', nRow).html(
511                             '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
512                         );
513
514                         $('td:eq(2)', nRow).html(
515                             aData['status'] == 'imported' ? _("Imported") :
516                             aData['status'] == 'ignored' ? _("Ignored") :
517                             aData['status'] == 'reverted' ? _("Reverted") :
518                             aData['status'] == 'staged' ? _("Staged") :
519                             aData['status'] == 'error' ? _("Error") :
520                             aData['status']
521                         );
522
523                         $('td:eq(3)', nRow).html(
524                             aData['overlay_status'] == 'no_match' ? _("No match") :
525                             aData['overlay_status'] == 'match_applied' ? _("Match applied") :
526                             aData['overlay_status'] == 'auto_match' ? _("Match found") :
527                             aData['overlay_status']
528                         );
529
530                         if ( aData['matches'].length > 0 ) {
531
532                             var any_checked = 0;
533                             $('td:eq(4)', nRow).html('<ul class="matches"></ul>');
534                             $('td:eq(5)', nRow).html('<ul class="matches"></ul>');
535                             var checked = "";
536                             var disabled = "";
537                             if( aData['status'] == "imported" || aData['status'] == "ignored" ){
538                                 disabled = ' disabled ';
539                             }
540                             aData['matches'].forEach(function(item,index){
541                                 if( item.chosen == 1 ){
542                                     checked = 'checked="checked"';
543                                     any_checked = 1;
544                                 }
545                                 [% IF(item.record_type == 'auth') -%]
546                                     var matching_msg = _("Matches authority %s (score=%s):%s");
547                                 [%- ELSE -%]
548                                     var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
549                                 [%- END %]
550                                     var match_option = "";
551                                     match_option = '<input type="radio" data-import_record_id="'+aData['import_record_id']+'" class="chosen" name="import_record_id_'+aData['import_record_id']+'_match" value="'+item.candidate_match_id+'" ' + checked + disabled + '> ';
552
553                                     var diff_url = '/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s';
554                                     var match_citation = '';
555                                     if( item.title  ){ match_citation += item.title + ' ' }
556                                     if( item.author ){ match_citation += item.author }
557                                 $('td:eq(4) ul', nRow).append('<li><label for="import_record_id_'+aData['import_record_id']+'_match_'+index+'">'+match_option+
558                                     matching_msg.format(item.candidate_match_id, item.score,
559                                         '<a target="_blank" href="' + record_details_url
560                                         + item.candidate_match_id + '">' + match_citation + '</a></label></li>')
561                                 );
562                                 $('td:eq(5) ul', nRow).append('<li><a href="'
563                                         + diff_url.format( [% import_batch_id | html %], aData['import_record_id'], item.candidate_match_id, item.record_type) + '">' + _("View") + '</a></li>');
564                                 checked = "";
565                             });
566                             if( !any_checked ){ checked = 'checked="checked"'; }
567                             $('td:eq(4) ul', nRow).prepend('<li><label><input type="radio" data-import_record_id="'+aData['import_record_id']+'" class="chosen" name="import_record_id_'+aData['import_record_id']+'_match" value="none" ' + checked + disabled + ' > '+_("Ignore matches")+'</label></li>');
568                             $('td:eq(5) ul', nRow).prepend('<li>&nbsp;</li>');
569                         }
570                         if (aData['diff_url']) {
571                             $('td:eq(5)', nRow).html(
572                                 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
573                             );
574                         }
575                         if (aData['matched']) {
576                             $('td:eq(6)', nRow).html(
577                                 '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url
578                                 + aData['matched'] + '"><i class="fa fa-eye"></i> ' + _("View") + '</a> '
579                                 [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
580                                     + '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url
581                                     + aData['matched'] + '"><i class="fa fa-pencil"></i> ' + _("Edit") + '</a>'
582                                 [% END %]
583                             );
584                         }
585                     },
586                 }));
587                 $("#import_batch_form").on("submit", function() {
588                     return submitBackgroundJob(document.getElementById("import_batch_form"));
589                 });
590                 $("#revert_batch_form").on("submit", function() {
591                     return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
592                 });
593             [% END %]
594
595             $("body").on("change", ".chosen", function(e) {
596                 let apimethod = "DELETE";
597                 let apidata ="";
598                 if( $(this).val() != 'none' ){
599                     apimethod = 'PUT';
600                     apidata = JSON.stringify({ candidate_match_id: $(this).val() });
601                 }
602                 $.ajax({
603                     url: '/api/v1/import_batches/[% import_batch_id | html %]/records/'+$(this).data('import_record_id')+'/matches/chosen',
604                     method: apimethod,
605                     data: apidata,
606                     contentType: 'application/json'
607                 }).fail(function(){ alert(_("Unable to update match choices")); return false; });
608             });
609
610             $("body").on("click", ".previewMARC", function(e) {
611                 e.preventDefault();
612                 var ltitle = $(this).text();
613                 var page = $(this).attr("href");
614                 $("#marcPreviewLabel").text(ltitle);
615                 $("#marcPreview .modal-body").load(page + " table");
616                 $('#marcPreview').modal({ show: true });
617             });
618             $("#marcPreview").on("hidden.bs.modal", function() {
619                 $("#marcPreviewLabel").html("");
620                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
621             });
622             $(".batch_form").on("submit", function() {
623                 if ($(this).hasClass("batch_delete")) {
624                     return confirm(_("Are you sure you want to permanently delete this batch?"));
625                 } else {
626                     return confirm(_("Clear all reservoir records staged in this batch?  This cannot be undone."));
627                 }
628             });
629             [% IF job_enqueued %]
630                 setTimeout(
631                     function() { window.location.href=$('a.job_details').attr('href'); },
632                     5000, // 5 secs to read
633                 );
634             [% END %]
635         });
636
637     </script>
638 [% END %]
639 [% INCLUDE 'intranet-bottom.inc' %]
640 [% BLOCK pagination %]
641     <nav>
642         <ul class="pagination">
643             [% FOREACH page IN pages %]
644                 [% IF ( page.current_page && page.page_number > 1 ) %]
645                     <li><a href="?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
646                     <li><a href="?offset=[% offset - results_per_page | uri %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
647                 [% END %]
648             [% END %]
649             [% FOREACH page IN pages %]
650                 [% IF ( page.current_page ) %]
651                     [% SET current_page = page.page_number %]
652                     <li class="active"><span class="current">[% page.page_number | html %]</span></li>
653                 [% ELSE %]
654                     <li><a class="nav" href="?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
655                 [% END %]
656             [% END %]
657             [% IF ( current_page < pages.size() ) %]
658                 <li>
659                     <a href="?offset=[% offset + results_per_page | uri %]" class="nav">Next <i class="fa fa-fw fa-angle-right"></i></a>
660                 </li>
661                 <li>
662                     <a href="?offset=[% ( results_per_page * ( pages.size - 1 ) ) | uri %]" class="nav">Last <i class="fa fa-fw fa-angle-double-right"></i></a>
663                 </li>
664             [% END %]
665         </ul>
666     </nav>
667 [% END %]