@extends('layouts.admin')

@section('content')
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">用户列表</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<div class="panel">
    <form action=''>
        <input type="hidden" class="btn btn-success" name='from_device' value='{{ @$from_device }}'/>

        <div class="form-group">
            <label>渠道名称</label>
            <input class="form-control" name="cm" value="{{ @$params['cm'] }}">
        </div>
       
        <div class="form-group">
            <label>open_id</label>
            <input class="form-control" name="open_id" value="{{ @$params['open_id'] }}">
        </div>
        <div class="form-group">
            <label>邀请者open_id</label>
            <input class="form-control" name="inventory_open_id" value="{{ @$params['inventory_open_id'] }}">
        </div>
        <div class="form-group">
            <label>选择公众号</label>
            <select class="form-control" name="wx_id">
                <option value="0" >全部</option>
                @foreach ($gzh_list as $id=>$gzh)
                <option value="{{ $id }}" {{ $id == @$params['wx_id'] ? 'selected' : '' }}>{{ $gzh->gzh_name }}</option>
                @endforeach
            </select>
        </div>

        <div class="form-group">
            <label>是否支付成功</label>
            <input  type='radio' name="is_pay" value= '100' {{ !isset($params['is_pay']) || @$params['is_pay']==100 ? 'checked' : '' }}>全部
            <input  type='radio' name="is_pay" value= '1' {{ @$params['is_pay']==1 ? 'checked' : '' }}>是
            <input  type='radio' name="is_pay" value= '0' {{ isset($params['is_pay']) && $params['is_pay']=='0' ? 'checked' : '' }}>否
        </div>

        <div class="form-group">
            <label>选择时间：</label>
            <input  name="start" onClick="WdatePicker()" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{ @$params['start'] }}"> -
            <input name="end" onClick="WdatePicker()" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{ @$params['end'] }}">
        </div>

        <button type="submit" class="btn btn-success">查询</button>
        <button type="button" class="btn btn-success" onclick="user_export()">导出</button> 
                        
    </form>
</div>
<div class="alert alert-success">

</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>ID</th>
                    <th>用户<br>公众号关注情况</th>
                    <th>公众号</th>
                    <th>邀请人</th>
                    <th>渠道名称</th>
                    <th>性别<br>省<br>市</th>
                    <th>open_id<br>邀请者open_id<br>授权时间<br>抽奖时间<br>下单时间<br>支付时间</th>
                    <th>课程分类<br>年龄段</th>
                    <th>是否支付<br>价格标签<br>抵扣金额</th>
                    <th></th>
                </tr>
                @foreach ($records as $record)
                <tr >
                    <td>{{ $record->id }}</td>
                    <td style='text-align:center;'><img src='{{ $record->headimgurl }}' style='width:40px;height:40px;margin:0 auto;'>
                    <br>{{ $record->nick_name }}
                    <br><br>
                    <p style='text-align:center;'>
                    @if (@$record->subscribe)
                       已关注:{{ $record->subscribe_time }}
                    @else
                       @if (@$record->unsubscribe_time)
                       取关时间：{{ $record->unsubscribe_time }}
                       @else
                       未关注
                       @endif
                    @endif
                    <p>
                    </td>
                    <td>
                       {{ $record->gzh_name }} 
                    </td>
                    <td style='text-align:center;'>
                    @if (@$record->inventory_nick_name)
                       <img src='{{ $record->inventory_headimgurl }}' style='width:40px;height:40px;margin:0 auto;'>
                       <br>{{ $record->inventory_nick_name }}
                    @else
                    @endif
                    
                    </td>
                    <td>
                    <span style="color:blue;font-weight:bold;">{{ $record->channel_name }}</span>
                    </td>
                    <td>
                      @if (@$record->sex == 1)
                       男
                    @else
                      女
                    @endif
                    
                    <br>{{ $record->province }}<br>{{ $record->city }}
                    </td>
                    </td>
                   <td>{{ $record->open_id }}<br>{{ $record->inventory_open_id }}<br>
                       <p style='text-align:left;'>授权时间:{{ $record->created_at }}</p>
                       <p style='text-align:left;'>抽奖时间:{{ $record->presale_created_at }}</p>
                       <p style='text-align:left;'>下单时间:{{ $record->pay_created_at }}</p>
                       <p style='text-align:left;'>支付时间:{{ $record->actual_pay_time }}</p>
                    </td>
                    <td>
                    @if (@$record->group_type=='single')
                       单人课程
                    @elseif (@$record->group_type=='spouse')
                      夫妻共读
                    @elseif (@$record->group_type=='ladybro')
                      闺蜜共读
                    @else
                       {{@$record->group_type}}
                    @endif
                    
                    <br>
                    @if (@$record->age_range=='0_3')
                       0~3岁
                    @elseif (@$record->age_range=='4_6')
                      4~6岁
                    @elseif (@$record->age_range=='7_12')
                      7~12岁
                    @else
                    @endif
                    
                    </td>
                    <td>
                    @if ($record->is_pay)  <span style="color:red;font-weight:bold;">是</span> @else 否 @endif
                    
                    <br>
                     @if (@$record->price_tag=='low')
                       低价格
                    @elseif (@$record->price_tag=='high')
                      高价格
                    @elseif (@$record->price_tag=='nomal')
                      低价格
                    @endif
                    <br>
                    {{ $record->discount_amount }}
                    </td>
                    <td></td>
                </tr>
                @endforeach
            </table>

        </div>
        
        <div class="paging">
            总计：{{ $records->total() }}
            {!! $records->appends($params)->links() !!}
         </div>
    </div>
</div>


<script type="text/javascript" src="{{ asset('admin/js/My97DatePicker/WdatePicker.js') }}"></script>
<script>

function user_export()
{
    $('form').attr('action',"{{ route('admin.wx_users.user_export') }}");
    $('form').submit().attr('action','');
}

</script>
@endsection
