]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/register.tt2
LP#1361266 Patron self-registration form accepts date of birth in wrong format
[working/Evergreen.git] / Open-ILS / src / templates / opac / register.tt2
1 [%- PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/org_selector.tt2";
3     WRAPPER "opac/parts/base.tt2";
4     INCLUDE "opac/parts/topnav.tt2";
5     ctx.page_title = l("Request Library Card");
6
7 # for privacy, reload the page after (default) 5 minutes
8 refresh_time = ctx.register.settings.refresh_timeout || 300; 
9 ctx.refresh = refresh_time _ '; ' _ ctx.opac_root _ '/home';
10
11 # some useful variables and MACROs for display, 
12 # field validation, and added info display
13
14 ctx_org = ctx.physical_loc || ctx.search_ou || ctx.aou_tree.id;
15
16 # list of the registration fields to (potentially) 
17 # display in the order they should be shown
18
19 # post_code is the only field below that is required in the database and
20 # post_code is only required if an address is created.
21 # To prevent any of these fields from showing locally, regardless org unit
22 # settings, simply remove the fields from this list.  In the case of 
23 # addresses, if all address fields are removed, no attempt at creating
24 # an address will be made (and post_code will no longer be required).
25
26 register_fields = [
27     {class => 'stgu',  name = 'first_given_name', label => l('First Name')},
28     {class => 'stgu',  name = 'second_given_name', label => l('Middle Name')},
29     {class => 'stgu',  name = 'family_name', label => l('Last Name')},
30     {class => 'stgma', name = 'street1', label => l('Street Address')},
31     {class => 'stgma', name = 'street2', label => l('Street Address (2)')},
32     {class => 'stgma', name = 'city', label => l('City')},
33     {class => 'stgma', name = 'county', label => l('County')},
34     {class => 'stgma', name = 'state', label => l('State')},
35     {class => 'stgma', name = 'post_code', label => l('Zip Code')},
36     {class => 'stgu',  name = 'dob', label => l('Date of Birth')},
37     {class => 'stgu',  name = 'day_phone', label => l('Phone Number')},
38     {class => 'stgu',  name = 'email', label => l('Email Address')}
39     {class => 'stgu',  name = 'usrname', label => l('Requested Username')}
40 ];
41
42 # The dojo date widget in the patron edit UI only accepts default 
43 # values in ISO8601 format.  It will not accept locale-shaped dates.
44 IF !ctx.register.settings.stgu.dob.example;
45     ctx.register.settings.stgu.dob.example = l('YYYY-MM-DD or YYYY/MM/DD');
46 END;
47
48 %]
49
50 <h2 class="sr-only">[% l('Account Registration') %]</h2>
51 <div id="content-wrapper">
52     <div id="main-content-register">
53         <div class="common-full-pad"></div>
54         <h1>[% l('Request a Library Card')%]</h1>
55         <hr/>
56
57         [% IF ctx.register.success %]
58             <h3>[% l('Registration successful!') %]<h3>
59             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
60
61             [% IF ctx.register.username_taken %]
62             <p>
63                 [% |l %]
64                 Note: The selected username may be in use by another patron.  
65                 You may select another username when finalizing your 
66                 registration or in the online catalog.
67                 [% END %]
68             </p>
69             [% END %]
70
71             <br/>
72             <p>
73                 <a href="[% ctx.opac_root %]/home" 
74                     class="opac-button">[% l('Return to the Catalog') %]</a>
75             </p>
76
77         [% ELSIF ctx.register.error %]
78             <h3>[% l('A registration error has occurred') %]</h3>
79             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
80
81             <br/>
82             <p>
83                 <a href="[% ctx.opac_root %]/home" 
84                     class="opac-button">[% l('Return to the Catalog') %]</a>
85             </p>
86
87         [% ELSE %]
88
89         [% IF ctx.user %]
90             <!-- if the user is logged in, make it 
91                 clear we are tracking the requestor -->
92             <h4>[% l('New account requested by [_1] [_2] [_3] [_4] [_5]',
93                     ctx.user.prefix, ctx.user.first_given_name,
94                     ctx.user.second_given_name, ctx.user.family_name,
95                     ctx.user.suffix
96                 ) | html %]</h4>
97         [% END %]
98
99         <form method='POST' onSubmit="return dobValidate(document.getElementById('stgu.dob'))">
100             <table>
101                 <tr>
102                     <td>
103                         <label for='stgu.home_ou'>[% l('Home Library') %]</label>
104                     </td>
105                     <td>[% INCLUDE build_org_selector 
106                             name='stgu.home_ou' 
107                             value=value || ctx_org
108                             can_have_users_only=1
109                             valid_org_list=ctx.register.valid_orgs
110                         %]
111                     </td>
112                     <td>
113                         [% IF ctx.register.invalid.bad_home_ou %]
114                         <span class='patron-reg-invalid'>
115                             [% l('Please select a valid library') %]
116                         </span>
117                         [% END %]
118                 </tr>
119 [%
120 # <=== shifting code left for readability
121
122 # render the table row for each of the register fields
123 FOR field_def IN register_fields;
124     fclass = field_def.class;
125     fname = field_def.name;
126     field_path = fclass _ "." _ fname;
127
128     show = ctx.register.settings.$fclass.$fname.show;
129     require = ctx.register.settings.$fclass.$fname.require;
130     example = ctx.register.settings.$fclass.$fname.example;
131     value = ctx.register.values.$fclass.$fname;
132
133     invalid_require = ctx.register.invalid.$fclass.$fname.require;
134     invalid_regex = ctx.register.invalid.$fclass.$fname.regex;
135
136     NEXT UNLESS require OR show;
137 %]
138 <tr>
139     <td>
140         <label for='[% field_path %]'>[% field_def.label | html %]</label>
141     </td>
142     <td>
143         <input 
144             type='text'
145             id='[% field_path %]'
146             name='[% field_path %]'
147             value='[% value || CGI.param(field_path) | html %]'/>
148         [% IF require %]
149         <span class='patron-reg-invalid'>*</span>
150         [% END %]
151     </td>
152     <td>
153
154     <!-- display errors and example text -->
155
156     [% IF invalid_require %]
157         <span class='patron-reg-invalid'>
158             [% l('This field is required') %]
159         </span>
160     [% ELSIF invalid_regex %]
161         <span class='patron-reg-invalid'>
162             [% l('The value entered does not have the correct format') %]
163         </span>
164     [% END %]
165     [% IF example %]
166         <span class='patron-reg-extra'>
167             [% l('(Example: [_1])', example) %]
168         </span>
169     [% END %]
170
171     </td>
172 </tr>
173 [% END %]
174 <!-- ====> shifting the code back to the right for context -->
175                     <tr>
176                         <td colspan='3'>
177                             <a href="[% ctx.opac_root %]/home" 
178                                 class="opac-button">[% l('Go Back') %]</a>
179                             <input type="submit" 
180                                 value="[% l('Submit Registration') %]" 
181                                 class="opac-button" />
182                         </td>
183                     </tr>
184                 </table>
185             </form>
186             [% END %]
187             <div class="common-full-pad"></div> 
188         </div>
189     </div>
190 [%- END %]