Bug 30952: Staff interface redesign (header)
[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; Tools &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"><i class="fa fa-home"></i></a>
30             </li>
31             <li>
32                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</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" value="Apply different matching rules" class="button" /></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                                         [% END %]
278                                         <br />
279                                         <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
280                                     </fieldset>
281                                 </form> <!-- /#import_batch_form -->
282                                 <div id="jobpanel">
283                                     <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
284                                     <div id="jobfailed"></div>
285                                 </div>
286                             [% END # /IF can_commit %]
287                             [% IF ( can_revert ) %]
288                                 <form method="post" id="revert_batch_form">
289                                     <input type="hidden" name="op" value="revert-batch" />
290                                     <input type="hidden" name="runinbackground" value="" />
291                                     <input type="hidden" name="completedJobID" value="" />
292                                     <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
293                                     <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" /></fieldset>
294                                 </form>
295                                 <div id="jobpanel">
296                                     <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
297                                     <div id="jobfailed"></div>
298                                 </div>
299                             [% END # /IF can_revert %]
300                         </div>
301                         [% END %]
302
303                     [% END # /IF batch_info %]
304
305                     <br style="clear:both;" />
306
307                     [% IF ( batch_list ) %]
308                         [% IF ( pages ) %]
309                             [% PROCESS pagination %]
310                         [% END %]
311
312                         <table>
313                             <tr>
314                                 <th>#</th>
315                                 <th>File name</th>
316                                 <th>Profile</th>
317                                 <th>Comments</th>
318                                 <th>Type</th>
319                                 <th>Status</th>
320                                 <th>Staged</th>
321                                 <th># Records</th>
322                                 <th># Items</th>
323                                 <th>Action</th>
324                             </tr>
325                             [% FOREACH batch_lis IN batch_list %]
326                                 <tr>
327                                     <td>[% batch_lis.import_batch_id | html %]</td>
328                                     <td><a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]">[% batch_lis.file_name | html %]</a></td>
329                                     <td>[% batch_lis.profile | html %]</td>
330                                     <td>[% batch_lis.comments | html %]</td>
331                                     <td>[% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %]</td>
332                                     <td>
333                                         [% IF ( batch_lis.import_status == 'cleaned' ) %]
334                                             <span>Cleaned</span>
335                                         [% ELSIF ( batch_lis.import_status == 'imported' ) %]
336                                             <span>Imported</span>
337                                         [% ELSIF ( batch_lis.import_status == 'importing' ) %]
338                                             <span>Importing</span>
339                                         [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
340                                             <span>Reverted</span>
341                                         [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
342                                             <span>Reverting</span>
343                                         [% ELSIF ( batch_lis.import_status == 'staged' ) %]
344                                             <span>Staged</span>
345                                         [% ELSE %]
346                                             <span>[% batch_lis.import_status | html %]</span>
347                                         [% END %]
348                                     </td>
349                                     <td>[% batch_lis.upload_timestamp | $KohaDates with_hours=1 %]</td>
350                                     <td>[% batch_lis.num_records | html %]</td>
351                                     <td>[% batch_lis.num_items | html %]
352                                         [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
353                                             (<a href="?import_batch_id=[% batch_lis.import_batch_id | uri %]&amp;op=create_labels">Create label batch</a>)
354                                         [% END %]
355                                     </td>
356                                     <td class="actions">
357                                         [% IF ( batch_lis.can_clean ) %]
358                                             <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">
359                                                 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
360                                                 <input type="hidden" name="op" value="clean-batch" />
361                                                 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-eraser"></i> Clean</button>
362                                             </form>
363                                         [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
364                                             <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">
365                                                 <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id | html %]" />
366                                                 <input type="hidden" name="op" value="delete-batch" />
367                                                 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
368                                             </form>
369                                         [% END %]
370                                     </td>
371                                 </tr>
372                             [% END # /FOREACH batch_lis %]
373                         </table>
374
375                         [% IF ( pages ) %]
376                             [% PROCESS pagination %]
377                         [% END %]
378                     [% END # /IF batch_lis %]
379
380                     [% IF import_batch_id && !did_clean %]
381                         <table id="records-table">
382                             <thead>
383                                 <tr>
384                                     <th>#</th>
385                                     <th>Citation</th>
386                                     <th>Status</th>
387                                     <th>Match type</th>
388                                     <th>Match details</th>
389                                     <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
390                                     <th>Record</th>
391                                 </tr>
392                             </thead>
393                         </table>
394
395                         <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
396                             <div class="modal-dialog modal-wide">
397                                 <div class="modal-content">
398                                     <div class="modal-header">
399                                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
400                                         <h3 id="marcPreviewLabel">MARC preview</h3>
401                                     </div>
402                                     <div class="modal-body">
403                                         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
404                                     </div>
405                                     <div class="modal-footer">
406                                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
407                                     </div>
408                                 </div>
409                             </div>
410                         </div> <!-- /#marcPreview -->
411                     [% END # /IF import_batch_id %]
412                 </main>
413
414             </div> <!-- /.col-sm-10.col-sm-push-2 -->
415             <div class="col-sm-2 col-sm-pull-10">
416                 <aside>
417                     [% INCLUDE 'tools-menu.inc' %]
418                 </aside>
419             </div> <!-- .col-sm-2.col-sm-pull-10 -->
420         </div> <!-- /.row -->
421
422 [% MACRO jsinclude BLOCK %]
423     [% Asset.js("js/tools-menu.js") | $raw %]
424     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
425     [% INCLUDE 'datatables.inc' %]
426     <script>
427         $(document).ready(function() {
428             $("#staged-record-matching-rules select").change(function() {
429                 var str = $(this).attr("id");
430                 $("#reset_" + str).parent().show();
431             });
432             $("a.reset").click(function() {
433                 var str = $(this).attr("id");
434                 str = str.replace("reset_", "")
435                 $("#" + str + " option[selected='selected']").attr("selected", "selected");
436                 $(this).parent().hide();
437             });
438
439             [% IF import_batch_id %]
440                 $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
441                     "bAutoWidth": false,
442                     "bFilter": false,
443                     "bProcessing": true,
444                     "bServerSide": true,
445                     "sAjaxSource": 'batch_records_ajax.pl',
446                     "sPaginationType": "full_numbers",
447                     "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
448                     "aoColumns": [
449                         { "mDataProp": "import_record_id" },
450                         { "mDataProp": "citation" },
451                         { "mDataProp": "status" },
452                         { "mDataProp": "overlay_status" },
453                         { "mDataProp": null, "sDefaultContent": "" },
454                         { "mDataProp": null, "sDefaultContent": "" },
455                         { "mDataProp": "matched" }
456                     ],
457                     "fnServerData": function(sSource, aoData, fnCallback) {
458                         aoData.push({ "name": "import_batch_id", "value": [% import_batch_id | html %] });
459
460                         $.ajax({
461                             'dataType': 'json',
462                             'type': 'POST',
463                             'url': sSource,
464                             'data': aoData,
465                             'success': function(json) {
466                                 fnCallback(json);
467                             }
468                         });
469                     },
470                     "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
471                         [% IF(record_type == 'auth') %]
472                             var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
473                         [% ELSE %]
474                             var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
475                         [% END %]
476                         [% IF(record_type == 'auth') %]
477                             var record_edit_url = "/cgi-bin/koha/authorities/authorities.pl?authid=";
478                         [% ELSE %]
479                             var record_edit_url = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
480                         [% END %]
481
482                         var additional_details = "";
483                         if( aData['author'] ){
484                             additional_details += " " + aData['author'] + " ";
485                         }
486
487                         if( aData['isbn'] ){
488                             additional_details += " (" + aData['isbn'] + ") ";
489                         }
490
491                         if( aData['issn'] ){
492                             additional_details += " (" + aData['issn'] + ") ";
493                         }
494
495                         $('td:eq(1)', nRow).html(
496                             '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a> ' + additional_details
497                         );
498
499                         $('td:eq(2)', nRow).html(
500                             aData['status'] == 'imported' ? _("Imported") :
501                             aData['status'] == 'ignored' ? _("Ignored") :
502                             aData['status'] == 'reverted' ? _("Reverted") :
503                             aData['status'] == 'staged' ? _("Staged") :
504                             aData['status'] == 'error' ? _("Error") :
505                             aData['status']
506                         );
507
508                         $('td:eq(3)', nRow).html(
509                             aData['overlay_status'] == 'no_match' ? _("No match") :
510                             aData['overlay_status'] == 'match_applied' ? _("Match applied") :
511                             aData['overlay_status'] == 'auto_match' ? _("Match found") :
512                             aData['overlay_status']
513                         );
514
515                         if ( aData['matches'].length > 0 ) {
516
517                             var any_checked = 0;
518                             $('td:eq(4)', nRow).html('<ul class="matches"></ul>');
519                             $('td:eq(5)', nRow).html('<ul class="matches"></ul>');
520                             var checked = "";
521                             var disabled = "";
522                             if( aData['status'] == "imported" || aData['status'] == "ignored" ){
523                                 disabled = ' disabled ';
524                             }
525                             aData['matches'].forEach(function(item,index){
526                                 if( item.chosen == 1 ){
527                                     checked = 'checked="checked"';
528                                     any_checked = 1;
529                                 }
530                                 [% IF(item.record_type == 'auth') -%]
531                                     var matching_msg = _("Matches authority %s (score=%s):%s");
532                                 [%- ELSE -%]
533                                     var matching_msg = _("Matches bibliographic record %s (score=%s):%s");
534                                 [%- END %]
535                                     var match_option = "";
536                                     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 + '> ';
537
538                                     var diff_url = '/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s';
539                                     var match_citation = '';
540                                     if( item.title  ){ match_citation += item.title + ' ' }
541                                     if( item.author ){ match_citation += item.author }
542                                 $('td:eq(4) ul', nRow).append('<li><label for="import_record_id_'+aData['import_record_id']+'_match_'+index+'">'+match_option+
543                                     matching_msg.format(item.candidate_match_id, item.score,
544                                         '<a target="_blank" href="' + record_details_url
545                                         + item.candidate_match_id + '">' + match_citation + '</a></label></li>')
546                                 );
547                                 $('td:eq(5) ul', nRow).append('<li><a href="'
548                                         + diff_url.format( [% import_batch_id | html %], aData['import_record_id'], item.candidate_match_id, item.record_type) + '">' + _("View") + '</a></li>');
549                                 checked = "";
550                             });
551                             if( !any_checked ){ checked = 'checked="checked"'; }
552                             $('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>');
553                             $('td:eq(5) ul', nRow).prepend('<li>&nbsp;</li>');
554                         }
555                         if (aData['diff_url']) {
556                             $('td:eq(5)', nRow).html(
557                                 '<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
558                             );
559                         }
560                         if (aData['matched']) {
561                             $('td:eq(6)', nRow).html(
562                                 '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url
563                                 + aData['matched'] + '"><i class="fa fa-eye"></i> ' + _("View") + '</a> '
564                                 [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
565                                     + '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url
566                                     + aData['matched'] + '"><i class="fa fa-pencil"></i> ' + _("Edit") + '</a>'
567                                 [% END %]
568                             );
569                         }
570                     },
571                 }));
572                 $("#import_batch_form").on("submit", function() {
573                     return submitBackgroundJob(document.getElementById("import_batch_form"));
574                 });
575                 $("#revert_batch_form").on("submit", function() {
576                     return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")) && submitBackgroundJob(document.getElementById("revert_batch_form"));
577                 });
578             [% END %]
579
580             $("body").on("change", ".chosen", function(e) {
581                 let apimethod = "DELETE";
582                 let apidata ="";
583                 if( $(this).val() != 'none' ){
584                     apimethod = 'PUT';
585                     apidata = JSON.stringify({ candidate_match_id: $(this).val() });
586                 }
587                 $.ajax({
588                     url: '/api/v1/import_batches/[% import_batch_id | html %]/records/'+$(this).data('import_record_id')+'/matches/chosen',
589                     method: apimethod,
590                     data: apidata,
591                     contentType: 'application/json'
592                 }).fail(function(){ alert(_("Unable to update match choices")); return false; });
593             });
594
595             $("body").on("click", ".previewMARC", function(e) {
596                 e.preventDefault();
597                 var ltitle = $(this).text();
598                 var page = $(this).attr("href");
599                 $("#marcPreviewLabel").text(ltitle);
600                 $("#marcPreview .modal-body").load(page + " table");
601                 $('#marcPreview').modal({ show: true });
602             });
603             $("#marcPreview").on("hidden.bs.modal", function() {
604                 $("#marcPreviewLabel").html("");
605                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
606             });
607             $(".batch_form").on("submit", function() {
608                 if ($(this).hasClass("batch_delete")) {
609                     return confirm(_("Are you sure you want to permanently delete this batch?"));
610                 } else {
611                     return confirm(_("Clear all reservoir records staged in this batch?  This cannot be undone."));
612                 }
613             });
614             [% IF job_enqueued %]
615                 setTimeout(
616                     function() { window.location.href=$('a.job_details').attr('href'); },
617                     5000, // 5 secs to read
618                 );
619             [% END %]
620         });
621
622     </script>
623 [% END %]
624 [% INCLUDE 'intranet-bottom.inc' %]
625 [% BLOCK pagination %]
626     <nav>
627         <ul class="pagination">
628             [% FOREACH page IN pages %]
629                 [% IF ( page.current_page && page.page_number > 1 ) %]
630                     <li><a href="?offset=0" class="nav"><i class="fa fa-fw fa-angle-double-left"></i> First</a></li>
631                     <li><a href="?offset=[% offset - results_per_page | uri %]"><i class="fa fa-fw fa-angle-left"></i> Previous</a></li>
632                 [% END %]
633             [% END %]
634             [% FOREACH page IN pages %]
635                 [% IF ( page.current_page ) %]
636                     [% SET current_page = page.page_number %]
637                     <li class="active"><span class="current">[% page.page_number | html %]</span></li>
638                 [% ELSE %]
639                     <li><a class="nav" href="?offset=[% page.offset | uri %]">[% page.page_number | html %]</a></li>
640                 [% END %]
641             [% END %]
642             [% IF ( current_page < pages.size() ) %]
643                 <li>
644                     <a href="?offset=[% offset + results_per_page | uri %]" class="nav">Next <i class="fa fa-fw fa-angle-right"></i></a>
645                 </li>
646                 <li>
647                     <a href="?offset=[% ( results_per_page * ( pages.size - 1 ) ) | uri %]" class="nav">Last <i class="fa fa-fw fa-angle-double-right"></i></a>
648                 </li>
649             [% END %]
650         </ul>
651     </nav>
652 [% END %]