View | Details | Raw Unified | Return to bug 10020
Collapse All | Expand All

(-)a/C4/Members.pm (-50 lines)
Lines 136-143 BEGIN { Link Here
136
        &checkuserpassword
136
        &checkuserpassword
137
        &Check_Userid
137
        &Check_Userid
138
        &Generate_Userid
138
        &Generate_Userid
139
        &fixEthnicity
140
        &ethnicitycategories
141
        &fixup_cardnumber
139
        &fixup_cardnumber
142
        &checkcardnumber
140
        &checkcardnumber
143
    );
141
    );
Lines 1724-1777 sub GetBorrowercategoryList { Link Here
1724
    return $data;
1722
    return $data;
1725
}    # sub getborrowercategory
1723
}    # sub getborrowercategory
1726
1724
1727
=head2 ethnicitycategories
1728
1729
  ($codes_arrayref, $labels_hashref) = &ethnicitycategories();
1730
1731
Looks up the different ethnic types in the database. Returns two
1732
elements: a reference-to-array, which lists the ethnicity codes, and a
1733
reference-to-hash, which maps the ethnicity codes to ethnicity
1734
descriptions.
1735
1736
=cut
1737
1738
#'
1739
1740
sub ethnicitycategories {
1741
    my $dbh = C4::Context->dbh;
1742
    my $sth = $dbh->prepare("Select code,name from ethnicity order by name");
1743
    $sth->execute;
1744
    my %labels;
1745
    my @codes;
1746
    while ( my $data = $sth->fetchrow_hashref ) {
1747
        push @codes, $data->{'code'};
1748
        $labels{ $data->{'code'} } = $data->{'name'};
1749
    }
1750
    return ( \@codes, \%labels );
1751
}
1752
1753
=head2 fixEthnicity
1754
1755
  $ethn_name = &fixEthnicity($ethn_code);
1756
1757
Takes an ethnicity code (e.g., "european" or "pi") and returns the
1758
corresponding descriptive name from the C<ethnicity> table in the
1759
Koha database ("European" or "Pacific Islander").
1760
1761
=cut
1762
1763
#'
1764
1765
sub fixEthnicity {
1766
    my $ethnicity = shift;
1767
    return unless $ethnicity;
1768
    my $dbh       = C4::Context->dbh;
1769
    my $sth       = $dbh->prepare("Select name from ethnicity where code = ?");
1770
    $sth->execute($ethnicity);
1771
    my $data = $sth->fetchrow_hashref;
1772
    return $data->{'name'};
1773
}    # sub fixEthnicity
1774
1775
=head2 GetAge
1725
=head2 GetAge
1776
1726
1777
  $dateofbirth,$date = &GetAge($date);
1727
  $dateofbirth,$date = &GetAge($date);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt (-2 lines)
Lines 49-56 Link Here
49
[% CASE 'contactfirstname'    %]<span>Contact: First name</span>
49
[% CASE 'contactfirstname'    %]<span>Contact: First name</span>
50
[% CASE 'contacttitle'        %]<span>Contact: Title</span>
50
[% CASE 'contacttitle'        %]<span>Contact: Title</span>
51
[% CASE 'relationship'        %]<span>Contact: Relationship</span>
51
[% CASE 'relationship'        %]<span>Contact: Relationship</span>
52
[% CASE 'ethnicity'           %]<span>Ethnicity</span>
53
[% CASE 'ethnotes'            %]<span>Ethnicity notes</span>
54
[% CASE 'sex'                 %]<span>Sex</span>
52
[% CASE 'sex'                 %]<span>Sex</span>
55
[% CASE 'altcontactfirstname' %]<span>Alternate contact: First name</span>
53
[% CASE 'altcontactfirstname' %]<span>Alternate contact: First name</span>
56
[% CASE 'altcontactsurname'   %]<span>Alternate contact: Surname</span>
54
[% CASE 'altcontactsurname'   %]<span>Alternate contact: Surname</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt (-4 lines)
Lines 49-58 Link Here
49
    <li><span class="label">Initials: </span>[% initials %]</li>
49
    <li><span class="label">Initials: </span>[% initials %]</li>
