@extends('Merchant::layouts.app')

@section('title', '核销列表')

@section('css')
    <link rel="stylesheet" href="{{ asset('assets/merchant/css/plugins/datapicker/datepicker3.css') }}"/>
@endsection

@push('script')
    <script type="text/javascript"
            src="{{ asset('assets/merchant/js/plugins/datapicker/bootstrap-datepicker.js') }}"></script>
    <script type="text/javascript">
        $("#time-interval .input-daterange").datepicker({
            keyboardNavigation: !1,
            forceParse: !1,
            autoclose: !0,
            clearBtn: true,
        });

        $("button").click(function () {
            var $this = $(this);
            var $form = $this.parents('form');
            $("input[name='action']").val($this.data('action'));
            $form.submit();
        });

    </script>
@endpush

@section('content')
    <div class="ibox">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12 m-b">
                    <form action="{{ route('merchant.coupons')}}" class="form-inline pull-right" method="get"
                          accept-charset="utf-8">
                        <div class="input-group">
                            <div class="form-group">
                                <input type="text" placeholder="网点名称" name="outlet" class="input-sm form-control"
                                       value="{{ Request::input('outlet') }}">
                            </div>

                            <div class="form-group">
                                <input type="text" placeholder="平安券编号" name="redemptionCode"
                                       class="input-sm form-control" value="{{ Request::input('redemptionCode') }}">
                            </div>

                            <div class="form-group">
                                <input type="text" placeholder="平安主订单号" name="pa_order_id"
                                       class="input-sm form-control" value="{{ Request::input('pa_order_id') }}">
                            </div>

                            <div class="form-group">
                                <select class="form-control m-b" name="status">
                                    <option value="">状态</option>
                                    <option value="2" @if(request()->status==2) selected="" @endif >核销成功</option>
                                    <option value="3" @if(request()->status==3) selected="" @endif >核销失败</option>
                                    {{-- <option value="4" @if(request()->status==4) selected="" @endif >已分润</option> --}}
                                </select>
                            </div>

                            <div class="form-group">
                                <select class="form-control m-b" name="type">
                                    <option value="">类型</option>
                                    <option value="all" @if(request()->type=='all') selected="" @endif >全部</option>
                                    <option value="pingan" @if(request()->type=='pingan') selected="" @endif >平安
                                    </option>
                                </select>
                            </div>

                            <div class="form-group">
                                <select class="form-control m-b" name="thirdPartyGoodsId">
                                    <option value="">政策</option>
                                    @foreach ($rules as $rule)
                                        <option value="{{ $rule->code }}"
                                                @if(request()->thirdPartyGoodsId== $rule->code) selected="" @endif >
                                            {{ $rule->title }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="form-group" id="time-interval">
                                <div class="input-daterange input-group">
                                    <input type="text" class="input-sm form-control" placeholder="核销时间" readonly
                                           name="start" value="{{ Request::input('start') }}"/>
                                    <span class="input-group-addon">~</span>
                                    <input type="text" class="input-sm form-control" placeholder="核销时间" readonly
                                           name="end" value="{{ Request::input('end') }}"/>
                                </div>
                            </div>

                            <span class="input-group-btn">
                            <input type="hidden" name="action" value="search">
                            <button type="button" class="btn btn-sm btn-primary" data-action="search"><i
                                        class="fa fa-check"></i>&nbsp;搜索</button>
                            <button type="button" class="btn btn-sm btn-warning confirm" tip='确认要导出当前条件内容？'
                                    data-action="excel"><i class="fa fa-paste"></i>&nbsp;导出</button>
                        </span>

                            <span class="input-group-btn">
{{--                            <button type="submit" class="btn btn-sm btn-primary " ><i class="fa fa-check"></i>&nbsp;搜索</button>--}}

                                {{--  <button class="btn btn-sm btn-primary" type="button" data-toggle="layer" data-height="360" data-width="700" href="{{ route('merchant.coupons.profits') }}">
                                     <i class="fa fa-plus"></i>
                                     批量分润
                                 </button> --}}
                        </span>
                        </div>
                    </form>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th width="100">ID</th>
                        <th>网点名称</th>
                        {{-- <th>订单号</th> --}}
                        <th>平安券编号</th>
                        <th>优惠政策</th>
                        <th>核销金额</th>
                        <th>平安主订单号</th>
                        <th>状态</th>
                        <th>处理结果</th>
                        <th>核销时间</th>
                        {{-- <th>操作</th> --}}
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($coupons as $coupon)
                        <tr>
                            <td> {{ $coupon->id }} </td>
                            <td>{{ $coupon->outlet ? $coupon->outlet->nickname : 'Id:' . $coupon->outletId }}</td>
                            {{-- <td>{{ $coupon->partnerOrderId }}</td> --}}
                            <td>{{ $coupon->redemptionCode }}</td>
                            <td>{{ $coupon->couponName }}</td>
                            <td>{{ $coupon->price }}</td>
                            {{--                            <td>{{ $coupon->orderid }}</td>--}}
                            <td>{{ $coupon->pa_order_id }}</td>
                            <td>{{ $coupon->status_text }}</td>
                            <td>{{ $coupon->remark }}</td>
                            <td>{{ $coupon->created_at }}</td>
                            {{--  <td>
                                 <a class="btn btn-sm  btn-primary ajax-get confirm" tip="您确定要分润吗" href="{{ route('merchant.coupons.profit',$coupon)}}">分润</a>
                             </td> --}}
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div>
                <span class="badge badge-primary">全部:{{ $data['all'] }}张 </span>
                <span class="badge badge-success">成功:{{ $data['pass'] }}张 </span>
                <span class="badge badge-error">失败:{{ $data['reject'] }}张 </span>
                {{-- <span class="badge badge-primary">核销金额:{{ $data['price'] }}元 </span> --}}
                {{-- <span class="badge badge-primary">分润金额:{{ $data['profit'] }}元 </span> --}}
                {{-- <span class="badge badge-primary">打款金额:{{ $data['hasPrice'] }}元 </span> --}}
            </div>
            <div class="text-right">
                {{
                    $coupons->appends(Request::all())->links('Merchant::common.pagination')
                 }}
            </div>
        </div>
    </div>
@endsection
