@extends('admin_dashboard')
@section('admin')
@php
$date = now()->toDateString();
$current_month = now()->month;
$current_year = now()->year;
// Daily works (today)
use App\Models\DailyWorkInfo;
use App\Models\LegalDocumentInfo;
use App\Models\Group;
use App\Models\Ledger_tran;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
$today = Carbon::today()->toDateString();
$works = DailyWorkInfo::with(['member', 'workType', 'thanksUser'])->whereDate('work_date', $today)->latest()->get();
$documents = LegalDocumentInfo::whereBetween('exp_ren_date', [
Carbon::tomorrow()->startOfDay(),
Carbon::today()->addDays(7)->endOfDay()
])->get();
// Today's group-wise receive & payment
$savingsLedgerCodes = [61, 62, 63, 64, 68, 129];
$groups = Group::orderBy('group_code')->get();
$groupTrans = DB::table('ledger_trans')
->whereDate('created_at', $today)
->whereIn('ledger_code', $savingsLedgerCodes)
->select(
DB::raw('CAST(SUBSTRING(subledger_code, 2, 2) AS UNSIGNED) as group_code'),
DB::raw('SUM(cr_amount) as total_receive'),
DB::raw('SUM(dr_amount) as total_payment')
)
->groupBy(DB::raw('CAST(SUBSTRING(subledger_code, 2, 2) AS UNSIGNED)'))
->get()
->keyBy('group_code');
@endphp
{{-- ── Page header ── --}}
Dashboard
{{ now()->format('l, d F Y') }}
Live
{{-- ── Today's Group Transactions ── --}}
Today's Group Receive & Payment
| # |
Group Name |
Today Receive (৳) |
Today Payment (৳) |
Net (৳) |
@php
$grandReceive = 0;
$grandPayment = 0;
@endphp
@forelse($groups as $key => $group)
@php
$trans = $groupTrans->get($group->group_code);
$receive = $trans ? floatval($trans->total_receive) : 0;
$payment = $trans ? floatval($trans->total_payment) : 0;
$net = $receive - $payment;
$grandReceive += $receive;
$grandPayment += $payment;
@endphp
| {{ $key + 1 }} |
{{ $group->group_code }}
{{ $group->group_name }}
|
{{ $receive > 0 ? number_format($receive, 2) : '—' }}
|
{{ $payment > 0 ? number_format($payment, 2) : '—' }}
|
{{ $net != 0 ? number_format($net, 2) : '—' }}
|
@empty
| No groups found. |
@endforelse
@if($groups->count() > 0)
| TOTAL |
{{ number_format($grandReceive, 2) }} |
{{ number_format($grandPayment, 2) }} |
{{ number_format($grandReceive - $grandPayment, 2) }}
|
@endif
{{-- ── Today's Work ── --}}
Today's Work
| # |
Date |
Manpower |
Work Type |
Detail |
Thanks By |
Remarks |
@forelse($works as $key => $work)
| {{ $key + 1 }} |
{{ \Carbon\Carbon::parse($work->work_date)->format('d-m-Y') }}
|
{{ $work->member->member_name ?? '—' }} |
{{ $work->workType->work_name ?? '—' }}
|
{{ $work->details }} |
{{ $work->thanksUser->name ?? '—' }} |
{{ $work->remarks }} |
@empty
|
No work entries for today.
|
@endforelse
{{-- ── Expiring Documents ── --}}
Documents Expiring Within 7 Days
| # |
Document Type |
Authority Name |
Expiry / Renew Date |
Days Left |
Remarks |
@forelse($documents as $key => $document)
@php
$daysLeft = now()->diffInDays(\Carbon\Carbon::parse($document->exp_ren_date), false);
$badgeClass = $daysLeft <= 2 ? 'background:#fee2e2;color:#991b1b;' : 'background:#fef3c7;color:#92400e;';
@endphp
| {{ $key + 1 }} |
{{ $document->document_type }} |
{{ $document->authority }} |
{{ \Carbon\Carbon::parse($document->exp_ren_date)->format('d-m-Y') }}
|
{{ $daysLeft }} day{{ $daysLeft == 1 ? '' : 's' }}
|
{{ $document->remarks }} |
@empty
|
No documents expiring soon.
|
@endforelse
@endsection