Quellcode durchsuchen

JPB & KT

master
Siti Rahayu vor 5 Jahren
Ursprung
Commit
854162a641

+ 203
- 61
app/Http/Controllers/Api/CompoundResourceController.php Datei anzeigen

@@ -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);
}

/**

+ 29
- 20
app/Http/Resources/CompoundResource.php Datei anzeigen

@@ -14,25 +14,34 @@ class CompoundResource extends JsonResource
*/
public function toArray($request)
{
return [
'_id' => $this->_id,
'jenis' => $this->jenis,
'kpd' => $this->kpd,
'no_plate' => $this->no_plate,
'nric' => $this->identity,
'no_daftar_syarikat' => $this->no_daftar_syarikat,
'nama' => $this->nama,
'tarikh_masa' => $this->created_at->format('d/m/Y H:i:s A'),
'kesalahan' => $this->faulty,
'enforcer' => $this->staffdetail,
'status' => $this->status,
'jumlah_asal_kompaun' => $this->jumlah_asal_kompaun,
'jumlah_kemaskini_kompaun' => $this->jumlah_kemaskini_kompaun,
'catatan_dari_admin' => $this->catatan_dari_admin,
'updated_by' => $this->updateby,
'amount_payment' => $this->amount_payment,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
'updated_at' => $this->updated_at->format('Y-m-d H:i'),
];
if($this->faulty != null && $this->staffdetail != null){

return [
'_id' => $this->_id,
'modul' => $this->modul,
'jenis' => $this->jenis,
'kpd' => $this->kpd,
'no_plate' => $this->no_plate,
'nric' => $this->identity,
'no_daftar_syarikat' => $this->no_daftar_syarikat,
'nama_syarikat' => $this->nama_syarikat,
'nama' => $this->nama,
'lesen' => $this->no_akaun_lesen,
'tarikh_masa' => $this->created_at->format('d/m/Y H:i:s A'),
'faulty_skter' => $this->faulty->sketr,
'faulty_name' => $this->faulty->nama,
'enforcer' => $this->staffdetail->no_badan.', '.$this->staffdetail->full_name,
'status' => $this->status,
'kadar_kompaun' => $this->jumlah_kemaskini_kompaun !== '' ? $this->jumlah_kemaskini_kompaun : $this->jumlah_asal_kompaun,
'catatan_dari_admin' => $this->catatan_dari_admin,
'updated_by' => $this->updateby,
'updates_by' => $this->update_by,
'tarikh_bayar' => $this->tarikh_bayar,
'amount_payment' => $this->amount_payment,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
'updated_at' => $this->updated_at->format('Y-m-d H:i'),
];
}
}
}

+ 2
- 0
resources/views/main-dashboard/compound/_part/filter_form.blade.php Datei anzeigen

@@ -20,6 +20,8 @@
<select class="form-control form-control-sm" name="type" id="type_C" required>
<option value="Parkir">Parkir</option>
<option value="Pelbagai">Pelbagai</option>
<option value="Pelbagai_JPB">Pelbagai JPB</option>
<option value="Pelbagai_KT">Pelbagai KT</option>
</select>
</div>
</div>

+ 1
- 1
resources/views/main-dashboard/compound/_part/menu_category.blade.php Datei anzeigen

@@ -27,7 +27,7 @@
<div class="panel-body">
<div class="{{ Request::is('main/compound') ? 'menu-active' : 'menu' }}"><a href="/main/compound">Semua Kompaun</a>&nbsp;<label class="badge badge-success">{{ $semua }} </label></div>

<div class="{{ Request::is('main/compound/new') ? 'menu-active' : 'menu' }}"><a href="/main/compound/new">Baru (03)</a>&nbsp;<label class="badge badge-success">{{ $baru }}</label></div>
<div class="{{ Request::is('main/compound/new') ? 'menu-active' : 'menu' }}"><a href="/main/compound/new">Baru (02-03)</a>&nbsp;<label class="badge badge-success">{{ $baru }}</label></div>

<div class="{{ Request::is('main/compound/investigation') ? 'menu-active' : 'menu' }}"><a href="/main/compound/investigation">Pengesahan Kompaun (04)</a>&nbsp;<label class="badge badge-success">{{ $invest }}</label></div>


+ 18
- 4
resources/views/main-dashboard/compound/compound_index.blade.php Datei anzeigen

@@ -240,6 +240,20 @@
$('#viewParkir').hide();
tablePl.ajax.url(SITEURL +'/api/list/compound'+ queryString2).load();
}
else if($('#type_C').val() == "Pelbagai_JPB"){
queryString2 = '?'+form_data;
$('#viewPelbagai').show();
$('#viewParkir').hide();
tablePl.ajax.url(SITEURL +'/api/list/compound'+ queryString2).load();
}
else if($('#type_C').val() == "Pelbagai_KT"){
queryString2 = '?'+form_data;
$('#viewPelbagai').show();
$('#viewParkir').hide();
tablePl.ajax.url(SITEURL +'/api/list/compound'+ queryString2).load();
}
console.log(SITEURL +'/api/list/compound'+ queryString1);
console.log(SITEURL +'/api/list/compound'+ queryString2);
@@ -300,12 +314,12 @@
function getDetail(id) {
$('#datePay').hide();
$('#id').val(id);
if($('#type_C').val() == 'Pelbagai'){
$('#datePay').show();
$('#tarikh_bayar').prop('required', true);
}else {
if($('#type_C').val() == 'Parkir'){
$('#datePay').hide();
$('#tarikh_bayar').prop('required', false);
}else {
$('#datePay').show();
$('#tarikh_bayar').prop('required', true);
}
$('#kemaskiniC').modal({

Laden…
Abbrechen
Speichern