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

<%
    JobApplication          jobApplication  =   (JobApplication) process.getAttribute("JobApplication");
    List<JobApplication>    applications    =   (List<JobApplication>) process.getAttribute("Applications");
    Long                    prevAppID       =   (Long) getData(request, "prevAppID");
    Long                    nextAppID       =   (Long) getData(request, "nextAppID");
    Job                     job             =   jobApplication.getJob();
    Candidate               candidate       =   jobApplication.getCandidate();
    String                  tabText         =   candidate.getToString();
    String                  currentPage     =   WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICATION);
%>

<oneit:dynIncluded>
<%
    Map<FactorClass, Tuple.T2<Double, ColorCode>>   roleScoreMap    =   (Map<FactorClass, Tuple.T2<Double, ColorCode>>)jobApplication.getRoleFit();
%>
<script>
    function tabToggle(tab) {
        $(".nav-justified li").each(function() {
            $(this).removeClass('active');
        });

        $(tab).addClass('active');
    }
    
    $(document).ready(function() 
    {   
        $('.expand-box span').click(function() {
            var $el = $(this);  
            if($(this).hasClass('hasarrow')){
                $el.find('img').attr('src','images/select-top-arrow.svg');
                $(this).removeClass('hasarrow');
            }
            else{
                $el.find('img').attr('src','images/select-down-arrow.svg');
                $(this).addClass('hasarrow');
            }    
        });
    });
</script>

