Bug 16847: Remove C4::Members::GetTitles
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 4 Jul 2016 14:03:18 +0000 (15:03 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 22 Jul 2016 17:23:42 +0000 (17:23 +0000)
This subroutine just reads the content of a pref, split it, add an
empty string and returns.
It is not really useful and the code in the script (memberentry.pl) uses
the only occurrence of CGI::popup_menu
Let's remove it and build the dropdown list in the template.

Test plan:
1/ Empty BorrowersTitles, edit a patron and confirm that the "Salutation"
does not appear
2/ Fill BorrowersTitles with "Mr|Mrs|Miss|Ms", edit a patron and confirm
that the "Salutation" dropdown list is correctly filled.
The default option should be selected if you are editing a patron with a
title defined.
This should also be tested at the OPAC.

Followed test pan, works as expected in Staff and OPAC
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Members.pm
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt
members/memberentry.pl
opac/opac-memberentry.pl

index 53ca664..061172f 100644 (file)
@@ -71,7 +71,6 @@ BEGIN {
 
         &GetAge
         &GetSortDetails
-        &GetTitles
 
         &GetHideLostItemsPreference
 
@@ -1640,26 +1639,6 @@ EOF
     return 0;
 }
 
-=head2 GetTitles (OUEST-PROVENCE)
-
-  ($borrowertitle)= &GetTitles();
-
-Looks up the different title . Returns array  with all borrowers title
-
-=cut
-
-sub GetTitles {
-    my @borrowerTitle = split (/,|\|/,C4::Context->preference('BorrowersTitles'));
-    unshift( @borrowerTitle, "" );
-    my $count=@borrowerTitle;
-    if ($count == 1){
-        return ();
-    }
-    else {
-        return ( \@borrowerTitle);
-    }
-}
-
 =head2 GetHideLostItemsPreference
 
   $hidelostitemspref = &GetHideLostItemsPreference($borrowernumber);
index 5dfd5a2..20725bd 100644 (file)
@@ -254,7 +254,7 @@ $(document).ready(function() {
                <ol>
                [% UNLESS ( I ) %]
         [% UNLESS notitle %]
-               [% IF ( title_cgipopup ) %]
+        [% IF Koha.Preference('BorrowersTitles') %]
             <li>
             [% IF ( mandatorytitle ) %]
                 <label for="btitle" class="required">
@@ -262,7 +262,16 @@ $(document).ready(function() {
                 <label for="btitle">
             [% END %]
             Salutation: </label>
-            [% borrotitlepopup %]
+            <select id="btitle" name="title">
+                <option value=""></option>
+                [% FOREACH t IN Koha.Preference('BorrowersTitles').split('\|') %]
+                    [% IF btitle == t %]
+                        <option value="[% t %]" selected="selected">[% t %]</option>
+                    [% ELSE %]
+                        <option value="[% t %]">[% t %]</option>
+                    [% END %]
+                [% END %]
+            </select>
             [% IF ( mandatorytitle ) %]<span class="required">Required</span>[% END %]
             </li>
                [% END %]
index b70ab9e..ca0358d 100644 (file)
                                 <legend id="identity_legend">Identity</legend>
 
                                 <ol>
-                                    [% UNLESS hidden.defined('title') || !member_titles %]
+                                    [% UNLESS hidden.defined('title') || !Koha.Preference('BorrowersTitles') %]
                                         <li>
                                             [% IF mandatory.defined('title') %]
                                                 <label for="borrower_title" class="required">
                                             Salutation:</label>
 
                                             <select id="borrower_title" name="borrower_title">
-                                                [% FOREACH mt IN member_titles %]
+                                                [% FOREACH mt IN Koha.Preference('BorrowersTitles').split('\|') %]
                                                     [% IF mt == borrower.title %]
                                                         <option value="[% mt %]" selected="selected">[% mt %]</option>
                                                     [% ELSE %]
index 0987168..32b2402 100755 (executable)
@@ -546,14 +546,6 @@ $template->param(
 
 my $default_borrowertitle = '';
 unless ( $op eq 'duplicate' ) { $default_borrowertitle=$data{'title'} }
-my($borrowertitle)=GetTitles();
-$template->param( title_cgipopup => 1) if ($borrowertitle);
-my $borrotitlepopup = CGI::popup_menu(-name=>'title',
-        -id => 'btitle',
-        -values=>$borrowertitle,
-        -override => 1,
-        -default=>$default_borrowertitle
-        );    
 
 my @relationships = split /,|\|/, C4::Context->preference('borrowerRelationship');
 my @relshipdata;
@@ -681,7 +673,7 @@ $template->param(
   borrowernumber  => $borrowernumber, #register number
   guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
   relshiploop => \@relshipdata,
-  borrotitlepopup => $borrotitlepopup,
+  btitle=> $default_borrowertitle,
   guarantorinfo   => $guarantorinfo,
   flagloop  => \@flagdata,
   category_type =>$category_type,
index de157ef..b73ee1b 100755 (executable)
@@ -68,7 +68,6 @@ $template->param(
     action            => $action,
     hidden            => GetHiddenFields( $mandatory, 'registration' ),
     mandatory         => $mandatory,
-    member_titles     => GetTitles() || undef,
     branches          => GetBranchesLoop(),
     OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
 );