<%@ 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="inc/stdimports.jsp" %>

<oneit:dynIncluded>
<%
    ObjectTransaction   objTran             = (process == null ? ObjectTransaction.getTransaction () : process.getTransaction ());

    Job job = (Job) process.getAttribute("Job");
    String  assessmentCriteriaPage      = WebUtils.getSamePageInRenderMode(request, "AssessmentCriteria");
    Article             bookingArticle      = WebUtils.getArticleByShortCut(objTran, "CreateJob");
    String              nextPage            = bookingArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "AssessmentCriteria").toMap());
    if(job == null)
    {
        job = Job.createJob(objTran);

        process.setAttribute("Job", job);

        %><%@include file="/saferedirect.jsp" %><%
    }

    Level[] levels  =   Level.SearchByAll().search(objTran);
%>
        <oneit:form name="editJob" method="post"    enctype="multipart/form-data">
    <div class="container-fluid">
            <%
                oneit.servlets.jsp.FormInformation     fi = oneit.servlets.jsp.FormJSP.getFormInformation (request);

                if (fi != null && fi.hasErrors ())
                {
            %>
                    <div class="alert alert-danger">
                        <oneit:multifieldtext prefixTextName="pageHeader_errorPrefix" suffixTextName="pageHeader_errorSuffix" fieldTextName="pageHeader_errorText" deriveAllFields="true"/>
                    </div>
            <%
                }
            %>
            
        <div class="row content">  
            <div class="main-content-area">
                <div class="">
                    <h1 class="page-title">Create a job <span class="active-time">(Active for 30 days)</span> </h1>
                    <div class="main-tab-form">
                        <ul class="nav nav-pills nav-justified">
                            <li class="active"><a href="#"><span>1</span>Job Detail</a></li>
                            <li class="complate"><a href="#"><span><img src="images/right-mark.png" /></span>Assessment Criteria</a></li>
                            <li><a href="#"><span>3</span>Workplace Culture</a></li>
                            <li><a href="#"><span>4</span>Job Match Assessment</a></li>
                            <li><a href="#"><span>5</span>Review and Submit</a></li>
                        </ul>
                    </div>
                    <div class="form-page-area">
                        <div class="create-job">
                            <div class="form-group">
                                <select class="form-control">
                                    <option>Optional: Use a previously created Job as a template</option>
                                    <option>One 1</option>
                                    <option>One 2</option>
                                    <option>One 3</option>
                                </select>              
                            </div>
                            <div class="form-group">
                                <label>Job Title</label>
                                <oneit:ormInput obj="<%= job %>"    type="text" attributeName="JobTitle"    cssClass="form-control" />                                
                            </div>
                            <div class="form-group">
                                <label>Job Description</label>
                                <oneit:ormtextarea    obj="<%= job %>"  attributeName="JobDescription"  cssClass="form-control textarea-box"/>
                            </div>
                            <div class="form-group">
                                <label>Job Type</label>
                            <%
                                FormTag     jobForm     = FormTag.getActiveFormTag(request);
                                FormBuilder formBuilder = jobForm.getFormBuilder();
                                String      optionKey   = WebUtils.getRadioSingleAssocKey(request, job, Job.SINGLEREFERENCE_Level);
                                String      formValue   = formBuilder.fieldValue (optionKey, job.getLevel() == null ? "" : job.getLevel().getID().toString());
                                int         index       = 0;

                                for (Level level : levels)
                                {
                                    String  id          = String.valueOf(level.getID().longID());
                                    String  selectedStr = (CollectionUtils.equals(id, formValue) ? "checked" : "");
                            %>
                                    <div class="<%= index == 0 ? "main-job-type" : "" %>">

                                        <div class="radio radio-primary job-detail-radio">
                                            <input type="radio" name="<%= optionKey %>" id="<%= id %>"  <%= selectedStr %>  value="<%= id %>">
                                            <label for="<%= id %>">
                                                <oneit:toString value="<%= level.getLevelDescription() %>"  mode="EscapeHTML" /> <br />
                                                <span class="sub-radio-title">
                                                    <oneit:toString value="<%= level.getLevelNotes() %>"    mode="EscapeHTML" />
                                                </span>
                                            </label>
                                        </div>
                                    </div>
                            <%
                                    index++;
                                }
                            %>
                            </div>
                            <div class="form-brack-line"></div>
                            <div class="">
                                <div class="optional-title">OPTIONAL</div>
                                <div class="row">
                                    <div class="col-sm-6 col-xs-12 form-group">
                                        <label>Client</label>
                                        <select class="form-control">
                                            <option>Please Select or Add New</option>
                                            <option>One 1</option>
                                            <option>One 2</option>
                                            <option>One 3</option>
                                        </select> 
                                    </div>              
                                    <div class="col-sm-6 col-xs-12 form-group">
                                        <label>Reference Number</label>
                                        <input type="text" class="form-control" />
                                    </div>         
                                </div>     
                            </div>
                            <div class="text-center">
                                <oneit:button   value="Proceed to Assessment Criteria"  name="gotoPage" cssClass="btn btn-primary" 
                                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", WebUtils.getSamePageInRenderMode(request, "AssessmentCriteria"))
                                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap()).toMap() %>"/>
                            </div>

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