@extends('layouts.admin') {{ config('app.name', 'Laravel') }} | Student | Details @section('main-content') @php if (!function_exists('dateformatter')) { function dateformatter($date1) { $year1 = substr($date1, 0, 4); $month1 = substr($date1, 5, 2); $day1 = substr($date1, 8, 2); return $day1 . '-' . $month1 . '-' . $year1; } } if (!function_exists('calculate_age')) { function calculate_age($dateOfBirth) { return \Carbon\Carbon::parse($dateOfBirth)->age; } } @endphp @php use Illuminate\Support\Carbon; // GROUP INVOICES BY LAST 6 MONTHS $filteredInvoices = $fee_dates ->sortByDesc(function ($inv) { return $inv->payment_date ?? $inv->created_at; }) ->take(60); // take a safe limit $monthlySummary = []; $statusSummary = []; foreach ($filteredInvoices as $invoice) { $month = Carbon::parse($invoice->payment_date ?? $invoice->created_at)->format('M Y'); if (!isset($monthlySummary[$month])) { $monthlySummary[$month] = ['total_fee' => 0, 'paid' => 0, 'remaining' => 0]; $statusSummary[$month] = ['Completed' => 0, 'Pending' => 0, 'Partial' => 0, 'paid_amount' => 0]; } // Table 1 $monthlySummary[$month]['total_fee'] += (float) $invoice->total_fee; $monthlySummary[$month]['paid'] += (float) $invoice->amountpaid; $monthlySummary[$month]['remaining'] += (float) $invoice->remaining_fee; // Table 2 $status = ucfirst($invoice->payment_status); if (isset($statusSummary[$month][$status])) { $statusSummary[$month][$status]++; $statusSummary[$month]['paid_amount'] += (float) $invoice->amountpaid; } } // Take only latest 6 months $monthlySummary = array_slice($monthlySummary, 0, 6, true); $statusSummary = array_slice($statusSummary, 0, 6, true); if (!function_exists('calculate_age_full')) { function calculate_age_full($dob) { if (empty($dob)) { return 'N/A'; } $birthDate = Carbon::parse($dob); $now = Carbon::now(); $diff = $birthDate->diff($now); $parts = []; if ($diff->y > 0) { $parts[] = $diff->y . ' year' . ($diff->y > 1 ? 's' : ''); } if ($diff->m > 0) { $parts[] = $diff->m . ' month' . ($diff->m > 1 ? 's' : ''); } if ($diff->d > 0) { $parts[] = $diff->d . ' day' . ($diff->d > 1 ? 's' : ''); } // If all 0 (like newborn today) if (empty($parts)) { return '0 days'; } return implode(' ', $parts); } } @endphp
{{-- student Top Section --}}

{{ $student->first_name ?? 'Student' }} {{ $student->last_name }},

I am studying in {{ $child_add_info->student_class }}

🎂 {{ !empty($student->dob) ? dateformatter($student->dob) . ' (' . calculate_age_full($student->dob) . ' old)' : 'N/A' }}

More Details
{{-- {{ dd($student->profile_photo_path) }} --}} Illustration
Fee Status Summary
@if (count($statusSummary)) @foreach ($statusSummary as $month => $data) @endforeach @else @endif
Month Completed Pending Partial
{{ $month }} {{ $data['Completed'] }} {{ $data['Pending'] }} {{ $data['Partial'] }}
No fee status summary data available.
Monthly Fee Breakdown
@if (count($monthlySummary)) @foreach ($monthlySummary as $month => $data) @endforeach @else @endif
Month Total Fee Paid Remaining
{{ $month }} ₹{{ number_format($data['total_fee']) }} ₹{{ number_format($data['paid']) }} ₹{{ number_format($data['remaining']) }}
No monthly fee breakdown data available.
{{-- Monthly Attendance --}}
Monthly Attendance Breakdown
@php $currentMonth = \Carbon\Carbon::now()->format('Y-m'); @endphp

