+
+ [% IF import_batch_id %]
+ $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "bAutoWidth": false,
+ "bFilter": false,
+ "bProcessing": true,
+ "bServerSide": true,
+ "sAjaxSource": 'batch_records_ajax.pl',
+ "sPaginationType": "full_numbers",
+ "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
+ "aoColumns": [
+ { "mDataProp": "import_record_id" },
+ { "mDataProp": "citation" },
+ { "mDataProp": "status" },
+ { "mDataProp": "overlay_status" },
+ { "mDataProp": "match_citation" },
+ { "mDataProp": "diff_url" },
+ { "mDataProp": "matched" }
+ ],
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
+
+ $.ajax({
+ 'dataType': 'json',
+ 'type': 'POST',
+ 'url': sSource,
+ 'data': aoData,
+ 'success': function(json){
+ fnCallback(json);
+ }
+ });
+ },
+ "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
+ [% IF ( record_type == 'auth' ) %]
+ var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
+ [% ELSE %]
+ var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
+ [% END %]
+
+ $('td:eq(1)', nRow).html(
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
+ );
+
+ $('td:eq(2)', nRow).html(
+ aData['status'] == 'imported' ? _("Imported") :
+ aData['status'] == 'ignored' ? _("Ignored") :
+ aData['status'] == 'reverted' ? _("Reverted") :
+ aData['status'] == 'staged' ? _("Staged") :
+ aData['status'] == 'error' ? _("Error") :
+ aData['status']
+ );
+
+ $('td:eq(3)', nRow).html(
+ aData['overlay_status'] == 'no_match' ? _("No match") :
+ aData['overlay_status'] == 'match_applied' ? _("Match applied") :
+ aData['overlay_status'] == 'auto_match' ? _("Match found") :
+ aData['overlay_status']
+ );
+
+ if ( aData['match_id'] ) {
+ [% IF ( record_type == 'auth' ) -%]
+ var matching_msg = _("Matches authority %s (score=%s):%s");
+ [%- ELSE -%]
+ var matching_msg = _("Matches biblio %s (score=%s):%s");
+ [%- END %]
+ $('td:eq(4)', nRow).html(
+ matching_msg.format(aData['match_id'], aData['score'],
+ '<a target="_blank" href="' + record_details_url
+ + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
+ );
+ }
+ if (aData['diff_url']){
+ $('td:eq(5)', nRow).html(
+ '<a href="'+aData['diff_url']+'">View</a>'
+ );
+ }
+ $('td:eq(6)', nRow).html(
+ '<a target="_blank" href="' + record_details_url
+ + aData['matched'] + '">' + aData['matched'] + '</a>'
+ );
+ },
+ }));
+ [% END %]
+ $("body").on("click",".previewMARC", function(e){
+ e.preventDefault();
+ var ltitle = $(this).text();
+ var page = $(this).attr("href");
+ $("#marcPreviewLabel").text(ltitle);
+ $("#marcPreview .modal-body").load(page + " table");
+ $('#marcPreview').modal({show:true});
+ });
+ $("#marcPreview").on("hidden", function(){
+ $("#marcPreviewLabel").html("");
+ $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/loading-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+ });