50
    <li><span class="label">Date of birth:</span>[% dateofbirth %]</li>
50
    <li><span class="label">Date of birth:</span>[% dateofbirth %]</li>
51
    <li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]</li>[% END %]
51
    <li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]</li>[% END %]
52
    [% IF ( printethnicityline ) %]
53
    <li><span class="label">Ethnicity:</span>[% ethnicity %]</li>
54
    <li><span class="label">Ethnicity notes: </span>[% ethnotes %]</li>
55
    [% END %]
56
    [% IF ( isguarantee ) %]
52
    [% IF ( isguarantee ) %]
57
        [% IF ( guaranteeloop ) %]
53
        [% IF ( guaranteeloop ) %]
58
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
54
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-4 lines)
Lines 218-227 function validate1(date) { Link Here
218
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
218
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
219
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
219
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
220
    </li>[% END %][% END %]
220
    </li>[% END %][% END %]
221
    [% IF ( printethnicityline ) %]
222
    <li><span class="label">Ethnicity:</span>[% ethnicity %]</li>
223
    <li><span class="label">Ethnicity notes: </span>[% ethnotes %]</li>
224
    [% END %]
225
    [% IF ( isguarantee ) %]
221
    [% IF ( isguarantee ) %]
226
        [% IF ( guaranteeloop ) %]
222
        [% IF ( guaranteeloop ) %]
227
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
223
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
(-)a/members/memberentry.pl (-16 / +1 lines)
Lines 92-98 my @errors; Link Here
92
my $default_city;
92
my $default_city;
93
# $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2
93
# $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2
94
my $check_categorytype=$input->param('check_categorytype');
94
my $check_categorytype=$input->param('check_categorytype');
95
# NOTE: Alert for ethnicity and ethnotes fields, they are invalid in all borrowers form
96
my $borrower_data;
95
my $borrower_data;
97
my $NoUpdateLogin;
96
my $NoUpdateLogin;
98
my $userenv = C4::Context->userenv;
97
my $userenv = C4::Context->userenv;
Lines 509-534 if(!defined($data{'sex'})){ Link Here
509
}
508
}
510
509
511
##Now all the data to modify a member.
510
##Now all the data to modify a member.
512
my ($categories,$labels)=ethnicitycategories();
513
  
514
my $ethnicitycategoriescount=$#{$categories};
515
my $ethcatpopup;
516
if ($ethnicitycategoriescount>=0) {
517
  $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
518
        -id => 'ethnicity',
519
        -tabindex=>'',
520
        -values=>$categories,
521
        -default=>$data{'ethnicity'},
522
        -labels=>$labels);
523
  $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
