<%@ 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>
<%
    //TODO: filter with Client;
    ObjectTransaction   objTran     =   process.getTransaction ();
    Job[]               jobs        =   Job.SearchByAll().andJobStatus(new EqualsFilter<>(JobStatus.DRAFT)).search(transaction);
    String              nextPage    =   WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICANTS);
    String              homePage    =   WebUtils.getSamePageInRenderMode(request, WebUtils.ADMIN_HOME);

%>
    <oneit:form name="editJob" method="post"    enctype="multipart/form-data">
        

        <div class="dashboard-content-area first-part">
            <div class="welcome-box">
                <div class="dashboard-welcome">
                    <div class="welcome-text"> Welcome <br/> back Maria! </div>
                    <a class="d-create-job-btn" href="<%= WebUtils.getArticleLink(request, objTran, WebUtils.CREATE_JOB, "Page") %>">Create New Job</a>
                </div>
                <div class="col-sm-3 col-xs-12 d-three-box green-light">
                    <div class="d-fl-left eq-height">
                        <div class="dash-count c-green"><oneit:toString value="<%= jobs.length %>"  mode="EscapeHTML"   nullValue="0"/></div>
                        <div class="d-box-title">Open Jobs</div>
                        <a href="#" class="arrow-btn">2 closing soon </a>
                    </div>
                </div>
                <div class="col-sm-3 col-xs-12 d-three-box gray-light">
                    <div class="d-fl-left eq-height">
                        <div class="dash-count c-gray">2</div>
                        <div class="d-box-title">Jobs complete</div>
                        <a href="#" class="arrow-btn">Review applicants</a>
                    </div>
                </div>
                <div class="col-sm-3 col-xs-12 d-three-box blue-light">
                    <div class="d-fl-left eq-height">
                        <div class="dash-count c-blue">2</div>
                        <div class="d-box-title">Applicants</div>
                        <div class="ending-time-states">Week ending May 12, 2017</div>
                        <div class="week-states">13 last week <span>(+5)</span></div>
                    </div>
                </div>        
            </div>
        </div>
        <div class="dashboard-content-area second-part">
            <div class="d-job-title">Active Jobs</div>
            <div class="main-job-list">
            <%
                for (Job job : jobs)
                {
                    
                    
            %>
                    <div class="job-list">
                        <div class="job-post jl-c eq-second-height">
                            <div class="job-post-name">
                                <oneit:toString value="<%= job.getJobTitle() %>"    mode="EscapeHTML" />
                                <!--TODO: Remove this edit button. Added for testing purposes of edit job-->
                                <oneit:button   value="EDIT"   name="gotoPage" cssClass="add-more-btn review-edit-btn pull-right"   skin="link"
                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                        .toMap() %>"/>
                            </div>
                            <div class="job-company-name">
                                <span class="superlaw">SUPERLAW</span>
                                <span class="calendar"><oneit:toString value="<%= job.getDaysTillClose() %>"    mode="EscapeHTML"/></span>
                            </div>
                        </div>
                        <div class="job-application jl-c eq-second-height">
                            <div class="ja-icon"><img src="images/job-list-user.png" /></div>
                            <div class="ja-count">
                                <oneit:toString value="<%= job.getNoOfCandidatesApplied() %>"   mode="EscapeHTML"   nullValue="0"/>
                                <span>Applicants</span>
                            </div>
                        </div>
                        <div class="job-shortlisted jl-c eq-second-height">
                            <div class="ja-icon"><img src="images/circle.png" /></div>
                            <div class="ja-count">
                                2/5
                                <span>shortlisted</span>
                            </div>
                        </div>
                        <div class="job-states jl-c">
                            <%
                                String  jobStatusKey    =   WebUtils.getInputKey(request, job, Job.FIELD_JobStatus);
                            %>
                            <select  onChange="updateJobStatus()" class="form-control status-img">
                                <option data-image="images/active.png">Active</option>
                                <option data-image="images/complete.png" value="<%= JobStatus.COMPLETE %>">Completed</option>
                            </select>
                        </div>
                        <script language="Javascript">
                            function updateJobStatus() {
                                $('#changeJobStatusBtn').click();
                            }
                        </script>

                        <oneit:button   name="changeJobStatus" cssClass="hide" value="Change Job Status"    id="changeJobStatusBtn"
                                                            requestAttribs='<%= CollectionUtils.mapEntry("nextPage", homePage).toMap() %>' />

                    </div>
            <%
                }
            %>
            </div>
        </div> 
    </oneit:form>
</oneit:dynIncluded>