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

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

<%! protected String getName (ServletConfig config) { return "sign_up_jsp"; } %>

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

<%
    ORMProcessState     process     =   (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
    ObjectTransaction   objTran     =   process.getTransaction ();
    Boolean             toRedirect  =   GenericObjDF.getOrCreateObject (request, "Company", Company.REFERENCE_Company);
    Company             company     =   (Company) process.getAttribute("Company");

    if(toRedirect)
    {
        company.addToHiringTeams(HiringTeam.createHiringTeam(objTran));
    }
    
    SecUser             secUser     =   null;
    CompanyUser         companyUser =   company.getAddedByUser(); 

    if(companyUser == null)
    {
        secUser     =   SecUser.createSecUser(objTran);
        companyUser =   secUser.getExtensionOrCreate(CompanyUser.REFERENCE_CompanyUser);

        company.setAddedByUser(companyUser);
        companyUser.setCompany(company);
        
        HiringTeam hiringTeam   =   company.getHiringTeamsAt(0);
        hiringTeam.setAddedByUser(companyUser);
        companyUser.setDefaultHiringTeam(hiringTeam);

        CompanyUserHiringTeamLink link  =   CompanyUserHiringTeamLink.createCompanyUserHiringTeamLink(objTran);
        link.setCompanyUser(companyUser);
        link.setHiringTeam(hiringTeam);
        link.setRole(RoleType.OWNER);
    }
    
    secUser     =   companyUser.getUser(); 
    
    if(toRedirect)
    {
        %><%@include file="/saferedirect.jsp"%><%
    }
    
    Debug.assertion(companyUser != null, "CompanyUser is null in admin portal");
%>

<script type="text/javascript">
    $(document).ready(function() {
        validate();
        $('input').on('change keyup', function() { validate() });
    });

    function validate() {
        var empty = false;
        $('input[required]').each(function() {
            if ( $.trim($( this ).val()) == '') {
                empty = true;
                if ($( this ).css('background-color') == 'rgb(250, 255, 189)') {
                   empty = false;
                }
            }
        });

        if (empty) {
            $('.send-btn').attr('disabled', 'disabled');
        } else {
            $('.send-btn').removeAttr('disabled');
        }
    }
</script>
<style>
    button[disabled] {
        opacity: 0.6;
        background-color: #0582ba;
    }
/*    #overlay {
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0,0,0,0.5);
        z-index: 2;
        cursor: pointer;
    }
    .welcome-pop-top {
        margin-top: 20%;
    }
    .main-welcome-popup h2 {
        padding: 0 20px 0;
    }*/
</style>

<div class="hire-the-right-candi">Hire the right candidate</div>
<div>&nbsp;</div>

<oneit:form name="sign_up"    method="post">
    <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
    
    <div class="main-box-layout login-box">
        <oneit:dynInclude   page="/extensions/adminportal/inc/company_user_data.jsp"    data="<%= CollectionUtils.EMPTY_MAP%>"  CompanyUser="<%= companyUser %>"
                            IncludePrivacyStatements="<%= Boolean.TRUE%>"   IncludePassword="<%= Boolean.FALSE%>"/>

        <oneit:button   value="Sign up"    name="send" cssClass="box-btn send-btn"
                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", "verification_sent.jsp")
                                                        .mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
                                                        .mapEntry("Company", company)
                                                        .toMap() %>"/>
    </div>
</oneit:form>
<!--    <div id="overlay">
        <div class="modal-dialog welcome-pop-top">
            <div class="modal-body main-welcome-popup">
                <h2>Talentology will be available for sign up soon!</h2>
                <p>In the meantime, if you have any questions or feedback, please <strong>contact us via our messenger</strong>.<br/>
                Thanks :)</p>
                <div class="create-y-f-job">
                    <a href=" https://www.talentology.com/support/">
                        Contact Us
                    </a>
                </div>
            </div>          
        </div>
    </div>-->

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