<%@ 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>
<%
    String          hiringTeamList  =   WebUtils.getSamePageInRenderMode(request, "Page");
    String          nextPage        =   WebUtils.getSamePageInRenderMode(request, "ManagePlan");
    SecUser         loggedInUser    =   SecUser.getTXUser(transaction);
    CompanyUser     companyUser     =   loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
    Company         company         =   companyUser.getCompany();
    HiringTeam      hiringTeam      =   (HiringTeam) process.getAttribute("HiringTeam");

    Debug.assertion(company != null , "Invalid company in admin portal my company");
    
    Debug.assertion(hiringTeam != null , "Invalid Hiring Team in admin portal manage plan");
    
    HiringTeam      billingTeam     =   hiringTeam.getManageOwnBilling() ? hiringTeam : hiringTeam.getBillingTeam();  
    PaymentPlan[]   plans           =   Utils.getPaymentPlansForJobs(transaction);
    Integer         maxCount        =   0;
    Integer         minCount        =   0;
    PaymentPlan[]     paymentPlans     =   PaymentPlan.SearchByAll().andDisabled(new EqualsFilter<>(Boolean.FALSE)).andActiveJobCount(new EqualsFilter<>(10)).search(transaction);
    if(company.getPaymentPlan() != null && company.getPaymentJobCount() == null)
    {
        company.setPaymentJobCount(company.getPaymentPlan().getActiveJobCount());
    }
    PaymentPlan paymentPlan =   PaymentPlan.getPaymentPlanByID(transaction, (long)38021473);
    if(plans.length > 0)
    {
        Collection<Integer> jCounts =   PaymentPlan.pipesPaymentPlan(plans).toActiveJobCount().vals();
        maxCount                    =   Collections.max(jCounts);
        minCount                    =   Collections.min(jCounts);
    }

