| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004 |
- <?php
-
- namespace App\Http\Controllers\Api;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\Api\BaseController;
- use Carbon\Carbon;
-
- use App\Model\Staff;
- use App\Model\StaffDetail;
- use App\Model\Module\Compound;
- use App\Model\Module\Department;
- use App\Model\Module\DeedLaw;
- use App\Model\Module\Faulty;
- use App\Model\Module\ConfidentialFile;
- use App\Model\Module\History;
- use App\Model\Module\SubHistory;
- use App\Model\Module\Memo;
- use App\Model\Module\Attachment;
-
- use App\Jobs\StoreCompound;
- use App\Jobs\StoreCompoundEPBT;
- use App\Jobs\UpdateCompoundPrice;
- use App\Http\Resources\CompoundResource;
-
- class CompoundResourceController extends BaseController
- {
- /**
- * @var ServiceCategory
- */
- protected $compound;
-
- /**
- * ServiceController constructor.
- *
- * @param ServiceCategory $ServiceCategory
- */
- public function __construct(Compound $compound)
- {
- $this->compound = $compound;
- }
-
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- private function searchCompoundAll($jenis,$modul,$status,$start_date,$end_date){
- $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();
-
- }else{
- $end = $dateS->copy()->endOfDay();
- }
-
- $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');
- });
- });
- }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){
-
- $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');
- });
- });
- }else {
- $compound = $compound->where('modul', $modul);
- }
-
- if($status == 'All'){
- $compound = $compound;
- }else {
- $compound = $compound->where('status', $status);
- }
-
- return $compound;
- }
-
- private function filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date){
- if(!empty($start_date)){
- $compound = $this->searchCompoundAll($jenis,$modul,$status,$start_date,$end_date);
- }else{
- $compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status);
- }
-
-
- if($enforcer == 'All'){
- return $compound;
- }else {
- $compound = $compound->where('dikeluarkan', $enforcer);
- return $compound;
- }
- }
-
- 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->whereIn('jbkod',$department);
- }else {
- $compound = $compound->where('seksyen_kesalahan', $faulty);
- return $compound;
- }
- }
-
- 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;
- }
- }
-
- 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;
- }
- }
-
- 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;
- }
- }
-
- 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;
- }
- }
-
- 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;
- }
- }
-
- 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;
- }
- }
-
- 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{
- 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 \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;
- })->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);
- }
-
- /**
- * Show the form for creating a new resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function create()
- {
- //
- }
-
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $data = array();
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- $kpd = 'KP' . $countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- if($request->jenis == 'Parkir'){
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => $kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- ];
- }elseif($request->jenis == 'Pelbagai_KT'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- ];
- }elseif($request->jenis == 'Pelbagai_JPB'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- ];
- }elseif($request->jenis == 'Pelbagai_PA'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- ];
- }
- elseif($request->jenis == 'Pelbagai_LESEN'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- ];
- }
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $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!');
- // }
- }
- }
- }
- }
-
-
- public function storeNotice(Request $request)
- {
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $data = array();
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- $kpd = 'KP' . $countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- if($request->jenis == 'Parkir'){
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => $kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- ];
- }elseif($request->jenis == 'Pelbagai_KT'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- ];
- }elseif($request->jenis == 'Pelbagai_JPB'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- ];
- }
- elseif($request->jenis == 'Pelbagai_LESEN'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- ];
- }
- elseif($request->jenis == 'Pelbagai_PA'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "bil_haiwan" => $request->bil_haiwan,
- ];
- }
-
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $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 notis!');
- // }
- }
- }
- }
- }
-
-
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- //
- }
-
- /**
- * Show the form for editing the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function edit($id)
- {
- //
- }
-
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
-
- public function updateStatusPaymentViaDashboard(Request $request)
- {
- $compound = $this->compound::with('ConfidentialFile')->find($request->id);
- $staff = StaffDetail::find($request->current_id);
- if(!empty($compound) && !empty($staff)){
- if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){
-
- if($compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }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',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- }else{
-
- if($compound->status != 'Berbayar' && $compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }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',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
- }
- }else{
- $response = [
- 'success' => false,
- 'message' => 'Kompaun ini tidak dijumpai / staff tidak ditemui',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- }
|