@extends(decide_template())

@section('title', $page_data['title'])

@section('page_styles')
<link href="/resources/assets/css/profile.css?v={{$local_version}}" rel="stylesheet" type="text/css">
<style>
    .admin_filter .lshapeBlk {
        padding-top: 30px;
    }
    .pt0 {
        padding-top: 0;
    }
    .kt-portlet .kt-portlet__foot {
        margin-top: 35px;
    }
    .days-block {
        margin-top: -13px;
    }
    .days-block span.select2-selection {
        height: 34px;
    }
    .days-block span.select2-selection .select2-selection__rendered {
        padding: 6px 15px;
    }
    #day1, #day2 {
        display:none
    }
    .delete-child22 {
        display: none;
    }
    .delete-child22 .child-block {
        padding-left: 35px;
    }
    .delete-child22 .child-block .lshBlksl {
        margin: 0;
    }
    .delete-child22 .child-block .lshapeBlk {
        padding-top: 7px;
    }
    .days-block .lshapeBlk {
        padding-top: 8px !important;
    }
</style>
@endsection

@section(decide_content())

<!-- END PAGE HEADER-->
@if($errors->any())
<!-- For PHP validations errors-->
<div class="alert alert-danger" data-name="aXaeRRAF">
    @foreach($errors->all() as $error)
    <p>{{ $error }}</p>
    @endforeach
</div>
@endif
<!-- will be used to show any messages -->
@if (Session::has('msg'))
<div class="alert alert-success" data-name="fYbTqLqs">
    {{ Session::get('msg') }}
</div>

@endif
@if (Session::has('error'))
<div class="alert alert-danger" data-name="hmZHvQIt">
    <p>{{ Session::get('error') }}</p>
</div>
@endif
<!-- will be used to show any messages about form -->
<div id="msg" class="display-hide" data-name="vqhKEXdr">
    <span id='msg-text'><span>
</div>
<?php
$setting = new \stdClass();
?>

