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

(-)a/C4/Members.pm (-2 / +2 lines)
Lines 2466-2479 sub GetBorrowersWithEmail { Link Here
2466
sub AddMember_Opac {
2466
sub AddMember_Opac {
2467
    my ( %borrower ) = @_;
2467
    my ( %borrower ) = @_;
2468
2468
2469
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2469
    $borrower{'categorycode'} //= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2470
2470
2471
    my $sr = new String::Random;
2471
    my $sr = new String::Random;
2472
    $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2472
    $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2473
    my $password = $sr->randpattern("AAAAAAAAAA");
2473
    my $password = $sr->randpattern("AAAAAAAAAA");
2474
    $borrower{'password'} = $password;
2474
    $borrower{'password'} = $password;
2475
2475
2476
    $borrower{'cardnumber'} = fixup_cardnumber();
2476
    $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} );
2477
2477
2478
    my $borrowernumber = AddMember(%borrower);
2478
    my $borrowernumber = AddMember(%borrower);
2479
2479
(-)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 50-56 Link Here
50
                    <div class="alert">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div>
51
                    <div class="alert">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div>
51
                [% END %]
52
                [% END %]
52
53
53
                [%  IF invalid_form_fields %]
54
                [% IF invalid_form_fields %]
54
                    <div class="alert alert-error"><strong>The following fields contain invalid information:</strong>
55
                    <div class="alert alert-error"><strong>The following fields contain invalid information:</strong>
55
                        <ul>
56
                        <ul>
56
                            [% FOREACH field IN invalid_form_fields %]
57
                            [% FOREACH field IN invalid_form_fields %]
Lines 63-68 Link Here
63
                    </div>
64
                    </div>
64
                [% END %]
65
                [% END %]
65
66
67
                [% IF cardnumber_wrong_length || cardnumber_already_exists %]
68
                    <div class="alert alert-error">
69
                        [% IF cardnumber_wrong_length %]
70
                        <strong>The entered <a href="#borrower_cardnumber">card number</a> is the wrong length.</strong>
71
                        [% ELSIF cardnumber_already_exists %]
72
                        <strong>The entered <a href="#borrower_cardnumber">card number</a> is already in use.</strong>
73
                        [% END %]
74
                        Please correct this and resubmit.
75
                    </div>
76
                [% END %]
77
66
                [% IF failed_captcha %]
78
                [% IF failed_captcha %]
67
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
79
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
68
                [% END %]
80
                [% END %]
Lines 74-83 Link Here
74
86
75
                        <legend id="library_legend">Library</legend>
87
                        <legend id="library_legend">Library</legend>
76
                            <ol>
88
                            <ol>
77
                                [% UNLESS hidden.defined('cardnumber') %]
89
                                [% UNLESS hidden.defined('cardnumber') || Koha.Preference('autoMemberNum') %]
78
                                <li>
90
                                <li>
79
                                    <label>Card number:</label>
91
                                    [% IF mandatory.defined('cardnumber') %]
80
                                    [% borrower.cardnumber %]
92
                                        <label for="borrower_cardnumber" class="required">
93
                                    [% ELSE %]
94
                                        <label for="borrower_cardnumber">
95
                                    [% END %]
96
                                    Library card number:
97
                                    </label>
98
                                    [% IF borrower %]
99
                                        <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" value="[% borrower.cardnumber %]" />
100
                                        [% IF mandatory.defined('cardnumber') %]<span class="required">Required</span>[% END %]
101
                                    [% ELSE %]
102
                                        [% borrower.cardnumber %]
103
                                    [% END %]
81
                                </li>
104
                                </li>
82
                                [% END %]
105
                                [% END %]
83
106
Lines 108-113 Link Here
108
                                        </select>
131
                                        </select>
109
                                    </li>
132
                                    </li>
110
                                [% END %]
133
                                [% END %]
134
135
                                [% UNLESS hidden.defined('categorycode') %]
136
                                    <li>
137
                                        <label for="borrower_categorycode">
138
                                        Category:</label>
139
140
                                        [% IF borrower %]
141
                                            <select id="borrower_categorycode" name="borrower_categorycode">
142
                                                [% FOREACH c IN Categories.all() %]
143
                                                    [% IF c.categorycode == Koha.Preference('PatronSelfRegistrationDefaultCategory') %]
144
                                                        <option value="[% c.categorycode %]" selected="selected">[% c.description %]</option>
145
                                                    [% ELSE %]
146
                                                        <option value="[% c.categorycode %]">[% c.description %]</option>
147
                                                    [% END %]
148
                                                [% END %]
149
                                            </select>
150
                                        [% ELSE %]
151
                                            [% Categories.GetName( borrower.categorycode ) %]
152
                                        [% END %]
153
                                    </li>
154
                                [% END %]
111
                            </ol>
155
                            </ol>
112
                        </fieldset>
156
                        </fieldset>
113
                [% END # / defined 'branchcode' %]
157
                [% END # / defined 'branchcode' %]
(-)a/opac/opac-memberentry.pl (-2 / +13 lines)
Lines 77-84 if ( $action eq 'create' ) { Link Here
77
77
78
    my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
78
    my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
79
    my $invalidformfields = CheckForInvalidFields(\%borrower);
79
    my $invalidformfields = CheckForInvalidFields(\%borrower);
80
    my $cardnumber_error_code;
81
    if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) {
82
        # No point in checking the cardnumber if it's missing and mandatory, it'll just generate a
83
        # spurious length warning.
84
        $cardnumber_error_code = checkcardnumber( $borrower{cardnumber}, $borrower{borrowernumber} );
85
    }
86
87
    if ( @empty_mandatory_fields || @$invalidformfields || $cardnumber_error_code ) {
88
        if ( $cardnumber_error_code == 1 ) {
89
            $template->param( cardnumber_already_exists => 1 );
90
        } elsif ( $cardnumber_error_code == 2 ) {
91
            $template->param( cardnumber_wrong_length => 1 );
92
        }
80
93
81
    if (@empty_mandatory_fields || @$invalidformfields) {
82
        $template->param(
94
        $template->param(
83
            empty_mandatory_fields => \@empty_mandatory_fields,
95
            empty_mandatory_fields => \@empty_mandatory_fields,
84
            invalid_form_fields    => $invalidformfields,
96
            invalid_form_fields    => $invalidformfields,
85
- 

Return to bug 14659