@extends('layouts.header')

@section('content')
<main>
                    <div class="container-fluid px-4">
                        <h1 class="mt-4">Dashboard</h1>
                        <ol class="breadcrumb mb-4">
                            <li class="breadcrumb-item active">Dashboard</li>
                        </ol>
                         <div class="row">
                            <div class="col-xl-4">
                                <div class="card bg-primary text-white mb-4">
                                    <div class="card-body d-flex align-items-center justify-content-between">
                                        <div class="text-center">
                                            <div class="h5">Sponsor Count</div>
                                            <div class="h2">{{ $sponsorCount }}</div>
                                            <div class="card-footer d-flex align-items-center justify-content-between">
                                        <a class="small text-white stretched-link"  href="{{ route('sponsor.list') }}">View Details</a>
                                        <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                                    </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-4">
                                <div class="card bg-warning text-white mb-4">
                                    <div class="card-body d-flex align-items-center justify-content-between">
                                        <div class="text-center">
                                            <div class="h5">Student Count</div>
                                            <div class="h2">{{ $studentCount }}</div>
                                            <div class="card-footer d-flex align-items-center justify-content-between">
                                        <a class="small text-white stretched-link"  href="{{ route('student.list') }}">View Details</a>
                                        <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                                    </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-4">
                                <div class="card bg-success text-white mb-4">
                                    <div class="card-body d-flex align-items-center justify-content-between">
                                        <div class="text-center">
                                            <div class="h5"> student without sponser</div>
                                            <div class="h2">{{$unmatchedStudentCount}}</div>
                                            <div class="card-footer d-flex align-items-center justify-content-between">
                                        <a class="small text-white stretched-link" href="{{ route('student.unsponserstudent') }}">View  Details</a>
                                        <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                                    </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- <div class="row">
                            <div class="col-xl-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <i class="fas fa-chart-area me-1"></i>
                                        Area Chart Example
                                    </div>
                                    <div class="card-body"><canvas id="myAreaChart" width="100%" height="40"></canvas></div>
                                </div>
                            </div>
                            <div class="col-xl-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <i class="fas fa-chart-bar me-1"></i>
                                        Bar Chart Example
                                    </div>
                                    <div class="card-body"><canvas id="myBarChart" width="100%" height="40"></canvas></div>
                                </div>
                            </div>
                        </div> -->
                          <div class="row">
                           <div class="col-xl-12">
                            <div class="card mb-4">
                            <div class="card-header">
                                <i class="fas fa-table me-1"></i>
                                Payment Details
                            </div>
                            <div class="card-body">
                                <table id="datatablesSimple" class="table">
                                    <thead>
                                        <tr>
                                            <th>Payment ID</th>
                                            <th>Sponsor Name</th>
                                            <th>Student Name</th>
                                            <th>Method</th>
                                            <th>Amount</th>
                                            <th>Received Date</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @php $counter = 1 @endphp 
                                        @foreach($payments as $payment)
                                        <tr>
                                            <td>{{ $counter++ }}</td>
                                            <td>{{ $payment->sponsor->fullName }}</td>
                                            <td>
                @foreach($payment->students as $student)
                    {{ $student->student_name }}<br>
                @endforeach
            </td>
                                            <td>{{ $payment->method }}</td>
                                            <td>{{ $payment->amount }}</td>
                                            <td>{{ $payment->created_at->format('d/m/Y') }}</td>

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



                    <div class="row">
    <div class="col-xl-12">
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-table me-1"></i>
                Due Details
            </div>
            <div class="card-body">
                <table id="datatablesSimple" class="table">
                    <thead>
                        <tr>
                            <th>Payment ID</th>
                            <th>Sponsor Name</th>
                            <th>Student Name</th>
                            <th>Method</th>
                            <th>Amount</th>
                            <th>Balance Amount</th>
                            <th>Received Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($dueList as $sponsor)
                        <!-- {{$sponsors }} -->
                            
                                <tr>
                                    <td>{{ $sponsor->id }}</td>
                                    <td>{{ $sponsor->sponsor->fullName }}</td>
                                    <td>{{ $payment->student->student_name }}</td>
                                    <td>{{ $payment->method }}</td>
                                    <td>{{ $payment->amount }}</td>
                                    <td>{{ max(0, 12000 - $payment->amount) }}</td>
                                    <td>{{ $payment->created_at->format('d/m/Y') }}</td>
                                </tr>
                            @endforeach
                       
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

                </main>
@endsection
