<%@ 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.getArticleLink(request, process.getTransaction (), WebUtils.JOB_APPLICATION, "Page");
    CompanyUser companyUser =   (CompanyUser) process.getAttribute("CompanyUser");
    SecUser     secUser     =   null;

    //to process company user verification
    String      id          =   request.getParameter("id");
    String      key         =   request.getParameter("key");
    Boolean     isVerify    =   Boolean.FALSE;
    
    if(id!=null && key!=null)
    {
        isVerify    =   Boolean.TRUE;
        companyUser =   CompanyUser.searchIdPin(transaction, Long.parseLong(id), key);

        if(companyUser!=null && companyUser.getIsAccountVerified()!=Boolean.TRUE)
        {
            secUser =   companyUser.getUser();
            process.setAttribute("CompanyUser", companyUser);
        }
    }
    else
    {
        response.sendRedirect(WebUtils.getSamePageInRenderMode(request, "AuthError"));
    }
    
    Debug.assertion(companyUser != null, "Invalid CompanyUser in admin portal");
%>
    <script type="text/javascript">
        $(document.body).addClass('bg-color');

        $(document).ready(function() {
            validate();
            $('input').on('change keyup', function() { validate() });
            interval =  setInterval(function() { validate(); }, 500);
        });

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

            if (empty) {
                $('.verify-btn').attr('disabled', 'disabled');
            } else {
                $('.verify-btn').removeAttr('disabled');
                 clearInterval(interval);
            }
        }
    </script>
    
    <style>
        button[disabled] {
            opacity: 0.6;
            background-color: #0582ba;
        }
    </style>

    <oneit:form name="verify"    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 %>"/>

            <oneit:button   value="Verify and login"    name="xxx" cssClass="box-btn send-btn"
                            requestAttribs="<%= CollectionUtils.mapEntry("nextPage", "sign_in.jsp").toMap() %>"/>
        </div>
    </oneit:form>
</oneit:dynIncluded>