%>
    <script type="text/javascript">
        var Popup = null;
        $(document).ready(function()
        {
            recalcFunction = setupRecalc ($("form#editCompany"), {'recalcOnError':true});
       
          Popup = new jBox('Modal', {
                id : "change-plan",
                overlay : true, 
                width : 600, height : 640
                });
                          
           $(".select-btn").on("click",function(){             
               Popup.setContent($("#" + $(this).data('popupid')  ));
               Popup.open();
               
           });               
        });                                                
    </script> 
    
    <div class="container-fluid">
        <div class="row content">
            <div class="main-content-area">
                <oneit:form name="editCompany"  method="post"    enctype="multipart/form-data">
                    
                    <h1 class="page-title page-title-with-arrow">
                        <oneit:button cssClass="arrow-btn-blue"  name="gotoPage" value=" " skin="link"
                                    requestAttribs="<%= CollectionUtils.mapEntry("nextPage", hiringTeamList).toMap() %>" >
                        <img src="images/arrow-left-prev_blue.svg" />
                    </oneit:button>
                        <%= hiringTeam.getHiringTeamName() %>
                    </h1>
                    <div class="my-company-area">
                        
                        <div style="padding-left: 15px; padding-right: 15px;">
                            <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
                        </div>

                        <oneit:dynInclude   page="/extensions/adminportal/inc/my_company_tabs.jsp"    TabNumber="2"    data="<%= CollectionUtils.EMPTY_MAP%>"/>

                        <div class="company-content-area">
                            <!-- Tab panes -->
                            <div class="tab-content">
                                <div class="tab-pane active" id="company-detail">
                                    <div>  
                                        <div class="tabpage-title manage-plan">
                                            <label class="label-20">Manage Plan</label>                
                                        </div>
                                        <div class="apply-coupon">
                                            <oneit:ormInput obj="<%= hiringTeam %>"    type="text" attributeName="CouponCode"   placeholder="Coupon Code"  cssClass="form-control" />      
                                            <oneit:button   value="APPLY"     name="applyCoupon"    cssClass="btn btn-input-inside"
                                                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                            .mapEntry("HiringTeam", hiringTeam)
                                                                                                            .toMap() %>" />
                                        </div>
                                    </div>
                                    <div class="coupon-applied-alert">
                                        coupon applied 
                                        <span class="coupon_code">
                                        <oneit:toString value="ABCD123" mode="EscapeHTML"/> - save
                                        <oneit:toString value="10%" mode="EscapeHTML"/>
                                        </span>
                                        <span class="expire">
                                        Expires
                                        <oneit:toString value="18 Sep 2018" mode="EscapeHTML"/>
                                        </span>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-12 oneit-radio coupon-applied">
                                            <div class="rectangle-5">
                                                <div class="manage-plan-row">
                                                    <div class="radio">
                                                        <label>
                                                        <oneit:ormInput obj="<%= hiringTeam %>" type="radio" attributeName="IsPPJ" value="true"/>
                                                        </label>
                                                     </div>
                                                    <div class="manage-plan-title">
                                                        <h3>Pay Per Job</h3>                                                        
                                                        <span>
                                                            You'll be charged each time you add a new job
                                                        </span>
                                                    </div>
                                                    <div class="manage-plan-payplan">
                                                        <div class="per-job-amount">
                                                        <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/>/ Job
                                                        </div>
                                                        <div class="per-job-amount-past">
                                                        was <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/> per job
                                                        </div>
                                                    </div>
                                                    <div class="clearboth"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-12 oneit-radio coupon-applied">                                             
                                            <div class="rectangle-5">
                                                <div class="manage-plan-row">
                                                    <div class="radio">
                                                        <label>
                                                            <oneit:ormInput obj="<%= hiringTeam %>" type="radio" attributeName="IsPPJ" value="false"/>
                                                        </label>
                                                    </div>
                                                    <div class="manage-plan-title">
                                                        <h3>Subscribe & Save</h3>                                                        
                                                        <span>
                                                            Intend to post multiple jobs this month?<br>
                                                            Find a plan to suit your hiring needs, and save today.
                                                        </span>
                                                    </div>
                                                    <div class="manage-plan-payplan">
                                                        <div class="per-job-amount">
                                                        </div>
                                                        <div class="per-job-amount-past">
                                                        </div>
                                                    </div>
                                                    <div class="clearboth"></div>
                                                </div>
                                                <div class="manage-plan-hidden-info">   
                                                    <div class="subscription-billed">
                                                        <img src="images/icon-calendar.png"> Your subscription is billed and resets on the   <oneit:toString value="12th" mode="EscapeHTML"/> of every month
                                                    </div>
                                                    <div class="choose-plan-row">    
                                                        <div class="choose-your-plan-title">
                                                            Choose Your Plan
                                                        </div>
                                                        <div class="choose-plan-headings">  
                                                            <div class="jobs-per-month">Jobe Per Month</div>
                                                            <div class="cost-per-job">Cost Per Job</div>
                                                            <div class="monthly-fee">Monthly Fee</div>
                                                        </div>
                                                        <div class="choose-plan-item ">
                                                            <div class="jobs">
                                                                10 Jobs 
                                                            </div>
                                                            <div class="cost">
                                                                <oneit:toString value="<%= 243.00 %>" mode="Currency"/>
                                                                <span class="past-val">
                                                                was <oneit:toString value="<%= 270.00 %>" mode="Currency"/>
                                                                </span>
                                                            </div>
                                                            <div class="fee">
                                                                <oneit:toString value="<%= 2430.00 %>" mode="Currency"/><span class="month"> / month </span>
                                                                <span class="past-val">
                                                                was <oneit:toString value="<%= 2700.00 %>" mode="Currency"/>
                                                                </span>
                                                            </div>
                                                            <div class="select-button">
                                                                <oneit:button   value="Active"     name="saveCompany"      cssClass="btn active-btn"
                                                                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                                    .toMap() %>" />

                                                                <a href="#" class="btn select-btn" data-popupid ="change-plan-popup01" >Select</a>
                                                            </div>
                                                                                                                    
                                                             <div id="change-plan-popup01" style="display:none" >
                                                                    <div class="change-plan-content">
                                                                        <h3>
                                                                            Upgrade to 20 Jobs per month?
                                                                        </h3>
                                                                        <div class="upgrade-info">
                                                                            Upgrading your plan to 20 jobs per month will incur an additional cost of $2,000 be billed immediately. 
                                                                            <span>
                                                                            This cose is to cover the differnce between your current active 10 job plan ($2,700) and the new 20 job plan ($4,700).
                                                                            </span>
                                                                        </div>
                                                                        <div class="change-plan-list">
                                                                            <div class="list-item">
                                                                                <span class="item-title">Jobs remaining this month</span>
                                                                                <span class="item-value">10 Job Remaining</span>
                                                                            </div>
                                                                            <div class="list-item">
                                                                                <span class="item-title">Date your plan will reset</span>
                                                                                <span class="item-value">12 September, 2018</span>
                                                                            </div>
                                                                            <div class="list-item">
                                                                                <span class="item-title">Date of next billing period</span>
                                                                                <span class="item-value">$4,700 on 12 September, 2018</span>
                                                                            </div>
                                                                        </div>
                                                                         <div class="upgrade-info">

                                                                            <span>
                                                                            Would you like to proceed with upgrading your account?
                                                                            </span>
                                                                        </div>


                                                                    </div>
                                                                    <div class="change-plan-button">
                                                                            <a class="change-plan-no-button">No</a>
                                                                     <oneit:button  skin="link" value="Yes"     name="saveCompany"      cssClass="change-plan-yes-button"
                                                                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                                    .toMap() %>" />
                                                                         
                                                                        </div>
                                                               </div>                                                       
                                                                                                                    
                                                        </div>
                                                        <div class="choose-plan-item active">
                                                            <div class="jobs">
                                                               10 Jobs 
                                                            </div>
                                                            <div class="cost">
                                                               <oneit:toString value="<%= 243.00 %>" mode="Currency"/>
                                                               <span class="past-val">
                                                               was <oneit:toString value="<%= 270.00 %>" mode="Currency"/>
                                                               </span>
                                                            </div>
                                                            <div class="fee">
                                                                <oneit:toString value="<%= 2430.00 %>" mode="Currency"/><span class="month"> / month </span>
                                                                <span class="past-val">
                                                                was <oneit:toString value="<%= 2700.00 %>" mode="Currency"/>
                                                                </span>
                                                            </div>
                                                            <div class="select-button">
                                                                <oneit:button   value="Active"     name="saveCompany1"      cssClass="btn active-btn"
                                                                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                                    .toMap() %>" />

                                                                <oneit:button   value="Select"     name="saveCompany"      cssClass="btn select-btn"
                                                                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                                    .toMap() %>" />
                                                            </div>
                                                        </div>
                                                        <div class="additional-jobs-over">
                                                            <span class="blue-alert">
                                                                Additional jobs over plan allowance are billed at the Cost Per Job for the subscription level
                                                            </span>
                                                            <span>
                                                                Would you like to set a maximum limit on the total jobs able to be posted
                                                            </span>
                                                        </div>
                                                        <div class="set-a-cap-option">
                                                            <div >
                                                                <span> No, leave it open</span>
                                                                <label class="switch">
                                                                    <oneit:recalcClass  htmlTag="span"  classScript="hiringTeam.isTrue(hiringTeam.getHasCap()) ? 'checkbox checked': 'checkbox unchecked'"    hiringTeam="<%= hiringTeam %>">
                                                                        <oneit:ormInput obj="<%= hiringTeam %>"    attributeName="HasCap"   type="checkbox"/>
                                                                    </oneit:recalcClass>
                                                                    <div class="slider round"></div>
                                                                </label>
                                                                <span>yes, set a cap</span>
                                                            </div>
                                                        </div>
                                                        <div class="setmax">
                                                            <div>
                                                                <oneit:ormInput obj="<%= hiringTeam %>"    type="text" attributeName="MaxCap"    cssClass="form-control" />      

                                                                <oneit:button   value="Set Max"     name="saveCompany"      cssClass="btn btn-primary"
                                                                                requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                                    .toMap() %>" />
                                                            </div>
                                                        </div>

                                                        <div class="form-group row">
                                                            <oneit:button   value="Update Subscription" name="saveCompany"      cssClass="btn btn-primary largeBtn btn-green save-btn" style="display:inline;"
                                                                            requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                                                            .mapEntry ("restartProcess", Boolean.TRUE)
                                                                                                            .mapEntry ("Company", company)
                                                                                                            .mapEntry ("IsPayment", Boolean.TRUE)
                                                                                                            .mapEntry ("PaymentPlan", paymentPlan)
                                                                                                            .mapEntry ("attribNamesToRestore", Collections.singleton("HiringTeam"))
                                                                                                            .toMap() %>" />
                                                        </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    <div class="text-center footer-note">
                                        Looking to cancel your account? Please <a href="http://www.talentology.com/">contact us.</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </oneit:form>
            </div>
        </div>
    </div>
                                                        
    
     
      
                                                         
</oneit:dynIncluded>
