@extends('admin.layout')

@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-content">

                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr>
                                <th class="sorting"> 头像</th>
                                <th class="sorting"> 微信昵称</th>
                                <th class="sorting"> 收货人</th>
                                <th class="sorting"> 联系电话</th>
                                <th class="sorting"> 收获地址</th>
                                <th class="sorting"> 备注</th>
                                <th width="22%">相关操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if(isset($list))
                                @foreach($list as $key => $item)
                                    <tr>
                                        <td><img src="{{ $item->user->avatar }}" alt="" style="height: 50px"></td>
                                        <td>{{$item->user->username}}</td>
                                        <td>{{$item->receiver_name}}</td>
                                        <td>{{$item->phone}}</td>
                                        <td>{{$item->receiver_address}}</td>
                                        <td>{{$item->remark}}</td>
                                        <td>
                                            @if(role('Furniture/Newgoods/Info/bookingremark'))
                                                <button class="btn btn-warning myModal1" data-toggle="modal"
                                                        data-content="{{$item->remark}}" data-id="{{ $item->id }}" data-target="#myModal">@if(!$item->remark)添加@else 修改@endif备注
                                                </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>


        <div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content animated flipInY">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                                    class="sr-only">Close</span></button>
                        <h4 class="modal-title">添加备注</h4></div>
                    <small class="font-bold">
                        <div class="modal-body">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">

                                    <form name="form_product" id="form-validation-1" action=""
                                          class="form-horizontal form-validation" accept-charset="UTF-8" method="post">

                                        <div class="form-group">

                                            <label class="control-label col-sm-1">备注</label>

                                            <div class="col-sm-11">
                                            <textarea id="remark" name="remark" class="form-control"
                                                      cols="20" rows="5"></textarea>
                                            </div>

                                        </div>

                                        <div class="form-group">
                                            <label class="control-label col-sm-3">&nbsp;</label>
                                            <div class="col-sm-11">
                                                <input type="hidden" name="_referer"
                                                       value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
                                                <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
                                                <input type="submit" class="btn btn-success" style="margin-right:20px;">
                                                <input type="reset" class="btn btn-default">
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        </div>
                    </small>
                </div>
                <small class="font-bold">
                </small>
            </div>
            <small class="font-bold">
            </small>
        </div>
    </div>

    <script>
        $('.myModal1').click(function () {
            var booking = $(this).attr('data-id');
            var remark = $(this).attr('data-content');
            $('#form-validation-1').attr('action', "/admin/Furniture/Newgoods/Info/bookingremark?id=" + booking)
            $('#remark').val(remark)
        })
    </script>
@endsection