Merged in izzati-feat-agama-bangsa (pull request #294)
tambah bangsa dan agama
This commit is contained in:
@@ -3080,36 +3080,87 @@ class AdminPageController extends Controller
|
||||
|
||||
|
||||
|
||||
public function BilanganPengadai(Request $request){
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['t_gadai','>=',$request->mula],['t_gadai','<=',$request->hingga]])
|
||||
->where('sttebus','=','')
|
||||
->select('nokp','sttebus')
|
||||
->groupBy('nokp')->get();
|
||||
|
||||
$gadai_pluck_nokp = $gadai->pluck('nokp');
|
||||
|
||||
if($request->jenis == 'pekerja'){
|
||||
|
||||
$customers = Customer::on('mysql7')
|
||||
->selectRaw('COUNT(*) AS bilangangadai')
|
||||
->addSelect(DB::connection($cawangan['mysql'])
|
||||
->raw('keterangan as keterangan'))
|
||||
->whereIn('kpbaru', $gadai_pluck_nokp)
|
||||
->orWhereIn('kplama', $gadai_pluck_nokp)
|
||||
->join('pekerjaan','customer.kodkerja','=','pekerjaan.kodkerja')
|
||||
->groupBy('pekerjaan.kodkerja')
|
||||
->get();
|
||||
|
||||
public function BilanganPengadai(Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where('t_gadai', '>=', $request->mula)
|
||||
->where('t_gadai', '<=', $request->hingga)
|
||||
->where('sttebus', '')
|
||||
->select('nokp')
|
||||
->groupBy('nokp')
|
||||
->get();
|
||||
|
||||
$gadai_pluck_nokp = $gadai->pluck('nokp');
|
||||
$jenis = $request->jenis;
|
||||
$filter_value = $request->value ?? null;
|
||||
|
||||
$customers = [];
|
||||
|
||||
if ($jenis === 'pekerja') {
|
||||
$customers = Customer::on('mysql7')
|
||||
->selectRaw('pekerjaan.keterangan, COUNT(*) AS bilangangadai')
|
||||
->whereIn('kpbaru', $gadai_pluck_nokp)
|
||||
->orWhereIn('kplama', $gadai_pluck_nokp)
|
||||
->join('pekerjaan', 'customer.kodkerja', '=', 'pekerjaan.kodkerja')
|
||||
->groupBy('pekerjaan.kodkerja')
|
||||
->get();
|
||||
|
||||
} elseif ($jenis === 'agama') {
|
||||
$agamaMap = [
|
||||
'01' => 'Islam',
|
||||
'02' => 'Hindu',
|
||||
'03' => 'Buddha',
|
||||
'04' => 'Kristian',
|
||||
'05' => 'Lain-lain',
|
||||
'' => 'Tiada Data',
|
||||
];
|
||||
|
||||
$query = Customer::on('mysql7')
|
||||
->selectRaw('kodugama as keterangan, COUNT(*) as bilangangadai')
|
||||
->whereIn('kpbaru', $gadai_pluck_nokp)
|
||||
->orWhereIn('kplama', $gadai_pluck_nokp);
|
||||
|
||||
if ($filter_value) {
|
||||
$query->where('kodugama', $filter_value); // contoh: '01'
|
||||
}
|
||||
|
||||
|
||||
|
||||
$customers = $query->groupBy('kodugama')->get();
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$customer->keterangan = $agamaMap[$customer->keterangan] ?? $customer->keterangan;
|
||||
}
|
||||
|
||||
} elseif ($jenis === 'bangsa') {
|
||||
$bangsaMap = [
|
||||
'M' => 'Melayu',
|
||||
'C' => 'Cina',
|
||||
'I' => 'India',
|
||||
'L' => 'Lain-lain',
|
||||
'' => 'Tiada Data',
|
||||
];
|
||||
|
||||
$query = Customer::on('mysql7')
|
||||
->selectRaw('bangsa as keterangan, COUNT(*) as bilangangadai')
|
||||
->whereIn('kpbaru', $gadai_pluck_nokp)
|
||||
->orWhereIn('kplama', $gadai_pluck_nokp);
|
||||
|
||||
if ($filter_value) {
|
||||
$query->where('bangsa', $filter_value); // contoh: 'M'
|
||||
}
|
||||
|
||||
$customers = $query->groupBy('bangsa')->get();
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$customer->keterangan = $bangsaMap[$customer->keterangan] ?? $customer->keterangan;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($customers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function AkruKeuntunganSebenar(Request $request){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user