first(); return $department->department_ids; } public function returnCompound($modul,$id, $status){ $department = $this->returnDepartment($id); if($status == 'Belum Bayar'){ if($modul == '06-07'){ $compound = Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get(); }else{ $compound = Compound::where('modul',$modul)->where('status','Belum Bayar')->get(); } }else{ $compound = Compound::where('status','Berbayar')->get(); } $temp = []; foreach($compound as $c){ if(in_array($c->jbkod, (array)$department)) { $temp[] = $c; } } return $temp; } /** * Create compound list interface controller. * * @return json */ public function index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles','Department'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.compound_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function investigation_index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.investigation_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function notice_index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.notice_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function confiscated_index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.confiscated_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function collapsed_index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.collapsed_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function completed_index(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $roles = $user->StaffDetail->Roles->toArray(); $department = $user->StaffDetail->Department; $site = SiteSetting::first(); $baru = count($this->returnCompound('03', $id,'Belum Bayar')); $invest = count($this->returnCompound('04', $id, 'Belum Bayar')); $notice = count($this->returnCompound('05', $id, 'Belum Bayar')); $inven = count($this->returnCompound('06-07', $id, 'Belum Bayar')); $collap = count($this->returnCompound('08', $id, 'Belum Bayar')); $comp = count($this->returnCompound('', $id, 'Berbayar')); return view('officer.compound.completed_index', compact('user','baru','invest','notice','inven','collap','comp','department','site','roles')); } public function viewCompoundHistoryDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); return view('officer.compound_detail.history_detail', compact('user','compound','file','role','site')); } public function viewCompoundDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles','Department'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $faulty = Faulty::with(['DeedLaw' => function($q){ $q->with('Department'); }])->where('_id',$compound->seksyen_kesalahan)->first(); $role = Roles::where('kod',$compound->modul)->first(); $total = ''; $enforcer = ''; if($compound->jumlah_kemaskini_kompaun == ''){ $total = $compound->jumlah_asal_kompaun; }else{ $total = $compound->jumlah_kemaskini_kompaun; } $site = SiteSetting::first(); $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first(); return view('officer.compound_detail.compound_detail', compact('user','compound','akta','faulty','role','total','enforcer','site')); } public function viewCompoundMemoDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $roles = Roles::all(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); return view('officer.compound_detail.memo_detail', compact('user','compound','file','roles','role','site')); } public function viewCompoundEditMemoDetail($kpd, $memo){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $memo = Memo::where('_id',$memo)->first(); $roles = Roles::all(); $site = SiteSetting::first(); return view('officer.compound_detail.compound_memo_edit', compact('user','compound','file','roles','memo','site')); } public function viewCompoundInvestigationDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first(); $akta = DeedLaw::where('akkod',$faulty->akkod)->first(); $role = Roles::where('kod',$compound->modul)->first(); $total = ''; $enforcer = ''; if($compound->jumlah_kemaskini_kompaun == ''){ $total = $compound->jumlah_asal_kompaun; }else{ $total = $compound->jumlah_kemaskini_kompaun; } $site = SiteSetting::first(); $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first(); return view('officer.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site')); } public function viewCompoundNoticeDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); return view('officer.compound_detail.notice_detail', compact('user','compound','file','role','site')); } public function viewCompoundInventoryDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); return view('officer.compound_detail.inventory_detail', compact('user','compound','file','role','site')); } public function viewCompoundAuctionDetail($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); return view('officer.compound_detail.auction_detail', compact('user','compound','file','role','site')); } public function viewTaskIndex($kpd){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Roles'); }])->find($id); $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); $roles = Roles::all(); $staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('jbkod',$user->StaffDetail->jbkod)->get(); $role = Roles::where('kod',$compound->modul)->first(); $site = SiteSetting::first(); $currentS = ''; $s = StaffDetail::where('roles_access','PenguatKuasa')->where('no_badan',$compound->penguatkuasa)->first(); if(!empty($s)){ $currentS = '['.$s->no_badan.'] '.$s->full_name; } return view('officer.compound_detail.compound_job',compact('user','compound','roles','staffs','role','currentS','site')); } public function manualCompound(){ $id = Auth::guard('ofr')->id(); $user = Staff::with(['StaffDetail' => function($q){ $q->with('Department'); }])->find($id); $finalFaulty = []; $site = SiteSetting::first(); $faulty = Faulty::with('Department'); $department = $user->StaffDetail->department_ids; $faulty->whereHas('Department', function($q) use ($department) { $q->whereIn('_id', $department); }); $akta = DeedLaw::orderBy('nama','ASC')->get(); $staff = StaffDetail::whereHas('Department', function($q) use ($department) { $q->whereIn('_id', $department); })->where('roles_access', 'PenguatKuasa'); $faulty = $faulty->get(); $staff = $staff->get(); return view('officer.compound.compound_form',compact('user','site','department','akta','faulty','staff')); } /** * Create generate kpd number controller. * * @return value */ public function generateKPD($uniq_id,$range){ $allowedNumbers = range(0, 9); shuffle($allowedNumbers); $digits = array_rand($allowedNumbers, $range); $number = ''; foreach($digits as $d){ $number .= $allowedNumbers[$d]; } return $uniq_id.$number; } public function storemanualCompound(Request $request){ $id = Auth::guard('ofr')->id(); $user = Staff::with('StaffDetail')->find($id); $faulty = Faulty::where('_id',$request->get('seksyen'))->first(); if(!empty($faulty)){ $kpd = 'KP' . $this->generateKPD($request->get('uniq_id'), 5); $no_siri = $this->generateKPD('', 5); $this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri)); $data = array(); $dataExist = false; do { $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first(); if(!empty($compound)){ $tawaran = ''; if($compound->jumlah_kemaskini_kompaun != ''){ $tawaran = $compound->jumlah_kemaskini_kompaun; }else{ $tawaran = $compound->jumlah_asal_kompaun; } array_push($data, array('kpd' => $kpd, 'jumlah_kompoun' => $tawaran)); $dataExist = true; } }while(!$dataExist); return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!'); }else{ return redirect()->back()->withInput()->with('error_msg', 'Tidak Berjaya! Rekod seksyen kesalahan tidak ditemui!'); } } }