@extends('admin.layouts.app')

@section('header')
    <style type="text/css">
        .tabs-container .nav li a.active {
            border-top: 2px solid #0e9aef;
            border-bottom: 1px solid #0e9aef;
            background-color: #0e9aef;
            color: #ffffff;
        }

        #tab-1 label {
            color: #ccc
        }

        #tab-1 span {
            font-weight: 500
        }

        .tabs-container .nav-tabs {
            border-bottom: 1px solid #eee;
        }

        .tabs-container ul.nav-tabs li {
            text-align: center;
            height: 60px;
            width: 20%;
            font-size: 16px;
        }

        @media (max-width: 600px) {
            .tabs-container ul.nav-tabs li {
                width: 100%;
            }
        }

        .tabs-container ul.nav-tabs li a {
            border-top: 3px solid #eee;
            line-height: 37px;
        }

        .tabs-container div.panel-body {
            border: none
        }

        .company_baseinfo h3 {
            font-size: 1px;
            margin: 0 auto;
        }

        .company_baseinfo h3 label {
            color: #ccc;
        }

        .tab-content h3 {
            border-bottom: 1px solid #ecf2f5;
            padding: 5px 0;
        }

        .tab-content h3::before {
            background-color: #0e9aef;
            content: '-';
            color: #0e9aef;
            margin-right: 5px;
            padding-right: 2px;
        }

        .dropdown-menu {
            left: 0 !important;
        }

        .ibox-content {
            height: 100%;
            background-color: #f5f9fc;
        }

        .ibox-content > .col-md-12, .ibox-content > .col-md-12 > .row {
            margin: auto;
            height: 100%;
        }

        .ibox-content .panel-body {
            background-color: #ffffff;
        }

        .contacts-count {
            background-color: #ccc;
            border-radius: 40%;
            display: inline-block;
            padding: 2px 5px;
            font-size: 12px;
            color: #fff
        }
    </style>
