From 322152a1528475cd9074465b7a8081ce47510a80 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Wed, 1 Apr 2015 13:28:20 +0200
Subject: [PATCH] Bug 9067: Hide item related strings when importing staged
 authority records

On importing authority records, the items related string should not be
displayed.

Test plan:
1/ Import an authority record
2/ Confirm the item related string are not displayed.
3/ Before this script, the record_type param was lost just after
importing the records. Now you should see
"Processing authority records" of "Processing bibliographic records" in
the "MARC staging results"
4/ Revert the import and check there is not item related strings.

No behavior should exist on importing bibliographic records.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
---
 .../prog/en/modules/tools/manage-marc-import.tt        | 18 ++++++++++++------
 .../prog/en/modules/tools/stage-marc-import.tt         |  4 +++-
 tools/stage-marc-import.pl                             |  7 +++++--
 3 files changed, 20 insertions(+), 9 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 0b10962..67cf116 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
@@ -306,7 +306,8 @@ $(document).ready(function(){
             [% END %]
         [% END %]
     </li>
-    
+
+    [% IF ( record_type == 'biblio' ) %]
     <li>
         [% IF ( can_commit ) %]
             <label for="item_action">Item processing:</label>
@@ -326,6 +327,7 @@ $(document).ready(function(){
             [% 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>
@@ -373,17 +375,21 @@ $(document).ready(function(){
   <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>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt
index b9b17f5..25d11ed 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt
@@ -66,7 +66,9 @@ function CheckForm(f) {
           <li>Did not check for matches with existing records in catalog</li>
         [% END %]
     [% END %]
-	<li>[% num_items %] item records found and staged</li>
+    [% IF record_type == 'biblio' %]
+        <li>[% num_items %] item records found and staged</li>
+    [% END %]
 	[% IF ( label_batch ) %]
 	  <li>New label batch created: # [% label_batch %] </li>
     [% END %]
diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl
index af1cdc3..897a5ca 100755
--- a/tools/stage-marc-import.pl
+++ b/tools/stage-marc-import.pl
@@ -67,8 +67,11 @@ my ($template, $loggedinuser, $cookie)
 					debug => 1,
 					});
 
-$template->param(SCRIPT_NAME => $ENV{'SCRIPT_NAME'},
-						uploadmarc => $fileID);
+$template->param(
+    SCRIPT_NAME => $ENV{'SCRIPT_NAME'},
+    uploadmarc  => $fileID,
+    record_type => $record_type,
+);
 
 my %cookies = parse CGI::Cookie($cookie);
 my $sessionID = $cookies{'CGISESSID'}->value;
-- 
1.9.1