@extends('admin/layout')
@section('header')
    <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
    <style>
        .btn-danger, .btn-primary, .btn-info {
            background: #2a94e0 !important;
            border-color: #2a94e0 !important;
        }

        .table-striped > tbody > tr:nth-of-type(odd) {
            background: #f8f8f8 !important;
        }

        .table-striped > tbody > tr .btn {
            background: none !important;
        }

        .table-striped > tbody > tr td {
            font-size: 14px !important;
        }

        .table-striped > tbody > tr:hover {
            background: #ffebd8 !important;
        }

        .table-striped > tbody > tr:hover .btn {
            background: #2a94e0 !important;
            color: #fff !important;
        }

        .table-striped > tbody > tr:hover .btn .glyphicon {
            color: #fff !important;
        }
    </style>
@endsection

@section('content')
    @php   $authUser=auth()->user() @endphp
    <body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="row" id="searchForm" onsubmit="units.search();return false;">

                            <div class="input-group">


                                <select name="manageHelperId" id="manageHelperId" title="" class="form-control"
                                        style="width: 150px;float: right" onchange="units.selectPage();">
                                    <option value="">请选择项目经理</option>
                                    @foreach($managerHelpers as $item)
                                        <option value="{{$item->id}}">{{$item->nickname}}</option>
                                    @endforeach

                                </select>

                                <select name="editorId" id="editorId" title="" class="form-control"
                                        style="width: 150px;float: right" onchange="units.selectPage();">
                                    <option value="">请选择建站采编</option>
                                    @foreach($editors as $item)
                                        <option value="{{$item->id}}">{{$item->nickname}}</option>
                                    @endforeach
                                </select>

                                <select name="optimizerId" id="optimizerId" title="" class="form-control"
                                        style="width: 150px;float: right"
                                        onchange="units.selectPage();">
                                    <option value="">请选择优化组长</option>
                                    @foreach($optimizers as $item)
                                        <option value="{{$item->id}}">{{$item->nickname}}</option>
                                    @endforeach
                                </select>
                                <select name="sellerId" id="sellerId" title="" class="form-control"
                                        style="width: 150px;float: right" onchange="units.selectPage();">
                                    <option value="">请选择销售</option>
                                    @foreach($sellerUsers as $item)
                                        <option value="{{$item->id}}">{{$item->nickname}}</option>
                                    @endforeach

                                </select>

                                <select name="serverId" id="serverId" title="" class="form-control"
                                        style="width: 150px;float: right" onchange="units.selectPage();">
                                    <option value="">请选择客服</option>
                                    @foreach($services as $item)
                                        <option value="{{$item->id}}">{{$item->nickname}}</option>
                                    @endforeach
                                </select>

                                <input type="text" class="form-control" id="monthRange" name="endDate"
                                       placeholder="截止时间"
                                       style="width: 150px;float: right">
                                <input type="text" class="form-control" id="monthRange2" name="startDate"
                                       placeholder="开始时间"
                                       style="width: 150px;float: right">
                                <input type="text" placeholder="请输入域名或项目名称" class="input-md form-control"
                                       name="keyword"
                                       id="keyword" style="width: 200px;float: right">
                                <span class="input-group-btn">

                                    <button type="button" class="btn btn-md btn-primary"
                                            onclick="units.search()"> 搜索</button>
                                    <button type="button" class="btn btn-md" style="margin-left: 10px"
                                            name="btnReset"> 重置</button>

                                            <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px" onclick="units.export()"> 导出</button>
                                    </span>
                            </div>

                        </form>
                        <hr>

                        <div class="table-responsive">

                            <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>

                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
    </body>
@endsection
@section('footer')
    <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>

    <script>

        laydate.render({
            elem: '#monthRange'
            , type: 'month'
            , format: 'yyyy-MM'
        });

        laydate.render({
            elem: '#monthRange2'
            , type: 'month'
            , format: 'yyyy-MM'
        });

        var units = {
            export:function(){

                var formValues = tips.getFormValues("#searchForm");

                var str=$.param(formValues);
                window.open('/admin/analyze/index/history-reach-export?='+str)
            },
            selectPage: function () {
                tips.selectPage();
            },
            search: function () {
                $('#table').bootstrapTable('selectPage', 1);
                // tips.tableRefresh();
            },
            openDetail: function (id, title) {
                tips.page('/admin/sites/' + id + '/overview', title);
            }
        };

        // 月流量 月询盘 月排名 月软文 项目经理 项目进度

        var config = {};
        config.url = '/admin/analyze/index/history-reach';
        config.pageSize = 20;
        config.showColumns = true;
        config.columns = [ //字段
            {
                title: '序号', align: 'center', formatter: function (value, item, index) {
                    return index + 1;
                },
                width: '10px'
            },
            {title: '达标时间', field: 'reach_at', align: 'center'},
            {title: '过期时间', field: 'expired_at', align: 'center'},
            {title: '公司', field: 'cn_title', align: 'center'},
            {title: '网站', field: 'domain', align: 'center'},
            {title: '关键词指标', field: 'keyword_goal', align: 'center'},
            {title: '实际达标关键词', field: 'top10', align: 'center'},
            {title: '达标时长', field: 'reach_days', align: 'center'},

            {title: '项目销售', field: 'seller_title', align: 'center'},
            {title: '客服经理', field: 'server_title', align: 'center'},
            {title: '项目经理1', field: 'managers_title', align: 'center'},
            {title: '项目经理', field: 'manage_helper_title', align: 'center'},
            {title: '优化师', field: 'optimizerTitle', align: 'center'},
            {title: '项目采编', field: 'ae_title', align: 'center',visible: false},

            /*{title: '项目经理1', field: 'managers_title', align: 'center', visible: false},*/
            /*{title: '项目经理', field: 'manage_helper_title', align: 'center'},*/
            /*{title: '项目采编', field: 'ae_title', align: 'center', visible: false},*/
            /*{title: '优化师', field: 'optimizerTitle', align: 'center'},*/
            {title: '竞价', field: 'bidTitle', align: 'center', visible: false},
            {title: '软文', field: 'articleTitle', align: 'center', visible: false},
            {title: '设计', field: 'designerTitle', align: 'center', visible: false},
            {title: '前端', field: 'webTitle', align: 'center', visible: false},
            /*{title: '客服经理', field: 'server_title', align: 'center'},*/
            /*{title: '项目销售', field: 'seller_title', align: 'center'},*/

            {title: '合同签订时间', field: 'sign_at', align: 'center', visible: false},
            {title: '下单时间', field: 'order_at', align: 'center', visible: false},
            {title: '分配时间', field: 'assign_at', align: 'center'},
            {title: '上线时间', field: 'online_at', align: 'center', visible: false},
            /*{title: '达标时间', field: 'reach_at', align: 'center', visible: false},*/
            /*{title: '过期时间', field: 'expired_at', align: 'center', visible: false},*/
            {title: '百千约访时间', field: 'bq_at', align: 'center', visible: false},
            {title: '续费次数', field: 'renewal_times', align: 'center', visible: false},
            {title: '续费时间', field: 'renewal_at', align: 'center', visible: false},


            // {title: '评分', field: 'score', align: 'center'},

            {
                title: '操作', field: 'id', align: 'center',
                formatter: function (value, row) {

                    var str = '<button onclick="units.openDetail(' + value + ',\'' + row.cn_title + '\')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>详情</button><br>';

                    return str;

                }
            }
        ];
        tips.bootstrapTable(config);


    </script>
@endsection