]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/register.tt2
LP2045292 Color contrast for AngularJS patron bills
[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 => 'stgu',  name = 'pref_first_given_name', label => l('Preferred First Name')},
31     {class => 'stgu',  name = 'pref_second_given_name', label => l('Preferred Middle Name')},
32     {class => 'stgu',  name = 'pref_family_name', label => l('Preferred Last Name')},
33     {class => 'stgma', name = 'street1', label => l('Street Address')},
34     {class => 'stgma', name = 'street2', label => l('Street Address (2)')},
35     {class => 'stgma', name = 'city', label => l('City')},
36     {class => 'stgma', name = 'county', label => l('County')},
37     {class => 'stgma', name = 'state', label => l('State')},
38     {class => 'stgma', name = 'post_code', label => l('Zip Code')},
39     {class => 'stgu',  name = 'dob', label => l('Date of Birth')},
40     {class => 'stgu',  name = 'day_phone', label => l('Phone Number')},
41     {class => 'stgu',  name = 'email', label => l('Email Address')}
42     {class => 'stgu',  name = 'usrname', label => l('Requested Username')}
43 ];
44
45 # The dojo date widget in the patron edit UI only accepts default 
46 # values in ISO8601 format.  It will not accept locale-shaped dates.
47 IF !ctx.register.settings.stgu.dob.example;
48     ctx.register.settings.stgu.dob.example = l('YYYY-MM-DD or YYYY/MM/DD');
49 END;
50
51 %]
52
53 <h2 class="sr-only">[% l('Account Registration') %]</h2>
54 <div id="content-wrapper">
55     <div id="main-content-register">
56         <div class="common-full-pad"></div>
57         <h1>[% l('Request a Library Card')%]</h1>
58         <hr/>
59
60         [% IF ctx.register.success %]
61             <h3>[% l('Registration successful!') %]<h3>
62             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
63
64             [% IF ctx.register.username_taken %]
65             <p>
66                 [% |l %]
67                 Note: The selected username may be in use by another patron.  
68                 You may select another username when finalizing your 
69                 registration or in the online catalog.
70                 [% END %]
71             </p>
72             [% END %]
73
74             <br/>
75             <p>
76                 <a href="[% ctx.opac_root %]/home" 
77                     class="opac-button">[% l('Return to the Catalog') %]</a>
78             </p>
79
80         [% ELSIF ctx.register.error %]
81             <h3>[% l('A registration error has occurred') %]</h3>
82             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
83
84             <br/>
85             <p>
86                 <a href="[% ctx.opac_root %]/home" 
87                     class="opac-button">[% l('Return to the Catalog') %]</a>
88             </p>
89
90         [% ELSE %]
91
92         [% IF ctx.user %]
93             <!-- if the user is logged in, make it 
94                 clear we are tracking the requestor -->
95             <h4>[% l('New account requested by [_1] [_2] [_3] [_4] [_5]',
96                     ctx.user.prefix, ctx.user.first_given_name,
97                     ctx.user.second_given_name, ctx.user.family_name,
98                     ctx.user.suffix
99                 ) | html %]</h4>
100         [% END %]
101
102         [%
103             #prepopulate org selector on refresh or error
104             cgi_org = CGI.param('stgu.home_ou') | html;
105             IF cgi_org && ctx.register.valid_orgs.grep("^$cgi_org$").size;
106                 prepopulate_org = cgi_org;
107             END
108         %]
109
110         <form method='POST' onSubmit="return dobValidate(document.getElementById('stgu.dob'))">
111             <table>
112                 <tr>
113                     <td>
114                         <label for='stgu.home_ou'>[% l('Home Library') %]</label>
115                     </td>
116                     <td>[% INCLUDE build_org_selector 
117                             name='stgu.home_ou' 
118                             value=value || prepopulate_org || ctx_org
119                             can_have_users_only=1
120                             valid_org_list=ctx.register.valid_orgs
121                         %]
122                     </td>
123                     <td>
124                         [% IF ctx.register.invalid.bad_home_ou %]
125                         <span class='patron-reg-invalid'>
126                             [% l('Please select a valid library') %]
127                         </span>
128                         [% END %]
129                 </tr>
130 [%
131 # <=== shifting code left for readability
132
133 # render the table row for each of the register fields
134 FOR field_def IN register_fields;
135     fclass = field_def.class;
136     fname = field_def.name;
137     orig_name = fname;
138
139     field_path = fclass _ "." _ fname;
140
141     IF fname.match('^pref_');
142         # Preferred name fields adopt most visibility, etc.
143         # settings from the primary name counterparts.
144         fname = fname.remove('^pref_');
145     END;
146
147     show = ctx.register.settings.$fclass.$fname.show;
148     require = ctx.register.settings.$fclass.$fname.require;
149     example = ctx.register.settings.$fclass.$fname.example;
150     value = ctx.register.values.$fclass.$fname;
151
152     invalid_require = ctx.register.invalid.$fclass.$fname.require;
153     invalid_regex = ctx.register.invalid.$fclass.$fname.regex;
154
155     IF orig_name.match('^pref_');
156         show = show || require;
157         require = 0; # pref name values never required
158     END;
159
160     NEXT UNLESS require OR show;
161 %]
162 <tr>
163     <td>
164         <label for='[% field_path %]'>[% field_def.label | html %]</label>
165     </td>
166     <td>
167         <input 
168             type='text'
169             id='[% field_path %]'
170             name='[% field_path %]'
171             value='[% value || CGI.param(field_path) | html %]'/>
172         [% IF require %]
173         <span class='patron-reg-invalid'>*</span>
174         [% END %]
175     </td>
176     <td>
177
178     <!-- display errors and example text -->
179
180     [% IF invalid_require %]
181         <span class='patron-reg-invalid'>
182             [% l('This field is required') %]
183         </span>
184     [% ELSIF invalid_regex %]
185         <span class='patron-reg-invalid'>
186             [% l('The value entered does not have the correct format') %]
187         </span>
188     [% END %]
189     [% IF example %]
190         <span class='patron-reg-extra'>
191             [% l('(Example: [_1])', example) %]
192         </span>
193     [% END %]
194
195     </td>
196 </tr>
197 [% END %]
198 <!-- ====> shifting the code back to the right for context -->
199                     [% IF ctx.register.opt_in_settings.size > 0 %]
200                         [% FOR optin IN ctx.register.opt_in_settings %]
201                         <tr>
202                             <td><label for="stgs.[% optin.name | uri %]'">[% optin.label | html %]</label></td>
203                             <td>
204                                 <input type='checkbox'
205                                     name='stgs.[% optin.name | uri %]'
206                                     id='stgs.[% optin.name | uri %]'
207                                     title="[% optin.label | html %]"
208                                 ></input>
209                             </td>
210                             <td><!-- display errors and example text --></td>
211                         </tr>
212                         [% END %]
213                     [% END %]
214                     <tr>
215                         <td colspan='3'>
216                             <a href="[% ctx.opac_root %]/home" 
217                                 class="opac-button">[% l('Go Back') %]</a>
218                             <input type="submit" 
219                                 value="[% l('Submit Registration') %]" 
220                                 class="opac-button" />
221                         </td>
222                     </tr>
223                 </table>
224             </form>
225             [% END %]
226             <div class="common-full-pad"></div> 
227         </div>
228     </div>
229 [%- END %]