524
}
525
511
526
my @typeloop;
512
my @typeloop;
527
my $no_categories = 1;
513
my $no_categories = 1;
528
my $no_add;
514
my $no_add;
529
foreach (qw(C A S P I X)) {
515
foreach (qw(C A S P I X)) {
530
    my $action="WHERE category_type=?";
516
    my $action="WHERE category_type=?";
531
	($categories,$labels)=GetborCatFromCatType($_,$action);
517
    my ($categories,$labels)=GetborCatFromCatType($_,$action);
532
    if(scalar(@$categories) > 0){ $no_categories = 0; }
518
    if(scalar(@$categories) > 0){ $no_categories = 0; }
533
	my @categoryloop;
519
	my @categoryloop;
534
	foreach my $cat (@$categories){
520
	foreach my $cat (@$categories){
Lines 711-717 $template->param( Link Here
711
  nodouble  => $nodouble,
697
  nodouble  => $nodouble,
712
  borrowernumber  => $borrowernumber, #register number
698
  borrowernumber  => $borrowernumber, #register number
713
  guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
699
  guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
714
  ethcatpopup => $ethcatpopup,
715
  relshiploop => \@relshipdata,
700
  relshiploop => \@relshipdata,
716
  city_loop => $city_arrayref,
701
  city_loop => $city_arrayref,
717
  borrotitlepopup => $borrotitlepopup,
702
  borrotitlepopup => $borrotitlepopup,
(-)a/members/moremember.pl (-5 lines)
Lines 153-159 if ( IsDebarred($borrowernumber) ) { Link Here
153
    }
153
    }
154
}
154
}
155
155
156
$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
157
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
156
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
158
157
159
my $catcode;
158
my $catcode;
Lines 165-174 if ( $category_type eq 'C') { Link Here
165
   $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
164
   $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
166
}
165
}
167
166
168
169
if ( $data->{'ethnicity'} || $data->{'ethnotes'} ) {
170
    $template->param( printethnicityline => 1 );
171
}
172
my ( $count, $guarantees ) = GetGuarantees( $data->{'borrowernumber'} );
167
my ( $count, $guarantees ) = GetGuarantees( $data->{'borrowernumber'} );
173
if ( $count ) {
168
if ( $count ) {
174
    $template->param( isguarantee => 1 );
169
    $template->param( isguarantee => 1 );
(-)a/opac/opac-user.pl (-2 lines)
Lines 83-90 my ( $borr ) = GetMemberDetails( $borrowernumber ); Link Here
83
my (  $today_year,   $today_month,   $today_day) = Today();
83
my (  $today_year,   $today_month,   $today_day) = Today();
84
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
84
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
85
85
86
$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} );
87
88
my $debar = IsDebarred($borrowernumber);
86
my $debar = IsDebarred($borrowernumber);
89
my $userdebarred;
87
my $userdebarred;
90
88
(-)a/t/Borrower.t (-10 / +2 lines)
Lines 106-113 my $borrower = Koha::Borrower->new( Link Here
106
        guarantorid         => '123454321',
106
        guarantorid         => '123454321',
107
        borrowernotes       => 'borrowernotes',
107
        borrowernotes       => 'borrowernotes',
108
        relationship        => 'myRelationship',
108
        relationship        => 'myRelationship',
109
        ethnicity           => undef,
110
        ethnotes            => undef,
111
        sex                 => 'M',
109
        sex                 => 'M',
112
        password            => 'hfkurhfe976634èj!',
110
        password            => 'hfkurhfe976634èj!',
113
        flags               => '55555',
111
        flags               => '55555',
Lines 132-138 my $borrower = Koha::Borrower->new( Link Here
132
130
133
#borrower Accessor tests
131
#borrower Accessor tests
134
subtest 'Accessor tests' => sub {
132
subtest 'Accessor tests' => sub {
135
    plan tests => 67;
133
    plan tests => 65;
136
    is( $borrower->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
134
    is( $borrower->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
137
    is( $borrower->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
135
    is( $borrower->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
138
    is( $borrower->surname,        'mySurname',                       'surname accessor returns correct value' );
136
    is( $borrower->surname,        'mySurname',                       'surname accessor returns correct value' );
Lines 179-186 subtest 'Accessor tests' => sub { Link Here
179
    is( $borrower->guarantorid,         '123454321',             'guarantorid accessor returns correct value' );
177
    is( $borrower->guarantorid,         '123454321',             'guarantorid accessor returns correct value' );
180
    is( $borrower->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
178
    is( $borrower->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
181
    is( $borrower->relationship,        'myRelationship',        'relationship accessor returns correct value' );
179
    is( $borrower->relationship,        'myRelationship',        'relationship accessor returns correct value' );
182
    is( $borrower->ethnicity,           undef,                   'ethnicity accessor returns correct value' );
183
    is( $borrower->ethnotes,            undef,                   'ethnotes accessor returns correct value' );
184
    is( $borrower->sex,                 'M',                     'sex accessor returns correct value' );
180
    is( $borrower->sex,                 'M',                     'sex accessor returns correct value' );
185
    is( $borrower->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
181
    is( $borrower->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
186
    is( $borrower->flags,               '55555',                 'flags accessor returns correct value' );
182
    is( $borrower->flags,               '55555',                 'flags accessor returns correct value' );
Lines 204-210 subtest 'Accessor tests' => sub { Link Here
204
200
205
#borrower Set tests
201
#borrower Set tests
206
subtest 'Set tests' => sub {
202
subtest 'Set tests' => sub {
207
    plan tests => 67;
203
    plan tests => 65;
208
204
209
    $borrower->set(
205
    $borrower->set(
210
        {
206
        {
Lines 254-261 subtest 'Set tests' => sub { Link Here
254
            guarantorid         => '223454321',
250
            guarantorid         => '223454321',
255
            borrowernotes       => 'Sborrowernotes',
251
            borrowernotes       => 'Sborrowernotes',
256
            relationship        => 'SmyRelationship',
252
            relationship        => 'SmyRelationship',
257
            ethnicity           => undef,
258
            ethnotes            => undef,
259
            sex                 => 'F',
253
            sex                 => 'F',
260
            password            => 'zerzerzer#',
254
            password            => 'zerzerzer#',
261
            flags               => '666666',
255
            flags               => '666666',
Lines 324-331 subtest 'Set tests' => sub { Link Here
324
    is( $borrower->guarantorid,         '223454321',                        'guarantorid field set ok' );
318
    is( $borrower->guarantorid,         '223454321',                        'guarantorid field set ok' );
325
    is( $borrower->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
319
    is( $borrower->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
326
    is( $borrower->relationship,        'SmyRelationship',                  'relationship field set ok' );
320
    is( $borrower->relationship,        'SmyRelationship',                  'relationship field set ok' );
327
    is( $borrower->ethnicity,           undef,                              'ethnicity field set ok' );
328
    is( $borrower->ethnotes,            undef,                              'ethnotes field set ok' );
329
    is( $borrower->sex,                 'F',                                'sex field set ok' );
321
    is( $borrower->sex,                 'F',                                'sex field set ok' );
330
    is( $borrower->password,            'zerzerzer#',                       'password field set ok' );
322
    is( $borrower->password,            'zerzerzer#',                       'password field set ok' );
331
    is( $borrower->flags,               '666666',                           'flags field set ok' );
323
    is( $borrower->flags,               '666666',                           'flags field set ok' );
(-)a/t/db_dependent/Members.t (-4 lines)
Lines 41-47 my $BRANCHCODE = 'CPL'; Link Here
41
my $CHANGED_FIRSTNAME = "Marry Ann";
41
my $CHANGED_FIRSTNAME = "Marry Ann";
42
my $EMAIL             = "Marie\@email.com";
42
my $EMAIL             = "Marie\@email.com";
43
my $EMAILPRO          = "Marie\@work.com";
43
my $EMAILPRO          = "Marie\@work.com";
44
my $ETHNICITY         = "German";
45
my $PHONE             = "555-12123";
44
my $PHONE             = "555-12123";
46
45
47
# XXX should be randomised and checked against the database
46
# XXX should be randomised and checked against the database
Lines 115-128 is($member->{dateofbirth}, undef, "Empty dates handled correctly"); Link Here
115
114
116
$member->{firstname} = $CHANGED_FIRSTNAME;
115
$member->{firstname} = $CHANGED_FIRSTNAME;
117
$member->{email}     = $EMAIL;
116
$member->{email}     = $EMAIL;
118
$member->{ethnicity} = $ETHNICITY;
119
$member->{phone}     = $PHONE;
117
$member->{phone}     = $PHONE;
120
$member->{emailpro}  = $EMAILPRO;
118
$member->{emailpro}  = $EMAILPRO;
121
ModMember(%$member);
119
ModMember(%$member);
122
my $changedmember=GetMemberDetails("",$CARDNUMBER);
120
my $changedmember=GetMemberDetails("",$CARDNUMBER);
123
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME &&
121
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME &&
124
     $changedmember->{email}     eq $EMAIL             &&
122
     $changedmember->{email}     eq $EMAIL             &&
125
     $changedmember->{ethnicity} eq $ETHNICITY         &&
126
     $changedmember->{phone}     eq $PHONE             &&
123
     $changedmember->{phone}     eq $PHONE             &&
127
     $changedmember->{emailpro}  eq $EMAILPRO
124
     $changedmember->{emailpro}  eq $EMAILPRO
128
     , "Member Changed")
125
     , "Member Changed")
129
- 

Return to bug 10020