LP1207396 Patron self-registration web form
authorBill Erickson <berick@esilibrary.com>
Fri, 2 Aug 2013 16:17:05 +0000 (12:17 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 2 Aug 2013 16:17:05 +0000 (12:17 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/opac/register.tt2

index c188554..6ebfe47 100644 (file)
@@ -22,6 +22,9 @@
             [% ELSE;
                 ctx_org = ctx.physical_loc || ctx.search_ou || ctx.aou_tree.id ;
 
+                addr_required = ctx.get_org_setting(ctx_org, 
+                    'ui.patron.registration.require_address');
+
                 # true if the selected field is required
                 MACRO require_field(cls, field_name) BLOCK;
                     sname = "ui.patron.edit.${cls}.${field_name}.require";
                     IF require_field(cls, field_name) || 
                         ctx.get_org_setting(ctx_org, sname); 1; ELSE; 0; END;
                 END;
+
+                # indicate whether a field is optional; display example text
+                MACRO show_field_extras(cls, field_name, test_req, test_ex) BLOCK;
+                    required = 0;
+                    example = '';
+
+                    sname = "ui.patron.edit.${cls}.${field_name}.example";
+                    IF test_ex;
+                        example = ctx.get_org_setting(ctx_org, sname);
+
+                        # day_phone is a special case, since there is a both
+                        # a day_phone example and generic phone example
+                        IF field_name == 'day_phone' AND !example;
+                            sname = 'ui.patron.edit.phone.example';
+                            example = ctx.get_org_setting(ctx_org, sname);
+                        END;
+                    END;
+                    
+                    SET required = require_field(cls, field_name) IF test_req;
+                    IF example;
+                        IF required;
+                            l('(Example: [_1])', example);
+                        ELSE;
+                            l('(Optional, Example: [_1])', example);
+                        END;
+                    ELSIF !required;
+                        l('(Optional)');
+                    END;
+                END;
             %]
 
             <form method='POST'>
@@ -61,6 +93,8 @@
                         <td>[% l('Last Name') %]</td>
                         <td><input type='text' name='stgu.family_name'/></td>
                     </tr>
+
+                    [% IF addr_required # --------------------------------- %]
                     <tr>
                         <td>[% l('Street Address') %]</td>
                         <td><input type='text' name='stgma.street1'/></td>
                     <tr>
                         <td>[% l('Street Address (2)') %]</td>
                         <td><input type='text' name='stgma.street2'/></td>
+                        <td>[% l('(Optional)') %]</td>
                     </tr>
                     <tr>
                         <td>[% l('City') %]</td>
                     <tr>
                         <td>[% l('State') %]</td>
                         <td><input type='text' name='stgma.state'/></td>
+                        <td>[% show_field_extras('aua', 'state', 1) %]</td>
                     </tr>
                     [% END %]
                     <tr>
                         <td>[% l('Post/Zip Code') %]</td>
                         <td><input type='text' name='stgma.post_code'/></td>
+                        <td>[% show_field_extras('aua', 'post_code', 0, 1) %]</td>
                     </tr>
                     [% IF show_field('aua', 'county') %]
                     <tr>
                         <td>[% l('County') %]</td>
                         <td><input type='text' name='stgma.county'/></td>
+                        <td>[% show_field_extras('aua', 'county', 1) %]</td>
                     </tr>
                     [% END %]
+                    [% END # addr_required -------------------------------- %]
+
                     [% IF show_field('au', 'dob') %]
                     <tr>
                         <td>[% l('Date of Birth') %]</td>
                         <td><input type='text' name='stgu.dob'/></td>
+                        <td>[% show_field_extras('au', 'dob', 1) %]</td>
                     </tr>
                     [% END %]
                     [% IF show_field('au', 'day_phone') %]
                     <tr>
                         <td>[% l('Phone Number') %]</td>
                         <td><input type='text' name='stgu.day_phone'/></td>
+                        <td>[% show_field_extras('au', 'day_phone', 1, 1) %]</td>
                     </tr>
                     [% END %]
-                    [% IF show_field('au', 'dob') %]
+                    [% IF show_field('au', 'email') %]
                     <tr>
                         <td>[% l('Email Address') %]</td>
                         <td><input type='text' name='stgu.email'/></td>
+                        <td>[% show_field_extras('au', 'email', 1, 1) %]</td>
                     </tr>
                     [% END %]
                     <tr>