Bug 8014 - On the patron entry form hide "restricted until" field if "Restricted...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / memberentrygen.tt
index 6d60917..41ce66d 100644 (file)
@@ -3,7 +3,7 @@
 [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] [% IF ( categoryname ) %] [% categoryname %] patron[% ELSE %][% IF ( I ) %] Organization patron[% END %][% IF ( A ) %] Adult patron[% END %][% IF ( C ) %] Child patron[% END %][% IF ( P ) %] Professional patron[% END %][% IF ( S ) %] Staff patron[% END %][% END %][% UNLESS ( opadd ) %] [% surname %], [% firstname %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
-<script type="text/JavaScript" language="JavaScript">
+<script type="text/JavaScript">
 //<![CDATA[
     $(document).ready(function() {
                $("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
             $("#guarantorsearch").val("Set to Patron");
         });
         $("#select_city").change(function(){
-            var myRegEx=new RegExp(/(.*)\|(.*)/);
+            var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/);
             document.form.select_city.value.match(myRegEx);
             document.form.zipcode.value=RegExp.$1;
             document.form.city.value=RegExp.$2;
+            document.form.state.value=RegExp.$3;
+            document.form.country.value=RegExp.$4;
         });
+
+        [% IF categorycode %]
+            update_category_code( "[% categorycode %]" );
+        [% ELSE %]
+            if ( $("#categorycode").length > 0 ){
+                var category_code = $("#categorycode").find("option:selected").val();
+                update_category_code( category_code );
+            }
+        [% END %]
+
     });
 
     function clear_entry(node) {
         $("select#patron_attr_" + newId, clone).attr('value','');
         original.parentNode.insertBefore(clone, original.nextSibling);
     }
+
+    function update_category_code(category_code) {
+        if ( $(category_code).is("select") ) {
+            category_code = $("#categorycode").find("option:selected").val();
+        }
+        var mytables = $(".attributes_table>tbody");
+
+        mytables.find("tr").each(function(){
+            $(this).hide()
+        });
+
+        mytables.find("tr[data-category_code="+category_code+"]").each(function(){
+            $(this).show();
+        });
+        mytables.find("tr[data-category_code='']").each(function(){
+            $(this).show();
+        });
+
+    }
+
                var MSG_SEPARATOR = _("Separator must be / in field ");
         var MSG_INCORRECT_DAY = _("Invalid day entered in field ");
         var MSG_INCORRECT_MONTH = _("Invalid month entered in field ");
         var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
         var MSG_MISSING_MANDATORY = _("The following fields are mandatory:");
         var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
+        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
 //]]>
 </script>
 <script type="text/javascript" src="[% themelang %]/js/members.js"></script>
 </head>
-<body>
+<body id="pat_memberentrygen" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 
        <div id="yui-main">
        <div class="yui-b">
 
+    [% IF error_alert %]
+        [% IF ( error_alert == "no_email" ) %]
+            <div class="error">This member has no email</div>
+        [% ELSE %]
+            <div class="error">[% error_alert %]</div>
+        [% END %]
+    [% END %]
+    [% IF info_alert %]
+        <div class="dialog message">Email has been sent.</div>
+    [% END %]
+
        [% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
                [% IF ( no_branches ) %]<p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>[% END %]
                [% IF ( no_categories ) %]<p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.</p>[% END %][% END %]</div>[% END %]
                                <p><a class="popup" href="javascript:Dopop('moremember.pl?print=brief&amp;borrowernumber=[% check_member %]');" >View existing record</a></p>
                                <form action="/cgi-bin/koha/members/memberentry.pl" method="get"><input type="hidden" name="op" value="modify" /><input type="hidden" name="borrowernumber" value="[% check_member %]" /><input type="hidden" name="category_type" value="[% check_categorytype %]" /><input class="edit" type="submit" value="It is a duplicate. Edit existing record" /></form>
 
-                               <form name="form_double" action="/cgi-bin/koha/members/memberentry.pl" method="post">
+                <form name="form_double" action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off">
                                <input type="hidden" name="nodouble" value="1" />
                                <input class="new" type="submit" value="Not a duplicate. Save as new record" />
                        </div>
                        [% IF ( ERROR_short_password ) %]
                                <li id="ERROR_short_password">Password must be at least [% minPasswordLength %] characters long.</li>
                        [% END %]
+                       [% IF ( ERROR_password_mismatch ) %]
+                               <li id="ERROR_password_mismatch">Passwords do not match.</li>
+                       [% END %]
             [% IF ( ERROR_extended_unique_id_failed ) %]
                 <li id="ERROR_extended_unique_id_failed">The attribute value 
                     [% ERROR_extended_unique_id_failed %] is already is use by another patron record.</li>
        [% END %]
 
 
-[% UNLESS ( check_member ) %]<form name="form" id="entryform"  action="/cgi-bin/koha/members/memberentry.pl" method="post">
+[% UNLESS ( check_member ) %]<form name="form" id="entryform"  action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off">
 <input type="hidden" name="nodouble"  value="[% nodouble %]" /> [% END %]
 <!--    field always hidden in different form (1,2,3) -->
 <input type="hidden" name="BorrowerMandatoryField" value="[% BorrowerMandatoryField %]" />
 <input type="hidden" name="borrowernumber" value="[% IF ( opduplicate ) %][% ELSE %][% borrowernumber %][% END %]" />
 <input type="hidden" name="nodouble"  value="[% IF ( opduplicate ) %][% ELSE %][% nodouble %][% END %]" />
 [% IF ( step ) %]<input type="hidden" name="step"  value="[% step %]" />[% END %]
-[% IF ( opadd ) %]<input type="hidden" name="op" value="insert" />[% ELSIF ( opduplicate ) %]<input type="hidden" name="op" value="insert" />[% ELSE %]<input type="hidden" name="op" value="save" />[% END %]
+[% IF ( opadd ) %]<input type="hidden" name="op" value="insert" />
+[% ELSIF ( opduplicate ) %]
+<input type="hidden" name="op" value="insert" />
+[% ELSE %]
+<input type="hidden" name="op" value="save" />
+[% IF step == 4 || step == 5 || step == 6 || step == 2 || step == 1 %]
+[%# Only put the cardnumber if we arent showing it in the form later %]
+[% IF cardnumber %]
+<input type="hidden" name="cardnumber" value="[% cardnumber %]" />
+[% END %]
+[% END %]
+[% END %]
 
 [% IF ( step_1 ) %]
+[%UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
        <fieldset class="rows" id="memberentry_identity">
-               <legend>[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
+               <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
                <ol>
                [% UNLESS ( I ) %]
+        [% UNLESS notitle %]
                [% IF ( title_cgipopup ) %]
             <li>
             [% IF ( mandatorytitle ) %]
             </li>
                [% END %]
         [% END %]
+               [% END %]
+        [% UNLESS nosurname %]
                <li>
                [% IF ( mandatorysurname ) %]
                <label for="surname" class="required">
                [% END %]
                Surname: </label>
                [% IF ( uppercasesurnames ) %]
-               <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% surname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                       [% IF ( opduplicate ) %]
+                               <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% surname %]" onclick="this.value=''" />
+                       [% ELSE %]
+                               <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% surname %]" />
+                       [% END %]
                [% ELSE %]
-               <input type="text" id="surname" name="surname" size="20"  value="[% surname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                       [% IF ( opduplicate ) %]
+                               <input type="text" id="surname" name="surname" size="20"  value="[% surname %]" onclick="this.value=''" />
+                       [% ELSE %]
+                               <input type="text" id="surname" name="surname" size="20"  value="[% surname %]" />
+                       [% END %]
                [% END %]
                [% IF ( mandatorysurname ) %]<span class="required">Required</span>[% END %]
                </li>
+        [% END %]
                [% UNLESS ( I ) %]
+        [% UNLESS nofirstname %]
             <li>
                 [% IF ( mandatoryfirstname ) %]
                 <label for="firstname" class="required">
                 <input type="text" id="firstname" name="firstname" size="20"  value="[% IF ( opduplicate ) %][% ELSE %][% firstname %][% END %]" />
                 [% IF ( mandatoryfirstname ) %]<span class="required">Required</span>[% END %]
             </li>
+        [% END %]
+        [% UNLESS nodateofbirth %]
             <li>
                 [% IF ( mandatorydateofbirth ) %]
                 <label for="dateofbirth" class="required">
         [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %]
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
             </li>
+        [% END %]
+        [% UNLESS noinitials %]
             <li>
                 [% IF ( mandatoryinitials ) %]
                     <label for="initials" class="required">
                     <label for="initials">
                 [% END %]
                 Initials: </label>
-                <input type="text" id="initials" name="initials" size="20"  value="[% initials %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] /> 
+                [% IF ( opduplicate ) %]
+                                       <input type="text" id="initials" name="initials" size="20"  value="[% initials %]" onclick="this.value=''" />
+                [% ELSE %]
+                                       <input type="text" id="initials" name="initials" size="20"  value="[% initials %]" />
+                [% END %]
                 [% IF ( mandatoryinitials ) %]<span class="required">Required</span>[% END %]
             </li>
         [% END %]
+        [% END %]
+        [% UNLESS noothernames %]
                <li>
                        [% IF ( mandatoryothernames ) %]
                        <label for="othernames" class="required">
                        <label for="othernames">
                        [% END %]
                        Other name: </label>
-                       <input type="text" id="othernames" name="othernames" size="20"  value="[% othernames %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                       [% IF ( opduplicate ) %]
+                               <input type="text" id="othernames" name="othernames" size="20"  value="[% othernames %]" onclick="this.value=''" />
+                       [% ELSE %]
+                               <input type="text" id="othernames" name="othernames" size="20"  value="[% othernames %]" />
+                       [% END %]
 [% IF ( mandatoryothernames ) %]<span class="required">Required</span>[% END %]
                [% IF ( I ) %]<input type="hidden" name="sex" value="N" />[% END %]
                </li>
+        [% END %]
     [% UNLESS ( I ) %]
+        [% UNLESS nosex %]
                <li class="radio">
                
                [% IF ( female ) %]
                                <label for="sex-none">N/A </label><input type="radio" name="sex" id="sex-none" value="" />
 [% END %]
                </li>
+        [% END %]
     [% END %]
                </ol>
        </fieldset>
-       
+[% END # hide fieldset %]
+
 [% IF ( showguarantor ) %]<input type="hidden" id="guarantorid" name="guarantorid"   value="[% guarantorid %]" />
     <fieldset class="rows">
-        <legend>Guarantor Information</legend>
+        <legend>Guarantor information</legend>
         <ol>
 [% IF ( P ) %]
                [% IF ( guarantorid ) %]
                    <span>[% contactname %]</span>
                    <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname %]" />
                    [% ELSE %]
-                   <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                           [% IF ( opduplicate ) %]
+                                               <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" onclick="this.value=''" />
+                           [% ELSE %]
+                                               <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
+                           [% END %]
                    [% END %]
                </li>
 [% ELSE %]
  [% END %]
      <span class="label">Patron #:</span> [% IF ( guarantorid ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid %]" target="blank">[% guarantorid %]</a>[% END %]
  </li>
+        [% UNLESS nocontactname %]
  <li>
      <label for="contactname">Surname: </label>
      [% IF ( guarantorid ) %]
      <span>[% contactname %]</span>
      <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname %]" />
      [% ELSE %]
-     <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+               [% IF ( opduplicate ) %]
+                       <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" onclick="this.value=''" />
+               [% ELSE %]
+                       <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
+               [% END %]
      [% END %]
  </li>
+        [% END %]
+        [% UNLESS nocontactfirstname %]
  <li>
      <label for="contactfirstname">First name: </label>
      [% IF ( guarantorid ) %]
      <span>[% contactfirstname %]</span>
      <input name="contactfirstname" id="contactfirstname" type="hidden" size="20" value="[% contactfirstname %]" />
      [% ELSE %]
-     <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+            [% IF ( opduplicate ) %]
+                               <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname %]" onclick="this.value=''" />
+            [% ELSE %]
+                               <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname %]" />
+            [% END %]
      [% END %]
  </li>
+        [% END %]
  [% IF ( relshiploop ) %]
  <li>
      <label for="relationship">Relationship: </label>
             [% IF ( guarantorid ) %]
             <input id="guarantorsearch" type="button" value="Change" onclick="Dopopguarantor('guarantor_search.pl?category_type=[% category_type %]');" />
             [% ELSE %]
-            <input id="guarantorsearch" type="button" value="Set to Patron" onclick="Dopopguarantor('guarantor_search.pl?category_type=[% category_type %]');" />
+            <input id="guarantorsearch" type="button" value="Set to patron" onclick="Dopopguarantor('guarantor_search.pl?category_type=[% category_type %]');" />
             [% END %]
             <input id="guarantordelete" type="button" value="Delete" />
         </li>
     </fieldset>
 
 [% END %]
+[% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %]
 <fieldset class="rows">
-    <legend>Main address</legend><ol>
+    <legend id="main_address_lgd">Main address</legend><ol>
+        [% UNLESS nostreetnumber %]
     <li>
       [% IF ( mandatorystreetnumber ) %]
       <label for="streetnumber" class="required">
       <label for="streetnumber">
       [% END %]
       Street number: </label>
