Bug 25879: Improve display of guarantor information in the patron entry form
authorOwen Leonard <oleonard@myacpl.org>
Fri, 26 Jun 2020 18:51:15 +0000 (18:51 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Aug 2020 05:55:44 +0000 (07:55 +0200)
This patch makes some changes to the patron entry template to improve
the display of guarantor information.

To test, apply the patch and locate a patron with a "Child" type
category.

 - Edit the patron's record
 - Under "Guarantor information," click the "Search to add" button.
 - Search for and select a patron.
 - The guarantor information should be added to the patron edit
   form. The information should be correct and well formatted.
 - Click the "Remove" link. The guarantor information should be
   removed.
 - Search for an select a guarantor again and save the record.
 - Edit the patron record again. The saved guarantor information should
   look correct.

Looks great!

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/js/members.js

index 0014a0f..e0e8902 100644 (file)
@@ -407,45 +407,30 @@ legend:hover {
 
                                 [% IF show_guarantor || guarantor %]
                                     [% SET possible_relationships = Koha.Preference('borrowerRelationship') %]
-                                    <span id="memberentry_guarantor_anchor">
+                                    <div id="memberentry_guarantor_anchor">
                                         <fieldset id="memberentry_guarantor" class="rows">
                                             <legend>Guarantor information</legend>
 
-                                            <span id="guarantor_relationships">
+                                            <div id="guarantor_relationships">
                                                 [% FOREACH r IN relationships %]
-                                                    <fieldset class="rows">
+                                                    <fieldset>
                                                         <ol>
                                                             [% IF category_type == 'I' %]
                                                                 <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
-                                                                    <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>[% END %]
+                                                                    <span class="label">Organization:</span>
+                                                                    [% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %]
                                                                 </li>
-
                                                                 <li>
-                                                                    <label for="guarantor_surname">Organization name: </label>
-                                                                    <span>[% r.guarantor.surname | html %]</span>
+                                                                    <span class="label">Relationship:</span>
+                                                                    <span>[% r.relationship | html %]</span>
                                                                 </li>
                                                             [% ELSE %]
                                                                 <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
-                                                                    <span class="label">Patron card number:</span>
-                                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor.cardnumber | html %]</a>
+                                                                    <span class="label">Guarantor:</span>
+                                                                    [% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %]
                                                                 </li>
-
-                                                                [% IF r.guarantor.surname %]
-                                                                    <li>
-                                                                        <label for="guarantor_surname">Surname: </label>
-                                                                        <span>[% r.guarantor.surname | html %]</span>
-                                                                    </li>
-                                                                [% END %]
-
-                                                                [% IF r.guarantor.firstname %]
-                                                                    <li>
-                                                                        <label for="guarantor_firstname">First name: </label>
-                                                                        <span>[% r.guarantor.firstname | html %]</span>
-                                                                    </li>
-                                                                [% END %]
-
                                                                 <li>
-                                                                    <label for="relationship">Relationship: </label>
+                                                                    <span class="label">Relationship:</span>
                                                                     <span>[% r.relationship | html %]</span>
                                                                 </li>
 
@@ -467,16 +452,6 @@ legend:hover {
                                                             </li>
 
                                                             <li>
-                                                                <label for="guarantor_surname">Surname: </label>
-                                                                <span class="new_guarantor_surname_text">[% guarantor.surname | html %]</span>
-                                                            </li>
-
-                                                            <li>
-                                                                <label for="guarantor_firstname">First name: </label>
-                                                                <span class="new_guarantor_firstname_text">[% guarantor.firstname | html %]</span>
-                                                            </li>
-
-                                                            <li>
                                                                 [% UNLESS empty_relationship_allowed %]
                                                                     <label for="guarantor_relationship" class="required">Relationship: </label>
                                                                     <select class="new_guarantor_relationship" name="new_guarantor_relationship" required="required">
@@ -503,27 +478,20 @@ legend:hover {
                                                         </ol>
                                                     </fieldset>
                                                 [% END %]
-                                            </span> <!-- #/guarantor_relationships -->
+                                            </div> <!-- #/guarantor_relationships -->
 
-                                            <fieldset class="rows guarantor" id="guarantor_template">
+                                            <fieldset class="guarantor" id="guarantor_template">
                                                 <ol>
                                                     <li class="guarantor-details" data-borrowernumber="0">
-                                                        <span class="label">Patron card number:</span>
-                                                        <span class="new_guarantor_id_text"></span>
+                                                        <span class="label">Guarantor:</span>
+                                                        <a class="new_guarantor_link" href="#" target="blank">
+                                                            <span class="new_guarantor_firstname_text"></span> <span class="new_guarantor_surname_text"></span>
+                                                            (<span class="new_guarantor_id_text"></span>)
+                                                         </a>
                                                         <input type="hidden" class="new_guarantor_id" name="new_guarantor_id" value=""/>
                                                     </li>
 
                                                     <li>
-                                                        <label for="guarantor_surname">Surname: </label>
-                                                        <span class="new_guarantor_surname_text"></span>
-                                                    </li>
-
-                                                    <li>
-                                                        <label for="guarantor_firstname">First name: </label>
-                                                        <span class="new_guarantor_firstname_text"></span>
-                                                    </li>
-
-                                                    <li>
                                                         [% UNLESS empty_relationship_allowed %]
                                                             <label for="guarantor_relationship" class="required">Relationship: </label>
                                                             <select class="new_guarantor_relationship" name="new_guarantor_relationship" required="required">
@@ -545,7 +513,7 @@ legend:hover {
 
                                                     <li>
                                                         <label for="guarantor_cancel">&nbsp;</label>
-                                                        <span><a href="#" class="guarantor_cancel">Remove</a></span>
+                                                        <span><a href="#" class="guarantor_cancel"><i class="fa fa-trash"></i> Remove</a></span>
                                                     </li>
                                                 </ol>
                                             </fieldset>
@@ -591,7 +559,7 @@ legend:hover {
                                                 [% END %]
                                             </ol>
                                         </fieldset> <!-- /#memberentry_guarantor -->
-                                    </span> <!-- #/memberentry_guarantor_anchor -->
+                                    </div> <!-- #/memberentry_guarantor_anchor -->
                                 [% END # /IF show_guarantor || guarantor  %]
 
                                 [% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %]
index 1e102f1..4de6e6e 100644 (file)
@@ -182,6 +182,7 @@ function select_user(borrowernumber, borrower, relationship) {
         if ( guarantor_id ) {
             fieldset.find('.new_guarantor_id').first().val( guarantor_id );
             fieldset.find('.new_guarantor_id_text').first().text( borrower.cardnumber );
+            fieldset.find('.new_guarantor_link').first().attr("href", "/cgi-bin/koha/members/moremember.pl?borrowernumber=" + guarantor_id );
         } else {
             fieldset.find('.guarantor_id').first().hide();
         }