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

(-)a/C4/Members.pm (-50 lines)
Lines 135-142 BEGIN { Link Here
135
        &checkuserpassword
135
        &checkuserpassword
136
        &Check_Userid
136
        &Check_Userid
137
        &Generate_Userid
137
        &Generate_Userid
138
        &fixEthnicity
139
        &ethnicitycategories
140
        &fixup_cardnumber
138
        &fixup_cardnumber
141
        &checkcardnumber
139
        &checkcardnumber
142
    );
140
    );
Lines 1614-1667 sub GetBorrowercategoryList { Link Here
1614
    return $data;
1612
    return $data;
1615
}    # sub getborrowercategory
1613
}    # sub getborrowercategory
1616
1614
1617
=head2 ethnicitycategories
1618
1619
  ($codes_arrayref, $labels_hashref) = &ethnicitycategories();
1620
1621
Looks up the different ethnic types in the database. Returns two
1622
elements: a reference-to-array, which lists the ethnicity codes, and a
1623
reference-to-hash, which maps the ethnicity codes to ethnicity
1624
descriptions.
1625
1626
=cut
1627
1628
#'
1629
1630
sub ethnicitycategories {
1631
    my $dbh = C4::Context->dbh;
1632
    my $sth = $dbh->prepare("Select code,name from ethnicity order by name");
1633
    $sth->execute;
1634
    my %labels;
1635
    my @codes;
1636
    while ( my $data = $sth->fetchrow_hashref ) {
1637
        push @codes, $data->{'code'};
1638
        $labels{ $data->{'code'} } = $data->{'name'};
1639
    }
1640
    return ( \@codes, \%labels );
1641
}
1642
1643
=head2 fixEthnicity
1644
1645
  $ethn_name = &fixEthnicity($ethn_code);
1646
1647
Takes an ethnicity code (e.g., "european" or "pi") and returns the
1648
corresponding descriptive name from the C<ethnicity> table in the
1649
Koha database ("European" or "Pacific Islander").
1650
1651
=cut
1652
1653
#'
1654
1655
sub fixEthnicity {
1656
    my $ethnicity = shift;
1657
    return unless $ethnicity;
1658
    my $dbh       = C4::Context->dbh;
1659
    my $sth       = $dbh->prepare("Select name from ethnicity where code = ?");
1660
    $sth->execute($ethnicity);
1661
    my $data = $sth->fetchrow_hashref;
1662
    return $data->{'name'};
1663
}    # sub fixEthnicity
1664
1665
=head2 GetAge
1615
=head2 GetAge
1666
1616
1667
  $dateofbirth,$date = &GetAge($date);
1617
  $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 229-238 function validate1(date) { Link Here
229
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
229
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
230
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
230
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
231
    </li>[% END %][% END %]
231
    </li>[% END %][% END %]
232
    [% IF ( printethnicityline ) %]
233
    <li><span class="label">Ethnicity:</span>[% ethnicity %]</li>
234
    <li><span class="label">Ethnicity notes: </span>[% ethnotes %]</li>
235
    [% END %]
236
    [% IF ( isguarantee ) %]
232
    [% IF ( isguarantee ) %]
237
        [% IF ( guaranteeloop ) %]
233
        [% IF ( guaranteeloop ) %]
238
            <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>
234
            <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 90-96 my $guarantorinfo = $input->param('guarantorinfo'); Link Here
90
my $step          = $input->param('step') || 0;
90
my $step          = $input->param('step') || 0;
91
my @errors;
91
my @errors;
92
my $default_city;
92
my $default_city;
93
# NOTE: Alert for ethnicity and ethnotes fields, they are invalid in all borrowers form
94
my $borrower_data;
93
my $borrower_data;
95
my $NoUpdateLogin;
94
my $NoUpdateLogin;
96
my $userenv = C4::Context->userenv;
95
my $userenv = C4::Context->userenv;
Lines 507-532 if(!defined($data{'sex'})){ Link Here
507
}
506
}
508
507
509
##Now all the data to modify a member.
508
##Now all the data to modify a member.
510
my ($categories,$labels)=ethnicitycategories();
511
  
512
my $ethnicitycategoriescount=$#{$categories};
513
my $ethcatpopup;
514
if ($ethnicitycategoriescount>=0) {
515
  $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
516
        -id => 'ethnicity',
517
        -tabindex=>'',
518
        -values=>$categories,
519
        -default=>$data{'ethnicity'},
520
        -labels=>$labels);
