DONE: centralize theme color, interactive dashboard, increase winner result, refer TODO

This commit is contained in:
ISMAIL MASSERAN
2026-05-10 11:51:19 +08:00
parent 654a0c9fea
commit fd1baf34c8
47 changed files with 2680 additions and 932 deletions
@@ -37,10 +37,65 @@ class SummaryController extends Controller
$rows = $q->get();
$defaultCashCents = 30000;
$defaultBankCents = 15000;
$outstandingCash = (int) DB::table('voter as v')
->where('v.election_id', $electionId)
->where('v.kehadiran', 1)
->where(function ($outer) use ($electionId) {
$outer->whereExists(function ($sub) use ($electionId) {
$sub->select(DB::raw(1))
->from('result as r')
->whereColumn('r.voter_id', 'v.id')
->where('r.election_id', $electionId);
})->orWhere(function ($q) {
$q->whereNotNull('v.fizikal_registration_verified_at')
->whereRaw('COALESCE(v.saham, 0) < 500');
});
})
->whereNotExists(function ($sub) use ($electionId) {
$sub->select(DB::raw(1))
->from('allowance_payouts as ap')
->whereColumn('ap.voter_id', 'v.id')
->where('ap.election_id', $electionId)
->where('ap.method', 'cash')
->where('ap.status', 'paid');
})
->count();
$outstandingBank = (int) DB::table('voter as v')
->where('v.election_id', $electionId)
->where('v.kehadiran', 2)
->whereExists(function ($sub) use ($electionId) {
$sub->select(DB::raw(1))
->from('result as r')
->whereColumn('r.voter_id', 'v.id')
->where('r.election_id', $electionId);
})
->whereNotExists(function ($sub) use ($electionId) {
$sub->select(DB::raw(1))
->from('allowance_payouts as ap')
->whereColumn('ap.voter_id', 'v.id')
->where('ap.election_id', $electionId)
->where('ap.method', 'bank')
->where('ap.status', 'paid');
})
->count();
$outstandingAllowanceCents = ($outstandingCash * $defaultCashCents) + ($outstandingBank * $defaultBankCents);
return response()->json([
'status' => 'success',
'election_id' => $electionId,
'rows' => $rows,
'outstanding_allowance' => [
'cents' => $outstandingAllowanceCents,
'cash_count' => $outstandingCash,
'bank_count' => $outstandingBank,
'default_cash_cents' => $defaultCashCents,
'default_bank_cents' => $defaultBankCents,
],
]);
}
}