Select a month to view breakdown.

{{-- Pie Chart for Selected Month --}}
Fee Payment Summary
@if (count($monthlyFeeStatus)) @else
No fee data available for the last 6 months.
@endif
{{-- Attendance --}}
Attendance Summary
@if (count($monthlyStats)) @else
No attendance data available for the last 6 months.
@endif
{{-- Documents --}}
Documents
Parent Documents
  • Aadhar Card: @if ($parent->aadhar_card) View @else Not Uploaded @endif
Student Documents
  • Birth Certificate: @if ($child_add_info->birth_certificate) View @else Not Uploaded @endif
  • Vaccination: @if ($child_add_info->vaccination_certificate) View @else Not Uploaded @endif
{{-- Primary Parent Info --}} @if ($parents)

Primary Parent

Parent Photo
{{ $parents->first_name }} {{ $parents->last_name }}

{{ $parents->occupation ?? 'Occupation not specified' }}


📞 Phone: {{ $parents->phone_number ?? 'N/A' }}

📧 Email: {{ $parents->email ?? 'N/A' }}

👪 Relation: {{ $parents->relation ?? 'N/A' }}

🎂 DOB: {{ !empty($parents->dob) ? dateformatter($parents->dob) . ' (' . calculate_age($parents->dob) . ' y/o)' : 'N/A' }}

🚻 Gender: {{ ucfirst($parents->gender ?? 'N/A') }}

@endif {{-- Secondary Parent Info --}} @if (isset($secondary_parent) && !$secondary_parent->isEmpty()) @foreach ($secondary_parent as $secParent) @php $allEmpty = empty($secParent->first_name) && empty($secParent->last_name) && empty($secParent->occupation) && empty($secParent->phone_number) && empty($secParent->email) && empty($secParent->relation) && empty($secParent->dob) && empty($secParent->gender); @endphp
@if ($allEmpty)

Secondary Parent

No Secondary Parent Info Available

@else

Secondary Parent

Parent Photo
{{ $secParent->first_name }} {{ $secParent->last_name }}

{{ $secParent->occupation ?? 'Occupation not specified' }}


📞 Phone: {{ $secParent->phone_number ?? 'N/A' }}

📧 Email: {{ $secParent->email ?? 'N/A' }}

👪 Relation: {{ $secParent->relation ?? 'N/A' }}

🎂 DOB: {{ !empty($secParent->dob) ? dateformatter($secParent->dob) . ' (' . calculate_age($secParent->dob) . ' y/o)' : 'N/A' }}

🚻 Gender: {{ ucfirst($secParent->gender ?? 'N/A') }}

@endif
@endforeach @endif {{-- Guardian Info --}} @if (isset($guardian_parent) && !$guardian_parent->isEmpty()) @foreach ($guardian_parent as $guardian) @php $allEmpty = empty($guardian->first_name) && empty($guardian->last_name) && empty($guardian->occupation) && empty($guardian->phone_number) && empty($guardian->email) && empty($guardian->relation) && empty($guardian->dob) && empty($guardian->gender); @endphp
@if ($allEmpty)

Guardian

No Guardian Info Available

@else

Guardian

Guardian Photo
{{ $guardian->first_name }} {{ $guardian->last_name }}

{{ $guardian->occupation ?? 'Occupation not specified' }}


📞 Phone: {{ $guardian->phone_number ?? 'N/A' }}

📧 Email: {{ $guardian->email ?? 'N/A' }}

👪 Relation: {{ $guardian->relation ?? 'N/A' }}

🎂 DOB: {{ !empty($guardian->dob) ? dateformatter($guardian->dob) . ' (' . calculate_age($guardian->dob) . ' y/o)' : 'N/A' }}

🚻 Gender: {{ ucfirst($guardian->gender ?? 'N/A') }}

@endif
@endforeach @endif
@endsection