| @@ -47,10 +47,10 @@ class CompoundResourceController extends BaseController | |||
| * @return \Illuminate\Http\Response | |||
| */ | |||
| private function searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7){ | |||
| $dateS = Carbon::createFromFormat('Y-m-d', $start_date); | |||
| $start = $dateS->copy()->startOfDay(); | |||
| if($end_date != ''){ | |||
| $dateE = Carbon::createFromFormat('Y-m-d', $end_date); | |||
| $end = $dateE->copy()->endOfDay(); | |||
| @@ -70,8 +70,8 @@ class CompoundResourceController extends BaseController | |||
| else | |||
| { | |||
| $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start, $end)); | |||
| } | |||
| } | |||
| if($modul == 'All'){ | |||
| $compound = $compound; | |||
| }else if($modul == '06-07'){ | |||
| @@ -106,7 +106,7 @@ class CompoundResourceController extends BaseController | |||
| else | |||
| { | |||
| $compound = Compound::where('jenis', $jenis); | |||
| } | |||
| } | |||
| if($modul == 'All'){ | |||
| $compound = $compound; | |||
| @@ -131,13 +131,13 @@ class CompoundResourceController extends BaseController | |||
| } | |||
| private function filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7){ | |||
| if(!empty($start_date)){ | |||
| $compound = $this->searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7); | |||
| }else{ | |||
| $compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status,$day3, $day7); | |||
| } | |||
| if($enforcer == 'All'){ | |||
| @@ -150,7 +150,7 @@ class CompoundResourceController extends BaseController | |||
| private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$day3, $day7){ | |||
| $compound = $this->filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7); | |||
| if($faulty == 'All'){ | |||
| return $compound->whereIn('jbkod',$department); | |||
| }else { | |||
| @@ -172,7 +172,12 @@ class CompoundResourceController extends BaseController | |||
| private function searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$day3, $day7){ | |||
| $compound = $this->searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$day3, $day7); | |||
| if(!empty($kpd)){ | |||
| $compound = $compound->where('kpd',$kpd); | |||
| if($modul == '02'){ | |||
| $compound = $compound->where('kpd',$kpd)->orWhere('non', $kpd); | |||
| } | |||
| else{ | |||
| $compound = $compound->where('kpd',$kpd); | |||
| } | |||
| return $compound; | |||
| }else{ | |||
| $compound = $compound->whereIn('status', ['Belum Bayar', 'Berbayar', 'Batal']); | |||
| @@ -268,7 +273,7 @@ class CompoundResourceController extends BaseController | |||
| // $day3 = 3; | |||
| // $day7 = ''; | |||
| ///////////////////////////////////////////////////////////////////////////////// | |||
| ///////////////////////////////////////////////////////////////////////////////// | |||
| $per_page = $request->per_page; | |||
| $kpd = $request->kpd; | |||
| @@ -301,18 +306,18 @@ class CompoundResourceController extends BaseController | |||
| } | |||
| if ($request->has('day7')) { | |||
| $day3 = $request->day7; //has() checks if param exist and filled | |||
| } | |||
| } | |||
| // if (!empty($start_date)) { | |||
| // } | |||
| $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, $day3, $day7)->orderBy('created_at','ASC')->get(); | |||
| // info($compound); | |||
| return \DataTables::of(CompoundResource::collection($compound))->addIndexColumn() | |||
| @@ -320,7 +325,7 @@ class CompoundResourceController extends BaseController | |||
| $curr = Carbon::now(); | |||
| $dtC = Carbon::parse($row['created_at'])->setTimezone('Asia/Kuala_Lumpur'); | |||
| if($curr->diffInDays($dtC) <= 3){ | |||
| if($curr->diffInDays($dtC) <= 3){ | |||
| $html = 'New'; | |||
| }else{ $html = ''; } | |||
| return $html; | |||
| @@ -331,13 +336,13 @@ class CompoundResourceController extends BaseController | |||
| if ($row['modul'] == '02') { | |||
| $data = '<b>Selesai</b><div style="margin-top: 8px"><span></span><br/></div>'; | |||
| $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; | |||
| $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>'; | |||
| } | |||
| else{ | |||
| $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>'; | |||
| } | |||
| $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/>'; | |||
| @@ -350,18 +355,18 @@ class CompoundResourceController extends BaseController | |||
| $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>'; | |||
| $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>'; | |||
| $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>'; | |||
| @@ -398,7 +403,7 @@ class CompoundResourceController extends BaseController | |||
| //check the lastest compound number stored in dbase filtered by jenis | |||
| $compound = Compound::where('jenis', $jenis)->withTrashed()->latest()->first(); | |||
| //sanitize compound number to return only integer | |||
| $kpd = filter_var($compound['kpd'], FILTER_SANITIZE_NUMBER_INT); | |||
| @@ -421,11 +426,11 @@ class CompoundResourceController extends BaseController | |||
| $kpd = '0'.$kpd; | |||
| } | |||
| }while(!empty(Compound::where('jenis', $jenis)->where('kpd', $tag.$kpd)->first())); | |||
| }while(!empty(Compound::where('jenis', $jenis)->where('kpd', $tag.$kpd)->first())); | |||
| } | |||
| //return kpd with tag | |||
| //return kpd with tag | |||
| $kpd = $tag . $kpd; | |||
| return $kpd; | |||
| @@ -455,8 +460,8 @@ class CompoundResourceController extends BaseController | |||
| if($request->jenis == 'Parkir') | |||
| { | |||
| if(!empty($faulty)){ | |||
| if(!empty($faulty)){ | |||
| $countKPD = $this->compound->withTrashed()->count(); | |||
| do { | |||
| @@ -502,18 +507,18 @@ class CompoundResourceController extends BaseController | |||
| "penguatkuasa" => '-', | |||
| "cpn_created" => Carbon::now()->toDateTimeString(), | |||
| ]; | |||
| $file = ConfidentialFile::create($fileData); | |||
| $saved = $file->compound()->create($compoundData); | |||
| } | |||
| }elseif(($request->jenis == 'Pelbagai_KT') || ($request->jenis == 'Pelbagai_JPB') || ($request->jenis == 'Pelbagai_PA') || ($request->jenis == 'Pelbagai_LESEN')){ | |||
| $kpd = $request->kpd; | |||
| $compound = Compound::where('jenis', $request->jenis)->where('kpd', $kpd)->first(); | |||
| info($compound); | |||
| if (!empty($compound)) { | |||
| $saved = ''; | |||
| @@ -521,7 +526,7 @@ class CompoundResourceController extends BaseController | |||
| if($compound->modul != '03') | |||
| { | |||
| if($request->jenis == 'Pelbagai_KT'){ | |||
| $compound->jenis = $request->jenis; | |||
| $compound->nama = $request->namaP; | |||
| $compound->identity = $request->noIc; | |||
| @@ -544,7 +549,7 @@ class CompoundResourceController extends BaseController | |||
| $compound->no_telefon = $request->tel; | |||
| $compound->no_akaun_lesen = $request->lesen; | |||
| $compound->cpn_created = Carbon::now()->toDateTimeString(); | |||
| }elseif($request->jenis == 'Pelbagai_JPB'){ | |||
| $compound->jenis = $request->jenis; | |||
| @@ -569,10 +574,10 @@ class CompoundResourceController extends BaseController | |||
| $compound->no_telefon = $request->tel; | |||
| $compound->no_akaun_lesen = $request->lesen; | |||
| $compound->cpn_created = Carbon::now()->toDateTimeString(); | |||
| }elseif($request->jenis == 'Pelbagai_PA'){ | |||
| $compound->jenis = $request->jenis; | |||
| $compound->nama = $request->namaP; | |||
| $compound->identity = $request->noIc; | |||
| @@ -596,10 +601,10 @@ class CompoundResourceController extends BaseController | |||
| $compound->no_akaun_lesen = $request->lesen; | |||
| $compound->bil_haiwan = $request->lesen; | |||
| $compound->cpn_created = Carbon::now()->toDateTimeString(); | |||
| }elseif($request->jenis == 'Pelbagai_LESEN'){ | |||
| $compound->jenis = $request->jenis; | |||
| $compound->nama = $request->namaP; | |||
| $compound->identity = $request->noIc; | |||
| @@ -622,7 +627,7 @@ class CompoundResourceController extends BaseController | |||
| $compound->no_telefon = $request->tel; | |||
| $compound->no_akaun_lesen = $request->lesen; | |||
| $compound->cpn_created = Carbon::now()->toDateTimeString(); | |||
| } | |||
| $saved = $compound->save(); | |||
| @@ -644,20 +649,20 @@ class CompoundResourceController extends BaseController | |||
| // $tawaran = $compound->jumlah_asal_kompaun; | |||
| // } | |||
| $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri)); | |||
| array_push($data, array('kpd' => $kpd)); | |||
| $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama)); | |||
| return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!'); | |||
| // } | |||
| } | |||
| } | |||
| } | |||
| else{ | |||
| return $this->sendResponse('', 'Kompaun ini tidak dijumpai!'); | |||
| } | |||
| } | |||
| return $this->sendResponse('', 'Kompaun ini tidak dijumpai!'); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -702,10 +707,10 @@ class CompoundResourceController extends BaseController | |||
| if($request->jenis == 'Parkir'){ | |||
| //for compound numbering | |||
| $countKPD = $this->compound->withTrashed()->count(); | |||
| $countKPD = $this->compound->withTrashed()->count(); | |||
| $no_siri = date('yn').'-'.$countKPD.'-0'; | |||
| $compoundData = [ | |||
| 'jenis' => 'Parkir', | |||
| 'kpd' => 'KPD'.$countKPD, | |||
| @@ -781,7 +786,7 @@ class CompoundResourceController extends BaseController | |||
| }elseif($request->jenis == 'Pelbagai_JPB'){ | |||
| $kpd = $this->generateCompoundNumber($request->jenis, 'JPB'); | |||
| $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-2'; | |||
| $compoundData = [ | |||
| @@ -823,8 +828,8 @@ class CompoundResourceController extends BaseController | |||
| elseif($request->jenis == 'Pelbagai_LESEN'){ | |||
| //HN bcs other N stands for notice. compound number no need front N | |||
| $kpd = $this->generateCompoundNumber($request->jenis, 'HN'); | |||
| $kpd = $this->generateCompoundNumber($request->jenis, 'HN'); | |||
| $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-3'; | |||
| $compoundData = [ | |||
| @@ -864,7 +869,7 @@ class CompoundResourceController extends BaseController | |||
| elseif($request->jenis == 'Pelbagai_PA'){ | |||
| $kpd = $this->generateCompoundNumber($request->jenis, 'PA'); | |||
| $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-4'; | |||
| $compoundData = [ | |||
| @@ -925,7 +930,7 @@ class CompoundResourceController extends BaseController | |||
| return $this->sendResponse($data, 'Berjaya simpan rekod notis!'); | |||
| // } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -947,11 +952,11 @@ class CompoundResourceController extends BaseController | |||
| $data = array(); | |||
| $faulty = Faulty::where('_id',$request->get('seksyen'))->first(); | |||
| if(!empty($faulty)){ | |||
| if(!empty($faulty)){ | |||
| $kpd = ''; | |||
| $no_siri =''; | |||
| $no_siri =''; | |||
| // $countKPD = $this->compound->withTrashed()->count(); | |||
| // do { | |||
| @@ -968,7 +973,7 @@ class CompoundResourceController extends BaseController | |||
| if($request->jenis == 'Parkir') | |||
| { | |||
| //for compound numbering | |||
| $countKPD = $this->compound->withTrashed()->count(); | |||
| $countKPD = $this->compound->withTrashed()->count(); | |||
| $no_siri = date('yn').'-'.$countKPD.'-0'; | |||
| @@ -1171,12 +1176,12 @@ class CompoundResourceController extends BaseController | |||
| $fileData = [ | |||
| 'no_siri' => $no_siri, | |||
| ]; | |||
| $file = ConfidentialFile::create($fileData); | |||
| $saved = $file->compound()->create($compoundData); | |||
| if($saved){ | |||
| // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); | |||
| // if(!empty($compound)){ | |||
| @@ -1190,16 +1195,16 @@ class CompoundResourceController extends BaseController | |||
| // } | |||
| $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri)); | |||
| array_push($data, array('kpd' => $kpd)); | |||
| $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama)); | |||
| return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!'); | |||
| } | |||
| } | |||
| return $this->sendResponse('Tidak Berjaya!', 'Kesalahan tidak dijumpai!'); | |||
| } | |||
| } | |||
| return $this->sendResponse('Tidak Berjaya!', 'Kesalahan tidak dijumpai!'); | |||
| } | |||
| } | |||
| @@ -1250,7 +1255,7 @@ class CompoundResourceController extends BaseController | |||
| $compound->catatan_dari_admin = $request->remark; | |||
| $compound->update_by = $request->current_id; | |||
| $saved = $compound->save(); | |||
| if($saved){ | |||
| $gDate = $compound->created_at->format('F Y'); | |||
| @@ -1278,7 +1283,7 @@ class CompoundResourceController extends BaseController | |||
| }else{ | |||
| return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun/Notis DiBatalkan" '); | |||
| } | |||
| }else{ | |||
| $response = [ | |||
| 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini', | |||
| @@ -1332,7 +1337,7 @@ class CompoundResourceController extends BaseController | |||
| } | |||
| } | |||
| }else{ | |||
| if($compound->status != 'Berbayar' && $compound->status != $request->status){ | |||
| @@ -1341,7 +1346,7 @@ class CompoundResourceController extends BaseController | |||
| // $compound->amount_payment = $request->amount; | |||
| $compound->update_by = $request->current_id; | |||
| $saved = $compound->save(); | |||
| if($saved){ | |||
| $gDate = $compound->created_at->format('F Y'); | |||
| @@ -1369,7 +1374,7 @@ class CompoundResourceController extends BaseController | |||
| }else{ | |||
| return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk notis ini di modul kategori "Kompaun/Notis DiBatalkan" '); | |||
| } | |||
| }else{ | |||
| $response = [ | |||
| 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini', | |||
| @@ -1446,7 +1451,7 @@ class CompoundResourceController extends BaseController | |||
| $compound->amount_payment = $request->amount; | |||
| $compound->update_by = $request->current_id; | |||
| $saved = $compound->save(); | |||
| if($saved){ | |||
| $gDate = $compound->created_at->format('F Y'); | |||
| @@ -1474,7 +1479,7 @@ class CompoundResourceController extends BaseController | |||
| }else{ | |||
| return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" '); | |||
| } | |||
| }else{ | |||
| $response = [ | |||
| 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini', | |||
| @@ -1528,7 +1533,7 @@ class CompoundResourceController extends BaseController | |||
| } | |||
| } | |||
| }else{ | |||
| if($compound->status != 'Berbayar' && $compound->status != $request->status){ | |||
| @@ -1537,7 +1542,7 @@ class CompoundResourceController extends BaseController | |||
| $compound->amount_payment = $request->amount; | |||
| $compound->update_by = $request->current_id; | |||
| $saved = $compound->save(); | |||
| if($saved){ | |||
| $gDate = $compound->created_at->format('F Y'); | |||
| @@ -1565,7 +1570,7 @@ class CompoundResourceController extends BaseController | |||
| }else{ | |||
| return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" '); | |||
| } | |||
| }else{ | |||
| $response = [ | |||
| 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini', | |||