<%@ 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" %>
<%@ page import="oneit.utils.text.FormatUtils"%>

<%
    Job             job         =   (Job) process.getAttribute("Job");
    String          currentPage =   (String) getData(request, "currentPage");
    AppSortOption   appSortOpt  =   (AppSortOption) getData(request, "sortOption");
    String          tabNumber   =   (String)  getData(request, "tabNumber");
    Boolean         isShortList =   getData(request, "isShortList")!= null ? (Boolean)  getData(request, "isShortList") : Boolean.FALSE;    
    Boolean         showOrderBy =   getData(request, "showOrderBy")!= null ? (Boolean)  getData(request, "showOrderBy") : Boolean.FALSE;
%>

<oneit:dynIncluded>
    <script type="text/javascript">
        $(document).ready(function() 
        {            
            $(".bullk-app-process").change(function()
            {
                $('.bulk-update').click();
            });
            
            enableBulkEdit();
             
            $(".applicant").change(function() {
                enableBulkEdit();
            });
            
            $('#AppProcessOption option:selected').removeAttr('selected');
            $('#AppProcessOption option:nth-child(1)').attr('selected','selected');
            $('#select2-AppProcessOption-container').empty();
            $('#select2-AppProcessOption-container').data("title", $('#select2-AppProcessOption-container').attr("title")).removeAttr("title");
        });
        
        function enableBulkEdit() {
            $(".bullk-app-process").prop("disabled",$('input[class=applicant]:checked').length===0);
        }
    </script>
    <div class="main-applicants-filter">
        <div class="appli-list-shorting">
            <div class="appli-shorting-dropdown appli-left">
                <span class="appli-order-label">Bulk Update</span>
                <oneit:ormEnum  obj="<%= job %>"    attributeName="AppProcessOption"    cssClass="form-control bullk-app-process"   id="AppProcessOption"
                                enums="<%= job.getValidProcessOptions(isShortList) %>"/>
                
                <oneit:button   name="bulkupdate"   value=" "   cssClass="bulk-update"  skin="link"
                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
                                                                    .mapEntry ("restartProcess", Boolean.TRUE)
                                                                    .mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
                                                                    .mapEntry("Job", job)
                                                                    .toMap() %>" />
            </div> 
            <%
                if(tabNumber != null)
                {
                    String  firstTab    =   WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICANTS);
                    String  secondTab   =   WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICANTS_GRID);
                    
                    if(isShortList)
                    {
                        firstTab    =   WebUtils.getSamePageInRenderMode(request, WebUtils.APPLICANTS_SHORTLIST);
                        secondTab   =   WebUtils.getSamePageInRenderMode(request, WebUtils.APPLICANTS_GRID);
                    }
            %>
                    <div class="appli-filter">
                        <ul class="">
                            <li class="lable-appli-shorting">View</li>
                            <li class="<%= (tabNumber == "1" ? "active" : "" ) + " short-list"%>">
                                    <oneit:button   value="List"   name="gotoPage" skin="link"
                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", firstTab)
                                                                    .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                    .toMap() %>"/>
                            </li>
                            <li class="<%= (tabNumber == "2" ? "active" : "" ) + " grid-list"%>">
                                    <oneit:button   value="Grid"   name="gotoPage" skin="link"
                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", secondTab)
                                                                    .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                    .toMap() %>"/>
                            </li>
                        </ul>
                    </div>
                    <%--
                        <div class="appli-shorting-dropdown">
                            <span class="appli-order-label">Export</span>
                            <select class="form-control">
                                <option>PDF</option>
                                <option>CSV</option>
                            </select>
                        </div>
                    --%>
            <%
                }

                if(showOrderBy)
                {
            %>
                    <div class="appli-shorting-dropdown">
                        <span class="appli-order-label">order by</span>
                        <select class="form-control"    onChange="location=this.value">
                        <%
                            for (AppSortOption  sortOption : AppSortOption.getAppSortOptionArray())
                            {
                                String  optionLink  =   currentPage + "&JobID=" + job.getID() + "&AppSortOption=" + sortOption.getName();
                        %>
                                <option <%= (appSortOpt != null && appSortOpt == sortOption ? "selected" : "" )%>  value="<%= optionLink %>">
                                    <oneit:toString value="<%= sortOption.getDescription() %>"   mode="EscapeHTML"/>
                                </option>
                        <%
                            }
                        %>
                        </select>
                    </div>
            <%
                }
            %>
        </div>
    </div>
        
</oneit:dynIncluded>
