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

(-)a/C4/Members.pm (-2 / +2 lines)
Lines 2410-2416 sub GetBorrowersWithEmail { Link Here
2410
sub AddMember_Opac {
2410
sub AddMember_Opac {
2411
    my ( %borrower ) = @_;
2411
    my ( %borrower ) = @_;
2412
2412
2413
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2413
    $borrower{'categorycode'} //= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2414
    if (not defined $borrower{'password'}){
2414
    if (not defined $borrower{'password'}){
2415
        my $sr = new String::Random;
2415
        my $sr = new String::Random;
2416
        $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2416
        $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
Lines 2418-2424 sub AddMember_Opac { Link Here
2418
        $borrower{'password'} = $password;
2418
        $borrower{'password'} = $password;
2419
    }
2419
    }
2420
2420
2421
    $borrower{'cardnumber'} = fixup_cardnumber();
2421
    $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} );
2422
2422
2423
    my $borrowernumber = AddMember(%borrower);
2423
    my $borrowernumber = AddMember(%borrower);
2424
2424
(-)a/Koha/Template/Plugin/Categories.pm (+15 lines)
Lines 21-26 use Template::Plugin; Link Here
21
use base qw( Template::Plugin );
21
use base qw( Template::Plugin );
22
22
23
use C4::Category;
23
use C4::Category;
24
use Koha::Database;
25
26
sub GetName {
27
    my ( $self, $categorycode ) = @_;
28
29
    my $schema = Koha::Database->new->schema;
30
    return $schema->resultset( 'Category' )->search( {
31
        categorycode => $categorycode,
32
    } )->get_column( 'description' )->next // '';
33
}
24
34
25
sub all {
35
sub all {
26
    my ( $self, $params ) = @_;
36
    my ( $self, $params ) = @_;
Lines 56-61 Koha::Template::Plugin::Categories - TT Plugin for categories Link Here
56
In a template, you can get the all categories with
66
In a template, you can get the all categories with
57
the following TT code: [% Categories.all() %]
67
the following TT code: [% Categories.all() %]
58
68
69
=head2 GetName
70
71
In a template, you can get the name of a patron category using
72
[% Categories.GetName( categorycode ) %].
73
59
=head1 AUTHOR
74
=head1 AUTHOR
60
75
61
Jonathan Druart <jonathan.druart@biblibre.com>
76
Jonathan Druart <jonathan.druart@biblibre.com>
(-)a/installer/data/mysql/atomicupdate/bug_14659-add_cardnumber_categorycode_PatronSelfRegistrationBorrowerUnwantedField_syspref.sql (+2 lines)
Line 0 Link Here
1
UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'cardnumber') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%cardnumber%';
2
UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'categorycode') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%categorycode%';
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-4 / +48 lines)
Lines 1-3 Link Here
1
[% USE Categories %]
1
[% USE Koha %]
2
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE KohaDates %]
3
[% SET userupdateview = 1 %]
4
[% SET userupdateview = 1 %]
Lines 53-59 Link Here
53
                    <div class="alert">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div>
54
                    <div class="alert">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div>
54
                [% END %]
55
                [% END %]
55
56
56
                [%  IF invalid_form_fields %]
57
                [% IF invalid_form_fields %]
57
                    <div class="alert alert-error"><strong>The following fields contain invalid information:</strong>
58
                    <div class="alert alert-error"><strong>The following fields contain invalid information:</strong>
58
                        <ul>
59
                        <ul>
59
                            [% FOREACH field IN invalid_form_fields %]
60
                            [% FOREACH field IN invalid_form_fields %]
Lines 69-74 Link Here
69
                    </div>
70
                    </div>
70
                [% END %]
71
                [% END %]
71
72
73
                [% IF cardnumber_wrong_length || cardnumber_already_exists %]
74
                    <div class="alert alert-error">
75
                        [% IF cardnumber_wrong_length %]
76
                        <strong>The entered <a href="#borrower_cardnumber">card number</a> is the wrong length.</strong>
77
                        [% ELSIF cardnumber_already_exists %]
78
                        <strong>The entered <a href="#borrower_cardnumber">card number</a> is already in use.</strong>
79
                        [% END %]
80
                        Please correct this and resubmit.
