Bug 21222: (bug 20226 follow-up) Fix patron creation
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / memberentrygen.tt
index 6086b3c..695b1e2 100644 (file)
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
+[% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Patrons &rsaquo; [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</title>
+<title>Koha &rsaquo; Patrons &rsaquo;
+    [% UNLESS blocking_error %]
+        [% IF ( opadd ) %]Add
+        [% ELSIF ( opduplicate ) %]Duplicate
+        [% ELSE %] Modify
+        [% END %] patron
+        [% IF (firstname) %][% firstname %] [% END %]
+        [% IF (surname) %][% surname %] [% END %]
+        ([%IF categoryname %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])
+    [% END %]
+</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-
-       [% IF categorycode %]
-               update_category_code( "[% categorycode %]" );
-       [% ELSE %]
-               if ( $("#categorycode_entry").length > 0 ){
-                       var category_code = $("#categorycode_entry").find("option:selected").val();
-                       update_category_code( category_code );
-               }
-       [% END %]
-       $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
-       dateformat = $("#dateofbirth").siblings(".hint").first().html();
-    if( $('#dateofbirth').length ) {
-        write_age();
-    }
-       $("#entryform").validate({
-               rules: {
-                       email: {
-                               email: true
-                       },
-                       emailpro: {
-                               email: true
-                       },
-                       B_email: {
-                               email: true
-                       }
-               },
-               submitHandler: function(form) {
-                       $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting');
-                       if (form.beenSubmitted)
-                               return false;
-                       else
-                               form.beenSubmitted = true;
-                               form.submit();
-                       }
-       });
-
-       var mrform = $("#manual_restriction_form");
-       var mrlink = $("#add_manual_restriction");
-       mrform.hide();
-       mrlink.on("click",function(e){
-               $(this).hide();
-               mrform.show();
-               e.preventDefault();
-       });
-       $("#cancel_manual_restriction").on("click",function(e){
-               $('#debarred_expiration').val('');
-               $('#add_debarment').val(0);
-               $('#debarred_comment').val('');
-               mrlink.show();
-               mrform.hide();
-               e.preventDefault();
-       });
-    $('#floating-save').css( { bottom: parseInt( $('#floating-save').css('bottom') ) + $('#changelanguage').height() + 'px' } );
-});
-
-function clear_entry(node) {
-       var original = $(node).parent();
-       $("textarea", original).attr('value', '');
-       $("select", original).attr('value', '');
-}
-
-function clone_entry(node) {
-       var original = $(node).parent();
-       var clone = original.clone();
-
-       var newId = 50 + parseInt(Math.random() * 100000);
-       $("input,select,textarea", clone).attr('id', function() {
-               return this.id.replace(/patron_attr_\d+/, 'patron_attr_' + newId);
-       });
-       $("input,select,textarea", clone).attr('name', function() {
-               return this.name.replace(/patron_attr_\d+/, 'patron_attr_' + newId);
-       });
-       $("label", clone).attr('for', function() {
-               return $(this).attr("for").replace(/patron_attr_\d+/, 'patron_attr_' + newId);
-       });
-       $("input#patron_attr_" + newId, clone).attr('value','');
-       $("select#patron_attr_" + newId, clone).attr('value','');
-       $(original).after(clone);
-       return false;
-}
-
-function update_category_code(category_code) {
-       if ( $(category_code).is("select") ) {
-               category_code = $("#categorycode_entry").find("option:selected").val();
-       }
-       var mytables = $(".attributes_table");
-       $(mytables).find("li").hide();
-       $(mytables).find(" li[data-category_code='"+category_code+"']").show();
-       $(mytables).find(" li[data-category_code='']").show();
-}
-
-function select_user(borrowernumber, borrower) {
-       var form = $('#entryform').get(0);
-       if (form.guarantorid.value) {
-               $("#contact-details").find('a').remove();
-               $("#contactname, #contactfirstname").parent().find('span').remove();
-       }
-
-       var id = borrower.borrowernumber;
-       form.guarantorid.value = id;
-       $('#contact-details')
-               .show()
-               .find('span')
-               .after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>');
-
-       $(form.contactname)
-               .val(borrower.surname)
-               .before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden';
-       $(form.contactfirstname)
-               .val(borrower.firstname)
-               .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
-
-       form.streetnumber.value = borrower.streetnumber;
-       form.address.value = borrower.address;
-       form.address2.value = borrower.address2;
-       form.city.value = borrower.city;
-       form.state.value = borrower.state;
-       form.zipcode.value = borrower.zipcode;
-       form.country.value = borrower.country;
-       form.branchcode.value = borrower.branchcode;
-
-       form.guarantorsearch.value = _("Change");
-
-       return 0;
-}
-
-    function write_age() {
-        var hint = $("#dateofbirth").siblings(".hint").first();
-        hint.html(dateformat);
-
-        var age = CalculateAge(document.form.dateofbirth.value);
-
-        if (!age.year && !age.month) {
-            return;
-        }
-
-        var age_string;
-        if (age.year || age.month) {
-            age_string = _("Age: ");
-        }
-
-        if (age.year) {
-            age_string += age.year > 1 ? _("%s years ").format(age.year) : _("%s year ").format(age.year);
-        }
-
-        if (age.month) {
-            age_string += age.month > 1 ? _("%s months ").format(age.month) : _("%s month ").format(age.month);
-        }
-
-        hint.html(age_string);
-    }
-
-        var MSG_SEPARATOR = _("Separator must be / in field %s");
-        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
-        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
-        var MSG_INCORRECT_YEAR = _("Invalid year entered in field %s");
-        var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
-        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
-        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
-        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
-        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
-        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
-        var LABEL_CHANGE = _("Change");
-        var LABEL_SET_TO_PATRON = _("Set to patron");
-//]]>
-</script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/members.js"></script>
 </head>
+
 <body id="pat_memberentrygen" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; 
