
<%@ 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.net.LoopbackHTTP"%>

<oneit:dynIncluded>
<%
    boolean toRedirect  =   GenericObjDF.getOrCreateObject (request, "Job", Job.REFERENCE_Job);
    Job     job         =   (Job) process.getAttribute("Job");

    Debug.assertion(job != null, "Job is null in admin portal create job");

    String  url         =   job.getShortenedUrlLink();
    boolean fromJob     =   request.getParameter("fromJob") != null ? Boolean.parseBoolean(request.getParameter("fromJob")) : false;
    String  nextPage    =   WebUtils.getSamePageInRenderMode(request, (fromJob ? "Page" : WebUtils.VIEW_APPLICANTS));

    String  advtEmail   =   "job"+job.getID().longID()+"@"+ Utils.ADVT_CONFIG_EMAIL_EXTENSION;

    HiringTeam  hiringTeam  =   job.getHiringTeam();
    HiringTeam  billingTeam =   hiringTeam.getManageOwnBilling() ? hiringTeam : hiringTeam.getBilledByTeam();
%>
    <script>
        function copyToClipboard(which,ele) {
            
            var aux = document.createElement("textarea");
            aux.value = $(ele).text().trim();
            document.body.appendChild(aux);
            aux.select();
            document.execCommand("copy");
            document.body.removeChild(aux);
            alert(which + " copied to clipboard");
        }
        
        
        
        function copyHTMLToClip(ele) {
            str =  $(ele).html().trim();          
            str = str.replace(/<span class="calcField">/g, '');
            str = str.replace(/<\/span>/g, '');
            str = str.replace(/<p><\/p>/g, '');
           
            function listener(e) {
              e.clipboardData.setData("text/html", str);
              e.clipboardData.setData("text/plain", str);
              e.preventDefault();
            }
            document.addEventListener("copy", listener);
            document.execCommand("copy");
            document.removeEventListener("copy", listener);
              alert("Text copied to clipboard");
          };
    </script>
    <oneit:form name="editJob" method="post"    enctype="multipart/form-data">
        
        <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
        
        <div class="main-created-job">
            <h1 class="page-title created-job-title">
                <%
                    if(fromJob)
                    {
                %>
                        Congratulations! Your job is now open
                <%
                    }
                %>
                <a href="<%= url %>" id="jobURL" style="display:none;">
                    <%= url %>
                </a>
            </h1>
            <div class="form-page-area no-float auto-width">
                <div class="job-share-icon">
                    <ul>
                        <li class="share-link" onclick="copyToClipboard('Link', '#jobURL' )">
                            <a class="linked-col" href="#">                               
                                <div><%= url %></div>
                                <span class="copy-link">(Copy link to clipboard)</span>
                            </a>
                        </li>
<!--                        <li class="share-btn"><a href="#">Share</a></li>
                        <li class="linkdin-icon"><a href="#"><img src="images/linkedin-icon.png" /></a></li>
                        <li class="facebook-icon"><a href="#"><img src="images/facebook-icon.png"/></a></li>
                        <li class="shape-icon"><a href="#"><img src="images/shape.png" /></a></li>
                        <li class="more-icon"><a href="#"><img src="images/more-icon.png" /></a></li>-->
                    </ul>
                </div>
                <p class="job-txt">
                    This job will be open for 30 days until&nbsp;<oneit:toString value="<%= job.getApplyBy() %>" mode="PerformaDate"/>.
                </p>
                <div class="text-center">
                    <oneit:button   value="<%= "Go to Job" + (fromJob ? "s" : "")%>"  name="gotoPage" cssClass="btn btn-primary largeBtn"
                                    requestAttribs='<%= CollectionUtils.mapEntry("nextPage", nextPage).toMap() %>'/>
                </div>
                <%
                    if(!billingTeam.isTrue(hiringTeam.getIsPPJ()))
                    {
                        Integer activeCount =   billingTeam.getUsedCredits();
                        Integer totCount    =   billingTeam.getAvailableCredits();
                        Integer remCount    =   totCount - activeCount > 0 ?  totCount - activeCount : 0;
                %>
                        <div class="space-55">You have <%= remCount %> jobs remaining for this month.</div>
                <%
                    }
                %>
                
            </div>
            <div class="job-desc-box">
                <%--<div class="form-group row">
                    <span class="col-md-12" style="font-size: 20px;font-weight: 300;color: #1A2531;">Advertisement Configuration Email
                    <a class="copy-to-clipboard" onclick="copyHTMLToClip('.advtEmail')" style="margin-top: 10px;padding-top: 5px;margin-right: 10px;">
                        COPY TO CLIPBOARD
                    </a></span><br/>
                    <span class="col-md-12 form-control advtEmail" ><%= advtEmail %></span>
                </div> --%>
                <div class="sample-job-advertise">
                    <span>
                        Advertisement Configuration Email
                    </span>
                        <a class="copy-to-clipboard" onclick="copyHTMLToClip('.advtEmail')">
                        COPY TO CLIPBOARD
                    </a>
                </div>
                <div style="margin-top:10px ">
                    <span class="form-control advtEmail" style="padding:15px"><%= advtEmail %></span>
                </div>
                <div class="sample-job-advertise" style="margin-top:40px">
                    <span>
                        Sample job advertisement text
                    </span>
                        <a class="copy-to-clipboard" onclick="copyHTMLToClip('.details-box')">
                        COPY TO CLIPBOARD
                    </a>
                </div>
                <div class="details-box">
                    <p><oneit:toString value="<%= job.getJobDescription() %>"  mode="ParagraphHTML" /></p>

                    <b>Organisation Culture Statement</b>    
                    <p><oneit:toString value="<%= job.getCultureStatement() %>"  mode="ParagraphHTML" /></p>

                    <b>Requirements</b>    
                    <ul>
                    <%
                        for (AssessmentCriteria criteria : job.getAssessmentCriteriasSet())
                        {
                    %>
                            <li><oneit:toString value="<%= criteria.getName() %>" mode="EscapeHTML"/></li>
                    <%
                        }
                    %>
                    </ul>

                </div>
            </div>
        </div>
        <style>
            .job-share-icon li a.linked-col {line-height: 20px;}
        </style>
    </oneit:form>
 </oneit:dynIncluded>
