DONE: centralize theme color, interactive dashboard, increase winner result, refer TODO
This commit is contained in:
@@ -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,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user