where('identity',$request)->get(); return $compound; } public function searchKpd($request){ $compound = Compound::with('Faulty','Department','DeedLaw')->where('kpd','like',$request)->get(); return $compound; } public function searchSyarikat($request){ $compound = Compound::with('Faulty','Department','DeedLaw')->where('no_daftar_syarikat','like',$request)->get(); return $compound; } public function searchPlate($request){ $compound = Compound::with('Faulty','Department','DeedLaw')->where('no_plate','like',$request)->get(); return $compound; } /** * Create search compound controller. * * @return json */ public function viewCompoundPersonal(Request $request) { $compound = array(); $search = $request->search; $api_integrasi = ApiIntegration::where('key', $request->key)->first(); if(!empty($api_integrasi)){ if($api_integrasi->status == 'active'){ if($search != '' && $search != '-'){ if(count($this->searchIdentity($search)) > 0){ $compound = $this->searchIdentity($search); } if(count($this->searchKpd($search)) > 0){ $compound = $this->searchKpd($search); } if(count($this->searchSyarikat($search)) > 0){ $compound = $this->searchSyarikat($search); } if(count($this->searchPlate($search)) > 0){ $compound = $this->searchPlate($search); } $data = array(); if(count($compound) > 0){ foreach($compound as $c){ // $department = Department::where('_id',$c->jbkod)->first(); // $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first(); // $akta = DeedLaw::where('_id',$faulty->deed_law_id)->first(); $cpn_date = ''; $cpn_time = ''; if (!empty($c->cpn_created)) { $cpn_date = Carbon::parse($c->cpn_created)->format("D, d M, 'y"); $cpn_time = Carbon::parse($c->cpn_created)->format("g:i A"); } if($c->jenis == 'Pelbagai_KT'){ array_push($data,array( "_id" => $c->_id, "jenis" => $c->jenis, "kpd"=> $c->kpd, "nama"=> $c->nama, "identity" => $c->identity, "no_tel" => $c->no_tel, "nama_syarikat" => $c->nama_syarikat, "no_daftar_syarikat" => strtoupper($c->no_daftar_syarikat), "no_akaun_lesen" => $c->no_akaun_lesen, "alamat" => $c->alamat, "no_plate" => strtoupper($c->no_plate), "no_cukai_jalan" => $c->no_cukai_jalan, "latlong" => $c->latlong, "nama_kawasan" => $c->nama_kawasan, "nama_taman" => $c->nama_taman, "nama_jalan" => $c->nama_jalan, "jbkod" => $c->Department->jnama, "akta" => $c->DeedLaw->nama, "seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama, "catatan" => $c->catatan, "jumlah_asal_kompaun" => $c->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun, "amount_payment" => $c->amount_payment, "receipt" => $c->receipt, "dikeluarkan" => $c->dikeluarkan, "status" => $c->status, "updated_at" => $c->updated_at->toDateTimeString(), "created_at" => $c->created_at->toDateTimeString(), "notice_created" => $c->notice_created, "cpn_created_date" => $cpn_date, "cpn_created_time" => $cpn_time, )); }else if($c->jenis == 'Pelbagai_JPB'){ array_push($data,array( "_id" => $c->_id, "jenis" => $c->jenis, "kpd"=> $c->kpd, "nama"=> $c->nama, "identity" => $c->identity, "no_tel" => $c->no_tel, "nama_syarikat" => $c->nama_syarikat, "no_daftar_syarikat" => strtoupper($c->no_daftar_syarikat), "no_akaun_lesen" => $c->no_akaun_lesen, "alamat" => $c->alamat, "no_plate" => strtoupper($c->no_plate), "no_cukai_jalan" => $c->no_cukai_jalan, "latlong" => $c->latlong, "nama_kawasan" => $c->nama_kawasan, "nama_taman" => $c->nama_taman, "nama_jalan" => $c->nama_jalan, "jbkod" => $c->Department->jnama, "akta" => $c->DeedLaw->nama, "seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama, "catatan" => $c->catatan, "jumlah_asal_kompaun" => $c->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun, "amount_payment" => $c->amount_payment, "receipt" => $c->receipt, "dikeluarkan" => $c->dikeluarkan, "status" => $c->status, "updated_at" => $c->updated_at->toDateTimeString(), "created_at" => $c->created_at->toDateTimeString(), "notice_created" => $c->notice_created, "cpn_created_date" => $cpn_date, "cpn_created_time" => $cpn_time, )); }else if($c->jenis == 'Pelbagai_LESEN'){ array_push($data,array( "_id" => $c->_id, "jenis" => $c->jenis, "kpd"=> $c->kpd, "nama"=> $c->nama, "identity" => $c->identity, "no_tel" => $c->no_tel, "nama_syarikat" => $c->nama_syarikat, "no_daftar_syarikat" => strtoupper($c->no_daftar_syarikat), "no_akaun_lesen" => $c->no_akaun_lesen, "alamat" => $c->alamat, "no_plate" => strtoupper($c->no_plate), "no_cukai_jalan" => $c->no_cukai_jalan, "latlong" => $c->latlong, "nama_kawasan" => $c->nama_kawasan, "nama_taman" => $c->nama_taman, "nama_jalan" => $c->nama_jalan, "jbkod" => $c->Department->jnama, "akta" => $c->DeedLaw->nama, "seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama, "catatan" => $c->catatan, "jumlah_asal_kompaun" => $c->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun, "amount_payment" => $c->amount_payment, "receipt" => $c->receipt, "dikeluarkan" => $c->dikeluarkan, "status" => $c->status, "updated_at" => $c->updated_at->toDateTimeString(), "created_at" => $c->created_at->toDateTimeString(), "notice_created" => $c->notice_created, "cpn_created_date" => $cpn_date, "cpn_created_time" => $cpn_time, )); }else if($c->jenis == 'Pelbagai_PA'){ array_push($data,array( "_id" => $c->_id, "jenis" => $c->jenis, "kpd"=> $c->kpd, "nama"=> $c->nama, "identity" => $c->identity, "no_tel" => $c->no_tel, "nama_syarikat" => $c->nama_syarikat, "no_daftar_syarikat" => strtoupper($c->no_daftar_syarikat), "no_akaun_lesen" => $c->no_akaun_lesen, "alamat" => $c->alamat, "no_plate" => strtoupper($c->no_plate), "no_cukai_jalan" => $c->no_cukai_jalan, "latlong" => $c->latlong, "nama_kawasan" => $c->nama_kawasan, "nama_taman" => $c->nama_taman, "nama_jalan" => $c->nama_jalan, "jbkod" => $c->Department->jnama, "akta" => $c->DeedLaw->nama, "seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama, "catatan" => $c->catatan, "bil_haiwan" => $c->bil_haiwan, "jumlah_asal_kompaun" => $c->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun, "amount_payment" => $c->amount_payment, "receipt" => $c->receipt, "dikeluarkan" => $c->dikeluarkan, "status" => $c->status, "updated_at" => $c->updated_at->toDateTimeString(), "created_at" => $c->created_at->toDateTimeString(), "notice_created" => $c->notice_created, "cpn_created_date" => $cpn_date, "cpn_created_time" => $cpn_time, )); }else if($c->jenis == 'Parkir'){ array_push($data,array( "_id" => $c->_id, "nama" => $c->nama, "identity" => $c->identity, "jenis" => $c->jenis, "kpd"=> $c->kpd, "no_plate" => strtoupper($c->no_plate), "no_cukai_jalan" => $c->no_cukai_jalan, "jenis_kenderaan" => $c->jenis_kenderaan, "model_kenderaan" => $c->model_kenderaan, "warna_kenderaan" => $c->warna_kenderaan, "nama_taman" => $c->nama_taman, "nama_jalan" => $c->nama_jalan, "no_parking" => $c->no_parking, "latlong" => $c->latlong, "jbkod" => $c->Department->jnama, "akta" => $c->DeedLaw->nama, "seksyen_kesalahan" => "[".$c->Faulty->sketr."] ".$c->Faulty->nama, "jumlah_asal_kompaun" => $c->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $c->jumlah_kemaskini_kompaun, "amount_payment" => $c->amount_payment, "receipt" => $c->receipt, "dikeluarkan" => $c->dikeluarkan, "status" => $c->status, "updated_at" => $c->updated_at->toDateTimeString(), "created_at" => $c->created_at->toDateTimeString(), "notice_created" => $c->notice_created, "cpn_created_date" => $cpn_date, "cpn_created_time" => $cpn_time, )); } } return $this->sendResponse($data, 'Result Found'); }else { return $this->sendResponse('', 'No Result'); } }else{ return $this->sendError('Search field is compulsory!', ''); } }else{ return $this->sendError('Invalid Api Key', ''); } }else{ return $this->sendError('Invalid Api Key', ''); } } /** * Create update compound controller. * * @return json */ public function updatePaymentIntegrasi(Request $request){ $api_integrasi = ApiIntegration::where('key', $request->key)->first(); if(!empty($api_integrasi)){ if($api_integrasi->status == 'active'){ $compound = Compound::with('ConfidentialFile')->where('kpd', $request->kp)->first(); if(!empty($compound)){ if($compound->status != 'Berbayar'){ $compound->status = 'Berbayar'; $compound->receipt = $request->receipt; $compound->amount_payment = $request->amount; $compound->save(); $now = Carbon::now(); $gDate = $now->format('F Y'); $historyData = [ 'tarikh_kumpulan' => $gDate, ]; $subHistory = [ 'no_siri' => $compound->ConfidentialFile->no_siri, 'tajuk' => "Pembayaran kompaun ".$request->orderid." telah dibuat secara 'online'", 'huraian' => "Pembayaran kompaun ".$request->orderid." telah dijelaskan pada hari ini.", ]; $groupByDate = History::where('tarikh_kumpulan', $gDate)->first(); if(!empty($groupByDate)){ $groupByDate->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($groupByDate); }else{ $history = History::create($historyData); $history->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($history); } $kpd = Compound::where('kpd', $request->kp)->first(); $department = Department::where('_id',$kpd->jbkod)->first(); $faulty = Faulty::where('_id',$kpd->seksyen_kesalahan)->first(); $akta = DeedLaw::where('_id',$faulty->deed_law_id)->first(); $data = [ "_id" => $kpd->_id, "kpd"=> $kpd->kpd, "nama"=> $kpd->nama, "identity" => $kpd->identity, "nama_syarikat" => $kpd->nama_syarikat, "no_daftar_syarikat" => $kpd->no_daftar_syarikat, "alamat" => $kpd->alamat, "no_plate" => $kpd->no_plate, "latlong" => $kpd->latlong, "jbkod" => $department->jnama, "akta" => "[".$akta->akkod."] ".$akta->nama, "seksyen_kesalahan" => "[".$faulty->sketr."] ".$faulty->nama, "jumlah_asal_kompaun" => $kpd->jumlah_asal_kompaun, "jumlah_kemaskini_kompaun" => $kpd->jumlah_kemaskini_kompaun, "amount_payment" => $kpd->amount_payment, "receipt" => $kpd->receipt, "dikeluarkan" => $kpd->dikeluarkan, "status" => $kpd->status, "updated_at" => $kpd->updated_at->toDateTimeString(), "created_at" => $kpd->created_at->toDateTimeString(), ]; return $this->sendResponse($data, 'Successfully update compound status'); }else{ return $this->sendResponse('', 'This compound already been paid'); } }else{ return $this->sendError('Record compound not found!', ''); } }else{ return $this->sendError('Invalid Api Key', ''); } }else{ return $this->sendError('Invalid Api Key', ''); } } public function compoundToEPBT() { $compound = Compound::with('Department','DeedLaw','Faulty','StaffDetail')->where('jenis', 'Pelbagai_JPB')->get(); dd($compound); if(!empty($compound)) { $data = []; foreach ($compound as $key => $c) { if($c->jenis == 'Pelbagai_KT') { $data = [ 'no_kom' => $c->kpd, 'jenis' => $c->jenis, 'nama' => $c->nama, 'no_ic' => $c->identity, 'no_tel' => $c->no_telefon, 'nama_syarikat' => $c->nama_syarikat, 'no_daftar_syarikat' => $c->no_daftar_syarikat, 'no_akaun_lesen' => $c->no_akaun_lesen, 'alamat' => $c->alamat, 'jabatan' => $c->Department->jnama, 'seksyen' => '['.$c->DeedLaw->akkod.'] ' . $c->DeedLaw->nama, 'kesalahan'=> '['.$c->Faulty->sketr.'] ' . $c->Faulty->nama, 'catatan' => $c->catatan, 'latlong' => $c->latlong, 'status' =>$c->status, 'amaun_bayar' => $c->amount_payment, 'receipt' => $c->receipt, ]; } if($c->jenis == 'Pelbagai_JPB') { $data = [ 'no_kom' => $c->kpd, 'jenis' => $c->jenis, 'nama' => $c->nama, 'no_ic' => $c->identity, 'no_tel' => $c->no_telefon, 'nama_syarikat' => $c->nama_syarikat, 'no_daftar_syarikat' => $c->no_daftar_syarikat, 'no_akaun_lesen' => $c->no_akaun_lesen, 'alamat' => $c->alamat, 'jabatan' => $c->Department->jnama, 'seksyen' => '['.$c->DeedLaw->akkod.'] ' . $c->DeedLaw->nama, 'kesalahan'=> '['.$c->Faulty->sketr.'] ' . $c->Faulty->nama, 'catatan' => $c->catatan, 'latlong' => $c->latlong, 'status' =>$c->status, 'amaun_bayar' => $c->amount_payment, 'receipt' => $c->receipt, ]; } if($c->jenis == 'Pelbagai_PA') { $data = [ 'no_kom' => $c->kpd, 'jenis' => $c->jenis, 'nama' => $c->nama, 'no_ic' => $c->identity, 'no_tel' => $c->no_telefon, 'nama_syarikat' => $c->nama_syarikat, 'no_daftar_syarikat' => $c->no_daftar_syarikat, 'no_akaun_lesen' => $c->no_akaun_lesen, 'alamat' => $c->alamat, 'jabatan' => $c->Department->jnama, 'seksyen' => '['.$c->DeedLaw->akkod.'] ' . $c->DeedLaw->nama, 'kesalahan'=> '['.$c->Faulty->sketr.'] ' . $c->Faulty->nama, 'bil_haiwan' => $c->bil_haiwan, 'catatan' => $c->catatan, 'latlong' => $c->latlong, 'status' =>$c->status, 'amaun_bayar' => $c->amount_payment, 'receipt' => $c->receipt, ]; } if($c->jenis == 'Pelbagai_LESEN') { $data = [ 'no_kom' => $c->kpd, 'jenis' => $c->jenis, 'nama' => $c->nama, 'no_ic' => $c->identity, 'no_tel' => $c->no_telefon, 'nama_syarikat' => $c->nama_syarikat, 'no_daftar_syarikat' => $c->no_daftar_syarikat, 'no_akaun_lesen' => $c->no_akaun_lesen, 'alamat' => $c->alamat, 'jabatan' => $c->Department->jnama, 'seksyen' => '['.$c->DeedLaw->akkod.'] ' . $c->DeedLaw->nama, 'kesalahan'=> '['.$c->Faulty->sketr.'] ' . $c->Faulty->nama, 'catatan' => $c->catatan, 'latlong' => $c->latlong, 'status' =>$c->status, 'amaun_bayar' => $c->amount_payment, 'receipt' => $c->receipt, ]; } if($c->jenis == 'Parkir') { $data = [ 'no_kom' => $c->kpd, 'jenis' => $c->jenis, 'nama' => $c->nama, 'no_ic' => $c->identity, 'no_tel' => $c->no_telefon, 'nama_syarikat' => $c->nama_syarikat, 'no_daftar_syarikat' => $c->no_daftar_syarikat, 'no_akaun_lesen' => $c->no_akaun_lesen, 'alamat' => $c->alamat, 'jabatan' => $c->Department->jnama, 'seksyen' => '['.$c->DeedLaw->akkod.'] ' . $c->DeedLaw->nama, 'kesalahan'=> '['.$c->Faulty->sketr.'] ' . $c->Faulty->nama, 'catatan' => $c->catatan, 'latlong' => $c->latlong, 'status' =>$c->status, 'amaun_bayar' => $c->amount_payment, 'receipt' => $c->receipt, ]; } } return $this->sendResponse($data, 'Successfully update compound status'); } } }