<%@ 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");
    CompanyUser         companyUser =   (CompanyUser) getData(request, "CompanyUser");
    SecUser             secUser     =   null;
    
    if(companyUser==null || request.getParameter("newuser") != null)
    {
        secUser     =   SecUser.createSecUser(objTran);
        companyUser =   secUser.getExtensionOrCreate(CompanyUser.REFERENCE_CompanyUser);
        
        companyUser.setCompany(company);
    }
    
    secUser =   companyUser.getUser();
%>

<oneit:form 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" />
        </div>
    </oneit:evalBody>
       
</oneit:form>