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

<oneit:dynIncluded>
<%
    String      nextPage        =   WebUtils.getSamePageInRenderMode(request, "SignIn");
    Job         job             =   (Job) process.getAttribute("Job");
    String      id              =   request.getParameter("id");
    String      key             =   request.getParameter("key");
    String      candidateId     =   request.getParameter("aid");
    String      pin             =   request.getParameter("pin");
    SecUser     secUser         =   null;
    Candidate   candidate       =   null;
    SecUser     loggedInUser    =   SecUser.getTXUser(transaction);

    if(id != null && key != null)
    {
        job = Job.searchJobKey(transaction, Long.parseLong(id), key);
            
        process.setAttribute("Job", job);
    }

    if(job != null && candidateId != null && pin != null)
    {
        candidate   =   Candidate.searchIdPin(transaction, Long.parseLong(candidateId), pin);

        if(candidate != null)
        {
            secUser =   candidate.getUser();

            String  navigateTo  =   WebUtils.getSamePageInRenderMode(request, "SignIn") + "&UserName=" + secUser.getEmail();

            if((loggedInUser != null && loggedInUser == secUser) || candidate.isUnverifiedEmailIngestUser() || !candidate.isTrue(candidate.getIsPasswordChanged()))
            {
                navigateTo  =   WebUtils.getSamePageInRenderMode(request,"VerifyIdentity");
            }
                
            navigateTo  =   navigateTo + "&JobID=" + job.getID().toString();

%>
                <oneit:form name="navigateJob" method="post" enctype="multipart/form-data">
                    <oneit:button   value=" "   name="verifyIdentity"   cssClass="verifyIdentity"   style="display:none;" 
                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", navigateTo)
                                                                        .mapEntry("Candidate", candidate)
                                                                        .mapEntry("Job", job)
                                                                        .mapEntry(NotificationUtils.DISPLAY_NOTIFICATION_PARAM, false)
                                                                        .toMap() %>"/>
                </oneit:form>
                <script type="text/javascript">
                    $(".verifyIdentity").click();
                </script>
<%           
        }
    }
    
    if(job != null)
    {
%>
        <style>
            .row {
                padding-bottom: 30px;
            }
            .power-footer {
                background-color:#fff;
            }
        </style>
        <div class="apply-job-logo-header">
            <div class="box-sizing-border-box">
                <div class="logo-img">
            <%
                BinaryContent   logo    =   job.getLogo();

                if(logo != null)
                {
                    int logoHeight  =   45;
            %>
                    <tagfile:img src="<%= ThumbnailUtils.filterImage(DiskFileBinaryContent.getRelativeURL(logo), "KEEP", new ScaleWithin (0, logoHeight)) %>" />
            <%
                }
            %>
                </div>
                <div class="header-title">
                    <%= job.getTeamName() %>
                </div>
            </div>
        </div>
        <div class="main-position-overview">
       

            <div class="overview-title">
                <oneit:toString value="<%= job.getJobTitle() %>"   mode="EscapeHTML"/>
            </div>
            <%
                if(job.getReferenceNumber() != null)
                {
            %>  
                    <div class="ref-number">
                        Ref: <oneit:toString value="<%= job.getReferenceNumber() %>"    mode="EscapeHTML"/>
                    </div>
            <%
                }
            %>
            
            <table class="table table-responsive pos-table">
                <tbody>
                    <tr>
                        <td class="pos-tabel-td">Location:</td>
                        <td class="pos-tabel-second"><oneit:toString    value="<%= job.getGoogleAddressText() %>"    mode="EscapeHTML"   nullValue="-"/></td>
                    </tr>
                    <tr>
                        <td class="pos-tabel-td">Type:</td>
                        <td class="pos-tabel-second"><oneit:toString    value="<%= job.getJobType() %>" mode="EscapeHTML"   nullValue="-"/></td>
                    </tr>
                    <tr>
                        <td class="pos-tabel-td">Apply by:</td>
                        <td class="pos-tabel-second"><oneit:toString    value="<%= job.getApplyBy() %>" mode="MidDate"      nullValue="-"/></td>
                    </tr>
                </tbody>
            </table>

            <div class="job-detail-title">
              Job Details
            </div>

            <div class="pos-content">
                <oneit:toString value="<%= job.getJobDescription() %>"  mode="ParagraphHTML"    nullValue="-"/>
            </div>
            
            <oneit:form name="applyJob" method="post" enctype="multipart/form-data">
                <div class="apply-job-btn">
                    <oneit:button   value="Apply Now"   name="gotoPage" skin="link" 
                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                    .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                    .toMap() %>"/>
                </div>
            </oneit:form>
        </div>
<%
    }
    else
    {
%>
        <div class="main-position-overview">
            <p class="overview-title" align="center">Job is either deleted, or has expired.</p>
        </div>
<%
    }
%>
</oneit:dynIncluded>