521
  $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
522
}
523
509
524
my @typeloop;
510
my @typeloop;
525
my $no_categories = 1;
511
my $no_categories = 1;
526
my $no_add;
512
my $no_add;
527
foreach (qw(C A S P I X)) {
513
foreach (qw(C A S P I X)) {
528
    my $action="WHERE category_type=?";
514
    my $action="WHERE category_type=?";
529
	($categories,$labels)=GetborCatFromCatType($_,$action);
515
    my ($categories,$labels)=GetborCatFromCatType($_,$action);
530
    if(scalar(@$categories) > 0){ $no_categories = 0; }
516
    if(scalar(@$categories) > 0){ $no_categories = 0; }
531
	my @categoryloop;
517
	my @categoryloop;
532
	foreach my $cat (@$categories){
518
	foreach my $cat (@$categories){
Lines 709-715 $template->param( Link Here
709
  nodouble  => $nodouble,
695
  nodouble  => $nodouble,
710
  borrowernumber  => $borrowernumber, #register number
696
  borrowernumber  => $borrowernumber, #register number
711
  guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
697
  guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
712
  ethcatpopup => $ethcatpopup,
713
  relshiploop => \@relshipdata,
698
  relshiploop => \@relshipdata,
714
  city_loop => $city_arrayref,
699
  city_loop => $city_arrayref,
715
  borrotitlepopup => $borrotitlepopup,
700
  borrotitlepopup => $borrotitlepopup,
(-)a/members/moremember.pl (-5 lines)
Lines 155-161 if ( IsDebarred($borrowernumber) ) { Link Here
155
    }
155
    }
156
}
156
}
157
157
158
$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
159
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
158
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
160
159
161
my $catcode;
160
my $catcode;
Lines 167-176 if ( $category_type eq 'C') { Link Here
167
   $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
166
   $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
168
}
167
}
169
168
170
171
if ( $data->{'ethnicity'} || $data->{'ethnotes'} ) {
172
    $template->param( printethnicityline => 1 );
173
}
174
my ( $count, $guarantees ) = GetGuarantees( $data->{'borrowernumber'} );
169
my ( $count, $guarantees ) = GetGuarantees( $data->{'borrowernumber'} );
175
if ( $count ) {
170
if ( $count ) {
176
    $template->param( isguarantee => 1 );
171
    $template->param( isguarantee => 1 );
(-)a/opac/opac-user.pl (-2 lines)
Lines 82-89 my ( $borr ) = GetMemberDetails( $borrowernumber ); Link Here
82
my (  $today_year,   $today_month,   $today_day) = Today();
82
my (  $today_year,   $today_month,   $today_day) = Today();
83
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
83
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
84
84
85
$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} );
86
87
my $debar = IsDebarred($borrowernumber);
85
my $debar = IsDebarred($borrowernumber);
88
my $userdebarred;
86
my $userdebarred;
89
87
(-)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 113-126 is($member->{dateofbirth}, undef, "Empty dates handled correctly"); Link Here
113
112
114
$member->{firstname} = $CHANGED_FIRSTNAME;
113
$member->{firstname} = $CHANGED_FIRSTNAME;
115
$member->{email}     = $EMAIL;
114
$member->{email}     = $EMAIL;
116
$member->{ethnicity} = $ETHNICITY;
117
$member->{phone}     = $PHONE;
115
$member->{phone}     = $PHONE;
118
$member->{emailpro}  = $EMAILPRO;
116
$member->{emailpro}  = $EMAILPRO;
119
ModMember(%$member);
117
ModMember(%$member);
120
my $changedmember=GetMemberDetails("",$CARDNUMBER);
118
my $changedmember=GetMemberDetails("",$CARDNUMBER);
121
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME &&
119
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME &&
122
     $changedmember->{email}     eq $EMAIL             &&
120
     $changedmember->{email}     eq $EMAIL             &&
123
     $changedmember->{ethnicity} eq $ETHNICITY         &&
124
     $changedmember->{phone}     eq $PHONE             &&
121
     $changedmember->{phone}     eq $PHONE             &&
125
     $changedmember->{emailpro}  eq $EMAILPRO
122
     $changedmember->{emailpro}  eq $EMAILPRO
126
     , "Member Changed")
123
     , "Member Changed")
127
- 

Return to bug 10020