From 1a88ca645858cc10e31d6d032f6aaae857f96804 Mon Sep 17 00:00:00 2001
From: mbeaulieu <mbeaulieu@inlibro.com>
Date: Thu, 14 Aug 2014 09:27:08 -0400
Subject: [PATCH] Bug 11876 - Diff column is now displayed.

If a match is found, a 'View' link appears in the Diff column.

Old patch was not implementing datatables, and therefore was not compatible with this version of Koha.
	modified:   koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
	modified:   tools/batch_records_ajax.pl
---
 .../prog/en/modules/tools/manage-marc-import.tt    |  100 ++------------------
 tools/batch_records_ajax.pl                        |    1 +
 2 files changed, 10 insertions(+), 91 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
index f2b3c26..ded1d22 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
@@ -66,7 +66,8 @@ $(document).ready(function(){
               { "mDataProp": "status" },
               { "mDataProp": "overlay_status" },
               { "mDataProp": "match_citation" },
-              { "mDataProp": "matched" },
+              { "mDataProp": "diff_url" },
+              { "mDataProp": "matched" }
           ],
           "fnServerData": function ( sSource, aoData, fnCallback ) {
               aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
@@ -122,8 +123,12 @@ $(document).ready(function(){
                     + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
                 );
             }
-
-            $('td:eq(5)', nRow).html(
+            if (aData['diff_url']){
+                $('td:eq(5)', nRow).html(
+                    '<a rel="gb_page_center[960,600]" href="'+aData['diff_url']+'">View</a>'
+                );
+            }
+            $('td:eq(6)', nRow).html(
                 '<a target="_blank" href="' + record_details_url
                     + aData['matched'] + '">' + aData['matched'] + '</a>'
             );
@@ -475,100 +480,13 @@ Page
                 <th>Status</th>
                 <th>Match type</th>
                 <th>Match details</th>
+                <th><abbr title="Differences between the original biblio and the imported" lang="en">Diff</abbr></th>
                 <th>Record</th>
             </tr>
         </thead>
     </table>
 [% END %]
 
-[% IF ( record_list ) %]
-  [% IF ( pages ) %]
-<div class="pages">
-Page
-    [% FOREACH page IN pages %]
-      [% IF ( page.current_page ) %]
-      <span class="current">[% page.page_number %]</span>
-      [% ELSE %]
-      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
-      [% END %]
-    [% END %]
-</div>
-  [% END %]
-<table>
-  <tr>
-    <th>#</th>
-    <th>Citation</th>
-    <th>Status</th>
-    <th>Match?</th>
-    <th>Record</th>
-    <th><abbr title="Differences between the original biblio and the imported" lang="en">Diff</abbr></th>
-
-  </tr>
-  [% FOREACH record_lis IN record_list %]
-  [% UNLESS ( loop.odd ) %]<tr data-id="[% record_lis.import_record_id %]" class="highlight">[% ELSE %]<tr data-id="[% record_lis.import_record_id %]">[% END %]
-    <td>[% record_lis.record_sequence %]</td>
-    <td><a class="citation" href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td>
-    <td>
-        [% IF ( record_lis.status == 'imported' ) %]
-            Imported
-        [% ELSIF ( record_lis.status == 'ignored' ) %]
-            Ignored
-        [% ELSIF ( record_lis.status == 'reverted' ) %]
-            Reverted
-        [% ELSIF ( record_lis.status == 'staged' ) %]
-            Staged
-        [% ELSIF ( record_lis.status == 'error' ) %]
-            Error
-        [% ELSE %]
-          [% record_lis.status %]
-        [% END %]
-    </td>
-    <td>
-        [% IF ( record_lis.overlay_status == 'no_match' ) %]
-            No match
-        [% ELSIF ( record_lis.overlay_status == 'match_applied' ) %]
-            Match applied
-        [% ELSIF ( record_lis.overlay_status == 'auto_match' ) %]
-            Match found
-        [% ELSE %]
-            [% record_lis.overlay_status %]
-        [% END %]
-    </td>
-    <td>[% IF ( record_lis.final_match_id ) %]
-        [% PROCESS final_match_link record=record_lis %]
-        [% END %]
-    </td>
-    [% IF ( record_lis.match_id ) %]
-        <td>
-            <a rel="gb_page_center[960,600]" href="/cgi-bin/koha/catalogue/showdiffmarc.pl?importid=[% record_lis.import_record_id %]&id=[% record_lis.match_id %]">View</a>
-        </td>
-    [% ELSE %]
-        <td>&nbsp;</td>
-    [% END %]
-  </tr>
-    [% PROCESS match_link record=record_lis %]
-  [% END %]
-</table>
-  [% IF ( pages ) %]
-<div class="pages">
-Page
-    [% FOREACH page IN pages %]
-      [% IF ( page.current_page ) %]
-      <span class="current">[% page.page_number %]</span>
-      [% ELSE %]
-      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
-      [% END %]
-    [% END %]
-</div>
-  [% END %]
-[% ELSE %]
-  [% IF ( batch_info ) %]
-    <div class="dialog alert">There are no records in this batch to import.
-    <a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>.</div>
-
-  [% END %]
-[% END %]
-
 </div>
 </div>
 <div class="yui-b">
diff --git a/tools/batch_records_ajax.pl b/tools/batch_records_ajax.pl
index bc0fe82..400358a 100755
--- a/tools/batch_records_ajax.pl
+++ b/tools/batch_records_ajax.pl
@@ -107,6 +107,7 @@ foreach my $record (@$records) {
           || q{},
         score => $#$match > -1 ? $match->[0]->{'score'} : 0,
         match_id => $match_id,
+        diff_url => $match_id ? "/cgi-bin/koha/catalogue/showdiffmarc.pl?importid=$record->{import_record_id}&id=$match_id" : undef
       };
 }
 
-- 
1.7.9.5