<%@ page extends="oneit.servlets.process.AJAXProcessJSP" %>

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

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

<%
    ORMProcessState             process     =   (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
    ObjectTransaction           objTran     =   process.getTransaction ();
    Company                     company     =   (Company) process.getAttribute("Company");
    HiringTeam                  hiringTeam  =   company.getDefaultHiringTeam();
    CompanyUserHiringTeamLink   link        =   (CompanyUserHiringTeamLink) getData(request, "UserLink");
    CompanyUser                 companyUser =   null;
    SecUser                     secUser     =   null;
    
    if(link == null)
    {
        link        =   CompanyUserHiringTeamLink.createCompanyUserHiringTeamLink(objTran);
        secUser     =   SecUser.createSecUser(objTran);
        
        objTran.setAttrib(SecUser.CREATE_USER_KEY, true);
        
        companyUser =   secUser.getExtensionOrCreate(CompanyUser.REFERENCE_CompanyUser);
        
        link.setHiringTeam(hiringTeam);
        link.setCompanyUser(companyUser);
    }

    companyUser =   link.getCompanyUser();
    secUser     =   companyUser.getUser();
%>

<oneit:form name="companyProfile"   method="POST">
    
    <oneit:evalBody buffer="<%= getBuffer(request) %>">
    <%
        FormTag     myForm          =   FormTag.getActiveFormTag(request);
        FormBuilder formBuilder     =   myForm.getFormBuilder();
        
        String      optionKey       =   WebUtils.getInputKey(request, secUser, SecUser.FIELD_Email);
        String      formValue       =   formBuilder.fieldValue (optionKey, secUser.getEmail());

        String      deleteVarKey    =   FormTag.getVariableKey (request);

        FormTag.setVariable (request, deleteVarKey, "objToDelete", secUser);
        FormTag.setVariable (request, deleteVarKey, "jqToDelete", "#" + secUser.getID());
    %>

        <div class="main-user-invite" id="<%= secUser.getID() %>">
            <span class="delete-company-user"  onclick="return deleteUser (<%= deleteVarKey %>)"><span></span></span>
            <oneit:ormInput obj="<%= secUser %>"    type="text" attributeName="Email"   cssClass="form-control" style="text-transform: lowercase"/>
        </div>
    </oneit:evalBody>
       
</oneit:form>