<!-- BEGIN FORM-->
<div class="col-md-12 p-0 profile-setup" data-name="XsoOeiyX">
    <div class="row" data-name="BapuoDZD">
        <div class="col-md-2">
            <div class="kt-portlet card card-flush submenu">
                <div class="card-header pt-7" id="kt_chat_contacts_header">
                    <!--begin::Card title-->
                    <div class="card-title">
                        <b class="mb0">{{ trans('user_management.setting.sidebat.widget_heading') }}</b>
                    </div>
                    <!--end::Card title-->
                </div>
                <div class="card-body pt-5 ">
                @include('user.user-sidebar')
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="kt-portlet kt-portlet--height-fluid" data-name="prkSruuU">
                <!-- <div class="kt-portlet__head" data-name="iHmRjKxJ">
                    <div class="kt-portlet__head-label" data-name="uHosdKpH">
                        <h3 class="kt-portlet__head-title">
                            {{ trans('User Settings') }}
                        </h3>
                    </div>
                </div> -->
                <div class="kt-portlet__body" data-name="VdCSpNWV">
                    <div class="tabbable tabbable-tabdrop" data-name="YcCSXTyE">
                        <ul class="nav nav-tabs" role="tablist">
                            <li class="nav-item">
                                <a href="#tab1" class="nav-link active" data-toggle="tab">
                                    {{ trans('user_management.setting.form_heading') }}
                                </a>
                            </li>
							@if (hook_exist('AutomationUserSettingsTab'))
                            <?php $vars1 = array(
                                ); ?>
                                {!! hook_get_output('AutomationUserSettingsTab',$vars1) !!}
                            @endif
                        </ul>
                        <div class="tab-content" data-name="VotfZrsj">
                            <div class="tab-pane active AsXQAAOwn" id="tab1" data-name="PgJqlMMM">
                            <div class="col-md-12" data-name="DhzxMJfK">
                                    <form action="{{ route('user.settings',  $user->id) }}" method="POST" id="profile-frm1" class="kt-form kt-form--label-right" autocomplete="off" autocomplete="off">
                                        <input type="hidden"  id="action" value="profile">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <input type="hidden" id="user-id" value="{{$user->id}}">
                                        <input type="hidden" name="_method" value="PUT">

                                        <div class="form-body" data-name="gKHGwhht">
                                                <div class="form-group" data-name="AiHTiXge">
                                                    <h3 class="mini_heading mt0">{{trans('user_management.setting.form.label.auto_resume_settings')}}</h3>
                                                    <hr>
                                                </div>
                                                <div class="form-group row delete-child2" data-name="fJObSmGY">
                                                    <div class="col-md-5 label-block" data-name="dAtunjW5">
                                                        <label class="col-form-label label-link">{{ trans('user_management.setting.form.label.title') }}
                                                            {!! popover('user_management.setting.form.label.title_description','common.description') !!}
                                                        </label>
                                                    </div>
                                                    <div class="col-md-1" data-name="dAtunjWz">
                                                        <span class="kt-switch kt-switch--outline kt-switch--icon kt-switch--success">
                                                            <label>
                                                                <input type="checkbox" autocomplete="off" id="logs1" name="enable_child" <?php if($check_limits['resume_daily']=='1'||$check_limits['resume_monthly']=='1'|| $check_limits['resume_credits']=='1') { ?> checked <?php } ?> >
                                                                <span></span>
                                                            </label>
                                                        </span>
                                                    </div>
                                                    
                                                </div>  

                                                
                                                <div class="delete-child">
                                                    <div class="form-group row" data-name="fJObSmGY">
                                                        <div class="child-block col-md-5 label-block">
                                                            <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                            <div class="lshBlksl" data-name="MQacFCdo">
                                                                <label class="col-form-label label-link">{{ trans('user_management.setting.form.label.auto_resume_daily') }}
                                                                    {!! popover('user_management.setting.modal_heading.daily_limit_description','common.description') !!}
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-1">
                                                            <span class="kt-switch kt-switch--outline kt-switch--icon kt-switch--success">
                                                                <label>
                                                                    <input type="checkbox" autocomplete="off" class="ev-switch" id="logs2" name="daily_resume" <?php if($check_limits['resume_daily']=='1') { ?> checked <?php } ?> onchange="getEvergreen()">
                                                                        <span></span>
                                                                </label>
                                                            </span>
                                                        </div>
                                                        
                                                    </div>
                                                </div>

                                               
                                                        
                                                <div class="delete-child">
                                                    <div class="form-group row" data-name="fJObSmGY">
                                                        <div class="child-block col-md-5 label-block">
                                                            <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                            <div class="lshBlksl" data-name="MQacFCdo">
                                                                <label class="col-form-label label-link">{{ trans('user_management.setting.form.label.auto_resume_monthly') }}
                                                                    {!! popover('user_management.setting.modal_heading.monthly_limit_description','common.description') !!}
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-1">
                                                            <span class="kt-switch kt-switch--outline kt-switch--icon kt-switch--success">
                                                                <label>
                                                                    <input type="checkbox" autocomplete="off" class="ev-switch day-switch" id="logs3" name="monthly_resume" <?php if($check_limits['resume_monthly']=='1') { ?> checked <?php } ?> onchange="getEvergreen()">
                                                                        <span></span>
                                                                </label>
                                                            </span>
                                                        </div>
                                                       
                                                    </div>
                                                   
                                                </div>
                                                

                                                @if(isCommercialLicense("Commercial ESP"))
                                                    <div class="delete-child">
                                                    <div class="form-group row" data-name="fJObSmGY">
                                                        <div class="child-block col-md-5 label-block">
                                                            <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                            <div class="lshBlksl" data-name="MQacFCdo">
                                                                <label class="col-form-label label-link">{{ trans('user_management.setting.form.label.auto_resume_credits') }}
                                                                {!! popover('user_management.setting.modal_heading.auto_resume_credits_description','common.description') !!}
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-1">
                                                            <span class="kt-switch kt-switch--outline kt-switch--icon kt-switch--success">
                                                                <label>
                                                                    <input type="checkbox" autocomplete="off" class="ev-switch day-switch" id="logs4" name="credit_resume" <?php if($check_limits['resume_credits']=='1') { ?> checked <?php } ?> onchange="getEvergreen()">
                                                                        <span></span>
                                                                </label>
                                                            </span>
                                                        </div>
                                                        
                                                    </div>
                                                   
                                                </div>
                                                @endif
                                                
                                                <div class="delete-child22 evergreen-block">
                                                    <div class="form-group row" data-name="fJObSmGY">
                                                        <div class="child-block col-md-5 label-block">
                                                            <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                            <div class="lshBlksl" data-name="MQacFCdo">
                                                                <label class="col-form-label label-link">{{ trans('user_management.setting.label.evergreen_campaign') }}
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-1 mb1">
                                                            <span class="kt-switch kt-switch--outline kt-switch--icon kt-switch--success">
                                                                <label>
                                                                    <input type="checkbox" autocomplete="off" name="resume-evergreen" id="resume-evergreen" <?php if($check_limits['evergreen_resume']=='1') { ?> checked <?php } ?>>
                                                                        <span></span>
                                                                </label>
                                                            </span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="delete-child22 days-block">
                                                    <div class="form-group row" data-name="fJObSmGY">
                                                        <div class="child-block col-md-5 label-block">
                                                            <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                            <div class="lshBlksl" data-name="MQacFCdo">
                                                                <label class="col-form-label label-link">{{ trans('user_management.setting.label.days') }}
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                        <select class="form-control m-select2" name="resume_days">
                                                                   
                                                                   <option value="1" <?php echo ($check_limits['resume_time'] == '1') ? 'selected' : ''; ?>>1</option>
                                                                    <option value="2" <?php echo ($check_limits['resume_time'] == '2') ? 'selected' : ''; ?>>2</option>
                                                                    <option value="3" <?php echo ($check_limits['resume_time'] == '3') ? 'selected' : ''; ?>>3</option>
                                                                    <option value="4" <?php echo ($check_limits['resume_time'] == '4') ? 'selected' : ''; ?>>4</option>
                                                                    <option value="5" <?php echo ($check_limits['resume_time'] == '5') ? 'selected' : ''; ?>>5</option>
                                                                    <option value="6" <?php echo ($check_limits['resume_time'] == '6') ? 'selected' : ''; ?>>6</option>
                                                                    <option value="7" <?php echo ($check_limits['resume_time'] == '7') ? 'selected' : ''; ?>>7</option>
                                                                </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                    
                                                <!-- <div class="delete-child admin_filter" data-name="jWDSQEXc">
                                                    <div class="lshapeBlk" data-name="DryEbTIz"><i class="la la-level-down lshap"></i></div>
                                                    <div class="lshBlksl form-group row pt0">
                                                        <label class="col-form-label col-md-12 pt0">Cron Time  </label>
                                                        <div class="col-md-8" data-name="jEFadLqJ">
                                                            <select class="form-control m-select2" name="process_cron_time">
                                                                <?php //$bounce_process_cron = \App\Models\UserCronSetting::getCronTime("bounce_process_cron"); ?>
                                                                    @foreach ($time_3 as $time_value => $time_name) {
                                                                    <option value="{{$time_value}}" <?php //if($check_limits->resume_cron_time==$time_value) { ?> selected <?php //} ?> >{{ $time_name }}</option>
                                                                    }
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                        <div class="col-md-4" data-name="jEFadLqJ">
                                                            <button type="button" class="btn btn-warning btn-run" onclick="runcron('bounce:processing --force');"><i class="fa fa-angle-right"></i> Force Run </button>
                                                        </div>
                                                    </div>                                                   
                                                </div> -->
                                                

                                            
                                            
                                            
                                        </div>
                                        <div class="kt-portlet__foot" data-name="lXJrqRqh">
                                            <div class="form-actions" data-name="BvcNhBxO">
                                                <div class="row" data-name="DnbCtPmu">
                                                    <div class="col-md-12" data-name="lmeoVHTw">
                                                        <button type="submit" name="save_add" class="btn btn-success" value="save_add">
                                                            {{trans('common.form.button.save')}}
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            @if (hook_exist('AutomationUserSettings'))
                                <?php $vars = array(
                                    'paused_action'=>isset($paused_action) ? $paused_action:'',
                                    'after_action'=>isset($after_action) ? $after_action:'',
                                    'user_id'=>$user->id
                                ); ?>
                                {!! hook_get_output('AutomationUserSettings',$vars) !!}
                            @endif
                        </div>
						
                    </div>
                </div>
                <!-- END EXAMPLE TABLE PORTLET-->
            </div>
        </div>
    </div>



    <!-- END FORM-->
    @endsection