@endsection
@section('content')
    <div class="row" style="height: 100%;background-color: #f5f9fc">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" style="height: 100%">
                <div class="ibox-title">
                    <h5>挖掘线索</h5>
                    <div class="ibox-tools">
                        <a href="javascript:history.back();" class="btn  btn-xs btn-primary">
                            返回
                        </a>
                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="col-md-12">

                        <div class="row">
                            <div class="col-lg-9 col-md-8">
                                <div class="panel-body">
                                    <div class="row" style="margin-bottom: 10px">
                                        <div class="col-lg-2 col-md-3">
                                            <img src="/base/img/companyAvatar.82b6c75.png" alt="">
                                        </div>

                                        <div class="col-lg-10 col-md-9">
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <h3 style="font-weight: 700">{{ $data->company_name }}</h3>
                                                </div>

                                                @if(!$data->isThread())
                                                    <div class="col-md-6">
                                                        <h3 class="pull-right" style="color: coral;font-size: 14px">请选择联系方式，添加为我的线索</h3>
                                                    </div>
                                                @endif
                                            </div>


                                            <div class="row company_baseinfo">
                                                <div class="col-md-4">
                                                    <h3><label for="">经营状态：</label>{{ $data->open_status }}</h3>
                                                </div>
                                                <div class="col-sm-4">
                                                    <h3><label>成立日期:</label>{{ $data->start_date }}</h3>
                                                </div>
                                                <div class="col-md-4">
                                                    <h3><label for="">公司类型：</label>{{ $data->ent_type }}</h3>
                                                </div>
                                                <div class="col-md-6">
                                                    <h3><label for="">企业地址：</label>{{ $data->reg_addr }}</h3>
                                                </div>

                                            </div>

                                        </div>

                                    </div>

                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="tabs-container">
                                                <ul class="nav nav-tabs">

                                                    <li>
                                                        <a data-toggle="tab" href="#tab-1" aria-expanded="true"
                                                           class="active show">基本信息</a>
                                                    </li>
                                                    <li>
                                                        <a data-toggle="tab" href="#tab-2" aria-expanded="true">变更纪录</a>
                                                    </li>
                                                    <li>
                                                        <a data-toggle="tab" href="#tab-3" aria-expanded="true">企业年报</a>
                                                    </li>
                                                    <li>
                                                        <a data-toggle="tab" href="#tab-4" aria-expanded="true">知识产权</a>
                                                    </li>
                                                    <li>
                                                        <a data-toggle="tab" href="#tab-5" aria-expanded="true">招聘信息</a>
                                                    </li>
                                                </ul>

                                                <div class="tab-content">
                                                    {{--基本信息 Start--}}
                                                    <div id="tab-1" class="tab-pane active show">
                                                        <div class="panel-body">
                                                            <h3>工商信息</h3>
                                                            <div class="form-group row">
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">统一社会信用代码/注册号:</label>
                                                                    <span>{{ $data->reg_no }}</span>

                                                                </div>

                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">组织机构代码:</label>
                                                                    <span>{{ $data->org_no }}</span>
                                                                </div>
                                                            </div>

                                                            <div class="form-group row">
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">法定代表人:</label>
                                                                    <span>{{ $data->legal_person }}</span>
                                                                </div>
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">经营状态:</label>
                                                                    <span>{{ $data->open_status }}</span>
                                                                </div>

                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">营业期限:</label>
                                                                    <span>{{ $data->open_time }}</span>
                                                                </div>
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">审核/年检日期:</label>
                                                                    <span>{{ $data->annual_date }}</span>
                                                                </div>
                                                            </div>

                                                            <div class="form-group row">
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">注册资本:</label>
                                                                    <span>{{ $data->reg_capital }}</span>
                                                                </div>
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">企业类型:</label>
                                                                    <span>{{ $data->ent_type }}</span>
                                                                </div>
                                                                {{--<div class="col-sm-6">--}}
                                                                {{--<label for="col-sm-3">机构类型:</label>--}}
                                                                {{--<span>{{ $data->annual_date }}</span>--}}
                                                                {{--</div>--}}
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">所属行业:</label>
                                                                    <span>{{ $data->industry }}</span>
                                                                </div>
                                                            </div>

                                                            <div class="form-group row">
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">行政区域:</label>
                                                                    <span>{{ $data->district }}</span>
                                                                </div>
                                                                <div class="col-sm-6">
                                                                    <label for="col-sm-3">登记机关:</label>
                                                                    <span>{{ $data->authority }}</span>
                                                                </div>
                                                                <div class="col-sm-12">
                                                                    <label for="col-sm-3">所在地址:</label>
                                                                    <span>{{ $data->reg_addr }}</span>
                                                                </div>
                                                                <div class="col-sm-12">
                                                                    <label for="col-sm-3">经营范围:</label>
                                                                    <span class="col-sm-8">{{ $data->scope }}</span>
                                                                </div>
                                                            </div>

                                                            <div class="form-group row">
                                                                <div class="col-sm-12">
                                                                    <label for="col-sm-3">网站地址:</label>
                                                                    <a href="http://{{ $data->website }}"
                                                                       target="_blank"><span>{{ $data->website }}</span></a>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="panel-body">
                                                            <h3>股东信息</h3>

                                                            <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                                                                <tr>
                                                                    <th>股东姓名</th>
                                                                    <th>持股比例</th>
                                                                    <th>认缴出资</th>
                                                                    <th>实缴出资</th>
                                                                </tr>

                                                                @foreach($data->shareholders() as $item)
                                                                    <tr>
                                                                        <td>{{ $item->username }}</td>
                                                                        <td>{{ $item->insto }}</td>
                                                                        <td>{{ $item->amount }}</td>
                                                                        <td>{{ $item->amount_paid or '-'}}</td>
                                                                    </tr>
                                                                @endforeach
                                                            </table>

                                                        </div>

                                                        <div class="panel-body">
                                                            <h3>主要人员</h3>

                                                            <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                                                                <tr>
                                                                    <th>序号</th>
                                                                    <th>姓名</th>
                                                                    <th>职务</th>
                                                                </tr>

                                                                @foreach($data->mainpersons() as $key => $item)
                                                                    <tr>
                                                                        <td>{{ $key+1 }}</td>
                                                                        <td>{{ $item->username }}</td>
                                                                        <td>{{ $item->post }}</td>
                                                                    </tr>
                                                                @endforeach
                                                            </table>
                                                        </div>
                                                    </div>

                                                    {{-- 变更纪录 --}}
                                                    <div id="tab-2" class="tab-pane">
                                                        <div class="panel-body">
                                                            <h3>变更纪录</h3>

                                                            <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                                                                <tr>
                                                                    <th>序号</th>
                                                                    <th>变更日期</th>
                                                                    <th>变更项目</th>
                                                                    <th>变更前</th>
                                                                    <th>变更后</th>
                                                                </tr>

                                                                @foreach($data->changeds() as $key =>$item)
                                                                    <tr>
                                                                        <td>{{ $key+1 }}</td>
                                                                        <td>{{ $item->changed_time }}</td>
                                                                        <td>{{ $item->changed_name }}</td>
                                                                        <td>{{ $item->changed_before }}</td>
                                                                        <td>{{ $item->changed_after }}</td>
                                                                    </tr>
                                                                @endforeach
                                                            </table>

                                                        </div>
                                                    </div>

                                                    {{-- 企业年报 --}}
                                                    <div id="tab-3" class="tab-pane">
                                                        <div class="panel-body">
                                                            <h3>企业年报</h3>
                                                            <p style="text-align: center;color: #ccc;font-weight: 500;">
                                                                暂无相关内容
                                                            </p>
                                                        </div>
                                                    </div>


                                                    {{-- 知识产权 --}}
                                                    <div id="tab-4" class="tab-pane">
                                                        <div class="panel-body">
                                                            <h3>知识产权</h3>
                                                            <p style="text-align: center;color: #ccc;font-weight: 500;">
                                                                暂无相关内容
                                                            </p>
                                                        </div>
                                                    </div>

                                                    {{-- 招聘信息 --}}
                                                    <div id="tab-5" class="tab-pane">
                                                        <div class="panel-body">
                                                            <h3>招聘信息</h3>
                                                            <p style="text-align: center;color: #ccc;font-weight: 500;">
                                                                暂无相关内容
                                                            </p>
                                                        </div>
                                                    </div>
                                                </div>


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

                                </div>
                            </div>

                            <div class="col-lg-3 col-md-4">
                                <div class="panel-body" style="overflow-y: auto">
                                    <h3>联系方式 <span class="contacts-count">{{ count($contacts) }}</span></h3>

                                    <div class="col-sm-12" style="padding: 0;">
                                        <ul class="sortable-list connectList agile-list ui-sortable"
                                            style="height: 780px">
                                            @if(count($contacts))
                                                @foreach($contacts as $item)
                                                    <li class="success-element">
                                                        <div class="agile-detail">
                                                            <div>
                                                                <label><i class="fa fa-phone" style="font-size: 20px;margin-right: 20px;vertical-align: middle"></i></label>
                                                                <span style="color: #0e9aef"> {{ $item->phone }}</span>

                                                            </div>

                                                            <div><label>联系人：</label><span>{{ $item->linkman }}</span>
                                                            </div>

                                                            <div><label>QQ号码：</label><span>{{ $item->qq }}</span></div>

                                                            <div><label>电子邮箱：</label><span>{{ $item->email }}</span>
                                                            </div>

                                                            <div><label>来源：</label><span>{{ $item->via_link }}</span>
                                                            </div>

                                                            <div><label>联系地址：</label><span>{{ $item->address }}</span>
                                                            </div>

                                                            {{--<label>备注：</label><input type="text" style="width: 70%" name="remark" value="{{ $item->remark }}">--}}
                                                            <div class="row" style="margin-bottom: .5rem">
                                                                <label class="col-sm-3"
                                                                       style="padding-right: 0">备注：</label>
                                                                <div class="col-sm-6" style="padding-left: 0">
                                                                    <div class="input-group">

                                                                        <input type="text"
                                                                               class="test_data {{$item->id}}"
                                                                               name="remark" value="{{ $item->remark }}"
                                                                               style="width: 100%">
                                                                        <div class="input-group-btn">
                                                                            <ul class="dropdown-menu dropdown-menu-right"
                                                                                role="menu">
                                                                            </ul>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <button class="btn btn-xs btn-success"
                                                                        onclick="addContactsRemark({{$item->id}})">修改
                                                                </button>
                                                            </div>


                                                            @if(!$data->isThread())
                                                                <a href='{{ U('User/Threads/create',['company_id'=>$data->id,'contact_id'=>$item->id])}}'
                                                                   class="btn btn-primary btn-rounded btn-block">领取线索</a>
                                                            @endif
                                                        </div>
                                                    </li>
                                                @endforeach
                                            @else
                                                <li class="success-element">
                                                    @if(!$data->isThread())
                                                        <form action="{{U('User/Threads/create')}}" method="get">
                                                            <div class="agile-detail" style="text-align: center">
                                                            <textarea name="remark" id=""
                                                                      style="width: 100%;height: 100px"
                                                                      placeholder="线索备注..."></textarea>
                                                                <input type="hidden" name="company_id"
                                                                       value="{{$data->id}}">
                                                                <button type="submit"
                                                                        class="btn btn-primary btn-rounded btn-block">
                                                                    领取线索
                                                                </button>
                                                            </div>
                                                        </form>
                                                    @endif
                                                </li>
                                            @endif
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


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

    </div>
@endsection

@section('js')
    <script src="/base/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script type="text/javascript">
        var testdataBsSuggest = $(".test_data").bsSuggest({
            indexId: 0,
            indexKey: 0,
            data: {
                "value": [
                    {"word": "空号"},
                    {"word": "关机"},
                    {"word": "无人接听"},
                    {"word": "已接通"},
                    {"word": "接通并挂断"}
                ], "defaults": "已接通"
            }
        });

        function addContactsRemark(id) {
            remark = $('.' + id).val()
            csrf_token = '{{ csrf_token() }}'
            $.ajax({
                url: '{{ U('Company/info/addremarks') }}',
                type: 'POST',
                data: {id: id, remark: remark, _token: csrf_token},
                success: function (data) {
                    layer.msg('修改备注成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        window.location.href = window.location.href
                    });
                }
            })
        }
    </script>

@endsection