Bug 14790 - Add OPAC view link to items editor
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / manage-marc-import.tt
index 98b2c08..e1119d1 100644 (file)
@@ -1,3 +1,30 @@
+[% BLOCK final_match_link %]
+    [% IF ( record.record_type == 'biblio' ) %]
+        <a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.final_match_id %]">[% record.final_match_id %]</a>
+    [% ELSIF ( record.record_type == 'auth' ) %]
+        <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record.final_match_id %]">[% record.final_match_id %]</a>
+    [% END %]
+[% END %]
+[% BLOCK match_link %]
+    [% IF ( record_lis.match_id ) %]
+        <tr>
+            <td />
+            [% IF ( record.record_type == 'biblio' ) %]
+                <td colspan="5">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
+            [% ELSIF ( record.record_type == 'auth' ) %]
+                <td colspan="5">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a> |
+        <a href="/cgi-bin/koha/authorities/merge.pl?mergereference=breeding&authid=[% record_lis.match_id %]&authid=[% record_lis.import_record_id %]">Merge</a>
+                </td>
+            [% END %]
+        </tr>
+    [% ELSIF ( record.record_type == 'auth') %]
+        <tr data-authid="[% record_lis.import_record_id %]">
+            <td />
+            <td  colspan="4"><a href="#" class="merge_auth">Search for a record to merge in a new window</a></td>
+        </tr>
+    [% END %]
+[% END %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
 [% IF ( import_batch_id ) %]
 [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
 [% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
+var MSG_CONFIRM_UNDO_IMPORT = _("Are you sure you want to undo the import of this batch into the catalog?");
+var MSG_CONFIRM_DELETE = _("Are you sure you want to permanently delete this batch?");
 
 $(document).ready(function(){
   $("#staged-record-matching-rules select").change(function(){
@@ -39,7 +68,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 %] } );
@@ -62,9 +92,7 @@ $(document).ready(function(){
             [% END %]
 
             $('td:eq(1)', nRow).html(
-                '<a href="javascript:void(0)" onclick="show_marc('
-                + aData['import_record_id']
-                + ')">' + aData['citation'] + '</a>'
+                '<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(
@@ -84,50 +112,50 @@ $(document).ready(function(){
             );
 
             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(
-                    [% IF ( record_type == 'auth' ) -%]
-                    _("Matches authority ")
-                    [%- ELSE -%]
-                    _("Matches biblio ")
-                    [%- END %]
-                    + aData['match_id']
-                    + " (" + _("score") + "="
-                    + aData['score']
-                    + '):' + '<a target="_blank" href="' + record_details_url
-                    + aData['match_id'] + '">' + aData['match_citation'] + '</a>'
+                    matching_msg.format(aData['match_id'], aData['score'],
+                    '<a target="_blank" href="' + record_details_url
+                    + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
                 );
             }
-
-            $('td:eq(5)', nRow).html(
+            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>");
+    });
 });
 
-function show_marc( id ) {
-    var page = "/cgi-bin/koha/catalogue/showmarc.pl?importid=" + id;
-
-    var $dialog = $('<div></div>')
-        .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
-        .dialog({
-            autoOpen: false,
-            modal: true,
-            height: 625,
-            width: 500,
-            title: _("MARC Preview")
-        });
-
-    $dialog.dialog('open');
-}
 //]]>
 </script>
 <style type="text/css">
        #jobpanel,#jobstatus,#jobfailed { display : none; }
        #jobstatus { margin:.4em; }
-    #jobprogress{ width:200px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; } span.change-status { font-style:italic; color:#666; display:none; }</style>
+    #jobprogress{ width:200px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; } span.change-status { font-style:italic; color:#666; display:none; }#marcPreview { width : 80%; margin-left : -40%; } @media (max-width: 767px) { #marcPreview { margin: 0; width : auto; } }
+</style>
 </head>
 <body id="tools_manage-marc-import" class="tools">
 [% INCLUDE 'header.inc' %]
@@ -168,6 +196,10 @@ function show_marc( id ) {
   <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div>
 [% END %]
 
+[% IF ( did_delete ) %]
+  <div class="dialog message">Import batch deleted successfully</div>
+[% END %]
+
 [% UNLESS ( batch_list ) %]
    [% UNLESS ( batch_info ) %]
    <div class="dialog message">
@@ -280,7 +312,8 @@ function show_marc( id ) {
             [% END %]
         [% END %]
     </li>
-    
+
+    [% IF ( record_type == 'biblio' ) %]
     <li>
         [% IF ( can_commit ) %]
             <label for="item_action">Item processing:</label>
@@ -300,6 +333,7 @@ function show_marc( id ) {
             [% END %]
         [% END %]
     </li>
+    [% END %]
   </ol>
 [% IF ( can_commit ) %]<fieldset class="action"><input type="submit" value="Apply different matching rules" class="button" /></fieldset></form>[% END %]
 </fieldset>
@@ -335,7 +369,7 @@ function show_marc( id ) {
     <input type="hidden" name="runinbackground" value="" />
     <input type="hidden" name="completedJobID" value="" />
     <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
-    <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" onclick="return submitBackgroundJob(this.form);" /></fieldset>
+    <fieldset class="action"><input type="submit" class="button" name="mainformsubmit" value="Undo import into catalog" onclick="return confirm(MSG_CONFIRM_UNDO_IMPORT) && submitBackgroundJob(this.form);" /></fieldset>
   </form>
   <div id="jobpanel"><div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
      <div id="jobfailed"></div></div>
@@ -347,17 +381,21 @@ function show_marc( id ) {
   <tr><td>Number of records added</td><td>[% num_added %]</td></tr>
   <tr><td>Number of records updated</td><td>[% num_updated %]</td></tr>
   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
-  <tr><td>Number of items added</td><td>[% num_items_added %]</td></tr>
-  <tr><td>Number of items replaced</td><td>[% num_items_replaced %]</td></tr>
-  <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored %]</td></tr>
+  [% IF ( record_type == 'biblio' ) %]
+      <tr><td>Number of items added</td><td>[% num_items_added %]</td></tr>
+      <tr><td>Number of items replaced</td><td>[% num_items_replaced %]</td></tr>
+      <tr><td>Number of items ignored because of duplicate barcode</td><td>[% num_items_errored %]</td></tr>
+  [% END %]
   </table>
   [% END %]
   [% IF ( did_revert ) %]
   <div class="dialog message">Success: Import reversed</div>
   <table>
   <tr><td>Number of records deleted</td><td>[% num_deleted %]</td></tr>
-  <tr><td>Number of items deleted</td><td>[% num_items_deleted %]</td></tr>
-  <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors %]</td></tr>
+  [% IF ( record_type == 'biblio' ) %]
+    <tr><td>Number of items deleted</td><td>[% num_items_deleted %]</td></tr>
+    <tr><td>Number of records not deleted due to items on loan</td><td>[% num_errors %]</td></tr>
+  [% END %]
   <tr><td>Number of records changed back</td><td>[% num_reverted %]</td></tr>
   <tr><td>Number of records ignored</td><td>[% num_ignored %]</td></tr>
   </table>
@@ -391,7 +429,7 @@ Page
     <th>Action</th>
   </tr>
   [% FOREACH batch_lis IN batch_list %]
-  [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+    <tr>
     <td>[% batch_lis.import_batch_id %]</td>
     <td><a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]">[% batch_lis.file_name %]</a></td>
     <td>[% batch_lis.comments %]</td>
@@ -416,11 +454,18 @@ Page
     <td>[% batch_lis.upload_timestamp %]</td>
     <td>[% batch_lis.num_records %]</td>
     <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;op=create_labels">(Create label batch)</a>[% END %]</td>
-    <td>[% IF ( batch_lis.can_clean ) %]
+    <td class="actions">
+        [% IF ( batch_lis.can_clean ) %]
           <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" >
             <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
             <input type="hidden" name="op" value="clean-batch" />
-            <input type="submit" class="button" value="Clean" onclick="return confirm(MSG_CONFIRM_CLEAN);" />
+            <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_CLEAN);"><i class="fa fa-eraser"></i> Clean</button>
+          </form>
+        [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
+          <form method="post" action="/cgi-bin/koha/tools/manage-marc-import.pl" name="delete_batch_[% batch_lis.import_batch_id %]" id="delete_batch_[% batch_lis.import_batch_id %]">
+            <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
+            <input type="hidden" name="op" value="delete-batch" />
+            <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_DELETE);"><i class="fa fa-trash"></i> Delete</button>
           </form>
         [% END %]
     </td>
@@ -450,10 +495,24 @@ 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>
+
+    <div id="marcPreview" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
+        <div class="modal-header">
+            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
+            <h3 id="marcPreviewLabel">MARC preview</h3>
+        </div>
+        <div class="modal-body">
+            <div id="loading"> <img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /> Loading </div>
+        </div>
+        <div class="modal-footer">
+            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
+        </div>
+    </div>
 [% END %]
 
 </div>