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