-[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]</a>  &rsaquo;[% END %]
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
+    [% UNLESS blocking_error %]
+    &rsaquo;[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]</a>  &rsaquo;[% END %]
 <strong>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron ([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</strong>
+    [% END %]
 </div>
 [% IF ( opadd ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
-   
+
    <div id="bd">
        <div id="yui-main">
        <div class="yui-b">
+    [% INCLUDE 'blocking_errors.inc' %]
     [% IF error_alert %]
         [% IF ( error_alert == "no_email" ) %]
             <div class="error">This member has no email</div>
@@ -199,27 +46,24 @@ function select_user(borrowernumber, borrower) {
         <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><strong>There are no libraries defined.</strong> [% IF ( CAN_user_parameters ) %]<a href="/cgi-bin/koha/admin/branches.pl">Please add a library.</a>[% ELSE %]An administrator must define at least one library.[% END %]</p>[% END %]
-            [% IF ( no_categories ) %]<p><strong>There are no patron categories defined.</strong> [% IF ( CAN_user_parameters ) %]<a href="/cgi-bin/koha/admin/categories.pl">Please add a patron category.</a>[% ELSE %]An administrator must define at least one patron category.</p>[% END %][% END %]</div>[% END %]
+    [% INCLUDE 'noadd-warnings.inc' %]
 
        [% UNLESS ( no_add ) %]
-    <h1>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</h1>
-  
+    <h1>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</h1>
+
+    [% IF quickadd && opadd && !check_member %]
+        <a href="#" class="toggle_quick_add"><i class="fa fa-plus-square"></i> Show full form</a>
+        <a href="#" class="toggle_quick_add" style="display:none"><i class="fa fa-minus-square"></i> Show brief form</a>
+    [% END %]
+
        [% IF ( check_member ) %]
                        <div class="dialog alert">
                                <h3>Duplicate patron record?</h3>
                 <p><a class="popup" href="#" onclick="Dopop('moremember.pl?print=brief&amp;borrowernumber=[% check_member %]');return false;" >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 %]" />
-                    <button type="submit" class="new"><i class="fa fa-pencil"></i> It is a duplicate.
-                    Edit existing record</button>
-                </form>
+                <button id="duplicate" type="submit" class="new"><i class="fa fa-pencil"></i> It is a duplicate.
+                Edit existing record</button>
 
-                <form name="form" action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off">
-                               <input type="hidden" name="nodouble" value="1" />
-                <button type="submit" class="new"><i class="fa fa-plus"></i> Not a duplicate.
+                <button type="submit" id="not-duplicate" class="new"><i class="fa fa-plus"></i> Not a duplicate.
                 Save as new record</button>
                        </div>
        [% END %]
@@ -238,12 +82,12 @@ function select_user(borrowernumber, borrower) {
                 <li id="ERROR_cardnumber">Cardnumber length is incorrect.</li>
             [% END %]
                        [% IF ( ERROR_age_limitations ) %]
-                               <li id="ERROR_age_limitations">Patron's age is incorrect for their category.  
+            <li id="ERROR_age_limitations">Patron's age is incorrect for their category.
                     Ages allowed are [% age_low %]-[% age_high %].</li>
                        [% END %]
                        [% IF ( ERROR_branch ) %]
                                <li id="ERROR_branch">Library is invalid.</li>
-                       [% END %]   
+            [% END %]
                        [% IF ( ERROR_dateofbirth ) %]
                                <li id="ERROR_dateofbirth">Date of birth is invalid.</li>
                        [% END %]
@@ -253,14 +97,20 @@ function select_user(borrowernumber, borrower) {
                        [% IF ( ERROR_dateexpiry ) %]
                                <li id="ERROR_dateexpiry">Date of expiration is invalid.</li>
                        [% END %]
-                       [% IF ( ERROR_short_password ) %]
-                               <li id="ERROR_short_password">Password must be at least [% minPasswordLength %] characters long.</li>
-                       [% END %]
+            [% IF ( ERROR_password_too_short ) %]
+                <li id="ERROR_short_password">Password must be at least [% minPasswordLength %] characters long.</li>
+            [% END %]
+            [% IF ( ERROR_password_too_weak ) %]
+                <li id="ERROR_weak_password">Password must contain at least one digit, one lowercase and one uppercase.</li>
+            [% END %]
+            [% IF ( ERROR_password_has_whitespaces ) %]
+                <li id="ERROR_weak_password">Password must not contain leading or trailing whitespaces.</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"><strong>[% ERROR_extended_unique_id_failed_description %]</strong> attribute value <i>[% ERROR_extended_unique_id_failed_value %]</i> is already in use by another patron record.</li>
+                <li id="ERROR_extended_unique_id_failed"><strong>[% ERROR_extended_unique_id_failed_description %]:</strong> Attribute value "[% ERROR_extended_unique_id_failed_value %]" is already in use by another patron record.</li>
                        [% END %]
             [% IF ERROR_bad_email %]
                 <li id="ERROR_bad_email">The primary email is invalid.</li>
@@ -276,23 +126,42 @@ function select_user(borrowernumber, borrower) {
        [% END %]
 
 
-[% 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 %]
+<div id="toolbar" class="btn-toolbar">
+[% UNLESS ( check_member ) %]
+    [% IF quickadd && opadd %]
+        <button class="btn btn-default btn-sm toggler" id="save_quick_add" name="save"><i class="fa fa-save"></i> Save</button>
+    [% END %]
+    <button class="btn btn-default btn-sm toggler" id="saverecord" name="save" ><i class="fa fa-save"></i> Save</button>
+    [% IF opadd %]
+        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/members/member.pl" class="toggler save_entryform">
+    [% ELSE %]
+        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">
+    [% END %]
+        <i class="fa fa-times"></i> Cancel
+    </a>
+[% END %]
+</div>
+
+<form name="form" id="entryform"  action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off" class="toggler" >
+[% UNLESS ( check_member ) %]
+    <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="category_type" value="[% category_type %]" />
 <input type="hidden" name="updtype" value="[% updtype %]" />
 <input type="hidden" name="destination" value="[% destination %]" />
 <input type="hidden" name="check_member" value="[% check_member %]" />
-<input type="hidden" name="borrowernumber" value="[% UNLESS opduplicate %][% borrowernumber %][% END %]" />
-<input type="hidden" name="nodouble"  value="[% UNLESS opduplicate %][% nodouble %][% END %]" />
+<input type="hidden" name="borrowernumber" value="[% borrowernumber UNLESS opduplicate %]" />
+<input type="hidden" name="nodouble"  value="[% nodouble UNLESS opduplicate %]" />
+<input type="hidden" name="csrf_token" value="[% csrf_token %]" />
 [% 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" />
-[% IF step == 4 || step == 5 || step == 6 || step == 2 || step == 1 %]
+[% IF step == 4 || step == 5 || step == 6 || step == 2 || step == 1 || step == 7 %]
 [%# Only put the cardnumber if we arent showing it in the form later %]
 [% IF cardnumber %]
 <input type="hidden" name="cardnumber" value="[% cardnumber %]" />
@@ -307,7 +176,7 @@ function select_user(borrowernumber, borrower) {
                <ol>
                [% UNLESS ( I ) %]
         [% UNLESS notitle %]
-               [% IF ( title_cgipopup ) %]
+        [% IF Koha.Preference('BorrowersTitles') %]
             <li>
             [% IF ( mandatorytitle ) %]
                 <label for="btitle" class="required">
@@ -315,7 +184,16 @@ function select_user(borrowernumber, borrower) {
                 <label for="btitle">
             [% END %]
             Salutation: </label>
-            [% borrotitlepopup %]
+            <select id="btitle" name="title">
+                <option value=""></option>
+                [% FOREACH t IN Koha.Preference('BorrowersTitles').split('\|') %]
+                    [% IF btitle == t %]
+                        <option value="[% t %]" selected="selected">[% t %]</option>
+                    [% ELSE %]
+                        <option value="[% t %]">[% t %]</option>
+                    [% END %]
+                [% END %]
+            </select>
             [% IF ( mandatorytitle ) %]<span class="required">Required</span>[% END %]
             </li>
                [% END %]
@@ -323,12 +201,20 @@ function select_user(borrowernumber, borrower) {
                [% END %]
         [% UNLESS nosurname %]
                <li>
-               [% IF ( mandatorysurname ) %]
-               <label for="surname" class="required">
-               [% ELSE %]
-               <label for="surname">
-               [% END %]
-               Surname: </label>
+
+        [% IF ( I ) %]
+            <label for="surname" class="required">
+                Name:
+            </label>
+        [% ELSE %]
+            [% IF ( mandatorysurname ) %]
+                <label for="surname" class="required">
+            [% ELSE %]
+                <label for="surname">
+            [% END %]
+            Surname: </label>
+        [% END %]
+
                [% IF ( uppercasesurnames ) %]
             <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% surname %]" />
                [% ELSE %]
@@ -346,7 +232,7 @@ function select_user(borrowernumber, borrower) {
                 <label for="firstname">
                 [% END %]
                 First name: </label>
-                <input type="text" id="firstname" name="firstname" size="20"  value="[% UNLESS opduplicate %][% firstname %][% END %]" />
+                <input type="text" id="firstname" name="firstname" size="20"  value="[% firstname | html UNLESS opduplicate %]" />
                 [% IF ( mandatoryfirstname ) %]<span class="required">Required</span>[% END %]
             </li>
         [% END %]
@@ -359,7 +245,7 @@ function select_user(borrowernumber, borrower) {
                 [% END %]
                 Date of birth: </label>
 
-                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="write_age();" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
+                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="write_age();" value="[% dateofbirth UNLESS opduplicate %]" class="datepicker" />
 
         [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %]
         [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %]
@@ -374,7 +260,7 @@ function select_user(borrowernumber, borrower) {
                     <label for="initials">
                 [% END %]
                 Initials: </label>
-                <input type="text" id="initials" name="initials" size="20"  value="[% UNLESS opduplicate %][% initials %][% END %]" />
+                <input type="text" id="initials" name="initials" size="20"  value="[% initials | html UNLESS opduplicate %]" />
                 [% IF ( mandatoryinitials ) %]<span class="required">Required</span>[% END %]
             </li>
         [% END %]
@@ -387,7 +273,7 @@ function select_user(borrowernumber, borrower) {
                        <label for="othernames">
                        [% END %]
             Other name: </label>
-            <input type="text" id="othernames" name="othernames" size="20"  value="[% UNLESS opduplicate %][% othernames %][% END %]" />
+            <input type="text" id="othernames" name="othernames" size="20"  value="[% othernames | html UNLESS opduplicate %]" />
 [% IF ( mandatoryothernames ) %]<span class="required">Required</span>[% END %]
                [% IF ( I ) %]<input type="hidden" name="sex" value="N" />[% END %]
                </li>
@@ -398,19 +284,19 @@ function select_user(borrowernumber, borrower) {
 
             [% UNLESS ( opduplicate ) %]
                 [% IF ( female ) %]
-                    <label for="sex-female">Female </label><input type="radio" name="sex" id="sex-female" value="F" checked="checked"  />
+                    <label for="sex-female"><input type="radio" name="sex" id="sex-female" value="F" checked="checked" /> Female</label>
                 [% ELSE %]
-                    <label for="sex-female">Female </label><input type="radio" name="sex" id="sex-female" value="F" />
+                    <label for="sex-female"><input type="radio" name="sex" id="sex-female" value="F" /> Female</label>
                 [% END %]
                 [% IF ( male ) %]
-                    <label for="sex-male">Male </label><input type="radio" name="sex" id="sex-male" value="M" checked="checked" />
+                    <label for="sex-male"><input type="radio" name="sex" id="sex-male" value="M" checked="checked" /> Male</label>
                 [% ELSE %]
-                    <label for="sex-male">Male </label><input type="radio" name="sex" id="sex-male" value="M" />
+                    <label for="sex-male"><input type="radio" name="sex" id="sex-male" value="M" /> Male</label>
                 [% END %]
                 [% IF ( none ) %]
-                    <label for="sex-none">None specified </label><input type="radio" name="sex" id="sex-none" value=""  checked="checked"  />
+                    <label for="sex-none"><input type="radio" name="sex" id="sex-none" value=""  checked="checked" /> None specified</label>
                 [% ELSE %]
-                    <label for="sex-none">None specified </label><input type="radio" name="sex" id="sex-none" value="" />
+                    <label for="sex-none"><input type="radio" name="sex" id="sex-none" value="" /> None specified</label>
                 [% END %]
             [% ELSE %]
                 <label for="sex-female">Female </label><input type="radio" name="sex" id="sex-female" value="F" />
@@ -425,9 +311,13 @@ function select_user(borrowernumber, borrower) {
        </fieldset>
 [% END # hide fieldset %]
 
-[% IF ( showguarantor ) %]<input type="hidden" id="guarantorid" name="guarantorid"   value="[% guarantorid %]" />
-    <fieldset class="rows">
-        <legend>Guarantor information</legend>
+[% IF ( showguarantor ) %]
+    <input type="hidden" id="guarantorid" name="guarantorid"   value="[% guarantorid %]" />
+    [% UNLESS step_6 %]
+        <input type="hidden" name="branchcode" value="[% branchcode %]" />
+    [% END %]
+    <fieldset id="memberentry_guarantor" class="rows">
+        <legend id="guarantor_lgd">Guarantor information</legend>
         <ol>
 [% IF ( P ) %]
                [% IF ( guarantorid ) %]
@@ -441,9 +331,9 @@ function select_user(borrowernumber, borrower) {
                    <label for="contactname">Organization name: </label>
                    [% IF ( guarantorid ) %]
                    <span>[% contactname %]</span>
-                   <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname %]" />
+                   <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname | html %]" />
                    [% ELSE %]
-                    <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
+                    <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
                    [% END %]
                </li>
 [% ELSE %]
@@ -453,16 +343,23 @@ function select_user(borrowernumber, borrower) {
  [% ELSE %]
  <li id="contact-details" style="display: none">
  [% END %]
-     <span class="label">Patron #:</span> [% IF ( guarantorid ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid %]" target="blank">[% guarantorid %]</a>[% END %]
+     <span class="label">Patron #:</span>
+     [% IF guarantorid %]
+        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
+            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid %]" target="blank">[% guarantorid | html %]</a>
+        [% ELSE %]
+            [% guarantorid | html %]
+        [% END %]
+    [% 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 %]" />
+     <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname | html %]" />
      [% ELSE %]
-        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
+        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
      [% END %]
  </li>
         [% END %]
@@ -471,9 +368,9 @@ function select_user(borrowernumber, borrower) {
      <label for="contactfirstname">First name: </label>
      [% IF ( guarantorid ) %]
      <span>[% contactfirstname %]</span>
-     <input name="contactfirstname" id="contactfirstname" type="hidden" size="20" value="[% contactfirstname %]" />
+     <input name="contactfirstname" id="contactfirstname" type="hidden" size="20" value="[% contactfirstname | html %]" />
      [% ELSE %]
-        <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname %]" />
+        <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname | html %]" />
      [% END %]
  </li>
         [% END %]
@@ -534,13 +431,13 @@ function select_user(borrowernumber, borrower) {
     <legend id="contact_lgd">Contact</legend><ol>
         [% UNLESS nophone %]
       <li>
-      [% IF ( mandatoryphone ) %] 
+      [% IF ( mandatoryphone ) %]
       <label for="phone" class="required">
       [% ELSE %]
       <label for="phone">
       [% END %]
       Primary phone: </label>
-        <input type="text" id="phone" name="phone" value="[% phone %]" />
+        <input type="text" id="phone" name="phone" value="[% phone | html %]" />
          [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
 
     </li>
@@ -553,7 +450,7 @@ function select_user(borrowernumber, borrower) {
       <label for="phonepro">
       [% END %]
       Secondary phone: </label>
-    <input type="text" id="phonepro" name="phonepro" value="[% phonepro %]" />
+    <input type="text" id="phonepro" name="phonepro" value="[% phonepro | html %]" />
          [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
     </li>
         [% END %]
@@ -565,7 +462,7 @@ function select_user(borrowernumber, borrower) {
       <label for="mobile">
       [% END %]
       Other phone: </label>
-        <input type="text" id="mobile" name="mobile" value="[% mobile %]" />
+        <input type="text" id="mobile" name="mobile" value="[% mobile | html %]" />
          [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
     </li>
         [% END %]
@@ -577,20 +474,20 @@ function select_user(borrowernumber, borrower) {
       <label for="email">
       [% END %]
       Primary email: </label>
-        <input type="text" id="email" name="email" size="45" value="[% email %]" />
+        <input type="text" id="email" name="email" size="45" value="[% email | html %]" />
          [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
 
     </li>
         [% END %]
         [% UNLESS noemailpro %]
     <li>
-      [% IF ( mandatoryemailpro ) %] 
+      [% 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 %]" />
+        <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro | html %]" />
          [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
     </li>
         [% END %]
@@ -602,7 +499,7 @@ function select_user(borrowernumber, borrower) {
       <label for="fax">
       [% END %]
       Fax: </label>
-        <input type="text" id="fax" name="fax" value="[% fax %]" />
+        <input type="text" id="fax" name="fax" value="[% fax | html %]" />
          [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
     </li>
         [% END %]
@@ -634,48 +531,53 @@ function select_user(borrowernumber, borrower) {
 [% END %]
 [% IF ( step_3 ) %]
 
+  [% SET autoMemberNum = Koha.Preference('autoMemberNum') %]
   <fieldset class="rows" id="memberentry_library_management">
     <legend id="library_management_lgd">Library management</legend><ol>
       [% UNLESS nocardnumber %]
         <li>
-          [% IF ( mandatorycardnumber ) %]
+          [% IF mandatorycardnumber %]
             <label for="cardnumber" class="required">
           [% ELSE %]
             <label for="cardnumber" class="validated">
           [% END %]
-          Card number: </label>
+            Card number: </label>
+
+          <!-- NOTE: div.hint closing tag isn't on the same line -->
           [% IF minlength_cardnumber == maxlength_cardnumber %]
-                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber %]" minlength="[% minlength_cardnumber %]" maxlength="[% maxlength_cardnumber %]" />
-                [% IF ( mandatorycardnumber ) %]<span class="required">Required</span>[% END %]
-                <div class="hint">Card number must be exactly [% minlength_cardnumber %] characters.</div>
+                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber | html %]" minlength="[% minlength_cardnumber %]" maxlength="[% maxlength_cardnumber %]" />
+                [% IF mandatorycardnumber %]<span class="required">Required</span>[% END %]<span id="cn_max" class="required">Card number must not be more than [% maxlength_cardnumber %] characters.</span>
+                <div class="hint">Card number must be exactly [% minlength_cardnumber %] characters.
           [% ELSIF minlength_cardnumber && maxlength_cardnumber %]
-                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber %]" minlength="[% minlength_cardnumber %]" maxlength="[% maxlength_cardnumber %]" />
-                [% IF ( mandatorycardnumber ) %]<span class="required">Required</span>[% END %]
-                <div class="hint">Card number must be between [% minlength_cardnumber %] and [% maxlength_cardnumber %] characters.</div>
+                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber | html %]" minlength="[% minlength_cardnumber %]" maxlength="[% maxlength_cardnumber %]" />
+                [% IF mandatorycardnumber %]<span class="required">Required</span>[% END %]<span id="cn_max" class="required">Card number must not be more than [% maxlength_cardnumber %] characters.</span>
+                <div class="hint">Card number must be between [% minlength_cardnumber %] and [% maxlength_cardnumber %] characters.
           [% ELSIF maxlength_cardnumber %]
-                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber %]" maxlength="[% maxlength_cardnumber %]" />
-                [% IF ( mandatorycardnumber ) %]<span class="required">Required</span>[% END %]
-                <div class="hint">Card number can be up to [% maxlength_cardnumber %] characters.</div>
+                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber | html %]" maxlength="[% maxlength_cardnumber %]" />
+                [% IF mandatorycardnumber %]<span class="required">Required</span>[% END %]<span id="cn_max" class="required">Card number must not be more than [% maxlength_cardnumber %] characters.</span>
+                <div class="hint">Card number can be up to [% maxlength_cardnumber %] characters.
           [% ELSE %]
-                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber %]" />
-                [% IF ( mandatorycardnumber ) %]<span class="required">Required</span>[% END %]
-                <div class="hint">There is no minimum or maximum character length.</div>
+                <input type="text" id="cardnumber" name="cardnumber" size="20" value="[% cardnumber | html %]" />
+                [% IF mandatorycardnumber %]<span class="required">Required</span>[% END %]
+                <div class="hint">There is no minimum or maximum character length.
+          [% END %]
+          [% IF autoMemberNum %]
+                [% IF mandatorycardnumber %]
+                    <br/><span class="error">AutoMemberNum is set to enabled, but cardnumber is marked as mandatory in BorrowerMandatoryField: auto calc has been disabled.</span>
+                [% ELSE %]
+                    <br/>Leave blank for auto calc during registration
+                [% END %]
           [% END %]
+                </div><!--/hint div -->
         </li>
       [% END %]
       [% UNLESS nobranchcode %]
     <li>
         <label for="libraries" class="required">Library:</label>
         <select name="branchcode" size="1" id="libraries">
-        [%- FOREACH branchloo IN branchloop %]
-          [% IF ( branchloo.selected ) -%]
-            <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
-          [%- ELSE -%]
-            <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
-          [%- END -%]
-        [%- END %]
-      </select>
-      <span class="required">Required</span>
+            [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %]
+        </select>
+        <span class="required">Required</span>
     </li>
         [% END %]
     <li>
@@ -740,7 +642,51 @@ function select_user(borrowernumber, borrower) {
             [% END %]
         </li>
     [% END %]
-       </ol>
+    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
+      <li><label for="checkprevcheckout">Check for previous checkouts: </label>
+        <select name="checkprevcheckout" id="checkprevcheckout">
+        [% IF ( checkprevcheckout == 'yes' ) %]
+          <option value="yes" selected="selected">Yes if settings allow it</option>
+          <option value="no">No if settings allow it</option>
+          <option value="inherit">Inherit from settings</option>
+        [% ELSIF ( checkprevcheckout == 'no' ) %]
+          <option value="yes">Yes if settings allow it</option>
+          <option value="no" selected="selected">No if settings allow it</option>
+          <option value="inherit">Inherit from settings</option>
+        [% ELSE %]
+          <option value="yes">Yes if settings allow it</option>
+          <option value="no">No if settings allow it</option>
+          <option value="inherit" selected="selected">Inherit from settings</option>
+        [% END %]
+        </select>
+       </li>
+     [% END %]
+    [% IF Koha.Preference('TranslateNotices') %]
+        <li>
+            <label for="lang">Preferred language for notices: </label>
+            <select id="lang" name="lang">
+                <option value="default">Default</option>
+                [% FOR language IN languages %]
+                    [% FOR sublanguage IN language.sublanguages_loop %]
+                        [% IF language.plural %]
+                            [% IF sublanguage.rfc4646_subtag == lang %]
+                                <option value="[% sublanguage.rfc4646_subtag %]" selected="selected">[% sublanguage.native_description %] [% sublanguage.region_description %] ([% sublanguage.rfc4646_subtag %])</option>
+                            [% ELSE %]
+                                <option value="[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] [% sublanguage.region_description %] ([% sublanguage.rfc4646_subtag %])</option>
+                            [% END %]
+                        [% ELSE %]
+                            [% IF sublanguage.rfc4646_subtag == lang %]
+                                <option value="[% sublanguage.rfc4646_subtag %]" selected="selected">[% sublanguage.native_description %] ([% sublanguage.rfc4646_subtag %])</option>
+                            [% ELSE %]
+                                <option value="[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] ([% sublanguage.rfc4646_subtag %])</option>
+                            [% END %]
+                        [% END %]
+                    [% END %]
+                [% END %]
+            </select>
+        </li>
+    [% END %]
+   </ol>
   </fieldset>
     [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
        <fieldset class="rows" id="memberentry_subscription">
@@ -776,15 +722,15 @@ function select_user(borrowernumber, borrower) {
                        Expiry date (leave blank for auto calc): </label>
             [% IF ( dateformat == "metric" ) %]
                                [% UNLESS ( opadd ) %]
-                    <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');" value="[% UNLESS opduplicate %][% dateexpiry %][% END %]" class="datepickerto" />
+                    <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');" value="[% dateexpiry UNLESS opduplicate %]" class="datepickerto" />
                                [% ELSE %]
                     <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" onchange="CheckDate(document.form.dateexpiry);check_manip_date('verify');" class="datepickerto" />
                                [% END %]
                        [% ELSE %]
                                [% UNLESS ( opadd ) %]
-                <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" value="[% UNLESS opduplicate %][% dateexpiry %][% END %]" class="datepickerto" />
+                <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" value="[% dateexpiry UNLESS opduplicate %]" class="datepickerto" />
                                [% ELSE %]
-                <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" class="datepickerto" />
+                <input type="text" id="to" name="dateexpiry" maxlength="10"  size="10" value="[% dateexpiry %]" class="datepickerto" />
                                [% END %]
                        [% END %]
                [% IF ( mandatorydateexpiry ) %]<span class="required">Required</span>[% END %]
@@ -797,22 +743,22 @@ function select_user(borrowernumber, borrower) {
                                <label for="opacnote" class="required">
                        [% ELSE %]
                                <label for="opacnote">
-                       [% END %]       
+            [% END %]
                        OPAC note: </label>
-            <textarea id="opacnote" name="opacnote" cols="55" rows="5">[% UNLESS opduplicate %][% opacnote %][% END %]</textarea>
+            <textarea id="opacnote" name="opacnote" cols="55" rows="5">[% opacnote | html UNLESS opduplicate %]</textarea>
                        <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 ) %]     
+            [% IF ( mandatoryborrowernotes ) %]
                                <label for="borrowernotes" class="required">
                        [% ELSE %]
                                <label for="borrowernotes">
                        [% END %]
                        Circulation note: </label>
-            <textarea id="borrowernotes" name="borrowernotes" cols="55" rows="5">[% UNLESS opduplicate %][% borrowernotes %][% END %]</textarea>
+            <textarea id="borrowernotes" name="borrowernotes" cols="55" rows="5">[% borrowernotes | html UNLESS opduplicate %]</textarea>
                        <div class="hint">This message displays when checking out to this patron</div>
          [% IF ( mandatoryborrowernotes ) %]<span class="required">Required</span>[% END %]
                </li>
@@ -894,8 +840,11 @@ function select_user(borrowernumber, borrower) {
                                [% 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 %]
+            [% IF ( mandatorypassword ) %]<span class="required">Required</span>[% END %]
+            [% IF ( ERROR_password_too_short ) %]<span class="required">Password is too short</span>[% END %]
+            [% IF ( ERROR_password_too_weak ) %]<span class="required">Password is too weak</span>[% END %]
+            [% IF ( ERROR_password_has_whitespaces ) %]<span class="required">Password has leading or trailing whitespaces</span>[% END %]
+            <div class="hint">Minimum password length: [% minPasswordLength %]</div>
                </li>
                <li>
                        [% IF ( mandatorypassword ) %]
@@ -944,8 +893,8 @@ function select_user(borrowernumber, borrower) {
         [% END # hide fieldset %][% END %]
                <!--this zones are not necessary in modif mode -->
         [% UNLESS ( opadd || opduplicate ) %]
-               <fieldset class="rows">
-            <legend>Patron account flags</legend>
+        <fieldset class="rows" id="memberentry_account_flags">
+            <legend id="account_flags_lgd">Patron account flags</legend>
                        <ol class="radio">
                        [% FOREACH flagloo IN flagloop %]
                                <li><label class="radio" for="yes[% flagloo.name %]">
@@ -953,18 +902,20 @@ function select_user(borrowernumber, borrower) {
                 [% IF ( flagloo.key == 'lost' ) %]Lost card:[% END %]
                 </label>
                 [% IF CAN_user_circulate_manage_restrictions %]
-                               <label for="yes[% flagloo.name %]">Yes </label>
+                            <label for="yes[% flagloo.name %]">
                                [% IF ( flagloo.yes ) %]
                                <input type="radio" id="yes[% flagloo.name %]" name="[% flagloo.name %]" value="1" checked="checked" />
                                [% ELSE %]
                                <input type="radio" id="yes[% flagloo.name %]" name="[% flagloo.name %]" value="1" />
                                [% END %]
-                               <label for="no[% flagloo.name %]">No </label>
+                            Yes </label>
+                            <label for="no[% flagloo.name %]">
                                [% IF ( flagloo.no ) %]
                                <input type="radio" id="no[% flagloo.name %]" name="[% flagloo.name %]" value="0" checked="checked"/>
                                [% ELSE %]
                                <input type="radio" id="no[% flagloo.name %]" name="[% flagloo.name %]" value="0" />
                                [% END %]
+                            No </label>
                 [% ELSE %]
                   [% IF flagloo.yes %]Yes[% ELSE %]No[% END %]
                 [% END %]
@@ -975,8 +926,8 @@ function select_user(borrowernumber, borrower) {
                        </ol>
                        </fieldset>
 
-              <fieldset class="rows">
-                <legend>Patron restrictions</legend>
+              <fieldset class="rows" id="memberentry_restrictions">
+                <legend id="restrictions_lgd">Patron restrictions</legend>
 
                 [% IF ( debarments ) %]
                     <table>
@@ -985,7 +936,8 @@ function select_user(borrowernumber, borrower) {
                                  <th>Type</th>
                                  <th>Comment</th>
                                  <th>Expiration</th>
-                                 [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+                                 <th>Created</th>
+                                 [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                                    <th>Remove?</th>
                                  [% END %]
                             </tr>
@@ -995,9 +947,16 @@ function select_user(borrowernumber, borrower) {
                             [% FOREACH d IN debarments %]
                                 <tr>
                                     <td>[% d.type %]</td>
-                                    <td>[% d.comment %]</td>
+                                    <td>
+                                    [% IF d.comment.search('OVERDUES_PROCESS') %]
+                                        Restriction added by overdues process [% d.comment.remove('OVERDUES_PROCESS ') %]
+                                    [% ELSE %]
+                                        [% d.comment %]
+                                    [% END %]
+                                    </td>
                                     <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
-                                    [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+                                    <td>[% d.created | $KohaDates %]</td>
+                                    [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                                       <td>
                                         <input type="checkbox" id="debarment_[% d.borrower_debarment_id %]" name="remove_debarment" value="[% d.borrower_debarment_id %]" />
                                       </td>
@@ -1010,14 +969,14 @@ function select_user(borrowernumber, borrower) {
                     <p>Patron is currently unrestricted.</p>
                 [% END %]
 
-                [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+                [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                     <p><a href="#" id="add_manual_restriction">Add manual restriction</a></p>
                     <fieldset id="manual_restriction_form">
                         <input type="hidden" id="add_debarment" name="add_debarment" value="0" />
-                        <legend>Add manual restriction</legend>
+                        <legend id="manual_restriction_lgd">Add manual restriction</legend>
                         <ol>
                             <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').val(1);" /></li>
-                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').val(1);" />
+                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" value="" class="datepicker" onchange="$('#add_debarment').val(1);" />
                                     <a href='javascript:void(0)' onclick="$('#debarred_expiration').val('');">Clear date</a></li>
 
                         </ol>
@@ -1031,20 +990,72 @@ function select_user(borrowernumber, borrower) {
 
 [% END %]
 
-[% IF ( step_4 ) %][% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %]
+[% IF ( step_7 ) %]
+[% IF Koha.Preference('HouseboundModule') %]
+  <fieldset class="rows" id="memberentry_housebound_roles">
+    <legend id="housebound_roles">Housebound roles</legend>
+    <ol class="radio">
+      <li>
+        <label class="radio" for="housebound_chooser">
+          Chooser:
+        </label>
+        [% IF ( housebound_role.housebound_chooser == 1 ) %]
+        <label for="yes_housebound_chooser">Yes </label>
+        <input type="radio" id="yes_housebound_chooser"
+               name="housebound_chooser" value="1"
+               checked="checked" />
+        <label for="no_housebound_chooser">No </label>
+        <input type="radio" id="no_housebound_chooser"
+               name="housebound_chooser" value="0" />
+        [% ELSE %]
+        <label for="yes_housebound_chooser">Yes </label>
+        <input type="radio" id="yes_housebound_chooser"
+               name="housebound_chooser" value="1" />
+        <label for="no_housebound_chooser">No </label>
+        <input type="radio" id="no_housebound_chooser"
+               name="housebound_chooser" value="0"
+               checked="checked" />
+        [% END %]
+      </li>
+      <li>
+        <label class="radio" for="housebound_deliverer">Deliverer:</label>
+        [% IF ( housebound_role.housebound_deliverer == 1 ) %]
+        <label for="yes_housebound_deliverer">Yes </label>
+        <input type="radio" id="yes_housebound_deliverer"
+               name="housebound_deliverer" value="1"
+               checked="checked" />
+        <label for="no_housebound_deliverer">No </label>
+        <input type="radio" id="no_housebound_deliverer"
+               name="housebound_deliverer" value="0" />
+        [% ELSE %]
+        <label for="yes_housebound_deliverer">Yes </label>
+        <input type="radio" id="yes_housebound_deliverer"
+               name="housebound_deliverer" value="1" />
+        <label for="no_housebound_deliverer">No </label>
+        <input type="radio" id="no_housebound_deliverer"
+               name="housebound_deliverer" value="0"
+               checked="checked" />
+        [% END %]
+      </li>
+    </ol>
+  </fieldset>
+[% END # hide fieldset %]
+[% END # IF step_7 %]
+
+[% IF ( step_4 ) %]
+[% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %]
   <fieldset class="rows" id="memberentry_patron_attributes">
-    <legend>Additional attributes and identifiers</legend>
+    <legend id="patron_attributes_lgd">Additional attributes and identifiers</legend>
     <input type="hidden" name="setting_extended_patron_attributes" value="1" />
     [% FOREACH pa_loo IN patron_attributes %]
         [% IF pa_loo.class %]
             <fieldset id="aai_[% pa_loo.class %]">
-            <legend>[% pa_loo.lib %]</legend>
+            <legend id="[% pa_loo.class %]_lgd">[% pa_loo.lib %]</legend>
         [% END %]
         <ol class="attributes_table">
             [% FOREACH patron_attribute IN pa_loo.items %]
                 <li data-category_code="[% patron_attribute.category_code %]">
                     <label for="[% patron_attribute.form_id %]">[% patron_attribute.description %]: </label>
-                        <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=""></option>
@@ -1063,6 +1074,7 @@ function select_user(borrowernumber, borrower) {
                         [% ELSE %]
                             <textarea rows="2" cols="30" id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">[% patron_attribute.value %]</textarea>
                         [% END %]
+                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
                         <a href="#" onclick="clear_entry(this); return false;"><i class="fa fa-fw fa-trash"></i> Clear</a>
                         [% IF ( patron_attribute.repeatable ) %]
                         <a href="#" onclick="clone_entry(this); return false;"><i class="fa fa-fw fa-plus"></i> New</a>
@@ -1130,6 +1142,7 @@ function select_user(borrowernumber, borrower) {
         <p><label for="SMSnumber">SMS number:</label>
             <input type="text" id="SMSnumber" name="SMSnumber" value="[% SMSnumber %]" />
         </p>
+        [% UNLESS nosms_provider_id %]
         <p>
             <label for="sms_provider_id">SMS provider:</label>
             <select id="sms_provider_id" name="sms_provider_id"/>
@@ -1143,26 +1156,21 @@ function select_user(borrowernumber, borrower) {
                 [% END %]
             </select>
         </p>
+        [% END %]
     [% END %]
   </fieldset>
 [% END %] [% END %]
 
-<fieldset class="rows" id="floating-save">
-[% UNLESS ( check_member ) %]
-    <fieldset class="action">
-        <button type="submit" name="save" onclick="return check_form_borrowers();">
-            <i class="fa fa-save"></i> Save
-        </button>
-      [% IF ( opadd ) %]
-       <a class="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a>
-          [% ELSE %]
-         <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
-          [% END %]
-    </fieldset>
-[% END %]
-</fieldset>
 </form>
-  
+
+[% IF quickadd && opadd  && !check_member %]
+    <form id="quick_add_form" class="toggler">
+        <fieldset class="rows quick_add"><legend>Quick add</legend>
+            <ol id="quick_add_list">
+            </ol>
+        </fieldset>
+    </form>
+[% END %]
 </div>
 </div>
 
@@ -1171,5 +1179,172 @@ function select_user(borrowernumber, borrower) {
 </div>[% END %]
 [% END %]
 </div>
-[% INCLUDE 'intranet-bottom.inc' %]
 
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") %]
+    [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'str/members-menu.inc' %]
+    [% Asset.js("js/members-menu.js") %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+                $("#saverecord").css({ 'margin-left': 0 });
+                var original_offset = $("#toolbar").position().top;
+                var additional_height = $("#filters").height();
+                $('#toolbar').fixFloat({ 'originalOffset': original_offset });
+                $("#filteraction_on").on("click", function(){
+                    $(window).off('scroll');
+                    $("#toolbar").css({ top: original_offset + additional_height });
+                    $('#toolbar').fixFloat({ 'originalOffset': original_offset + additional_height });
+                });
+                $("#filteraction_off").on("click", function(){
+                    $(window).off('scroll');
+                    $("#toolbar").css({ top: original_offset });
+                    $('#toolbar').fixFloat({ 'originalOffset': original_offset });
+                })
+
+            [% IF categorycode %]
+                update_category_code( "[% categorycode %]" );
+            [% ELSE %]
+                if ( $("#categorycode_entry").length > 0 ){
+                    var category_code = $("#categorycode_entry").find("option:selected").val();
+                    update_category_code( category_code );
+                }
+            [% END %]
+        });
+
+        function update_cardnumber_warning(size){
+            var max_len = [% maxlength_cardnumber %];
+            if ( size >= max_len ) {
+                $("#cn_max").show();
+            } else {
+                $("#cn_max").hide();
+            }
+        }
+
+        $(document).ready(function() {
+            $("#cn_max").hide();
+            var content;
+            $("#cardnumber").on("keydown", function(e){
+                content = $(this).val();
+            });
+            $("#cardnumber").on("keyup", function(e){
+                // .val() will return the value of the input after the key has been released
+                var l = $(this).val().length;
+                if ( l == content.length + 1 ) { l--; }
+                update_cardnumber_warning(l);
+            });
+            $("#cardnumber").bind("paste", function(e){
+                var pastedData = e.originalEvent.clipboardData.getData('text');
+                update_cardnumber_warning(pastedData.length - 1);
+            } );
+            var toggle_quick_add = $(".toggle_quick_add");
+            $(toggle_quick_add).click(function(e){
+                toggle_quick_add.toggle();
+                e.preventDefault();
+                var toggle_to = '';
+                var toggle_from = '';
+                if( $("#entryform:visible").length ) {
+                    toggle_to = "#quick_add_form label";
+                    toggle_from = "#entryform label";
+                } else {
+                    toggle_to="#entryform label";
+                    toggle_from = "#quick_add_form label";
+                }
+                $(toggle_from).each(function() {
+                    var input_label = $(this).attr('for');
+                    if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) {
+                        $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') );
+                        return;
+                    }
+                    $(toggle_to+"[for='"+input_label+"']").next().val(  $(this).next().val() );
+                });
+
+                $(".toggler").toggle();
+            });
+
+            $("#save_quick_add").click(function(){
+                $("#quick_add_form").validate();
+                if( $("#quick_add_form").valid()){
+                    $('.toggle_quick_add').click();
+                    $('#saverecord').click();
+                }
+                else {return false;}
+            });
+
+            $("#saverecord").click(function(){
+                if( check_form_borrowers() ){
+                    $("#entryform").submit();
+                }
+            });
+
+            $('#duplicate').on('click', function() {
+                $("input[name='op']").val('modify');
+                $("input[name='borrowernumber']").val('[% check_member %]');
+                $("input[name='check_member']").val('');
+                $('#entryform').submit();
+            });
+
+            $('#not-duplicate').on('click', function() {
+                $("input[name='nodouble']").val('1');
+                $('#entryform').submit();
+            });
+        });
+
+        var MSG_SEPARATOR = _("Separator must be / in field %s");
+        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
+        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
+        var MSG_INCORRECT_YEAR = _("Invalid year entered in field %s");
+        var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
+        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
+        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
+        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
+        var MSG_MONTH = _("%s month")
+        var MSG_MONTHS = _("%s months")
+        var MSG_YEAR = _("%s year")
+        var MSG_YEARS = _("%s years")
+        var LABEL_CHANGE = _("Change");
+        var LABEL_SET_TO_PATRON = _("Set to patron");
+        var LABEL_AGE = _("Age");
+
+        [% IF quickadd && opadd  && !check_member %]
+            $(document).ready(function () {
+
+                $("#entryform,#saverecord").hide();
+                [% q_add_f = Koha.Preference('PatronQuickAddFields').split('\|') %]
+                var qaddfields = [[% FOREACH field IN q_add_f.unique %]"[% field %]",[% END %]];
+                var skipped_fields = ["contactname","contactfirstname","relationship"]; //Guarantor form is pulled as a whole, ignore individual fields
+                $("#entryform label").each(function () {
+                    var input_label = $(this).attr('for');
+                    if ( input_label == 'sex-female' ) {
+                        input_label='sex';
+                    }
+                    else if ( input_label == 'btitle' ) {
+                        input_label='title';
+                    }
+                    if ( skipped_fields.indexOf( input_label ) != -1 ) { input_label=""; }
+                    if( qaddfields.indexOf( input_label ) != -1 || $(this).attr('class') == 'required' ){
+                       $(this).parent().clone().appendTo("#quick_add_list");
+                       [% UNLESS mandatorypassword %]
+                             if( input_label == 'password' ) $("#entryform label[for='password2']").parent().clone().appendTo("#quick_add_list");
+                       [% END %]
+                    }
+                });
+                    if( $("#memberentry_guarantor").length ) {
+                        $("#memberentry_guarantor").clone().appendTo("#quick_add_list").css("margin",0);
+                        $("#quick_add_form #memberentry_guarantor").append("<p>" + _("Note: Quick add guarantor form populates address fields in full form") + "</p>");
+                        $("#quick_add_list #guarantordelete").prop('id','qagd');
+                    }
+                $("#qagd").click(function() { $("#guarantordelete").click(); });
+                $("#quick_add_form").show();
+            });
+        [% END %]
+
+    </script>
+    [% Asset.js("js/members.js") %]
+    [% Asset.js("js/messaging-preference-form.js") %]
+[% END %]
+
+[% INCLUDE 'intranet-bottom.inc' %]
+[% PROCESS 'password_check.inc' %]
+[% PROCESS 'add_password_check' new_password => 'password' %]