<%@ page extends="oneit.servlets.jsp.JSPInclude" %>

<%@ include file="/inc/stdimports50.jsp" %><%-- This is in cougar --%>
<%@ include file="/inc/stdcms.jsp" %><%-- This is in cougar --%>
<%@ include file="/extensions/performa/inc/stdimports.jsp" %>

<oneit:dynIncluded>
<%
    ObjectTransaction   objTran         =   process.getTransaction ();
    SecUser             loggedInUser    =   SecUser.getTXUser(transaction);
    CompanyUser         companyUser     =   loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);

    Debug.assertion(companyUser != null , "Invalid user in admin portal my details");

    String              nextPage        =   WebUtils.getSamePageInRenderMode(request, "Page");
    boolean             emailChanged    =   request.getAttribute("EmailChanged") != null ? (boolean) request.getAttribute("EmailChanged") : false;
%>
    <script type="text/javascript">
        $(document).ready(function()
        {
            $('input[name$=ConfirmPassword]').val('');
            <%
                if(emailChanged)
                {
            %>
                    $('#password-confirm-popup').modal('show');
            <%
                }
            %>
            $(".close-popup-btn").click(function(){
                $('#password-confirm-popup').modal('hide');
            });
        });
        
    </script>
    
    <oneit:form name="editUser" method="post"    enctype="multipart/form-data">
        <div class="container-fluid">
            <div class="row content">
                <div class="main-content-area">
                    <h1 class="page-title">My Details</h1> 
                        <div style="padding-left: 15px; padding-right: 15px;">
                            <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
                            <%
                                if(companyUser.getIsEmailChanged()==Boolean.TRUE && request.getSession().getAttribute("EmailStillNotVerified")!=null)
                                {
                                    request.getSession().removeAttribute("EmailStillNotVerified");
                            %>
                                   <div class="error-message message-common">
                                        <img src="images/infomation-icon.png" class="alert-icon">
                                        <span class="message-txt">Your email address change still hasn't been verified!</span>
                                   </div> 
                            <%
                                }
                            %>
                        </div>
                        <div class="my-company-area">
                            <oneit:dynInclude   page="/extensions/adminportal/inc/my_details_tabs.jsp"    TabNumber="1"    data="<%= CollectionUtils.EMPTY_MAP%>"/>

                            <div class="company-content-area">
                            <!-- Tab panes -->
                            <div class="tab-content">
                                <div class="tab-pane active" id="company-detail">
                                    <div class="tabpage-title">
                                        My Details
                                    </div>
                                    <div class="form-group">
                                        <label><oneit:label GUIName="Email Address" /></label>
                                        <oneit:ormInput obj="<%= loggedInUser %>" type="text" attributeName="Email"  cssClass="form-control" />   
                                        <%  
                                            if(companyUser.getIsEmailChanged()==Boolean.TRUE)
                                            {
                                        %>
                                                <div class="email-verify">Email address not yet verified. 
                                                    <oneit:button   value=" "    name="resendVerification"  skin="link" cssClass="email-verify-link"
                                                                    requestAttribs="<%= CollectionUtils.mapEntry("CompanyUser", companyUser)
                                                                                                        .mapEntry("nextPage", nextPage)
                                                                                                        .mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
                                                                                                        .toMap() %>">
                                                        Resend verification email
                                                    </oneit:button>
                                                </div>
                                        <%
                                            }
                                        %>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-6">
                                            <label><oneit:label GUIName="First Name" /></label>
                                            <oneit:ormInput obj="<%= loggedInUser %>" type="text" attributeName="FirstName"   cssClass="form-control" />                                
                                        </div>
                                        <div class="col-md-6">
                                            <label><oneit:label GUIName="Last Name" /></label>
                                            <oneit:ormInput obj="<%= loggedInUser %>" type="text" attributeName="LastName"   cssClass="form-control" />                                
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label><oneit:label GUIName="Phone" /></label>
                                        <oneit:ormInput obj="<%= companyUser %>" type="text" attributeName="Phone"   cssClass="form-control" />                                
                                    </div>
                                    
                                    <div class="form-group">
                                        <label><oneit:label GUIName="Default Hiring Team"/></label>
                                        <div class="wider-select">
                                            <tagfile:ormsingleasso_select obj="<%= companyUser %>"  assocName="DefaultHiringTeam"   options="<%= Utils.getHiringTeamsByUser(companyUser) %>"/>
                                        </div> 
                                                                                <tagfile:ormsingleasso_select obj="<%= companyUser %>"  assocName="DefaultHiringTeam"   options="<%= companyUser.getCompany().getHiringTeamsSet().toArray(new HiringTeam[0]) %>"/>

                                    </div>
                                    <div class="text-center form-group">
                                        <oneit:button   value="Save Updates"    name="saveUserDetails"  cssClass="btn btn-primary largeBtn"
                                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                            .mapEntry("CompanyUser", companyUser)
                                                                                            .toMap() %>" />
                                    </div> 
                                </div>
                            </div>
                        </div>
                        </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="password-confirm-popup" role="dialog">
            <div class="modal-dialog welcome-pop-top">
                <div class="modal-body notification-popup">
                    <span class="close-popup-btn">
                        <img src="images/notification-popup-close.svg">
                    </span>
                    <h2>Nearly There!</h2>
                    <p>Please confirm your password to finish updating your email.</p>
                    <oneit:ormInput obj="<%= companyUser %>"    type="password" attributeName="ConfirmPassword" cssClass="form-control"/>

                    <div class="save-my-details">
                        <oneit:button   value="Save"    name="saveUserDetails"  cssClass="btn btn-primary btn-orange save-my-details-btn"
                                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                        .mapEntry("CompanyUser", companyUser)
                                                                                        .toMap() %>" />
                    </div>
                </div>          
            </div>
        </div>
    </oneit:form>
</oneit:dynIncluded>
