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