@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.unionpay.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="shop_no" class="input-sm form-control"
                                       value="{{ Request::input('shop_no') }}">
                            </div>
                            <div class="form-group">
                                <input type="text" placeholder="门店名称" name="shop_name" class="input-sm form-control"
                                       value="{{ Request::input('shop_name') }}">
                            </div>

                            <div class="form-group">
                                <input type="text" placeholder="优惠券券编号" name="coupon_no"
                                       class="input-sm form-control" value="{{ Request::input('coupon_no') }}">
                            </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">
                        </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>
                        <th>核销时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($coupons as $coupon)
                        <tr>
                            <td> {{ $coupon->id }} </td>
                            <td> {{ $coupon->mobile }} </td>
                            <td>{{ $coupon->shop_no }}</td>
                            <td>{{ $coupon->outlet ? $coupon->outlet->nickname : ''  }}</td>
                            <td>{{ $coupon->coupon_no }}</td>
                            <td>{{ $coupon->orig_amt/100 }}</td>
                            <td>{{ $coupon->discount_amt/100 }}</td>
                            <td>{{ $coupon->pay_amt/100 }}</td>
                            {{--                            <td>{{ $coupon->effective_date_time }}</td>--}}
                            {{--                            <td>{{ $coupon->expire_date_time }}</td>--}}
                            <td>{{ $coupon->status_text }}</td>
                            <td>{{ $coupon->updated_at }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div class="text-right">
                {{
                    $coupons->appends([
                    'shop_no'=>Request::input('shop_no'),
                    'shop_name'=>Request::input('shop_name'),
                    'coupon_no'=>Request::input('coupon_no'),
                    'start'=>Request::input('start'),
                    'end'=>Request::input('end'),
                    ])->links('Merchant::common.pagination')
                 }}
            </div>
        </div>
    </div>
@endsection