@section('page_scripts')
    <script src="/themes/default/js/jquery.form.min.js"
        type="text/javascript"></script>
    <script src="/themes/default/js/jquery.validate.js"
        type="text/javascript"></script>
    <script src="/themes/default/js/additional-methods.js"
        type="text/javascript"></script>
    <script src="/themes/default/js/init.js"
        type="text/javascript"></script>
    <script src="/themes/default/js/select2.full.min.js"
        type="text/javascript"></script>
    <script src="/themes/default/js/select2.js" type="text/javascript">
    </script>
    <script src="/themes/default/js/form-controls.js"
        type="text/javascript"></script>

    <script src="/themes/default/js/includes/intlTelInput.js" type="text/javascript"></script>
    <script src="/themes/default/js/includes/validate-form.js" type="text/javascript"></script>
    <script src="/themes/default/js/includes/profile.js" type="text/javascript"></script>
   
    <script type="text/javascript">
        function getEvergreen(){
            var daily0 = $('#logs2').is(":checked");
            var monthly0 = $('#logs3').is(":checked");
            var nocredit0 = $('#logs4').is(":checked");
            var montly,daily,no_credit;
           
            if (daily0) {
                daily='on';
            } else {
                daily='off';
            }
            if (monthly0) {
                monthly='on';
            } else {
                monthly='off';
            }
            if (nocredit0) {
                no_credit='on';
            } else {
                no_credit='off';
            }
           // alert('daily:'+daily);
            //alert('monthly:'+monthly);
            //alert('nocredit:'+no_credit);

            if( daily=='on' || monthly=='on' || no_credit=='on'){
                $(".evergreen-block").slideDown();
            }
            else {
                $(".evergreen-block").slideUp();
            }

            if( monthly=='on' || no_credit=='on'){
                $(".days-block").slideDown();
            }
            else {
                $(".days-block").slideUp();
            }







           // $monthly=document.getElementById('logs3').value;
            
        }
    $(document).ready(function () {
		  $("#nocontinue").click(function() {
            $("#limit-child").slideUp();
        });
        $("#continue").click(function() {
            $("#limit-child").slideDown();
        });
        <?php
         if($paused_action=='continue'){
            ?>
            $("#limit-child").slideDown();
            <?php
         }
         else {
            ?>
 $("#limit-child").slideUp();
            <?php
         }
        ?>
		
        var count = 0;
        var days = 0;
        $(".ev-switch").change(function() {
           
        });
        $(".day-switch").change(function() {
           
        });
        $("#logs2").change(function() {
            var checked = $(this).is(":checked");
            if(checked){
                //$(".evergreen-block").slideDown();
            } else {
                //$(".evergreen-block").slideUp();
            }
        });
        $("#logs3").change(function() {
            var checked = $(this).is(":checked");
            if(checked){
                $("#day1").show();
            } else {
                $("#day1").hide();
            }
        });
        $("#logs4").change(function() {
            var checked = $(this).is(":checked");
            if(checked){
                $("#day2").show();
            } else {
                $("#day2").hide();
            }
        });
<?php  
if($check_limits['resume_daily']=='1'||$check_limits['resume_monthly']=='1'|| $check_limits['resume_credits']=='1') {
?>
 var checked = $("#logs1").is(":checked");
            if(checked) {
                $("#feild1").slideUp();
                $(".delete-child").slideDown();
                $(".evergreen-block").slideDown();
            }
<?php
}
if($check_limits['resume_monthly']=='1'|| $check_limits['resume_credits']=='1') {
    ?>
     var checked = $("#logs1").is(":checked");
                if(checked) {
                    $(".days-block").slideDown();
                }
    <?php
    }
?>
        $("#logs1").click(function() {
            var checked = $("#logs1").is(":checked");
            if(checked) {
                $("#feild1").slideUp();
                $(".delete-child").slideDown();
            } else {
                $("#feild1").slideDown();
                $(".delete-child").slideUp();
                $(".delete-child22").slideUp();
                $("#logs2").prop("checked" , false);
                $("#logs3").prop("checked" , false);
                $("#logs4").prop("checked" , false);
                $("#resume-evergreen").prop("checked" , false);
            }
        });

       
    });
    $('.form-control').on('keypress keyup change', function(e) {
        id = this.id;
        id = '#'+id;
        err_id = '#'+this.id+'-error';
        if(id !="#")
        $(id).removeClass('is-invalid');
        $(err_id).css('display','none');
    });
</script> 
<script type="text/javascript">
    $(document).ready(function() {
       $(".m-select2").select2();
    });

    function runcron(cron) {
        $(".blockUI").show();
        $.ajax({
            url: "/setting/run/cron/manually",
            type: 'POST',
            data: {cron: cron},
            success: function(result) {
                // console.log(result);
                setTimeout(function(){
                    $("#status").css("display", "flex");
                    //Command: toastr["success"] ("Cron successfuly running!");
                    $(".blockUI").hide();
                }, 1500);
                setTimeout(function(){
                    $("#status").fadeOut();
                    $(".blockUI").hide();
                }, 6500);
            }, 
            error: function(error){
                $(".blockUI").hide();
                console.log(error)
            }
        });
    }
   
</script>
@endsection