From 0960f2f1617e23762692dbbf895dfe6c7c41edcc Mon Sep 17 00:00:00 2001
From: Katrin Fischer <katrin.fischer.83@web.de>
Date: Thu, 17 Aug 2017 14:51:08 +0000
Subject: [PATCH] Bug 19129 - Clean up Details tab for Organisation patrons

Problem: A patron category "I" would cause display problems
on the details in the intranet. This is because the templates
confused patron category "I" with patron type "I" (organisation).

Patch:
- Cleans up variable confusion by introducint a new
  variable 'is_organisation' instead of using 'I'.
- The template contained code to change the labels below
  the address to 'Organisational phone:" etc., I have removed
  this part as it does not match the edit form anymore.
- Initials, date of birth and gender are still hidden for
  organisation - matching the edit form.

Bonus:
- The patron category description was missing on the
  right and left side of the details tab. Now it displays.
- Fixes some html issues:
  - doubled up class attribute in a tag
  - doubled up </li></li>

To test:
- Create 3 patrons
  - patron category code doesn't matter, but category type organisation
  - patron category code 'I', category type NOT organisation
  - patron category code NOT I, category type NOT organisaton
- Check details tab in patron account in staff for all 3
  - Verify patron category description shows correctly
  - Verify information added to the account displays correctly
    (phone numbers, emails, ...)
---
 .../intranet-tmpl/prog/en/includes/circ-menu.inc   |  7 +-
 .../prog/en/includes/members-toolbar.inc           |  4 +-
 .../prog/en/modules/members/moremember.tt          | 74 ++++++++++------------
 3 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
index 8bc4a5c..e621d64 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
@@ -23,7 +23,8 @@
         [% INCLUDE 'member-display-address-style-us.inc' %]
     [% END %]
 
-    [% IF ( phone ) %]<li class="patronphone">
+    [% IF ( phone || mobile || phonepro ) %]<li class="patronphone">
+    [% IF ( phone ) %]
         <a href="tel:[% phone | url %]">[% phone | html %]</a>
     [% ELSE %]
         [% IF ( mobile ) %]
@@ -32,8 +33,8 @@
             [% IF ( phonepro ) %]
                 <a href="tel:[% phonepro | url %]">[% phonepro | html %]</a>
             [% END %]
