|
|
@@ -56,45 +56,51 @@ class CompoundResourceController extends BaseController |
|
|
|
$end = $dateS->copy()->endOfDay(); |
|
|
|
} |
|
|
|
|
|
|
|
if($modul == '06-07'){ |
|
|
|
$compound = Compound::where(function($q){ |
|
|
|
$compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start, $end)); |
|
|
|
|
|
|
|
if($modul == 'All'){ |
|
|
|
$compound = $compound; |
|
|
|
}else if($modul == '06-07'){ |
|
|
|
$compound = $compound->where(function($q){ |
|
|
|
$q->where(function($query){ |
|
|
|
$query->where('modul', '06')->orWhere('modul','07'); |
|
|
|
}); |
|
|
|
})->where('status', $status)->where('jenis', $jenis)->whereBetween('created_at', array($start, $end)); |
|
|
|
}else if($status != 'Berbayar'){ |
|
|
|
if($status == 'All'){ |
|
|
|
$compound = Compound::where('modul', $modul)->where('status','!=','Berbayar')->where('jenis', $jenis) |
|
|
|
->whereBetween('created_at', array($start, $end)); |
|
|
|
}else{ |
|
|
|
$compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis) |
|
|
|
->whereBetween('created_at', array($start, $end)); |
|
|
|
} |
|
|
|
// $compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis) |
|
|
|
// ->whereBetween('created_at', array($start, $end)); |
|
|
|
}else{ |
|
|
|
$compound = Compound::where('status', $status)->where('jenis', $jenis) |
|
|
|
->whereBetween('created_at', array($start, $end)); |
|
|
|
}); |
|
|
|
}else { |
|
|
|
$compound = $compound->where('modul', $modul); |
|
|
|
} |
|
|
|
|
|
|
|
if($status == 'All'){ |
|
|
|
$compound = $compound; |
|
|
|
}else { |
|
|
|
$compound = $compound->where('status', $status); |
|
|
|
} |
|
|
|
|
|
|
|
return $compound; |
|
|
|
} |
|
|
|
|
|
|
|
private function searchCompoundAllWithoutDate($jenis,$modul,$status){ |
|
|
|
if($modul == '06-07'){ |
|
|
|
$compound = Compound::where(function($q){ |
|
|
|
|
|
|
|
$compound = Compound::where('jenis', $jenis); |
|
|
|
|
|
|
|
if($modul == 'All'){ |
|
|
|
$compound = $compound; |
|
|
|
}else if($modul == '06-07'){ |
|
|
|
$compound = $compound->where(function($q){ |
|
|
|
$q->where(function($query){ |
|
|
|
$query->where('modul', '06')->orWhere('modul','07'); |
|
|
|
}); |
|
|
|
})->where('status', $status)->where('jenis', $jenis); |
|
|
|
}else if($status != 'Berbayar'){ |
|
|
|
if($status == 'All'){ |
|
|
|
$compound = Compound::where('modul', $modul)->where('status','!=','Berbayar')->where('jenis', $jenis); |
|
|
|
}else{ |
|
|
|
$compound = Compound::where('modul', $modul)->where('status', $status)->where('jenis', $jenis); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
$compound = Compound::where('status', $status)->where('jenis', $jenis); |
|
|
|
}); |
|
|
|
}else { |
|
|
|
$compound = $compound->where('modul', $modul); |
|
|
|
} |
|
|
|
|
|
|
|
if($status == 'All'){ |
|
|
|
$compound = $compound; |
|
|
|
}else { |
|
|
|
$compound = $compound->where('status', $status); |
|
|
|
} |
|
|
|
|
|
|
|
return $compound; |
|
|
|
} |
|
|
|
|
|
|
@@ -105,6 +111,7 @@ class CompoundResourceController extends BaseController |
|
|
|
$compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($enforcer == 'All'){ |
|
|
|
return $compound; |
|
|
|
}else { |
|
|
@@ -113,65 +120,200 @@ class CompoundResourceController extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date){ |
|
|
|
private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department){ |
|
|
|
$compound = $this->filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
if($faulty == 'All'){ |
|
|
|
return $compound; |
|
|
|
return $compound->whereIn('jbkod',$department); |
|
|
|
}else { |
|
|
|
$compound = $compound->where('seksyen_kesalahan', $faulty); |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function index(Request $request) |
|
|
|
{ |
|
|
|
// |
|
|
|
$per_page = $request->per_page; |
|
|
|
$kpd = $request->kpd; |
|
|
|
private function searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no){ |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department); |
|
|
|
if(!empty($plate_no)){ |
|
|
|
$compound = $compound->where('no_plate',$plate_no); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$modul = $request->modul; |
|
|
|
$status = $request->status; |
|
|
|
$jenis = $request->type; |
|
|
|
private function searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd){ |
|
|
|
$compound = $this->searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no); |
|
|
|
if(!empty($kpd)){ |
|
|
|
$compound = $compound->where('kpd',$kpd); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
$compound = $compound->whereIn('status', ['Belum Bayar', 'Berbayar', 'Batal']); |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$start_date = $request->start_date; |
|
|
|
$end_date = $request->end_date; |
|
|
|
private function searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no){ |
|
|
|
$compound = $this->searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd); |
|
|
|
if(!empty($company_no)){ |
|
|
|
$compound = $compound->where('no_daftar_syarikat','LIKE',$company_no); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$enforcer = $request->enforcer; |
|
|
|
$faulty = $request->faulty; |
|
|
|
private function searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric){ |
|
|
|
$compound = $this->searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no); |
|
|
|
if(!empty($nric)){ |
|
|
|
$compound = $compound->where('identity',$nric); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$plate_no = strtolower($request->plate_no); |
|
|
|
$company_no = strtolower($request->company_no); |
|
|
|
$nric = $request->nric; |
|
|
|
private function searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license){ |
|
|
|
$compound = $this->searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric); |
|
|
|
if(!empty($license)){ |
|
|
|
$compound = $compound->where('no_akaun_lesen', 'exists', true)->where('no_akaun_lesen',$license); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$nested_data = array(); |
|
|
|
private function searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP){ |
|
|
|
$compound = $this->searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license); |
|
|
|
if(!empty($namaP)){ |
|
|
|
$compound = $compound->where('nama', 'LIKE', "%{$namaP}%"); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!empty($plate_no)) { |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
$compound = $compound->where('no_plate',$plate_no)->orderBy('created_at','ASC')->get(); |
|
|
|
}else if(!empty($kpd)){ |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
$compound = $compound->where('kpd',$kpd)->orderBy('created_at','ASC')->get(); |
|
|
|
}else if(!empty($company_no)){ |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
$compound = $compound->where('no_daftar_syarikat',$company_no)->orderBy('created_at','ASC')->get(); |
|
|
|
}else if(!empty($nric)){ |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
$compound = $compound->where('identity',$nric)->orderBy('created_at','ASC')->get(); |
|
|
|
private function searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name){ |
|
|
|
$compound = $this->searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP); |
|
|
|
if(!empty($company_name)){ |
|
|
|
$compound = $compound->where('nama_syarikat', 'exists', true)->where('nama_syarikat', 'LIKE', '%{$company_name%}'); |
|
|
|
return $compound; |
|
|
|
}else{ |
|
|
|
$compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date); |
|
|
|
$compound = $compound->orderBy('created_at','ASC')->get(); |
|
|
|
return $compound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function index(Request $request) |
|
|
|
{ |
|
|
|
|
|
|
|
$per_page = ''; |
|
|
|
$kpd = ''; |
|
|
|
|
|
|
|
$modul = 'All'; |
|
|
|
$status = 'All'; |
|
|
|
$jenis = 'Pelbagai_JPB'; |
|
|
|
if(!empty($request->department)){ |
|
|
|
$department = ["5df721c5cde7fd741433c6b2","5d957899f3da686c08192026","5d9d4a699b802d5a31031a8a","5d9d4db1aa95fa07f7245e28","5d9d5955eb4f92300927f188","5d9e965fec0023467756a02a","5d9eba38e4be2267877896a8"]; |
|
|
|
}else { |
|
|
|
$department = []; |
|
|
|
} |
|
|
|
$start_date = '2020-07-18'; |
|
|
|
$end_date = '2020-08-14'; |
|
|
|
|
|
|
|
$enforcer = 'All'; |
|
|
|
$faulty = 'All'; |
|
|
|
|
|
|
|
$plate_no = strtolower(''); |
|
|
|
$company_no = strtolower(''); |
|
|
|
$nric = ''; |
|
|
|
$license = ''; |
|
|
|
$namaP = ''; |
|
|
|
$company_name = ''; |
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
// $per_page = $request->per_page; |
|
|
|
// $kpd = $request->kpd; |
|
|
|
|
|
|
|
// $modul = $request->modul; |
|
|
|
// $status = $request->status; |
|
|
|
// $jenis = $request->type; |
|
|
|
// if(!empty($request->department)){ |
|
|
|
// $department = json_decode($request->department); |
|
|
|
// }else { |
|
|
|
// $department = []; |
|
|
|
// } |
|
|
|
// $start_date = $request->start_date; |
|
|
|
// $end_date = $request->end_date; |
|
|
|
|
|
|
|
// $enforcer = $request->enforcer; |
|
|
|
// $faulty = $request->faulty; |
|
|
|
|
|
|
|
// $plate_no = strtolower($request->plate_no); |
|
|
|
// $company_no = strtolower($request->company_no); |
|
|
|
// $nric = $request->nric; |
|
|
|
// $license = $request->license; |
|
|
|
// $namaP = $request->nameP; |
|
|
|
// $company_name = $request->company_name; |
|
|
|
|
|
|
|
$nested_data = array(); |
|
|
|
|
|
|
|
$compound = $this->searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name)->orderBy('created_at','ASC')->get(); |
|
|
|
|
|
|
|
// return $compound; |
|
|
|
return \DataTables::of(CompoundResource::collection($compound))->addIndexColumn() |
|
|
|
->addColumn('index', function($row) { |
|
|
|
$curr = Carbon::now(); |
|
|
|
$dtC = Carbon::parse($row['created_at'])->setTimezone('Asia/Kuala_Lumpur'); |
|
|
|
|
|
|
|
if($curr->diffInDays($dtC) <= 3){ |
|
|
|
$html = 'New'; |
|
|
|
}else{ $html = ''; } |
|
|
|
return $html; |
|
|
|
})->rawColumns(['index'])->make(true); |
|
|
|
})->addColumn('status_kemaskini', function($row) { |
|
|
|
$data = ''; |
|
|
|
if($row['status'] == 'Berbayar'){ |
|
|
|
|
|
|
|
$data = '<b>'.$row['status'].'</b><div style="margin-top: 8px"><span>Bayaran: </span><br/>'; |
|
|
|
$data .= 'RM '.$row['amount_payment'].'</div>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; |
|
|
|
|
|
|
|
if($row['updated_by'] !== null ){ |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>'; |
|
|
|
}else { |
|
|
|
if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){ |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['tarikh_bayar'].' <br/>'.$row['updates_by'].'</div>'; |
|
|
|
}else { |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['updated_at'].' <br/>'.$row['updates_by'].'</div>'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else if($row['status'] == 'Belum Bayar' && $row['updated_by'] !== null){ |
|
|
|
$data = '<b>'.$row['status'].'</b>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>'; |
|
|
|
}else if($row['status'] == 'Batal' && $row['updated_by'] !== null){ |
|
|
|
$data = '<b>'.$row['status'].'</b>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>'; |
|
|
|
}else if($row['status'] == 'Buang' && $row['updated_by'] !== null){ |
|
|
|
$data = '<b>'.$row['status'].'</b>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; |
|
|
|
$data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>'; |
|
|
|
$data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>'; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$data = $row['status']; |
|
|
|
} |
|
|
|
|
|
|
|
return $data; |
|
|
|
})->addColumn('kesalahan', function($row) { |
|
|
|
$data = '<b>Seksyen '.$row['faulty_skter'].'</b><br/>'.$row['faulty_name']; |
|
|
|
return $data; |
|
|
|
})->rawColumns(['index','status_kemaskini','kesalahan'])->make(true); |
|
|
|
} |
|
|
|
|
|
|
|
/** |