@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>
        <div class="form-group">
            <label>选择应用</label>
            <select class="form-control" name="app_id">
                <option value="0" >全部</option>
                @foreach ($app_list as $id=>$application_title)
                <option value="{{ $id }}" {{ $id == @$params['app_id'] ? 'selected' : '' }}>{{ $application_title}}</option>
                @endforeach
            </select>
        </div>
        <div class="form-group">
            <label>选择省份</label>
            <select class="form-control" name="province_code">
                <option value="-1" >全部</option>
                @foreach ($province_list as $id=>$province)
                <option value="{{ $province['province_code'] }}" {{ $province['province_code'] == @$params['province_code'] ? 'selected' : '' }}>{{ $province['province_name']}}</option>
                @endforeach
            </select>
        </div>
        <div class="form-group">
            <label>渠道号</label>
            <input class="form-control" name="cm" value="{{ @$params['cm'] }}">
        </div>
        <div class="form-group">
            <label>计费代码</label>
            <input class="form-control" name="fee_code" value="{{ @$params['fee_code'] }}">
        </div>
        <div class="form-group">
            <label>商户订单号</label>
            <input class="form-control" name="cp_order_no" value="{{ @$params['cp_order_no'] }}">
        </div>
        <div class="form-group">
            <label>是否支付成功</label>
            <input  type='radio' name="success" value= '100' {{ !isset($params['success']) || @$params['success']==100 ? 'checked' : '' }}>全部
            <input  type='radio' name="success" value= '1' {{ @$params['success']==1 ? 'checked' : '' }}>是
            <input  type='radio' name="success" value= '0' {{ isset($params['success']) && @$params['success']<1 ? 'checked' : '' }}>否
        </div>
        <div class="form-group">
            <label>运营商</label>
            <input  type='radio' name="ptype" value= '100' {{ !isset($params['ptype']) || @$params['ptype']==100 ? 'checked' : '' }}>全部
            <input  type='radio' name="ptype" value= '1' {{ @$params['ptype']==1 ? 'checked' : '' }}>移动
            <input  type='radio' name="ptype" value= '2' {{ @$params['ptype']==2 ? 'checked' : '' }}>联通
        </div>
        <div class="form-group">
            <label>通知状态</label>
            <input  type='radio' name="cp_notify_status" value='100' {{ !isset($params['cp_notify_status']) || @$params['cp_notify_status']==100 ? 'checked' : '' }}>全部(不含优化)
            <input  type='radio' name="cp_notify_status" value='1' {{ @$params['cp_notify_status']==1 ? 'checked' : '' }}>成功
            <input  type='radio' name="cp_notify_status" value='0' {{ isset($params['cp_notify_status']) && @$params['cp_notify_status']==0 ? 'checked' : '' }}>失败
            <input  type='radio' name="cp_notify_status" value='2' {{ @$params['cp_notify_status']==2 ? 'checked' : '' }}>掉单
            <input  type='radio' name="cp_notify_status" value='4' {{ @$params['cp_notify_status']==4 ? 'checked' : '' }}>状态错误
            <input  type='radio' name="cp_notify_status" value='5' {{ @$params['cp_notify_status']==5 ? 'checked' : '' }}>优化
       
        </div>
        <div class="form-group">
            <label>选择时间：</label>
            <input  name="start"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" onClick="WdatePicker()" value="{{ @$params['start'] }}"> -
            <input name="end"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" onClick="WdatePicker()" value="{{ @$params['end'] }}">
        </div>
        <button type="submit" class="btn btn-success">搜索</button>
    </form>
</div>
<div class="alert alert-success">
成功充值总额/总充值总额(占比)：
{{ $total_amount }}/{{ $all_total_amount }}(@if ($total_amount > 0) {{ round($total_amount / $all_total_amount,2) }} @else {{0}} @endif)
<br>
成功确认总额/总确认总额(占比)：
{{ $confirm_amount }}/{{ $all_confirm_amount }}(@if ($confirm_amount > 0) {{ round($confirm_amount / $all_confirm_amount,2) }} @else {{0}} @endif)

</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>应用名称</th>
                    <th>成功订单数量/总订单数量(占比)</th>
                    <th>成功订单总额/总订单总额(占比)</th>
                    <th>成功实收总额/总实收总额(占比)</th>
                </tr>
                @foreach ($all_records as $app_id=>$all_record)
                      @if (isset($records[$app_id]))
	                  <tr>
	                    <td>
	                    <button type="button" href="{{ route('admin.pay_records.order_prov_tj',['app_id'=>@$app_id,'start'=>@$params['start'],'end'=>@$params['end'],'group_type'=>'province'] ) }}" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
                            {{ @$app_list[$app_id] }}
                        </button>
                        </td>
	                    <td>{{ $records[$app_id]->_count }}/{{ $all_record->_count }}(@if ($all_record->_count > 0) {{ round($records[$app_id]->_count / $all_record->_count,2) }} @else {{0}} @endif)</td>
	                    <td>{{ $records[$app_id]->_total }}/{{ $all_record->_total }}(@if ($all_record->_total > 0) {{ round($records[$app_id]->_total / $all_record->_total,2) }} @else {{0}} @endif)</td>
	                    <td>{{ $records[$app_id]->_confirm }}/{{ $all_record->_confirm }}(@if ($all_record->_confirm > 0) {{ round($records[$app_id]->_confirm / $all_record->_confirm,2) }} @else {{0}} @endif)</td>
	                </tr>
	                @else
	                <tr>
	                    <td>
	                    <button type="button" href="{{ route('admin.pay_records.order_prov_tj',['app_id'=>@$app_id,'start'=>@$params['start'],'end'=>@$params['end'],'group_type'=>'province'] ) }}" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
                            {{ @$app_list[$app_id] }}
                        </button>
                        </td>
	                    <td>{{ 0 }}/{{ $all_record->_count }}(@if ($all_record->_count > 0) {{ round(0 / $all_record->_count,2) }} @else {{0}} @endif)</td>
	                    <td>{{ 0 }}/{{ $all_record->_total }}(@if ($all_record->_total > 0) {{ round(0 / $all_record->_total,2) }} @else {{0}} @endif)</td>
	                    <td>{{ 0 }}/{{ $all_record->_confirm }}(@if ($all_record->_confirm > 0) {{ round(0 / $all_record->_confirm,2) }} @else {{0}} @endif)</td>
	                </tr>
	                @endif
                @endforeach
            </table>
        </div>
        
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">详情</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript" src="{{ asset('js/My97DatePicker/WdatePicker.js') }}"></script>
<script>
    $('#myModal').on('hidden.bs.modal',function(e){
        $(this).removeData('bs.modal');
    });

</script>

@endsection