<div class="main-applicant-content dashboard-content-area v-applicant-area ">
    <div class="applicant-header">
        <oneit:button   name="gotoPage" value=" "   cssClass="prev-btn" skin="link"
                        requestAttribs="<%= CollectionUtils.mapEntry("procParams", CollectionUtils.mapEntry("Applications", applications).toMap())
                                                        .mapEntry("nextPage", currentPage+"&JobApplicationID="+prevAppID ).toMap() %>" >
            <img src="images/arrow-left-prev.svg" />
        </oneit:button>
        <div class="main-appli-name">
            <div class="appli-name"><oneit:toString value="<%= candidate.getToString() %>"  mode="EscapeHTML"/></div>
            <div class="appli-applied">
                Applied <oneit:toString  value="<%= jobApplication.getSubmittedDate() %>"   mode="MidDate"/>
            </div>
        </div>
        <div class="main-export">
            <span class="export-candidate"  style="display: none;">
                <select class="form-control">
                    <option>Export Candidate Report</option>
                    <option>PDF</option>
                    <option>Excel</option>
                </select>
            </span>
            <span class="appli-status-short">
                <oneit:ormEnum  obj="<%= jobApplication %>" onChange="$('#saveBtn').click()"  attributeName="ApplicationStatus"   cssClass="form-control status-img"
                                enums="<%= jobApplication.getAvailableStatuses() %>"/>
                <oneit:button   name="save" value="Save"    cssClass="hidden"   id="saveBtn"
                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
                                                                .mapEntry ("attribNamesToRestore", new HashSet<String> (Arrays.asList(new String[] {"Job", "JobApplication"})))
                                                                .mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).mapEntry("Job", job).toMap())
                                                                .mapEntry ("restartProcess", Boolean.TRUE).toMap() %>" />
            </span>
        </div>
        <oneit:button   name="gotoPage" value=" "   cssClass="next-btn" skin="link"
                        requestAttribs="<%= CollectionUtils.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).mapEntry("Applications", applications).toMap())
                                                        .mapEntry("nextPage", currentPage+"&JobApplicationID="+nextAppID ).toMap() %>" >
            <img src="images/arrow-right-next.svg" />
        </oneit:button>
    </div>
    <div class="main-applicant-content"> 
        <div class="applicant-sub-part">
            <div class="applicant-left">
                <%
                    Tuple.T2<Double, ColorCode> roleFitData =   (jobApplication.getRoleFit()!=null && jobApplication.getRoleFit().get(null)!=null) ? (Tuple.T2<Double, ColorCode>) jobApplication.getRoleFit().get(null) : null;
                    String                      colorClass  =   "percent-" +(roleFitData!=null ? roleFitData.get1().getCSSClass() : "green");
                %>
                <div class="applicant-progress">
                    <div class="<%= job.getIncludeAssessmentCriteria()==Boolean.TRUE ? "col-sm-4" : "col-sm-6" %> col-xs-12 text-center thr-block role-fit" href="#1a" data-toggle="tab"    id="progress1"  onClick="tabToggle('#tab1')">
                        <label class="progress-label">role fit</label>
                        <div class="<%= colorClass %> fixed-width">
                            <p style="display:none;"><oneit:toString value="<%= roleFitData.get0() %>"    mode="TwoDPDouble"  nullValue="0"/></p>
                        </div>
                        <div class="row four-label">
                            <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                <div class="a-label-row">
                                    <span class="yellow-dot"></span><span class="r-y-label text-dot-dot">Achievement</span>
                                </div>
                                <div class="a-label-row">
                                    <span class="red-dot"></span><span class="r-y-label text-dot-dot">Item with a long ti</span>
                                </div>
                            </div>
                            <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                <div class="a-label-row">
                                    <span class="yellow-dot"></span><span class="r-y-label text-dot-dot">Remuneration</span>
                                </div>
                                <div class="a-label-row">
                                    <span class="red-dot"></span><span class="r-y-label text-dot-dot">Item title</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="<%= job.getIncludeAssessmentCriteria()==Boolean.TRUE ? "col-sm-4" : "col-sm-4" %> col-xs-12 text-center thr-block culture-fit" href="#2a" data-toggle="tab"    id="progress2"  onClick="tabToggle('#tab2')">
                        <label class="progress-label">culture fit</label>
                        <div class="percent-green fixed-width">
                            <p style="display:none;"><oneit:toString value="<%= jobApplication.getCultureFitScore() %>" mode="TwoDPDouble" /></p>
                        </div>
                        <div class="row four-label">
                            <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                <div class="a-label-row">
                                    <span class="yellow-dot"></span><span class="r-y-label text-dot-dot">Achievement</span>
                                </div>                    
                                <div class="a-label-row">
                                    <span class="red-dot"></span><span class="r-y-label text-dot-dot">Item title</span>
                                </div>
                            </div>
                            <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                <div class="a-label-row">
                                    <span class="yellow-dot"></span><span class="r-y-label text-dot-dot">Remuneration</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <%
                        if(job.getIncludeAssessmentCriteria()==Boolean.TRUE)
                        {
                    %>
                            <div class="col-sm-4 col-xs-12 text-center thr-block requirement-fit" href="#3a" data-toggle="tab"    id="progress3"  onClick="tabToggle('#tab3')">
                                <label class="progress-label">requirements</label>
                                <div class="percent-blue fixed-width">
                                    <p style="display:none;"><oneit:toString value="<%= jobApplication.getRequirementFitScore() %>" mode="TwoDPDouble" /></p>
                                </div>
                                <div class="row four-label">
                                <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                        <div class="a-label-row">
                                            <span class="yellow-dot"></span><span class="r-y-label text-dot-dot">Item title</span>
                                        </div> 
                                        <div class="a-label-row">&nbsp;</div>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-6 text-left">
                                        <div class="a-label-row">
                                            <span class="red-dot"></span><span class="r-y-label text-dot-dot">Item title</span>
                                        </div>
                                        <div class="a-label-row">&nbsp;</div>
                                    </div>
                                </div>
                            </div>

                    <%
                        }
                    %>
                </div>
                <div class="applicant-tab">
                    <div class="tab-content clearfix">
                        <div class="tab-pane active" id="1a">
                        <%
                            for(FactorClass factorClass : jobApplication.getSortedFactorClasses())
                            {
                                if(roleScoreMap.get(factorClass) != null && roleScoreMap.get(factorClass).get0() > 0d)
                                {
                                    Map<FactorLevelLink, Map>   factorDetails   =   AnalysisEngine.getFactorScoreDetails(candidate, job.getLevel(), factorClass);
                                    Double                      rating          =   roleScoreMap.get(factorClass).get0();
                                    ColorCode                   colorCode       =   roleScoreMap.get(factorClass).get1();
                                    String                      cssClass        =   colorCode.getCSSClass();
                        %>
                                    <div class="main-pro-bar">
                                        <div class="pro-bar">
                                            <span class="appli-label"><oneit:toString   value="<%= factorClass %>"  mode="EscapeHTML"/></span>
                                            <span class="appli-percen gray"><oneit:toString  value="<%= rating %>"  mode="TwoDPDouble"/></span>
                                            <span class="appli-progress-bar">
                                                <div class="progress">
                                                    <div class="progress-bar <%= cssClass %>" role="progressbar" aria-valuenow="<%= rating %>" aria-valuemin="0" aria-valuemax="100" style="width:<%= rating %>%"></div>
                                                </div>
                                            </span>
                                            <span class="expand-box">
                                                <span class="hasarrow"><img src="images/select-down-arrow.svg"></span>
                                            </span>
                                        </div>

                                        <div class="expand-hide-tag" style="display: block;">
                                        <%
                                            for(FactorLevelLink factorLevelLink : factorDetails.keySet())
                                            {
                                                Map factorLinkDetails   =   factorDetails.get(factorLevelLink);

                                                if(!factorLinkDetails.isEmpty())
                                                {
                                                    FactorScore factorScore =   (FactorScore) factorLinkDetails.get("factorScore");
                                        %>
                                                    <div class="tab-row">
                                                        <div class="tab-view-label"><oneit:toString value="<%= factorLevelLink.getFactor() %>"  mode="EscapeHTML"/></div>
                                                        <div class="tab-view-side">
                                                            <div class="result-want">
                                                                <div class="result"><oneit:toString value="<%= factorLevelLink.getLeftAnnot() %>"   mode="EscapeHTML"/></div>
                                                                <div class="wants"><oneit:toString  value="<%= factorLevelLink.getRightAnnot() %>"  mode="EscapeHTML"/></div>
                                                            </div>
                                                            <div class="result-bar">
                                                                <ul>
                                                                <%
                                                                    Map<FactorScoreResult, Double>  factorScoreDetails  =   (Map<FactorScoreResult, Double>)factorLinkDetails.get("factorScoreDetails");
                                                                
                                                                    for(FactorScoreResult factorScoreResult : factorScoreDetails.keySet())
                                                                    {
                                                                %>
                                                                        <li class="<%= factorScoreResult.getColorCode() != null ? factorScoreResult.getColorCode().getCSSClass() : "" %>"   style="width: <%= factorScoreDetails.get(factorScoreResult) %>%; height: 10px"></li>
                                                                <%
                                                                    }
                                                                %>
                                                                </ul>
                                                                <span class="triangle-arrow" style="left: <%= factorLinkDetails.get("scoreLeftMargin")%>%;"></span>
                                                            </div>
                                                            <div class="like-strive"><oneit:toString    value="<%= factorScore != null ? factorScore.getNarrative() : null %>"  mode="EscapeHTML"/></div>
                                                        </div>
                                                    </div>
                                        <%
                                                }
                                            }
                                        %>
                                        </div>
                                    </div>
                        <%
                                }
                            }
                        %>
                        </div>
                        <div class="tab-pane" id="2a">
                            <%
                                Map<CultureClass, Long> cultureFitData  =   (Map<CultureClass, Long>)jobApplication.getCultureFit();
                            
                                for(CultureClass cClass: cultureFitData.keySet())
                                {
                                    if(cClass==null)
                                    {
                                        continue;
                                    }
                                
                                    Long    rating  =   cultureFitData.get(cClass);
                            %>
                                    <div class="main-pro-bar">
                                        <div class="pro-bar">
                                            <span class="appli-label"><oneit:toString   value="<%= cClass %>"   mode="EscapeHTML"/></span>
                                            <span class="appli-percen"><oneit:toString  value="<%= rating %>"   mode="TwoDPDouble" /></span>
                                            <span class="appli-progress-bar">
                                                <div class="progress">
                                                    <div class="progress-bar" role="progressbar" aria-valuenow="<%= rating %>" aria-valuemin="0" aria-valuemax="100" style="width:<%= rating %>%;"></div>
                                                </div>
                                            </span>
                                            <span class="expand-box">
                                            <span class="hasarrow"><img src="images/select-down-arrow.svg" /></span>
                                            </span>
                                        </div>
                                        <div class="expand-hide-tag">
                                            <div class="tab-row">
                                                <div class="tab-view-label">
                                                    Achievement
                                                </div>
                                                <div class="tab-view-side">
                                                    <div class="result-want">
                                                        <div class="result">Not results focused</div>
                                                        <div class="wants">Wants results</div>
                                                    </div>
                                                    <div class="result-bar">
                                                        <ul>
                                                            <li class="red-b" style="width: 26.5%; height: 10px;"></li>
                                                            <li class="yellow-b" style="width: 26.5%; height: 10px;"></li>
                                                            <li class="green-b" style="width: 47%; height: 10px;"></li>
                                                        </ul>
                                                        <span class="triangle-arrow" style="left: 48%;"></span>
                                                    </div>
                                                    <div class="like-strive">Likely to strive to achive results</div>
                                                </div>
                                            </div>
                                            <div class="tab-row">
                                                <div class="tab-view-label">
                                                    Remuneration
                                                </div>
                                                <div class="tab-view-side">
                                                    <div class="result-want">
                                                        <div class="result">Low concern</div>
                                                        <div class="wants">High concern</div>
                                                    </div>
                                                    <div class="result-bar">
                                                        <ul>
                                                            <li class="red-b" style="width: 23.2%; height: 10px;"></li>
                                                            <li class="yellow-b" style="width: 57.6%; height: 10px;"></li>
                                                            <li class="green-b" style="width: 19%; height: 10px;"></li>
                                                        </ul>
                                                        <span class="triangle-arrow" style="left: 72%;"></span>
                                                    </div>
                                                    <div class="like-strive">Financial reward is less of a motivation than many other factors</div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                            <%
                                }
                            %>
                        </div>
                        <%
                            if(job.getIncludeAssessmentCriteria()==Boolean.TRUE)
                            {
                        %>
                                <div class="tab-pane" id="3a">
                                    <%
                                        Map<Importance, Long>   requirementFitData  =   (Map<Importance, Long>)jobApplication.getRequirementFit();

                                        for(Importance importance: requirementFitData.keySet())
                                        {
                                            if(importance==null)
                                            {
                                                continue;
                                            }

                                            Long    rating  =   requirementFitData.get(importance);
                                    %>
                                            <div class="main-pro-bar">
                                                <div class="pro-bar">
                                                    <span class="appli-label"><oneit:toString   value="<%= importance %>"   mode="EscapeHTML"/></span>
                                                    <span class="appli-percen"><oneit:toString  value="<%= rating %>"   mode="TwoDPDouble" /></span>
                                                    <span class="appli-progress-bar">
                                                        <div class="progress">
                                                            <div class="progress-bar" role="progressbar" aria-valuenow="<%= rating %>" aria-valuemin="0" aria-valuemax="100" style="width:<%= rating %>%"></div>
                                                        </div>
                                                    </span>
                                                    <span class="expand-box">
                                                    <span class="hasarrow"><img src="images/select-down-arrow.svg" /></span>
                                                    </span>
                                                </div>
                                                <div class="expand-hide-tag">
                                                    <div class="tab-row">
                                                        <div class="tab-view-label">
                                                            Achievement
                                                        </div>
                                                        <div class="tab-view-side">
                                                            <div class="result-want">
                                                                <div class="result">Not results focused</div>
                                                                <div class="wants">Wants results</div>
                                                            </div>
                                                            <div class="result-bar">
                                                                <ul>
                                                                    <li class="red-b" style="width: 26.5%; height: 10px;"></li>
                                                                    <li class="yellow-b" style="width: 26.5%; height: 10px;"></li>
                                                                    <li class="green-b" style="width: 47%; height: 10px;"></li>
                                                                </ul>
                                                                <span class="triangle-arrow" style="left: 48%;"></span>
                                                            </div>
                                                            <div class="like-strive">Likely to strive to achive results</div>
                                                        </div>
                                                    </div>
                                                    <div class="tab-row">
                                                        <div class="tab-view-label">
                                                            Remuneration
                                                        </div>
                                                        <div class="tab-view-side">
                                                            <div class="result-want">
                                                                <div class="result">Low concern</div>
                                                                <div class="wants">High concern</div>
                                                            </div>
                                                            <div class="result-bar">
                                                                <ul>
                                                                    <li class="red-b" style="width: 23.2%; height: 10px;"></li>
                                                                    <li class="yellow-b" style="width: 57.6%; height: 10px;"></li>
                                                                    <li class="green-b" style="width: 19%; height: 10px;"></li>
                                                                </ul>
                                                                <span class="triangle-arrow" style="left: 72%;"></span>
                                                            </div>
                                                            <div class="like-strive">Financial reward is less of a motivation than many other factors</div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                    <%
                                        }
                                    %>
                                </div>
                        <%
                            }
                        %>
                        <div class="tab-pane" id="4a">
                        </div>
                    </div>
                </div>
            </div>
            <div class="applicant-right">

                <div class="app-right-b">
                    <div class="overall-suit">overall rank</div>
                    <div class="big-percentage">                        
                        <oneit:toString value="<%= jobApplication.getOverallRank() %>"   mode="Integer" />
                    </div>
                </div>
                <div class="applicant-contact-info">
                    <div class="contact-title">Contact</div>
                    <div class="contact-row">
                        <div class="contact-label">E</div>
                        <div class="contact-value">
                            <a href="<%= "mailto:" + candidate.getUser().getUserName() %>">
                                <oneit:toString value="<%= candidate.getUser().getUserName() %>" mode="EscapeHTML" />
                            </a>
                        </div>
                    </div>
                    <div class="contact-row">
                        <div class="contact-label">P</div>
                        <div class="contact-value">
                            <oneit:toString value="<%= candidate.getPhone() %>" mode="EscapeHTML" />
                        </div>
                    </div>
                    <div class="contact-row"    style="display: none;">
                        <div class="contact-label"><img src="images/linkdin-icon.png" /></div>
                        <div class="contact-value"><a href="#">View LinkedIn profile</a></div>
                    </div>
                    <div class="contact-row"    style="display: none;">
                        <div class="contact-label"><img src="images/download-icon.png" /></div>
                        <div class="contact-value"><a href="#">Download Resume</a></div>
                    </div>
                </div>
                <div class="applicant-note" style="display: none;">
                    <div class="applicant-note-title">Notes</div>
                    <div class="note-txt-box">
                        <textarea class="form-control"></textarea>
                        <input type="button" class="add-note-btn" value="ADD NOTE" />
                    </div>
                </div>
                <div class="admin-notes"    style="display: none;">
                    <div class="admin-name">Admin name</div>
                    <div class="date-value">TODAY</div>
                    <div class="admin-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan interdum nisi, sed laoreet dui rhoncus.</div>
                    <div class="admin-br-line"></div>
                    <div class="admin-name">Admin name</div>
                    <div class="date-value">2 days ago</div>
                    <div class="admin-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
                </div>
            </div>
        </div>
    </div>
</div>

</oneit:dynIncluded>