@extends('admin.layouts.app')

@section('content')

    <?php
    if (!isset($data)) $data = array();
    if (!$data && session("data")) {
        $data = session("data");
    }
    if (!$data && session('_old_input')) {
        $data = session("_old_input");
    }
    ?>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>线索跟进</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">

                    <div class="row">
                        <div class="col-lg-10">
                            <form name="form_product" id="form-validation" action=""
                                  class="form-horizontal form-validation" accept-charset="UTF-8" method="post">


                                <div class="form-group row">
                                    <textarea name="data[remark]" id="remark"
                                              style="width: 100%;height: 80px;margin-bottom: 8px" required></textarea>
                                    <br/>
                                    <input type="hidden" name="data[threads_id]" value="{{ $data['id'] }}">
                                    {{ csrf_field() }}

                                </div>
                            </form>
                            <button class="btn btn-primary btn-rounded btn-block" onclick="addProgress()">添加进度</button>
                            <div id="progress_list">
                                @include('admin.user.threads.progress')
                            </div>
                        </div>
                        <!-- /.col-lg-10 -->
                    </div>
                    <!-- /.row -->
                </div>
            </div>
        </div>
    </div>

@endsection

@section('js')
    <script type="text/javascript">
        function addProgress() {
            data = $("#form-validation").serialize()
            if (!$('#remark').val()) {
                layer.alert('请填写跟进内容')
            } else {
                $.ajax({
                    type: 'post',
                    data: data,
                    dataType: "json",
                    success: function (data) {
                        $('#remark').val('')
                        $('#progress_list').html(data.html)
                    }
                })
            }

        }

    </script>
@endsection