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 34fef89..41ce66d 100644 (file)
             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 ");
@@ -65,7 +95,7 @@
 </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>
        [% 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 %]" />
 [% 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 %]">
+<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 %]
                </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 ) %]
             [% 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>
 [% 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 ) %]
 
 [% 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 ) %] 
       [% ELSE %]
       <label for="phone">
       [% END %]
-      Primary Phone: </label>
+      Primary phone: </label>
       [% IF ( opduplicate ) %]
                        <input type="text" id="phone" name="phone" value="[% phone %]" onclick="this.value=''" />
       [% ELSE %]
       [% ELSE %]
       <label for="phonepro">
       [% END %]
-      Secondary Phone: </label>
+      Secondary phone: </label>
       [% IF ( opduplicate ) %]
                        <input type="text" id="phonepro" name="phonepro" value="[% phonepro %]" onclick="this.value=''" />
       [% ELSE %]
       [% ELSE %]
       <label for="mobile">
       [% END %]
-      Other Phone: </label>
+      Other phone: </label>
       [% IF ( opduplicate ) %]
                <input type="text" id="mobile" name="mobile" value="[% mobile %]" onclick="this.value=''" />
       [% ELSE %]
       [% ELSE %]
       <label for="email">
       [% END %]
-      Primary Email: </label>
+      Primary email: </label>
       [% IF ( opduplicate ) %]
                <input type="text" id="email" name="email" size="45" value="[% email %]" onclick="this.value=''" />
       [% ELSE %]
       [% ELSE %]
       <label for="emailpro">
       [% END %]
-      Secondary Email: </label>
+      Secondary email: </label>
       [% IF ( opduplicate ) %]
                <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro %]" onclick="this.value=''" />
       [% ELSE %]
 
     [% 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 ) %]
                        </ol>
                </fieldset>
     [% END # UNLESS noB_address && noB_city && noB_state && noB_phone && noB_email %]
-[% END %]              
+[% 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 ) %]
 [% 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">
         [% 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>
   </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 ) %]
 
     [% 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 ) %]
                </li>
                </ol>
                </fieldset>
-        [% END # hide 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 ) %]
                 <label for="nodebarred">No </label>
                 <input type="radio" id="nodebarred" name="debarred" value="0" checked="checked"/>
                                [% END %]
-                               
-                               <br />
-                               <label for="datedebarred" class="radio">until:</label> 
-                               [% IF opduplicate %]
-                                   <input type="text" name="datedebarred" id="debarred" class="debarred" value="[% datedebarred %]" onclick="this.value=''" />
-                               [% ELSE %]
-                                   <input type="text" name="datedebarred" id="debarred" 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 : "debarred",
-                               ifFormat : "[% DHTMLcalendar_dateformat %]",
-                               button : "debarred_button"
-                           }
-                           );
-                       </script>
-                       <br />
+
+                <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> 
+                                  <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 %]
-                    [% 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 %]
-                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
-                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
-                    [% 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 ) %]
 [% INCLUDE 'members-menu.inc' %]
 </div>[% END %]
 [% END %]
-[% END %]
 </div>
 [% INCLUDE 'intranet-bottom.inc' %]