<%@ 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>
<%
    ObjectTransaction   objTran         = process.getTransaction ();
    String              currentPage     = WebUtils.getSamePageInRenderMode(request, "JobMatchAssessment");
    String              nextPage        = WebUtils.getSamePageInRenderMode(request, "SubmitApplication");
    JobApplication      jobApplication  = (JobApplication) process.getAttribute("JobApplication");
    Job                 job             = jobApplication.getJob();
    int                 questionNumber  = process.getAttribute("QuestionNumber")!= null ? (int) process.getAttribute("QuestionNumber") : 0;
    String              sectionNo       =   jobApplication.isIncludeAssessmentCriteria() ? "3" : "2";
    List<Question>      allQuestions    = (List<Question>) process.getAttribute("AllQuestions");
    
    if(allQuestions==null)
    {
        allQuestions    = job.getAllLeftQuestions();
        
        process.setAttribute("AllQuestions", allQuestions);
    }
    
%>
    <script>
        $(document.body).addClass('bg-color');
    </script>
    
    <div class="main-application-outline">
        <div class="selection-aust-logo">
            <img src="images/australia-post.png" />
            <span><oneit:toString value="<%= job.getJobTitle() %>"  mode="EscapeHTML"/></span>
        </div>
        <div class="show-mobile-title">
            <div class="mobile-title-page">Section <oneit:toString value="<%= sectionNo %>" mode="EscapeHTML"/> - Job Match Assessment</div>
            <div class="mobile-estimated">Estimated time to complete: <b>20 mins</b></div>
        </div>
        <div class="section-title m-hide">Section <oneit:toString value="<%= sectionNo %>" mode="EscapeHTML"/></div>
        <div class="section-c-title m-hide">
            Job Match Assessment
            <span>Estimated time to complete: <b>20 mins</b></span>
        </div>
        <div class="section-tab-view">
            
            <oneit:form name="editApplication"  method="post"   enctype="multipart/form-data">
            
                <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
                
                <oneit:dynInclude   page="/extensions/applicantportal/inc/application_main_tabs.jsp"    PageNumber="3"  data="<%= CollectionUtils.EMPTY_MAP%>"/>

                <div class="section-page-area section-job-match">
                    <div class="main-sc-section sj-1">
                        <p>Using the scale given, indicate how important to you are the following aspects in your work life. Use the following system:</p>
                        <ul class="security-level">
                            <li><span>1</span> means of very little importance to you</li>
                            <li><span>4</span> means about average in importance to you</li>
                            <li><span>7</span> means of high importance to you</li>
                        </ul>
                        <p>Use the other numbers (2, 3, 5, 6) to indicate in-between levels of importance to you.</p>            
                    </div>
                    <div class="selection-br-line"></div>
                    <div class="main-sc-section main-rate-section">
                        <%
                            FormTag     applicationForm     =   FormTag.getActiveFormTag(request);
                            FormBuilder formBuilder         =   applicationForm.getFormBuilder();
                            int         totNoOfQuestions    =   allQuestions.size();
                            
                            if(questionNumber<totNoOfQuestions)
                            {
                                Answer  answer      =   jobApplication.getPAAnswerOrCreate(allQuestions.get(questionNumber), questionNumber);
                                String  optionKey   =   WebUtils.getInputKey(request, answer, Answer.FIELD_AnswerNo);
                                String  formValue   =   formBuilder.fieldValue (optionKey, answer.getAnswerNo() == null ? "" : String.valueOf(answer.getAnswerNo()));
                                String  numberText  =   (questionNumber + 1) + "/" + totNoOfQuestions;
                        %>
                                <div class="rateing-title">
                                    Rate the importance of each item below
                                    <span><oneit:toString value="<%= numberText %>"   mode="EscapeHTML"/></span>
                                </div>
                                <div class="rating-box-title">
                                    <oneit:toString value="<%= answer.getQuestion().getDescription() %>"    mode="EscapeHTML"/>
                                </div>
                                <div class="ratting-box">
                                    <span>Very little importance</span>  
                                    <ul class="pagination ratting-number">
                                        <%
                                            for(int index=1; index<=7; index++)
                                            {
                                                String  activeStr   = (CollectionUtils.equals(String.valueOf(index), formValue) ? "active" : "");
                                                String  selectedStr = (CollectionUtils.equals(String.valueOf(index), formValue) ? "checked" : "");
                                        %>
                                        <li class="<%= activeStr %>">
                                            <a href="javascript:void(0);">
                                                <input type="radio" name="<%= optionKey %>" id="<%= index %>" value="<%= index %>" <%= selectedStr %>>
                                                <label for="<%= index %>"><%= index %></label>
                                            </a>
                                        </li>
                                        <%
                                            }
                                        %>
                                    </ul>
                                    <span>High importance</span>
                                </div>
                        <%
                            }
                        %>
                        <div >
                            <span style="float: left">
                                <%
                                    if(questionNumber>0)
                                    {
                                %>
                                        <oneit:button   value="Previous"    name="gotoPage" cssClass="box-btn-gray" 
                                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
                                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber - 1)).toMap())
                                                                                        .toMap() %>"/>
                                <%
                                    }
                                %>
                            </span>
                            <span style="float: right">
                                <%
                                    if((questionNumber+1)<totNoOfQuestions)
                                    {
                                %>
                                        <oneit:button   value="Next"    name="gotoPage" cssClass="box-btn" 
                                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
                                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber + 1)).toMap())
                                                                                        .toMap() %>"/>
                                <%
                                    }
                                %>
                            </span>
                        </div>
                        <div class="auto-save">
                            <oneit:button   value="Complete"    name="completeApplication"  cssClass="box-btn"
                                            requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                            .mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
                                                                            .mapEntry("attribNamesToRestore", Collections.singleton("JobApplication"))
                                                                            .mapEntry("restartProcess", Boolean.TRUE)
                                                                            .toMap() %>"/>
                            <%-- <div>Autosaved 1 min ago.</div> --%>
                        </div>
                    </div>                      
                </div>
            </oneit:form>
        </div>
    </div>
</oneit:dynIncluded>