<%@ 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" %>

<%@ include file="inc/htmlheader_nopriv.jsp" %>

<oneit:dynIncluded>

<%
    String      nextPage    =   WebUtils.getArticleByShortCut(process.getTransaction(), WebUtils.ADMIN_HOME).getLink(request) + "?showModal=true";
    Company     company     =   (Company) process.getAttribute("Company");
    Boolean     socialLogin =   CollectionUtils.equals(process.getAttribute("socialLogin"), Boolean.TRUE);
    
    Debug.assertion(company != null, "Invalid company user in admin portal");
    
    CompanyUser companyUser =   company.getAddedByUser();
    SecUser     secUser     =   companyUser.getUser();
    Integer     pageNumber  =   2;
    boolean     toRedirect  =   company.createDefaultUser();
    
    if (toRedirect)
    {
        %><%@include file="/saferedirect.jsp"%><%
    }
%>

<script type="text/javascript">
    function addUser()  {
        var divID = "#usersSection";

        ajaxProcessAddJQ ("<%= request.getContextPath() %>/extensions/adminportal/inc/invite_user_add.jsp", divID, {}, function (theHTML_JQ) {
            $(divID).append (theHTML_JQ);
        });
    }
        
    function deleteUser(deleteVarKey) {
        ajaxProcessDeleteJQ("<%= request.getContextPath() %>/genericDelete_AJAX.jsp", "#usersSection" , { varKey: deleteVarKey });
        return false;
    }
</script>
<div class="hire-the-right-candi" style="">You're nearly there...</div>

<div class="section-tab-view">
    <oneit:form name="companyProfile" method="post" enctype="multipart/form-data">

        <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
        
        <oneit:dynInclude   page="/extensions/adminportal/inc/company_profile_tabs.jsp" TabNumber="2"   data="<%= CollectionUtils.EMPTY_MAP%>"/>

        <div class="section-page-area"  style="text-align: left">
            <div class="main-sc-section">
                <div class="form-group">
                    <div id="usersSection">
                    <%
                        for (CompanyUser cUser : company.getUsersSet())
                        {
                            if(!CollectionUtils.equals(cUser, companyUser))
                            {
                    %>
                                <oneit:dynInclude   page="/extensions/adminportal/inc/invite_user_add.jsp"  
                                                    CUser="<%= cUser %>"
                                                    data="<%= CollectionUtils.EMPTY_MAP%>"/>
                    <%
                            }
                        }
                    %>
                    </div>
                </div>
            </div>

            <div class="main-sc-section main-add-more content-to-center">
                <oneit:button   value="Add Another"  name="newUser"   cssClass="add-more-btn" skin="link"
                                onClick="<%="addUser(); return false;"%>"
                                requestAttribs="<%= CollectionUtils.EMPTY_MAP %>"/>
            </div>

            <div class="main-sc-section text-center company-profile-btn">
                <oneit:button   value="Send invites & proceed"  name="sendCompanyUserInvites"   cssClass="btn btn-primary box-btn"
                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                    .mapEntry("CompanyUser", companyUser)
                                                                    .mapEntry("procParams", CollectionUtils.mapEntry("socialLogin", socialLogin).mapEntry("Company", company).toMap())
                                                                    .toMap() %>"/>
            </div>
        </div>
    </oneit:form>
</div>
</oneit:dynIncluded>

<%@ include file="inc/htmlfooter_nopriv.jsp" %>