@extends('base.base')

    @section('title', '系统健康状态管理')


@section('base')

<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">系统健康状态配置</h3>
            </div>

            @if(session('success'))
                <div class="alert alert-success">
                    {{ session('success') }}
                </div>
            @endif

            <form method="POST" action="{{ route('admin.system_health.update') }}">
                {{ csrf_field() }}

                <div class="box-body">
                    <div class="form-group">
                        <label>系统总开关</label>
                        <div class="radio">
                            <label>
                                <input type="radio" name="status" value="1" {{ $healthConfig['status'] == 1 ? 'checked' : '' }}>
                                开启
                            </label>
                            <label style="margin-left: 20px;">
                                <input type="radio" name="status" value="0" {{ $healthConfig['status'] == 0 ? 'checked' : '' }}>
                                关闭
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>支付系统状态</label>
                        <div class="radio">
                            <label>
                                <input type="radio" name="pay_status" value="1" class="toggle-input" data-target="pay-maintenance" {{ !is_array($healthConfig['pay']) ? 'checked' : '' }}>
                                正常
                            </label>
                            <label style="margin-left: 20px;">
                                <input type="radio" name="pay_status" value="0" class="toggle-input" data-target="pay-maintenance" {{ is_array($healthConfig['pay']) ? 'checked' : '' }}>
                                维护
                            </label>
                        </div>
                    </div>

                    <div id="pay-maintenance" class="conditional-form-group" style="{{ is_array($healthConfig['pay']) ? '' : 'display: none;' }}">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>支付维护开始时间</label>
                                    <input type="datetime-local" name="pay_start_time" class="form-control" value="{{ is_array($healthConfig['pay']) ? date('Y-m-d\TH:i', $healthConfig['pay']['st']) : '' }}">
                                    <small class="text-muted">请输入当地时间（根据系统时区设置）</small>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>支付维护结束时间</label>
                                    <input type="datetime-local" name="pay_end_time" class="form-control" value="{{ is_array($healthConfig['pay']) ? date('Y-m-d\TH:i', $healthConfig['pay']['ed']) : '' }}">
                                    <small class="text-muted">请输入当地时间（根据系统时区设置）</small>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>提现系统状态</label>
                        <div class="radio">
                            <label>
                                <input type="radio" name="cashout_status" value="1" class="toggle-input" data-target="cashout-maintenance" {{ !is_array($healthConfig['cashout']) ? 'checked' : '' }}>
                                正常
                            </label>
                            <label style="margin-left: 20px;">
                                <input type="radio" name="cashout_status" value="0" class="toggle-input" data-target="cashout-maintenance" {{ is_array($healthConfig['cashout']) ? 'checked' : '' }}>
                                维护
                            </label>
                        </div>
                    </div>

                    <div id="cashout-maintenance" class="conditional-form-group" style="{{ is_array($healthConfig['cashout']) ? '' : 'display: none;' }}">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>提现维护开始时间</label>
                                    <input type="datetime-local" name="cashout_start_time" class="form-control" value="{{ is_array($healthConfig['cashout']) ? date('Y-m-d\TH:i', $healthConfig['cashout']['st']) : '' }}">
                                    <small class="text-muted">请输入当地时间（根据系统时区设置）</small>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>提现维护结束时间</label>
                                    <input type="datetime-local" name="cashout_end_time" class="form-control" value="{{ is_array($healthConfig['cashout']) ? date('Y-m-d\TH:i', $healthConfig['cashout']['ed']) : '' }}">
                                    <small class="text-muted">请输入当地时间（根据系统时区设置）</small>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>系统公告</label>
                        <textarea name="notice" class="form-control" rows="3" placeholder="输入系统公告内容">{{ $healthConfig['notice'] }}</textarea>
                    </div>
                </div>

                <div class="box-footer">
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $(function() {
        // 切换条件表单的显示/隐藏
        $('.toggle-input').on('change', function() {
            var target = $(this).data('target');
            if ($(this).val() == '0') {
                $('#' + target).show();
            } else {
                $('#' + target).hide();
            }
        });
    });
</script>
@endsection
