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