@extends('admin.layout')

@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>订单列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <form method="GET" action="" accept-charset="UTF-8">

                            <div class="col-sm-4">
                                <div class="input-group">
                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
                                           name="keyword" class="input-sm form-control">
                                    <span class="input-group-btn">
									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
								</span>
                                </div>
                            </div>
                        </form>
                    </div>

                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                        <thead>
                        <tr>
                            <th class="sorting" data-sort="out_trade_no"> 订单编号</th>
                            <th class="sorting" data-sort="username"> 用户姓名</th>
                            <th class="sorting" data-sort="sex"> 性别</th>
                            <th class="sorting" data-sort="phone"> 电话</th>
                            <th class="sorting" data-sort="email"> 邮箱</th>
                            <th class="sorting" data-sort="store_id"> 预约店铺</th>
                            <th class="sorting" data-sort="schedule_time"> 预约时间</th>
                            <th class="sorting" data-sort="status">订单状态</th>
                            <th width="22%">相关操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if(isset($list))
                            @foreach($list as $key => $item)
                                <tr>
                                    <td>{{ $item->out_trade_no }}</td>
                                    <td>{{ $item->username }}</td>
                                    <td>@if($item->sex == 1)女@else男@endif</td>
                                    <td>{{ $item->phone }}</td>
                                    <td>{{ $item->email }}</td>
                                    <td>{{ $item->store() }}</td>
                                    <td>{{ $item->schedule_time }}</td>
                                    <td>{{ $item->status() }}
                                        @if(isset($item->paidinfo->type) && $item->paidinfo->type ==1 && $item->status == 1)
                                            <span style="color: red">(定金:待付{{$item->price - $item->deposit}}
                                                元)</span
                                            >@endif
                                    </td>
                                    <td>
                                        @if($item->status ==1)
                                            <button onclick="window.location.href='{{ U('Order/Info/update',['id'=>$item->id])}}'"
                                                    class="btn btn-info">拍摄完成
                                            </button>
                                        @endif

                                        @if($item->status == 2 && !$item->photo)
                                            <button onclick="window.location.href='{{ U('Order/Info/upload',['id'=>$item->id])}}'"
                                                    class="btn btn-success">上传图片
                                            </button>
                                        @endif

                                        @if($item->status ==3 && !count($item->refundinfo))
                                            <button onclick="window.location.href='{{ U('Order/Info/refund',['id'=>$item->id])}}'"
                                                    class="btn btn-warning">退款
                                            </button>
                                        @endif


                                        @if(role('Order/Info/view'))
                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Order/Info/view',['id'=>$item->id])}}'});"
                                                    class="btn btn-primary ">查看
                                            </button>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                        @endif

                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="dataTables_info" id="DataTables_Table_0_info"
                                 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
                                条，共{{ $list->lastPage() }}页，总{{ $list->total() }}条。
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {!! $list->setPath('')->appends(Request::all())->render() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection