@extends('cp.web.layouts.admin')

@section('content')
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">cp数据详情</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <div class="panel">
        @if (session('message'))
            <div class="alert alert-success" role="alert">{{session('message')}}</div>
        @endif

        @if(($errors->has('message')))
            <div class="alert alert-danger" role="alert">{{$errors->first('message')}}</div>
        @endif
        <form action='{{url("book/cpDataStats")}}' method="get">
            <div class="form-group">
                <label for="book_name">书名</label>
                <input class="form-control" name="book_name" id="book_name" value="{{ @$param['book_name'] }}">
            </div>
            <div class="form-group">
                <label for="bid">bid</label>
                <input class="form-control" name="bid"  id="bid" value="{{ @$param['bid'] }}" placeholder="多个以逗号隔开">
            </div>
            <div class="form-group">
                <label for="cp_source">cp_source</label>
                <select class="form-control" name="cp_source"  id="cp_source">
                    <option value="">--</option>
                    @foreach($cps as $v)
                        @if( isset($param['cp_source']) && $param['cp_source'] == $v->username)
                            <option value="{{$v->username}}" selected>{{$v->username}}</option>
                        @else
                            <option value="{{$v->username}}">{{$v->username}}</option>
                        @endif
                    @endforeach
                </select>
            </div>

            <div class="form-group">
                <label for="cp_sources">日期</label>
                <input class="form-control" name="start_time"  type="date">
                <input class="form-control" name="end_time"  type="date">
            </div>

            <div class="form-group">
                <label for="cp_sources">统计规则</label>
                <label class="checkbox-inline">
                    <input type="checkbox" value="cp_source" name="groupby[]" > 按cp
                </label>

                <label class="checkbox-inline">
                    <input type="checkbox" value="month" name="groupby[]" > 按月
                </label>

                <label class="checkbox-inline">
                    <input type="checkbox" value="bid" name="groupby[]" > 按书
                </label>

            </div>

            <button type="submit" class="btn btn-success">查询</button>
            <a href="{{url('book/cpDataStats?')}}{{http_build_query($exporparam)}}" class="btn btn-success"  data-title="添加cp">导出</a>
        </form>
    </div>

    <div class="panel panel-default">

        <div class="panel-heading">
            列表
        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
            <div class="dataTable_wrapper">
                <table class="table table-striped table-bordered table-hover" id="dataTables-example" style="text-align: center">
                    <tr>
                        <th>图书bid</th>
                        <th>书名</th>
                        <th>所属cp</th>
                        <th>日期</th>
                        <th>书币</th>
                        <th>月份</th>
                        <th>年份</th>
                    </tr>
                    @foreach ($data as $record)
                        <tr >
                            <td>{{ $record->bid }}</td>
                            <td>{{ $record->book_name }}</td>
                            <td>{{ $record->cp_source }}</td>
                            <td>{{ $record->day }}</td>
                            <td>{{ $record->charge_balance }}</td>
                            <td>{{ $record->month }}</td>
                            <td>{{ $record->year }}</td>
                        </tr>
                    @endforeach
                </table>
            </div>
            <div class="paging">
                总计：{{ $data->total() }}
                {{ $data->appends($param)->links() }}
            </div>
        </div>
    </div>
@endsection