@extends('admin.layout.main')
@section('content')
<div class="row">
    <div class="col-lg-12" style="padding-left: 4px;padding-right: 4px;">
        <div class="card m-b-15" style="border-radius: 5px;">
            <div class="card-header">
                <h5 class="card-title" style="font-weight: bold; padding-top: 15px; font-size: 20px;">Reports</h5>
            </div>

            <div class="card-body" style="padding-bottom: 50px;">
                <form method="post" action="{{url('admin/reposerch')}}">@csrf

                    <div class="row">
                        <div class="col-md-4">
                            <select style="width: 100%;margin-bottom: 10px;height: 38px;" name="rtype" class="form-control">
                                <option value="1">Add Fund</option>
                                <option value="2">Fund Transfer </option>
                                <option value="3">Convert Fund</option>
                                <option value="4">Withdraw</option>
                            </select>
                        </div>

                        <div class="col-md-4">
                            <select style="width: 100%;margin-bottom: 10px;height: 38px;" name="dtype" class="form-control">
                                <option value="1">Today </option>
                                <option value="2">Yesterday </option>
                                <option value="3">Last 3 Days </option>
                                <option value="4">Last 7 Days </option>
                                <option value="5">Last 30 Days </option>
                                <option value="6">Last 365 Days </option>
                                <option value="7">Lifetime </option>
                            </select>
                        </div>

                        <div class="col-md-4">
                            <button style="height: 38px;background: #ec1666;color: #fff;" type="submit" class="btn">Confirm Now</button>
                        </div>
                    </div>

                </form>
            </div>

        </div>

        @if($repo_count > 0)
        <div id="printArea">
            <div style="padding: 10px; background: #042c48;border-radius: 6px;">
                <p style="text-align: center;border-bottom: 1px solid #e4e4e466;padding-bottom: 10px;margin-bottom: 7px;">
                   <span style="font-size:20px;font-weight: 600;">{{$rname}}</span> <br>
                    {{$rtype}} Report
                </p>
                <p style="text-align: center;">
                    Total {{$rname}}: ${{$totalin}}
                </p>
            </div>

            <div class="card m-b-10" style="border-radius: 5px;margin-top: 10px;">
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="datatable" class="display table table-striped table-bordered" style="width: 100%;">
                            <thead style="background: #1f3740;">
                                <tr>
                                    <th style="text-align: center; color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;">No.</th>
                                    <th style="color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;min-width: 150px;">Date</th>
                                    <th style="color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;">Type</th>
                                    <th style="color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;min-width: 110px;">Action</th>
                                    <th style="color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;min-width: 90px;min-width: 200px;">Details</th>
                                    <th style="text-align: center; color: #fff;padding-top: 3px;padding-bottom: 3px;font-size: 13px;min-width: 90px;">Amount</th>

                                </tr>
                            </thead>
                            <tbody>
                                <?php $no=1; ?>
                                @foreach($reports as $repo)
                                <tr>
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;text-align: center; color: #fff;">{{$no++}}</td>
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px; color: #fff;">{{$repo->created_at}}</td>
                                    
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;color: #fff;">{{$repo->bal_type}}</td>
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;color: #fff;">{{$repo->action}}</td>
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;color: #fff;">{{$repo->details}} {{$repo->from_user}}</td>

                                    @if(is_null($repo->bal_out))
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;text-align: center; color: #bdffba;">+{{$repo->bal_in}}</td>
                                    @else
                                    <td style="padding-top: 3px;padding-bottom: 3px;font-size: 13px;text-align: center; color: red;">-{{$repo->bal_out}}</td>
                                    @endif

                                </tr>
                                @endforeach
                            </tbody>                      
                           
                        </table>
                    </div>
                </div>
            </div>

            <a style="color:white;padding: 2px 10px;font-size:15px;background: red;" href="javascript:window.print()"><i class="fa fa-print"></i> Print</a> 
        </div>

        @else
        <div style="padding: 10px; background: #042c48;border-radius: 6px;">
            <p style="text-align: center;border-bottom: 1px solid #e4e4e466;padding-bottom: 10px;margin-bottom: 7px;">
               <span style="font-size:20px;font-weight: 600;">{{$rname}}</span> <br>
                {{$rtype}} Report
            </p>
            <p style="color:#f4a6b4;font-size: 25px;text-align: center;">No Data Available!</p>
        </div>  
        @endif
       
    </div> 
      
</div>
@endsection