81
                    </div>
82
                [% END %]
83
72
                [% IF failed_captcha %]
84
                [% IF failed_captcha %]
73
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
85
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
74
                [% END %]
86
                [% END %]
Lines 106-115 Link Here
106
118
107
                        <legend id="library_legend">Library</legend>
119
                        <legend id="library_legend">Library</legend>
108
                            <ol>
120
                            <ol>
109
                                [% UNLESS hidden.defined('cardnumber') %]
121
                                [% UNLESS hidden.defined('cardnumber') || Koha.Preference('autoMemberNum') %]
110
                                <li>
122
                                <li>
111
                                    <label>Card number:</label>
123
                                    [% IF mandatory.defined('cardnumber') %]
112
                                    [% borrower.cardnumber %]
124
                                        <label for="borrower_cardnumber" class="required">
125
                                    [% ELSE %]
126
                                        <label for="borrower_cardnumber">
127
                                    [% END %]
128
                                    Library card number:
129
                                    </label>
130
                                    [% IF borrower %]
131
                                        <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" value="[% borrower.cardnumber %]" />
132
                                        [% IF mandatory.defined('cardnumber') %]<span class="required">Required</span>[% END %]
133
                                    [% ELSE %]
134
                                        [% borrower.cardnumber %]
135
                                    [% END %]
113
                                </li>
136
                                </li>
114
                                [% END %]
137
                                [% END %]
115
138
Lines 140-145 Link Here
140
                                        </select>
163
                                        </select>
141
                                    </li>
164
                                    </li>
142
                                [% END %]
165
                                [% END %]
166
167
                                [% UNLESS hidden.defined('categorycode') %]
168
                                    <li>
169
                                        <label for="borrower_categorycode">
170
                                        Category:</label>
171
172
                                        [% IF borrower %]
173
                                            <select id="borrower_categorycode" name="borrower_categorycode">
174
                                                [% FOREACH c IN Categories.all() %]
175
                                                    [% IF c.categorycode == Koha.Preference('PatronSelfRegistrationDefaultCategory') %]
176
                                                        <option value="[% c.categorycode %]" selected="selected">[% c.description %]</option>
177
                                                    [% ELSE %]
178
                                                        <option value="[% c.categorycode %]">[% c.description %]</option>
179
                                                    [% END %]
180
                                                [% END %]
181
                                            </select>
182
                                        [% ELSE %]
183
                                            [% Categories.GetName( borrower.categorycode ) %]
184
                                        [% END %]
185
                                    </li>
186
                                [% END %]
143
                            </ol>
187
                            </ol>
144
                        </fieldset>
188
                        </fieldset>
145
                [% END # / defined 'branchcode' %]
189
                [% END # / defined 'branchcode' %]
(-)a/opac/opac-memberentry.pl (-2 / +13 lines)
Lines 80-87 if ( $action eq 'create' ) { Link Here
80
    my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
80
    my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
81
    my $invalidformfields = CheckForInvalidFields(\%borrower);
81
    my $invalidformfields = CheckForInvalidFields(\%borrower);
82
    delete $borrower{'password2'};
82
    delete $borrower{'password2'};
83
    my $cardnumber_error_code;
84
    if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) {
85
        # No point in checking the cardnumber if it's missing and mandatory, it'll just generate a
86
        # spurious length warning.
87
        $cardnumber_error_code = checkcardnumber( $borrower{cardnumber}, $borrower{borrowernumber} );
88
    }
89
90
    if ( @empty_mandatory_fields || @$invalidformfields || $cardnumber_error_code ) {
91
        if ( $cardnumber_error_code == 1 ) {
92
            $template->param( cardnumber_already_exists => 1 );
93
        } elsif ( $cardnumber_error_code == 2 ) {
94
            $template->param( cardnumber_wrong_length => 1 );
95
        }
83
96
84
    if (@empty_mandatory_fields || @$invalidformfields) {
85
        $template->param(
97
        $template->param(
86
            empty_mandatory_fields => \@empty_mandatory_fields,
98
            empty_mandatory_fields => \@empty_mandatory_fields,
87
            invalid_form_fields    => $invalidformfields,
99
            invalid_form_fields    => $invalidformfields,
88
- 

Return to bug 14659