]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/register.tt2
a1c7b0e0e192cc53cf060458640bebe662cf992c
[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
39 <div id="content-wrapper">
40     <div id="main-content-register">
41         <div class="common-full-pad"></div>
42         <h1>[% l('Request a Library Card')%]</h1>
43         <hr/>
44
45         [% IF ctx.register.success %]
46             <h3>[% l('Registration successful!') %]<h3>
47             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
48
49             [% IF ctx.register.username_taken %]
50             <p>
51                 [% |l %]
52                 Note: The selected username may be in use by another patron.  
53                 You may select another username when finalizing your 
54                 registration or in the online catalog.
55                 [% END %]
56             </p>
57             [% END %]
58
59             <br/>
60             <p>
61                 <a href="[% ctx.opac_root %]/home" 
62                     class="opac-button">[% l('Return to the Catalog') %]</a>
63             </p>
64
65         [% ELSIF ctx.register.error %]
66             <h3>[% l('A registration error has occurred') %]</h3>
67             <h4>[% l('Please see library staff to complete your registration.') %]</h4>
68
69             <br/>
70             <p>
71                 <a href="[% ctx.opac_root %]/home" 
72                     class="opac-button">[% l('Return to the Catalog') %]</a>
73             </p>
74
75         [% ELSE %]
76
77         [% IF ctx.user %]
78             <!-- if the user is logged in, make it 
79                 clear we are tracking the requestor -->
80             <h4>[% l('New account requested by [_1] [_2] [_3] [_4] [_5]',
81                     ctx.user.prefix, ctx.user.first_given_name,
82                     ctx.user.second_given_name, ctx.user.family_name,
83                     ctx.user.suffix
84                 ) | html %]</h4>
85         [% END %]
86
87         <form method='POST'>
88             <table>
89                 <tr>
90                     <td>
91                         <label for='stgu.home_ou'>[% l('Home Library') %]</label>
92                     </td>
93                     <td>[% INCLUDE build_org_selector 
94                             name='stgu.home_ou' 
95                             value=value || ctx_org
96                             can_have_users_only=1
97                             valid_org_list=ctx.register.valid_orgs
98                         %]
99                     </td>
100                     <td>
101                         [% IF ctx.register.invalid.bad_home_ou %]
102                         <span class='patron-reg-invalid'>
103                             [% l('Please select a valid library') %]
104                         </span>
105                         [% END %]
106                 </tr>
107 [%
108 # <=== shifting code left for readability
109
110 # render the table row for each of the register fields
111 FOR field_def IN register_fields;
112     fclass = field_def.class;
113     fname = field_def.name;
114     field_path = fclass _ "." _ fname;
115
116     show = ctx.register.settings.$fclass.$fname.show;
117     require = ctx.register.settings.$fclass.$fname.require;
118     example = ctx.register.settings.$fclass.$fname.example;
119     value = ctx.register.values.$fclass.$fname;
120
121     invalid_require = ctx.register.invalid.$fclass.$fname.require;
122     invalid_regex = ctx.register.invalid.$fclass.$fname.regex;
123
124     NEXT UNLESS require OR show;
125 %]
126 <tr>
127     <td>
128         <label for='[% field_path %]'>[% field_def.label | html %]</label>
129     </td>
130     <td>
131         <input 
132             type='text' 
133             name='[% field_path %]'
134             value='[% value || CGI.param(field_path) | html %]'/>
135         [% IF require %]
136         <span class='patron-reg-invalid'>*</span>
137         [% END %]
138     </td>
139     <td>
140
141     <!-- display errors and example text -->
142
143     [% IF invalid_require %]
144         <span class='patron-reg-invalid'>
145             [% l('This field is required') %]
146         </span>
147     [% ELSIF invalid_regex %]
148         <span class='patron-reg-invalid'>
149             [% l('The value entered does not have the correct format') %]
150         </span>
151     [% END %]
152     [% IF example %]
153         <span class='patron-reg-extra'>
154             [% l('(Example: [_1])', example) %]
155         </span>
156     [% END %]
157
158     </td>
159 </tr>
160 [% END %]
161 <!-- ====> shifting the code back to the right for context -->
162                     <tr>
163                         <td colspan='3'>
164                             <a href="[% ctx.opac_root %]/home" 
165                                 class="opac-button">[% l('Go Back') %]</a>
166                             <input type="submit" 
167                                 value="[% l('Submit Registration') %]" 
168                                 class="opac-button" />
169                         </td>
170                     </tr>
171                 </table>
172             </form>
173             [% END %]
174             <div class="common-full-pad"></div> 
175         </div>
176     </div>
177 [%- END %]