hardcoded election_id on all kehadiran pages
This commit is contained in:
@@ -6,8 +6,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use App\Voter;
|
use App\Voter;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
class FizikalController extends Controller
|
class FizikalController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -15,27 +13,33 @@ class FizikalController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function index($id)
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
$electionId = 8;
|
||||||
$physicals = $this->getFizikalKehadiran($id);
|
|
||||||
$total_physicals = Voter::where('kehadiran', 1)->count();
|
|
||||||
$votes = Voter::where('election_id', $id)->count();
|
|
||||||
$voters = \App\Voter::where('election_id', $id)->get();
|
|
||||||
|
|
||||||
|
// Get only voters who attended physically for election_id = 8
|
||||||
|
$physicals = Voter::where('election_id', $electionId)
|
||||||
|
->where('kehadiran', 1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Total physical attendees
|
||||||
|
$total_physicals = Voter::where('election_id', $electionId)
|
||||||
|
->where('kehadiran', 1)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// Total voters for the election
|
||||||
|
$votes = Voter::where('election_id', $electionId)->count();
|
||||||
|
|
||||||
|
// All voters for the election
|
||||||
|
$voters = Voter::where('election_id', $electionId)->get();
|
||||||
|
|
||||||
|
// Load PDF view
|
||||||
$pdf = App::make('dompdf.wrapper');
|
$pdf = App::make('dompdf.wrapper');
|
||||||
$pdf->loadView('report.fizikal', compact('physicals', 'voters','total_physicals','votes'));
|
$pdf->loadView('report.fizikal', compact('physicals', 'voters', 'total_physicals', 'votes'));
|
||||||
|
|
||||||
return $pdf->stream();
|
return $pdf->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFizikalKehadiran($id)
|
|
||||||
{
|
|
||||||
return \App\Voter::where('kehadiran', 1)->get();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,18 +15,27 @@ class KehadiranController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index($id)
|
public function index($id)
|
||||||
{
|
{
|
||||||
//
|
$electionId = 8; // fixed election ID
|
||||||
$kehadiranAll = $this->getKehadiranAll($id);
|
|
||||||
$totalkehadiranAll = Voter::where('kehadiran','!=', 0)->count();
|
|
||||||
$votes = Voter::where('election_id', $id)->count();
|
|
||||||
$voters = \App\Voter::where('election_id', $id)->get();
|
|
||||||
|
|
||||||
|
$totalkehadiranAll = Voter::where('election_id', $electionId)
|
||||||
|
->whereIn('kehadiran', [1, 2])
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$votes = Voter::where('election_id', $electionId)->count();
|
||||||
|
|
||||||
|
$voters = Voter::where('election_id', $electionId)->get();
|
||||||
|
|
||||||
$pdf = App::make('dompdf.wrapper');
|
$pdf = App::make('dompdf.wrapper');
|
||||||
$pdf->loadView('report.kehadiran-pdf', compact('voters', 'kehadiranAll', 'totalkehadiranAll', 'votes'));
|
$pdf->loadView('report.kehadiran-pdf', compact(
|
||||||
|
'voters',
|
||||||
|
'totalkehadiranAll',
|
||||||
|
'votes'
|
||||||
|
));
|
||||||
return $pdf->stream();
|
return $pdf->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function getKehadiranAll($id)
|
private function getKehadiranAll($id)
|
||||||
{
|
{
|
||||||
return \App\Voter::where('kehadiran','!=', 0)->get();
|
return \App\Voter::where('kehadiran','!=', 0)->get();
|
||||||
|
|||||||
@@ -5,97 +5,33 @@ namespace App\Http\Controllers;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use App\Voter;
|
use App\Voter;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class MayaController extends Controller
|
class MayaController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
public function index()
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function index($id)
|
|
||||||
{
|
{
|
||||||
//
|
$electionId = 8;
|
||||||
$virtuals = $this->getMayaKehadiran($id);
|
|
||||||
$total_virtuals = Voter::where('kehadiran', 2)->count();
|
|
||||||
$votes = Voter::where('election_id', $id)->count();
|
|
||||||
$voters = \App\Voter::where('election_id', $id)->get();
|
|
||||||
|
|
||||||
|
// Only virtual attendees (kehadiran = 2) for election_id = 8
|
||||||
|
$virtuals = Voter::where('election_id', $electionId)
|
||||||
|
->where('kehadiran', 2)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Total virtual attendees
|
||||||
|
$total_virtuals = Voter::where('election_id', $electionId)
|
||||||
|
->where('kehadiran', 2)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// Total voters for election 8
|
||||||
|
$votes = Voter::where('election_id', $electionId)->count();
|
||||||
|
|
||||||
|
// All voters for the election
|
||||||
|
$voters = Voter::where('election_id', $electionId)->get();
|
||||||
|
|
||||||
|
// Load view into PDF
|
||||||
$pdf = App::make('dompdf.wrapper');
|
$pdf = App::make('dompdf.wrapper');
|
||||||
$pdf->loadView('report.maya', compact('virtuals', 'voters','total_virtuals','votes'));
|
$pdf->loadView('report.maya', compact('virtuals', 'voters', 'total_virtuals', 'votes'));
|
||||||
|
|
||||||
return $pdf->stream();
|
return $pdf->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMayaKehadiran($id)
|
|
||||||
{
|
|
||||||
return \App\Voter::where('kehadiran', 2)->get();
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Show the form for creating a new resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the specified resource.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function show($id)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for editing the specified resource.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function edit($id)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param int $id
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function update(Request $request, $id)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function destroy($id)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user