-      <input type="text" id="streetnumber" name="streetnumber" size="5" value="[% streetnumber %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+               <input type="text" id="streetnumber" name="streetnumber" size="5" value="[% streetnumber %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input type="text" id="streetnumber" name="streetnumber" size="5" value="[% streetnumber %]" />
+      [% END %]
 [% IF ( mandatorystreetnumber ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS nostreettype %]
     [% IF ( road_cgipopup ) %]
       <li>
       [% IF ( mandatorystreettype ) %]
          [% IF ( mandatorystreettype ) %]<span class="required">Required</span>[% END %]
       </li>
     [% END %] 
+        [% END %]
+        [% UNLESS noaddress %]
     <li>
       [% IF ( mandatoryaddress ) %]
       <label for="address" class="required">
       <label for="address">
       [% END %]
       Address: </label>
-      <input type="text" id="address" name="address" size="35" value="[% address %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+                       <input type="text" id="address" name="address" size="35" value="[% address %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" id="address" name="address" size="35" value="[% address %]" />
+      [% END %]
          [% IF ( mandatoryaddress ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS noaddress2 %]
     <li>
       [% IF ( mandatoryaddress2 ) %]
       <label for="address2" class="required">
       <label for="address2">
       [% END %]
       Address 2: </label>
-      <input type="text" id="address2" name="address2" size="35" value="[% address2 %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+                       <input type="text" id="address2" name="address2" size="35" value="[% address2 %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" id="address2" name="address2" size="35" value="[% address2 %]" />
+      [% END %]
          [% IF ( mandatoryaddress2 ) %]<span class="required">Required</span>[% END %]
     </li>  
+        [% END %]
+        [% UNLESS nocity %]
     <li>
       [% IF ( mandatorycity ) %]
         <label for="city" class="required">
         <label for="city">
       [% END %]
       City: </label>
-        
-        <input type="text" id="city" name="city" size="20" value="[% city %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+        [% IF ( opduplicate ) %]
+                       <input type="text" id="city" name="city" size="20" value="[% city %]" onclick="this.value=''" />
+        [% ELSE %]
+                       <input type="text" id="city" name="city" size="20" value="[% city %]" />
+        [% END %]
         [% IF ( city_cgipopup ) %]or <strong>choose</strong>
         <select id="select_city" name="select_city">
         [% FOREACH city_loo IN city_loop %]
             [% IF ( city_loo.selected ) %]
-            <option value="[% city_loo.city_zipcode %]|[% city_loo.city_name %]" selected="selected">
+            <option value="[% city_loo.city_zipcode %]|[% city_loo.city_name %]|[% city_loo.city_state %]|[% city_loo.city_country %]" selected="selected">
             [% ELSE %]
-            <option value="[% city_loo.city_zipcode %]|[% city_loo.city_name %]">
+            <option value="[% city_loo.city_zipcode %]|[% city_loo.city_name %]|[% city_loo.city_state %]|[% city_loo.city_country %]">
             [% END %]
-                [% city_loo.city_name %] [% city_loo.city_zipcode %]
+                [% city_loo.city_name %] [% city_loo.city_state %] [% city_loo.city_zipcode %]
             </option>
         [% END %]
         </select>
         [% END %]
          [% IF ( mandatorycity ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS nostate %]
     <li> 
       [% IF ( mandatorystate ) %]
         <label for="state" class="required">
       <input type="text" name="state" id="state" size="20" value="[% state %]" />
          [% IF ( mandatorystate ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS nozipcode %]
     <li> 
       [% IF ( mandatoryzipcode ) %]
         <label for="zipcode" class="required">
         <label for="zipcode">
       [% END %]
       Zip/Postal code: </label>
-      <input type="text" name="zipcode" id="zipcode" size="10" value="[% zipcode %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+                       <input type="text" name="zipcode" id="zipcode" size="10" value="[% zipcode %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" name="zipcode" id="zipcode" size="10" value="[% zipcode %]" />
+      [% END %]
          [% IF ( mandatoryzipcode ) %]<span class="required">Required</span>[% END %]
     </li>
-    
+        [% END %]
+        [% UNLESS nocountry %]
     <li> 
       [% IF ( mandatorycountry ) %]
         <label for="country" class="required">
         <label for="country">
       [% END %]
       Country: </label>
-      <input type="text" name="country" id="country" size="20" value="[% country %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+                       <input type="text" name="country" id="country" size="20" value="[% country %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" name="country" id="country" size="20" value="[% country %]" />
+      [% END %]
          [% IF ( mandatorycountry ) %]<span class="required">Required</span>[% END %]
     </li>    
-  
+        [% END %]
        </ol>
     </fieldset>
+[% END # nostreet && nocity etc group%]
+
+[% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %]
   <fieldset class="rows" id="memberentry_contact">
-    <legend>Contact</legend><ol>
+    <legend id="contact_lgd">Contact</legend><ol>
+        [% UNLESS nophone %]
       <li>
       [% IF ( mandatoryphone ) %] 
       <label for="phone" class="required">
       [% ELSE %]
       <label for="phone">
       [% END %]
-      Phone (home): </label>
-      <input type="text" id="phone" name="phone" value="[% phone %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      Primary phone: </label>
+      [% IF ( opduplicate ) %]
+                       <input type="text" id="phone" name="phone" value="[% phone %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" id="phone" name="phone" value="[% phone %]" />
+      [% END %]
          [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
 
     </li>
+        [% END %]
+        [% UNLESS nophonepro %]
     <li>
       [% IF ( mandatoryphonepro ) %]
       <label for="phonepro" class="required">
       [% ELSE %]
       <label for="phonepro">
       [% END %]
-      Phone (work): </label>
-      <input type="text" id="phonepro" name="phonepro" value="[% phonepro %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      Secondary phone: </label>
+      [% IF ( opduplicate ) %]
+                       <input type="text" id="phonepro" name="phonepro" value="[% phonepro %]" onclick="this.value=''" />
+      [% ELSE %]
+                       <input type="text" id="phonepro" name="phonepro" value="[% phonepro %]" />
+      [% END %]
          [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS nomobile %]
     <li>
       [% IF ( mandatorymobile ) %]
       <label for="mobile" class="required">
       [% ELSE %]
       <label for="mobile">
       [% END %]
-      Phone (cell): </label>
-      <input type="text" id="mobile" name="mobile" value="[% mobile %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      Other phone: </label>
+      [% IF ( opduplicate ) %]
+               <input type="text" id="mobile" name="mobile" value="[% mobile %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input type="text" id="mobile" name="mobile" value="[% mobile %]" />
+      [% END %]
          [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS noemail %]
     <li>
       [% IF ( mandatoryemail ) %]
       <label for="email" class="required">
       [% ELSE %]
       <label for="email">
       [% END %]
-      Primary Email: </label>
-      <input type="text" id="email" name="email" size="45" value="[% email %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />  
+      Primary email: </label>
+      [% IF ( opduplicate ) %]
+               <input type="text" id="email" name="email" size="45" value="[% email %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input type="text" id="email" name="email" size="45" value="[% email %]" />
+      [% END %]
          [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
 
     </li>
+        [% END %]
+        [% UNLESS noemailpro %]
     <li>
       [% IF ( mandatoryemailpro ) %] 
       <label for="emailpro" class="required">
       [% ELSE %]
       <label for="emailpro">
       [% END %]
-      Secondary Email: </label>
-      <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      Secondary email: </label>
+      [% IF ( opduplicate ) %]
+               <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro %]" />
+      [% END %]
          [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
+        [% UNLESS nofax %]
     <li>
       [% IF ( mandatoryfax ) %]
       <label for="fax" class="required">
       <label for="fax">
       [% END %]
       Fax: </label>
-      <input type="text" id="fax" name="fax" value="[% fax %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+               <input type="text" id="fax" name="fax" value="[% fax %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input type="text" id="fax" name="fax" value="[% fax %]" />
+      [% END %]
          [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
        </ol>
   </fieldset>
-
+[%END # hide fieldset %]
 
 <!-- ************************ STEP_1 *********************** -->
 [% END %]
 [% IF ( step_6 ) %]
 
+    [% UNLESS noB_address && noB_address2 && noB_city && noB_zipcode && noB_state && noB_country &&nocontactnote && noB_phone && noB_email %]
                <fieldset class="rows" id="memberentry_address">
-               <legend>Alternate address</legend><ol>
+               <legend id="alt_address_lgd">Alternate address</legend><ol>
+        [% UNLESS noB_address %]
                        <li>
                                [% IF ( mandatoryB_address ) %]
                                        <label for="B_address" class="required">
                                        <label for="B_address">
                                [% END %]
                                Address: </label>
-                               <input type="text" id="B_address" name="B_address" size="40" value="[% B_address %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" id="B_address" name="B_address" size="40" value="[% B_address %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" id="B_address" name="B_address" size="40" value="[% B_address %]" />
+                               [% END %]
          [% IF ( mandatoryB_address ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_address2 %]
                        <li>
                                [% IF ( mandatoryB_address2 ) %]
                                        <label for="B_address2" class="required">
                                        <label for="B_address2">
                                [% END %]
                                Address 2: </label>
-                               <input type="text" id="B_address2" name="B_address2" size="40" value="[% B_address2 %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" id="B_address2" name="B_address2" size="40" value="[% B_address2 %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" id="B_address2" name="B_address2" size="40" value="[% B_address2 %]" />
+                               [% END %]
          [% IF ( mandatoryB_address2 ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_city %]
                        <li>
                                [% IF ( mandatoryB_city ) %]
                                        <label for="B_city" class="required" >
                                <input type="text" id="B_city" name="B_city" size="20" value="[% B_city %]" />
          [% IF ( mandatoryB_city ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_state %]
                        <li>
                                [% IF ( mandatoryB_state ) %]
                                        <label for="B_state" class="required" >
                                <input type="text" id="B_state" name="B_state" size="20" value="[% B_state %]" />
          [% IF ( mandatoryB_state ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_zipcode %]
                        <li>
                                [% IF ( mandatoryB_zipcode ) %]
                                        <label for="B_zipcode" class="required">
                                        <label for="B_zipcode">
                                [% END %]
                                Zip/Postal code: </label>
-                               <input type="text" id="B_zipcode" name="B_zipcode" maxlength="10" size="10" value="[% B_zipcode %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" id="B_zipcode" name="B_zipcode" maxlength="10" size="10" value="[% B_zipcode %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" id="B_zipcode" name="B_zipcode" maxlength="10" size="10" value="[% B_zipcode %]" />
+                               [% END %]
          [% IF ( mandatoryB_zipcode ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_country %]
                        <li>
                                [% IF ( mandatoryB_country ) %]
                                        <label for="B_country" class="required">
                                        <label for="B_country">
                                [% END %]
                                Country: </label>
-                               <input type="text" id="B_country" name="B_country" size="20" value="[% B_country %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" id="B_country" name="B_country" size="20" value="[% B_country %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" id="B_country" name="B_country" size="20" value="[% B_country %]" />
+                               [% END %]
          [% IF ( mandatoryB_country ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noB_phone %]
             <li>
                 [% IF ( mandatoryB_phone ) %]
                 <label for="B_phone" class="required">
                 [% ELSE %]
                 <label for="B_phone">
                 [% END %]
-                Phone: </label>  
-                <input type="text" id="B_phone" name="B_phone" value="[% B_phone %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                Phone: </label>
+                [% IF ( opduplicate ) %]
+                                       <input type="text" id="B_phone" name="B_phone" value="[% B_phone %]" onclick="this.value=''" />
+                [% ELSE %]
+                                       <input type="text" id="B_phone" name="B_phone" value="[% B_phone %]" />
+                [% END %]
                 [% IF ( mandatoryB_phone ) %]<span class="required">Required</span>[% END %]
             </li>
+        [% END %]
+        [% UNLESS noB_email %]
                        <li> 
         [% IF ( mandatoryB_email ) %]
           <label for="B_email" class="required">
           <label for="B_email">
         [% END %]
         Email: </label>
-        <input type="text" id="B_email" name="B_email" size="45" value="[% B_email %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+        [% IF ( opduplicate ) %]
+                       <input type="text" id="B_email" name="B_email" size="45" value="[% B_email %]" onclick="this.value=''" />
+        [% ELSE %]
+                       <input type="text" id="B_email" name="B_email" size="45" value="[% B_email %]" />
+               [% END %]
                [% IF ( mandatoryB_email ) %]<span class="required">Required</span>[% END %] </li>
+        [% END %]
+        [% UNLESS nocontactnote %]
             <li>
                 [% IF ( mandatorycontactnote ) %]
                 <label for="contactnote" class="required">
                 <textarea id="contactnote" name="contactnote" cols="40" rows="2">[% contactnote %]</textarea>
         [% IF ( mandatorycontactnote ) %]<span class="required">Required</span>[% END %]
             </li>
+        [% END %]
                        </ol>
                </fieldset>
-[% END %]              
+    [% END # UNLESS noB_address && noB_city && noB_state && noB_phone && noB_email %]
+[% END %]
 [% IF ( step_2 ) %]
+    [% UNLESS noaltcontactsurname && noaltcontactfirstname && noaltcontactaddress1 && noaltcontactaddress2 && noaltcontactaddress3 && noaltcontactstate && noaltcontactzipcode && noaltcontactcountry && noaltcontactphone %]
                <fieldset class="rows" id="memberentry_altaddress">       
-                   <legend>Alternate Contact</legend><ol>
+            <legend id="alt_contact_lgd">Alternate contact</legend><ol>
+        [% UNLESS noaltcontactsurname %]
                        <li>
                            [% IF ( mandatoryaltcontactsurname ) %]
                                <label for="altcontactsurname" class="required">
                                <label for="altcontactsurname">
                                [% END %]
                                Surname:</label>
-                               <input type="text" name="altcontactsurname" id="altcontactsurname" value="[% altcontactsurname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactsurname" id="altcontactsurname" value="[% altcontactsurname %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactsurname" id="altcontactsurname" value="[% altcontactsurname %]" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactsurname ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactfirstname %]
                        <li>
                            [% IF ( mandatoryaltcontactfirstname ) %]
                                <label for="altcontactfirstname" class="required">
                                <label for="altcontactfirstname">
                                [% END %]
                                First name:</label>
-                               <input type="text" name="altcontactfirstname" id="altcontactfirstname" value="[% altcontactfirstname %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactfirstname" id="altcontactfirstname" value="[% altcontactfirstname %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactfirstname" id="altcontactfirstname" value="[% altcontactfirstname %]" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactfirstname ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactaddress1 %]
                        <li>
                            [% IF ( mandatoryaltcontactaddress1 ) %]
                                <label for="altcontactaddress1" class="required">
                                <label for="altcontactaddress1">
                                [% END %]
                                Address:</label>
-                               <input type="text" name="altcontactaddress1" id="altcontactaddress1" value="[% altcontactaddress1 %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] size="40" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactaddress1" id="altcontactaddress1" value="[% altcontactaddress1 %]" onclick="this.value=''" size="40" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactaddress1" id="altcontactaddress1" value="[% altcontactaddress1 %]" size="40" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactaddress1 ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactaddress2 %]
                        <li>
                            [% IF ( mandatoryaltcontactaddress2 ) %]
                                <label for="altcontactaddress2" class="required">
                                <label for="altcontactaddress2">
                                [% END %]
                                Address 2:</label>
-                               <input type="text" name="altcontactaddress2" id="altcontactaddress2" value="[% altcontactaddress2 %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] size="40" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactaddress2" id="altcontactaddress2" value="[% altcontactaddress2 %]" onclick="this.value=''" size="40" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactaddress2" id="altcontactaddress2" value="[% altcontactaddress2 %]" size="40" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactaddress2 ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactaddress3 %]
                        <li>
                            [% IF ( mandatoryaltcontactaddress3 ) %]
                                <label for="altcontactaddress3" class="required">
                                <input type="text" name="altcontactaddress3" id="altcontactaddress3" value="[% altcontactaddress3 %]" size="20" />
                                [% IF ( mandatoryaltcontactaddress3 ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactstate %]
                        <li>
                            [% IF ( mandatoryaltcontactstate ) %]
                                <label for="altcontactstate" class="required">
                                <input type="text" name="altcontactstate" id="altcontactstate" value="[% altcontactstate %]" size="20" />
                                [% IF ( mandatoryaltcontactstate ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactzipcode %]
                        <li>
                            [% IF ( mandatoryaltcontactzipcode ) %]
                                <label for="altcontactzipcode" class="required">
                                <label for="altcontactzipcode">
                                [% END %]
                                Zip/Postal code:</label>
-                               <input type="text" name="altcontactzipcode" id="altcontactzipcode" value="[% altcontactzipcode %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] size="5" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactzipcode" id="altcontactzipcode" value="[% altcontactzipcode %]" onclick="this.value=''" size="5" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactzipcode" id="altcontactzipcode" value="[% altcontactzipcode %]" size="5" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactzipcode ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
+        [% UNLESS noaltcontactcountry %]
                        <li>
                            [% IF ( mandatoryaltcontactcountry ) %]
                                <label for="altcontactcountry" class="required">
                                <label for="altcontactcountry">
                                [% END %]
                                Country:</label>
-                               <input type="text" name="altcontactcountry" id="altcontactcountry" value="[% altcontactcountry %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] size="20" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactcountry" id="altcontactcountry" value="[% altcontactcountry %]" onclick="this.value=''" size="20" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactcountry" id="altcontactcountry" value="[% altcontactcountry %]" size="20" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactcountry ) %]<span class="required">Required</span>[% END %]
                        </li>                   
+        [% END %]
+        [% UNLESS noaltcontactphone %]
                        <li>
                            [% IF ( mandatoryaltcontactphone ) %]
                                <label for="altcontactphone" class="required">
                                <label for="altcontactphone">
                                [% END %]
                                Phone:</label>
-                               <input type="text" name="altcontactphone" id="altcontactphone" value="[% altcontactphone %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+                               [% IF ( opduplicate ) %]
+                                       <input type="text" name="altcontactphone" id="altcontactphone" value="[% altcontactphone %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                       <input type="text" name="altcontactphone" id="altcontactphone" value="[% altcontactphone %]" />
+                               [% END %]
                                [% IF ( mandatoryaltcontactphone ) %]<span class="required">Required</span>[% END %]
                        </li>
+        [% END %]
             </ol>
         </fieldset>
+    [% END # UNLESS noaltcontactsurname && noaltcontactfirstname etc %]
 
-
-  [% IF ( I ) %]
-       [% IF ( memberofinstution ) %]
-       <fieldset class="rows" id="memberentry_organisation">
-               <legend>Organizations</legend><ol>
-               <li>
-                       [% IF ( mandatoryphone ) %] 
-                       <label for="organisations" class="required">
-                       [% ELSE %]
-                       <label for="organisations">
-                       [% END %]
-                       Organization(s): </label>
-                       [% CGIorganisations %]
-         [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]
-               </li>
-               </ol>
-       </fieldset>
-       [% END %]
-  [% END %]
-              
 [% END %]
 [% IF ( step_3 ) %]
 
   <fieldset class="rows" id="memberentry_library_management">
-    <legend>Library Management</legend><ol>
+    <legend id="library_management_lgd">Library management</legend><ol>
+        [% UNLESS nocardnumber %]
    <li> [% IF ( mandatorycardnumber ) %]
       <label for="cardnumber" class="required">
     [% ELSE %]
       <label for="cardnumber">
     [% END %] 
     Card number: </label>
-    <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% IF ( opduplicate ) %][% ELSE %][% cardnumber %][% END %]" />
+    [% IF ( opduplicate ) %]
+               <input type="text" id="cardnumber" name="cardnumber" size="20" />
+    [% ELSE %]
+               <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber %]" />
+    [% END %]
          [% IF ( mandatorycardnumber ) %]<span class="required">Required</span>[% END %]</li>
+        [% END %]
+        [% UNLESS nobranchcode %]
     <li>
       [% IF ( mandatorybranchcode ) %]
         <label for="branchcode" class="required">
       [% CGIbranch %]
          [% IF ( mandatorybranchcode ) %]<span class="required">Required</span>[% END %]
     </li>
+        [% END %]
     <li>
         <label for="categorycode">Category: </label>
-        <select id="categorycode" name="categorycode">
+        <select id="categorycode" name="categorycode" onchange="update_category_code(this);">
         [% FOREACH typeloo IN typeloop %]
-                       [% FOREACH categoryloo IN typeloo.categoryloop %]
-                               [% IF ( loop.first ) %]
-                                       [% IF ( categoryloo.typename_C ) %]<optgroup label="Child">[% END %]
-                                       [% IF ( categoryloo.typename_A ) %]<optgroup label="Adult">[% END %]
-                                       [% IF ( categoryloo.typename_S ) %]<optgroup label="Staff">[% END %]
-                                       [% IF ( categoryloo.typename_I ) %]<optgroup label="Organization">[% END %]
-                                       [% IF ( categoryloo.typename_P ) %]<optgroup label="Professional">[% END %]
-                                       [% IF ( categoryloo.typename_X ) %]<optgroup label="Statistical">[% END %]
-                           [% END %]
-                               [% IF ( categoryloo.categorycodeselected ) %]
-               <option value="[% categoryloo.categorycode %]" selected="selected">[% categoryloo.categoryname %]</option>
-                               [% ELSE %]
-<option value="[% categoryloo.categorycode %]">[% categoryloo.categoryname %]</option>
-                               [% END %]
-                               [% IF ( loop.last ) %]
-                               </optgroup>
-                               [% END %]
+            [% FOREACH categoryloo IN typeloo.categoryloop %]
+                [% IF ( loop.first ) %]
+                    [% IF ( typeloo.typename_C ) %]<optgroup label="Child"        value="C">[% END %]
+                    [% IF ( typeloo.typename_A ) %]<optgroup label="Adult"        value="A">[% END %]
+                    [% IF ( typeloo.typename_S ) %]<optgroup label="Staff"        value="S">[% END %]
+                    [% IF ( typeloo.typename_I ) %]<optgroup label="Organization" value="I">[% END %]
+                    [% IF ( typeloo.typename_P ) %]<optgroup label="Professional" value="P">[% END %]
+                    [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical"  value="X">[% END %]
+                [% END %]
+                [% IF ( categoryloo.categorycodeselected ) %]
+                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
+                [% ELSE %]
+                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
+                [% END %]
+                [% IF ( loop.last ) %]
+                    </optgroup>
+                [% END %]
             [% END %]
        [% END %]
        </select>
     </li>
+        [% UNLESS nosort1 %]
     <li>
       [% IF ( mandatorysort1 ) %]
         <label for="sort1" class="required">
          [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %]
       [% END %]   
     </li>
+        [% END %]
+        [% UNLESS nosort2 %]
     <li>
     [% IF ( mandatorysort2 ) %]
     <label for="sort2" class="required">
     [% IF ( CGIsort2 ) %] 
       [% CGIsort2 %]
     [% ELSE %]
-      <input  type="text" id="sort2" name="sort2" size="20"  value="[% sort2 %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+      [% IF ( opduplicate ) %]
+               <input  type="text" id="sort2" name="sort2" size="20"  value="[% sort2 %]" onclick="this.value=''" />
+      [% ELSE %]
+               <input  type="text" id="sort2" name="sort2" size="20"  value="[% sort2 %]" />
+      [% END %]
          [% IF ( mandatorysort2 ) %]<span class="required">Required</span>[% END %]
     [% END %] 
     </li>
+        [% END %]
        </ol>
   </fieldset>
+    [% UNLESS nodateenrolled && nodateexpiry &&  noopacnote && noborrowernotes %]
        <fieldset class="rows" id="memberentry_subscription">
-       <legend>Library set-up</legend><ol>
+       <legend id="library_setup_lgd">Library set-up</legend><ol>
+        [% UNLESS nodateenrolled %]
                <li>
                        [% IF ( mandatorydateenrolled ) %]
                        <label for="dateenrolled" class="required">
                        <label for="dateenrolled">
                        [% END %]
                        Registration date: </label>
-                       <input type="text" id="dateenrolled" name="dateenrolled"  maxlength="10" size="10" [% IF ( metric ) %]onchange="CheckDate(document.form.dateenrolled);check_manip_date('verify');"[% END %] value="[% dateenrolled %]" />
+                       [% IF ( metric ) %]
+                               <input type="text" id="dateenrolled" name="dateenrolled"  maxlength="10" size="10" onchange="CheckDate(document.form.dateenrolled);check_manip_date('verify');" value="[% dateenrolled %]" />
+                       [% ELSE %]
+                               <input type="text" id="dateenrolled" name="dateenrolled"  maxlength="10" size="10" value="[% dateenrolled %]" />
+                       [% END %]
             <img src="[% themelang %]/lib/calendar/cal.gif" id="dateenrolled_button" alt="Show Calendar" />
       <script language="JavaScript" type="text/javascript">
         Calendar.setup(
                [% IF ( ERROR_dateenrolled ) %]<span class="required">(Error)</span>[% END %]
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                </li>
+        [% END %]
+        [% UNLESS nodateexpiry %]
                <li>
                        [% IF ( mandatorydateexpiry ) %]
                        <label for="dateexpiry" class="required">
                        <label for="dateexpiry">
                        [% END %]
                        Expiry date (leave blank for auto calc) </label>
-                       <input type="text" id="dateexpiry" name="dateexpiry" maxlength="10"  size="10" [% IF ( metric ) %]onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');"[% END %] value="[% UNLESS ( opadd ) %][% dateexpiry %][% END %]" />
+                       [% IF ( metric ) %]
+                               [% UNLESS ( opadd ) %]
+                                       <input type="text" id="dateexpiry" name="dateexpiry" maxlength="10"  size="10" onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');" value="[% dateexpiry %]" />
+                               [% ELSE %]
+                                       <input type="text" id="dateexpiry" name="dateexpiry" maxlength="10"  size="10" onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');" />
+                               [% END %]
+                       [% ELSE %]
+                               [% UNLESS ( opadd ) %]
+                               <input type="text" id="dateexpiry" name="dateexpiry" maxlength="10"  size="10" value="[% dateexpiry %]" />
+                               [% ELSE %]
+                               <input type="text" id="dateexpiry" name="dateexpiry" maxlength="10"  size="10" />
+                               [% END %]
+                       [% END %]
             <img src="[% themelang %]/lib/calendar/cal.gif" id="dateexpiry_button" alt="Show Calendar" />
       <script language="JavaScript" type="text/javascript">
         Calendar.setup(
                [% IF ( ERROR_dateexpiry ) %]<span class="required">(Error)</span>[% END %]
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                </li>
+        [% END %]
+        [% UNLESS noopacnote %]
                <li>
                        [% IF ( mandatoryopacnote ) %]
                                <label for="opacnote" class="required">
                        <div class="hint">This message appears on this patron's user page in the OPAC</div>
          [% IF ( mandatoryopacnote ) %]<span class="required">Required</span>[% END %]
                </li>
+        [% END %]
+        [% UNLESS noborrowernotes %]
                <li>
                        [% IF ( mandatoryborrowernotes ) %]     
                                <label for="borrowernotes" class="required">
                        <div class="hint">This message displays when checking out to this patron</div>
          [% IF ( mandatoryborrowernotes ) %]<span class="required">Required</span>[% END %]
                </li>
+        [% END %]
                </ol>
        </fieldset>
+    [% END # hide fieldset %]
+
+    [% UNLESS nouserid && nopassword %]
        <fieldset class="rows" id="memberentry_userid">
-               <legend>OPAC/Staff Login</legend><ol>
+        <legend id="opac_staff_login_lgd">OPAC/Staff login</legend><ol>
+        [% UNLESS nouserid %]
                <li>
                        [% IF ( mandatoryuserid ) %]
                        <label for="userid" class="required">
                        Username: </label>
 
 [% IF ( NoUpdateLogin ) %]
-<input type="text" id="userid" name="userid" size="20" disabled="disabled" value="[% IF ( opduplicate ) %][% ELSE %][% userid %][% END %]" />
+       [% IF ( opduplicate ) %]
+               <input type="text" id="userid" name="userid" size="20" disabled="disabled" />
+       [% ELSE %]
+               <input type="text" id="userid" name="userid" size="20" disabled="disabled" value="[% userid %]" />
+       [% END %]
 [% ELSE %]
-<input type="text" id="userid" name="userid" size="20" value="[% IF ( opduplicate ) %][% ELSE %][% userid %][% END %]" />
+       [% IF ( opduplicate ) %]
+               <input type="text" id="userid" name="userid" size="20" value="" />
+       [% ELSE %]
+               <input type="text" id="userid" name="userid" size="20" value="[% userid %]" />
+       [% END %]
 [% END %]
 
          [% IF ( mandatoryuserid ) %]<span class="required">Required</span>[% END %]
                </li>
+        [%END %]
+        [% UNLESS nopassword %]
                <li>
                        [% IF ( mandatorypassword ) %]
                        <label for="password" class="required">
                        Password: </label>
                        [% IF ( opadd ) %]
                        [% IF ( NoUpdateLogin ) %]
-                               <input type="text" id="password" name="password" size="20"  disabled="disabled" value="[% IF ( opduplicate ) %][% ELSE %][% password %][% END %]" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="password" id="password" name="password" size="20"  disabled="disabled" />
+                               [% ELSE %]
+                                       <input type="password" id="password" name="password" size="20"  disabled="disabled" value="[% password %]" />
+                               [% END %]
 [% ELSE %]
-                               <input type="text" id="password" name="password" size="20" value="[% IF ( opduplicate ) %][% ELSE %][% password %][% END %]" />
+                               [% IF ( opduplicate ) %]
+                                       <input type="password" id="password" name="password" size="20" />
+                               [% ELSE %]
+                                       <input type="password" id="password" name="password" size="20" value="[% password %]" />
+                               [% END %]
 [% END %]
                        [% ELSE %]
                        [% IF ( password ) %]
                                [% IF ( NoUpdateLogin ) %]
-                                       <input type="text" id="password" name="password" size="20"  disabled="disabled" value="****" />
+                                       <input type="password" id="password" name="password" size="20"  disabled="disabled" value="****" />
                                [% ELSE %]
-                                       <input type="text" id="password" name="password" size="20" value="[% IF ( opduplicate ) %][% ELSE %]****[% END %]" />
+                                       [% IF ( opduplicate ) %]
+                                               <input type="password" id="password" name="password" size="20" />
+                                       [% ELSE %]
+                                               <input type="password" id="password" name="password" size="20" value="****" />
+                                       [% END %]
                                [% END %]
                        [% ELSE %]
                                [% IF ( NoUpdateLogin ) %]
-                                       <input type="text" id="password" name="password" size="20"  disabled="disabled" value="" />
+                                       <input type="password" id="password" name="password" size="20"  disabled="disabled" value="" />
                                [% ELSE %]
-                                       <input type="text" id="password" name="password" size="20" value="" />
+                                       <input type="password" id="password" name="password" size="20" value="" />
                                [% END %]
                        [% END %]
                        [% END %]
          [% IF ( mandatorypassword ) %]<span class="required">Required</span>[% END %][% IF ( ERROR_short_password ) %]<span class="required">Password is too short</span>[% END %]
 [% IF ( minPasswordLength ) %]<div class="hint">Minimum password length: [% minPasswordLength %]</div>[% END %]
-               </li></ol>
+               </li>
+               <li>
+                       [% IF ( mandatorypassword ) %]
+                       <label for="password2" class="required">
+                       [% ELSE %]
+                       <label for="password2">
+                       [% END %]
+                       Confirm password: </label>
+                       [% IF ( opadd ) %]
+                       [% IF ( NoUpdateLogin ) %]
+                               [% IF ( opduplicate ) %]
+                                       <input type="password" id="password2" name="password2" size="20"  disabled="disabled" />
+                               [% ELSE %]
+                                       <input type="password" id="password2" name="password2" size="20"  disabled="disabled" value="[% password %]" />
+                               [% END %]
+[% ELSE %]
+                               [% IF ( opduplicate ) %]
+                                       <input type="password" id="password2" name="password2" size="20" />
+                               [% ELSE %]
+                                       <input type="password" id="password2" name="password2" size="20" value="[% password %]" />
+                               [% END %]
+[% END %]
+                       [% ELSE %]
+                       [% IF ( password ) %]
+                               [% IF ( NoUpdateLogin ) %]
+                                       <input type="password" id="password2" name="password2" size="20"  disabled="disabled" value="****" />
+                               [% ELSE %]
+                                       [% IF ( opduplicate ) %]
+                                               <input type="password" id="password2" name="password2" size="20" />
+                                       [% ELSE %]
+                                               <input type="password" id="password2" name="password2" size="20" value="****" />
+                                       [% END %]
+                               [% END %]
+                       [% ELSE %]
+                               [% IF ( NoUpdateLogin ) %]
+                                       <input type="password" id="password2" name="password2" size="20"  disabled="disabled" value="" />
+                               [% ELSE %]
+                                       <input type="password" id="password2" name="password2" size="20" value="" />
+                               [% END %]
+                       [% END %]
+                       [% END %]
+         [% IF ( mandatorypassword ) %]<span class="required">Required</span>[% END %][% IF ( ERROR_password_mismatch ) %]<span class="required">Passwords do not match</span>[% END %]
+               </li>
+               </ol>
                </fieldset>
+        [% END # hide fieldset %][% END %]
                <!--this zones are not necessary in modif mode -->
                [% UNLESS ( opadd ) %]
                <fieldset class="rows">
-                       <legend>Patron Account Flags</legend>
+            <legend>Patron account flags</legend>
                        <ol class="radio">
                        [% FOREACH flagloo IN flagloop %]
                                <li><label class="radio" for="yes[% flagloo.name %]">
-                               [% IF ( flagloo.key == 'gonenoaddress' ) %]Gone no Address:[% END %]
+                [% IF ( flagloo.key == 'gonenoaddress' ) %]Gone no address:[% END %]
                                [% IF ( flagloo.key == 'debarred' ) %]Restricted:[% END %]
-                               [% IF ( flagloo.key == 'lost' ) %]Lost Card:[% END %]
+                [% IF ( flagloo.key == 'lost' ) %]Lost card:[% END %]
                 </label>
                                <label for="yes[% flagloo.name %]">Yes </label>
                                [% IF ( flagloo.yes ) %]
                                <input type="radio" id="no[% flagloo.name %]" name="[% flagloo.name %]" value="0" />
                                [% END %]
 
-</li>
+            </li>
                        [% END %]
+                       <li>
+                               <label for="yesdebarred" class="radio">Restricted: </label>
+                               [% IF ( debarred ) %]
+                               <label for="yesdebarred">Yes </label>
+                               <input type="radio" id="yesdebarred" name="debarred" value="1" checked="checked"/>
+                <label for="nodebarred">No </label>
+                <input type="radio" id="nodebarred" name="debarred" value="0"/>
+                               [% ELSE %]
+                               <label for="yesdebarred">Yes </label>
+                               <input type="radio" id="yesdebarred" name="debarred" value="1" />
+                <label for="nodebarred">No </label>
+                <input type="radio" id="nodebarred" name="debarred" value="0" checked="checked"/>
+                               [% END %]
+
+                <span id="debarreduntil"><label for="datedebarred" class="inline">Until:</label>
+                                [% IF opduplicate %]
+                                    <input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" onclick="this.value=''" />
+                                [% ELSE %]
+                                    <input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" />
+                                [% END %]
+                                <img src="[% themelang %]/lib/calendar/cal.gif" id="debarred_button" alt="Show Calendar" />
+                                 <script language="JavaScript" type="text/javascript">
+                                    Calendar.setup(
+                                    {
+                                        inputField : "datedebarred",
+                                        ifFormat : "[% DHTMLcalendar_dateformat %]",
+                                       button : "debarred_button"
+                                    }
+                                    );
+                                </script> <span class="hint">(optional)</span> </span>
+                </li>
+                <li>
+                       <label for="debarredcomment" class="radio">Comment:</label>
+                              [% IF ( opduplicate ) %] 
+                                  <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
+                              [% ELSE %]
+                                  <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3">[% debarredcomment %]</textarea>
+                              [% END %]
+               </li>
+
                        </ol>
                        </fieldset>
-               [% END %]       
+    
+               [% END %]
 
 [% END %]
 
   <fieldset class="rows" id="memberentry_patron_attributes">
     <input type="hidden" name="setting_extended_patron_attributes" value="1" />
     <legend>Additional attributes and identifiers</legend>
-    <table>
-        <tr>
-            <th>Type</th>
-            <th colspan="2">Value</th>
-        </tr>
-        [% FOREACH patron_attribute IN patron_attributes %]
-        <tr>
-            <td>[% patron_attribute.code %] ([% patron_attribute.description %])
-            </td>
-            <td>
-                <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
-                [% IF ( patron_attribute.use_dropdown ) %]
-                    <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
-                        <option value="" />
-                        [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
-                            [% IF ( auth_val_loo.selected ) %]
-                                <option value="[% auth_val_loo.authorised_value %]" selected="selected">
-                                    [% auth_val_loo.lib %]
-                                </option>
+    [% FOREACH pa_loo IN patron_attributes %]
+        [% IF pa_loo.class %]
+            <table id="aai_[% pa_loo.class %]" class="attributes_table">
+            <caption>[% pa_loo.lib %]</caption>
+        [% ELSE %]
+            <table id="aai" class="attributes_table">
+        [% END %]
+        <thead>
+            <tr>
+                <th>Type</th>
+                <th colspan="2">Value</th>
+            </tr>
+        </thead>
+        <tbody>
+            [% FOREACH patron_attribute IN pa_loo.items %]
+                <tr data-category_code="[% patron_attribute.category_code %]">
+                    <td>
+                        [% patron_attribute.code %] ([% patron_attribute.description %])
+                    </td>
+                    <td>
+                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
+                        [% IF ( patron_attribute.use_dropdown ) %]
+                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
+                                <option value="" />
+                                [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
+                                    [% IF ( auth_val_loo.selected ) %]
+                                        <option value="[% auth_val_loo.authorised_value %]" selected="selected">
+                                            [% auth_val_loo.lib %]
+                                        </option>
+                                    [% ELSE %]
+                                        <option value="[% auth_val_loo.authorised_value %]" >
+                                            [% auth_val_loo.lib %]
+                                        </option>
+                                    [% END %]
+                                [% END %]
+                            </select>
+                        [% ELSE %]
+                            [% IF ( opduplicate ) %]
+                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
+                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
                             [% ELSE %]
-                                <option value="[% auth_val_loo.authorised_value %]" >
-                                    [% auth_val_loo.lib %]
-                                </option>
+                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
+                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
                             [% END %]
                         [% END %]
-                    </select>
-                [% ELSE %]
-                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
-                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]"[% IF ( patron_attribute.opduplicate ) %] onclick="this.value=''"[% END %] />
-                [% END %]
-                [% IF ( patron_attribute.password_allowed ) %]
-                    (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
-                           id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
-                [% END %]
-            </td>
-            <td>
-                <a href="#" onclick="clear_entry(this); return false;">Clear</a>
-                [% IF ( patron_attribute.repeatable ) %]
-                <a href="#" onclick="clone_entry(this); return false;">New</a>
-                [% END %]
-            </td>
-        </tr>
-        [% END %]
-    </table>
+                        [% IF ( patron_attribute.password_allowed ) %]
+                            (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
+                                   id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
+                        [% END %]
+                    </td>
+                    <td>
+                        <a href="#" onclick="clear_entry(this); return false;">Clear</a>
+                        [% IF ( patron_attribute.repeatable ) %]
+                        <a href="#" onclick="clone_entry(this); return false;">New</a>
+                        [% END %]
+                    </td>
+                </tr>
+            [% END %]
+        </tbody>
+        </table>
+    [% END %]
   </fieldset>
 [% END %][% END %][% END %]
 
     </script>
     [% END %]
     <input type="hidden" name="setting_messaging_prefs" value="1" />
-    <legend>Patron messaging preferences</legend>
+    <legend id="patron_messaging_prefs_lgd">Patron messaging preferences</legend>
     [% IF type_only %]
-        <i>If no preferences are selected, the default preferences for the category chosen will be applied on save, otherwise your selection here is saved</i>
+        <p>If no preferences are selected, the default preferences for the category chosen will be applied on save, otherwise your selection here is saved</p>
     [% END %]
     [% INCLUDE 'messaging-preference-form.inc' %]
     [% IF ( SMSSendDriver ) %]
-        <p><label for="SMSnumber">SMS number:</label> 
-          <input type="text" id="SMSnumber" name="SMSnumber" value="[% SMSnumber %]"[% IF ( opduplicate ) %] onclick="this.value=''"[% END %] />
+        <p><label for="SMSnumber">SMS number:</label>
+          [% IF ( opduplicate ) %]
+            <input type="text" id="SMSnumber" name="SMSnumber" value="[% SMSnumber %]" onclick="this.value=''" />
+          [% ELSE %]
+            <input type="text" id="SMSnumber" name="SMSnumber" value="[% SMSnumber %]" />
+        [% END %]
         </p>
     [% END %]
   </fieldset>