-        [% END %]</li>
-    [% END %]
+        [% END %]
+    [% END %]</li>[% END %]
     [% IF ( email ) %]
         <li class="email"> <a href="mailto:[% email | url %]" title="[% email | html %]">[% email | html %]</a></li>
     [% ELSE %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
index 5b467ac..7b91418 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
@@ -199,7 +199,7 @@ function searchToHold(){
                 [% IF ( is_child ) %]
                     <li><a id="updatechild" href="#">Update child to adult patron</a></li>
                 [% ELSE %]
-                    <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="Patron is an adult" id="updatechild" href="#">Update child to adult patron</a></li></li>
+                    <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="Patron is an adult" id="updatechild" href="#">Update child to adult patron</a></li>
                 [% END %]
                 [% IF Koha.Preference('intranetreadinghistory') %]
                     [%IF ( privacy == 2 ) %]
@@ -249,7 +249,7 @@ function searchToHold(){
                 </div>
                 <div class="modal-footer">
                     <button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button>
-                    <button class="btn btn-default deny" href="#" class="cancel" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> Cancel</button>
+                    <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> Cancel</button>
                 </div>
             </form>
         </div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
index fd6b5e9..589acd6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -218,12 +218,12 @@ function validate1(date) {
     </div>
     [% END %]
 
-<h3>[% UNLESS ( I ) %]
+<h3>[% UNLESS ( is_organisation ) %]
    [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
  <div class="yui-u first">
 <div id="patron-information" style="padding : .5em;">
 
-     [% UNLESS ( I ) %][% IF ( othernames ) %]&ldquo;[% othernames | html %]&rdquo;[% END %]
+    [% IF ( othernames ) %]&ldquo;[% othernames | html %]&rdquo;[% END %]
 
     <div class = "address">
         [% IF Koha.Preference( 'AddressFormat' ) %]
@@ -234,46 +234,40 @@ function validate1(date) {
     </div>
 		    
 	<div class="rows">
-		<ol>
-        [% IF ( I ) %]
-            [% IF ( phonepro ) %]<li><span class="label">Organization phone: </span><a href="tel:[% phonepro %]">[% phonepro | html %]</a></li>[% END %]
-            [% IF ( emailpro ) %]<li class="email"><span class="label">Organization email: </span>[% emailpro | html %]</li>[% END %]
-        [% ELSE %]
-            [% IF ( phone ) %]<li><span class="label">Primary phone: </span><a href="tel:[% phone %]">[% phone | html %]</a></li>[% END %]
-            [% IF ( phonepro ) %]<li><span class="label">Secondary phone: </span><a href="tel:[% phonepro %]">[% phonepro | html %]</a></li>[% END %]
-            [% IF ( mobile ) %]<li><span class="label">Other phone: </span><a href="tel:[% mobile %]">[% mobile | html %]</a></li>[% END %]
-        [% END %]
-
-	[% IF ( fax ) %]<li><span class="label">Fax: </span>[% fax %]</li>[% END %]
-    [% UNLESS ( I ) %]
+    <ol>
+        [% IF ( phone ) %]<li><span class="label">Primary phone: </span><a href="tel:[% phone %]">[% phone | html %]</a></li>[% END %]
+        [% IF ( phonepro ) %]<li><span class="label">Secondary phone: </span><a href="tel:[% phonepro %]">[% phonepro | html %]</a></li>[% END %]
+        [% IF ( mobile ) %]<li><span class="label">Other phone: </span><a href="tel:[% mobile %]">[% mobile | html %]</a></li>[% END %]
+        [% IF ( fax ) %]<li><span class="label">Fax: </span>[% fax %]</li>[% END %]
         [% IF ( email ) %]<li class="email"><span class="label">Primary email:</span><a title="[% email %]" href="mailto:[% email | url %]">[% email | html %]</a></li>[% END %]
         [% IF ( emailpro ) %]<li class="email"><span class="label">Secondary email: </span><a title="[% emailpro %]" href="mailto:[% emailpro | url %]">[% emailpro | html %]</a></li>[% END %]
-    [% END %]
-    [% IF ( initials ) %]<li><span class="label">Initials: </span>[% initials %]</li>[% END %]
-    [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %] ([% age %] years)</li>[% END %]
-    [% IF ( sex ) %]<li><span class="label">Gender:</span>
-    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
-    </li>[% END %][% END %]
-    [% IF guarantees %]
-        <li>
-            <span class="label">Guarantees:</span>
-            <ul>
-                [% FOREACH guarantee IN guarantees %]
-                    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
+        [% UNLESS ( is_organisation ) %]
+            [% IF ( initials ) %]<li><span class="label">Initials: </span>[% initials %]</li>[% END %]
+            [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %] ([% age %] years)</li>[% END %]
+            [% IF ( sex ) %]<li><span class="label">Gender:</span>
+                [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
+            </li>[% END %]
+        [% END %]
+        [% IF guarantees %]
+            <li>
+                <span class="label">Guarantees:</span>
+                <ul>
+                    [% FOREACH guarantee IN guarantees %]
+                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
+                    [% END %]
+                </ul>
+            </li>
+        [% ELSIF guarantor %]
+            <li>
+                <span class="label">Guarantor:</span>
+                [% IF guarantor.borrowernumber %]
+                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.borrowernumber %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
+                [% ELSE %]
+                    [% guarantor.firstname | html %] [% guarantor.surname | html %]
                 [% END %]
-            </ul>
-        </li>
-    [% ELSIF guarantor %]
-        <li>
-            <span class="label">Guarantor:</span>
-            [% IF guarantor.borrowernumber %]
-                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.borrowernumber %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
-            [% ELSE %]
-                [% guarantor.firstname | html %] [% guarantor.surname | html %]
-            [% END %]
-        </li>
-    [% END %]
-</ol>
+            </li>
+        [% END %]
+    </ol>
 </div>
       <div class="action">
         [% IF ( guarantor.borrowernumber ) %]
@@ -400,7 +394,7 @@ function validate1(date) {
 <ol>
     <li><span class="label">Card number: </span>[% cardnumber %]</li>
 	<li><span class="label">Borrowernumber: </span> [% borrowernumber %]</li>
-    <li><span class="label">Category: </span>[% description %] ([% categorycode %])</li>
+    <li><span class="label">Category: </span>[% categoryname %] ([% categorycode %])</li>
     <li><span class="label">Registration date: </span>[% dateenrolled | $KohaDates %]</li>
     
     <li><span class="label">Expiration date: </span>
-- 
2.1.4