Dashboard sipadu mbip
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CompoundController.php 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <?php
  2. namespace App\Http\Controllers\Main;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Auth;
  6. use Carbon\Carbon;
  7. use App\SiteSetting;
  8. use App\Model\Staff;
  9. use App\Model\StaffDetail;
  10. use App\Model\User;
  11. use App\Model\UserDetail;
  12. use App\Model\Module\Roles;
  13. use App\Model\Module\Department;
  14. use App\Model\Module\DeedLaw;
  15. use App\Model\Module\Faulty;
  16. use App\Model\Module\Compound;
  17. use App\Model\Module\CompoundInvestigation;
  18. use App\Model\Module\ConfidentialFile;
  19. use App\Model\Module\History;
  20. use App\Model\Module\SubHistory;
  21. use App\Model\Module\Memo;
  22. use App\Model\Module\Attachment;
  23. use App\Jobs\StoreCompound;
  24. use App\Jobs\StoreCompoundManual;
  25. use App\Jobs\UpdateCompoundPrice;
  26. class CompoundController extends Controller
  27. {
  28. /**
  29. * Create compound list interface controller.
  30. *
  31. * @return json
  32. */
  33. public function index(){
  34. $id = Auth::guard('sadmin')->id();
  35. $user = Staff::with('StaffDetail')->find($id);
  36. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  37. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  38. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  39. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  40. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  41. $comp = count(Compound::where('status','Berbayar')->get());
  42. // $department = Department::all();
  43. $site = SiteSetting::first();
  44. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  45. $faulty = Deedlaw::with('Faulty')->get();
  46. return view('main-dashboard.compound.compound_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  47. }
  48. public function investigation_index(){
  49. $id = Auth::guard('sadmin')->id();
  50. $user = Staff::with('StaffDetail')->find($id);
  51. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  52. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  53. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  54. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  55. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  56. $comp = count(Compound::where('status','Berbayar')->get());
  57. // $department = Department::all();
  58. $site = SiteSetting::first();
  59. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  60. $faulty = Deedlaw::with('Faulty')->get();
  61. return view('main-dashboard.compound.investigation_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  62. }
  63. public function notice_index(){
  64. $id = Auth::guard('sadmin')->id();
  65. $user = Staff::with('StaffDetail')->find($id);
  66. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  67. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  68. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  69. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  70. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  71. $comp = count(Compound::where('status','Berbayar')->get());
  72. // $department = Department::all();
  73. $site = SiteSetting::first();
  74. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  75. $faulty = Deedlaw::with('Faulty')->get();
  76. return view('main-dashboard.compound.notice_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  77. }
  78. public function confiscated_index(){
  79. $id = Auth::guard('sadmin')->id();
  80. $user = Staff::with('StaffDetail')->find($id);
  81. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  82. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  83. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  84. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  85. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  86. $comp = count(Compound::where('status','Berbayar')->get());
  87. // $department = Department::all();
  88. $site = SiteSetting::first();
  89. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  90. $faulty = Deedlaw::with('Faulty')->get();
  91. return view('main-dashboard.compound.confiscated_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  92. }
  93. public function collapsed_index(){
  94. $id = Auth::guard('sadmin')->id();
  95. $user = Staff::with('StaffDetail')->find($id);
  96. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  97. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  98. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  99. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  100. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  101. $comp = count(Compound::where('status','Berbayar')->get());
  102. // $department = Department::all();
  103. $site = SiteSetting::first();
  104. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  105. $faulty = Deedlaw::with('Faulty')->get();
  106. return view('main-dashboard.compound.collapsed_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  107. }
  108. public function completed_index(){
  109. $id = Auth::guard('sadmin')->id();
  110. $user = Staff::with('StaffDetail')->find($id);
  111. $baru = count(Compound::where('modul','03')->where('status','Belum Bayar')->get());
  112. $invest = count(Compound::where('modul','04')->where('status','Belum Bayar')->get());
  113. $notice = count(Compound::where('modul','05')->where('status','Belum Bayar')->get());
  114. $inven = count(Compound::where('modul','06')->orWhere('modul','07')->where('status','Belum Bayar')->get());
  115. $collap = count(Compound::where('modul','08')->where('status','Belum Bayar')->get());
  116. $comp = count(Compound::where('status','Berbayar')->get());
  117. // $department = Department::all();
  118. $site = SiteSetting::first();
  119. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  120. $faulty = Deedlaw::with('Faulty')->get();
  121. return view('main-dashboard.compound.completed_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  122. }
  123. public function viewCompoundHistoryDetail($kpd){
  124. $id = Auth::guard('sadmin')->id();
  125. $user = Staff::with('StaffDetail')->find($id);
  126. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  127. $file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  128. $role = Roles::where('kod',$file->modul)->first();
  129. $site = SiteSetting::first();
  130. return view('main-dashboard.compound_detail.history_detail', compact('user','compound','file','role','site'));
  131. }
  132. public function viewCompoundDetail($kpd){
  133. $id = Auth::guard('sadmin')->id();
  134. $user = Staff::with('StaffDetail')->find($id);
  135. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  136. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  137. $faulty = Faulty::with(['DeedLaw' => function($q){
  138. $q->with('Department');
  139. }])->where('_id',$compound->seksyen_kesalahan)->first();
  140. $role = Roles::where('kod',$compound->modul)->first();
  141. $total = ''; $enforcer = '';
  142. if($compound->jumlah_kemaskini_kompaun == ''){
  143. $total = $compound->jumlah_asal_kompaun;
  144. }else{
  145. $total = $compound->jumlah_kemaskini_kompaun;
  146. }
  147. $site = SiteSetting::first();
  148. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  149. return view('main-dashboard.compound_detail.compound_detail', compact('user','compound','file','faulty','role','total','enforcer','site'));
  150. }
  151. public function viewCompoundMemoDetail($kpd){
  152. $id = Auth::guard('sadmin')->id();
  153. $user = Staff::with('StaffDetail')->find($id);
  154. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  155. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  156. $roles = Roles::all();
  157. $role = Roles::where('kod',$compound->modul)->first();
  158. $site = SiteSetting::first();
  159. return view('main-dashboard.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
  160. }
  161. public function viewCompoundEditMemoDetail($kpd, $memo){
  162. $id = Auth::guard('sadmin')->id();
  163. $user = Staff::with('StaffDetail')->find($id);
  164. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  165. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  166. $memo = Memo::where('_id',$memo)->first();
  167. $roles = Roles::all();
  168. $role = Roles::where('kod',$compound->modul)->first();
  169. $site = SiteSetting::first();
  170. return view('main-dashboard.compound_detail.compound_memo_edit', compact('user','compound','file','roles','role','memo','site'));
  171. }
  172. public function viewCompoundInvestigationDetail($kpd){
  173. $id = Auth::guard('sadmin')->id();
  174. $user = Staff::with('StaffDetail')->find($id);
  175. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  176. $investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
  177. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  178. $faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
  179. $akta = DeedLaw::where('akkod',$faulty->akkod)->first();
  180. $role = Roles::where('kod',$compound->modul)->first();
  181. $total = ''; $enforcer = '';
  182. if($compound->jumlah_kemaskini_kompaun == ''){
  183. $total = $compound->jumlah_asal_kompaun;
  184. }else{
  185. $total = $compound->jumlah_kemaskini_kompaun;
  186. }
  187. $site = SiteSetting::first();
  188. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  189. return view('main-dashboard.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
  190. }
  191. public function viewCompoundNoticeDetail($kpd){
  192. $id = Auth::guard('sadmin')->id();
  193. $user = Staff::with('StaffDetail')->find($id);
  194. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  195. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  196. $role = Roles::where('kod',$compound->modul)->first();
  197. $site = SiteSetting::first();
  198. return view('main-dashboard.compound_detail.notice_detail', compact('user','compound','file','role','site'));
  199. }
  200. public function viewCompoundInventoryDetail($kpd){
  201. $id = Auth::guard('sadmin')->id();
  202. $user = Staff::with('StaffDetail')->find($id);
  203. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  204. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  205. $role = Roles::where('kod',$compound->modul)->first();
  206. $site = SiteSetting::first();
  207. return view('main-dashboard.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
  208. }
  209. public function viewCompoundAuctionDetail($kpd){
  210. $id = Auth::guard('sadmin')->id();
  211. $user = Staff::with('StaffDetail')->find($id);
  212. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  213. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  214. $role = Roles::where('kod',$compound->modul)->first();
  215. $site = SiteSetting::first();
  216. return view('main-dashboard.compound_detail.auction_detail', compact('user','compound','file','role','site'));
  217. }
  218. public function viewTaskIndex($kpd){
  219. $id = Auth::guard('sadmin')->id();
  220. $user = Staff::with('StaffDetail')->find($id);
  221. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  222. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  223. $staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('department_ids',$compound->jbkod)->get();
  224. $roles = Roles::get();
  225. $role = Roles::where('kod',$compound->modul)->first();
  226. $department = Department::get();
  227. $site = SiteSetting::first();
  228. $currentS = '';
  229. $s = StaffDetail::where('roles_access','PenguatKuasa')->where('_id',$compound->penguatkuasa)->first();
  230. if(!empty($s)){
  231. $currentS = '['.$s->no_badan.'] '.$s->full_name;
  232. }
  233. return view('main-dashboard.compound_detail.compound_job',compact('user','compound','file','roles','staffs','role','department','currentS','site'));
  234. }
  235. public function manualCompound(){
  236. $id = Auth::guard('sadmin')->id();
  237. $user = Staff::with('StaffDetail')->find($id);
  238. $site = SiteSetting::first();
  239. $faulty = Faulty::with('DeedLaw','Department')->get();
  240. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  241. return view('main-dashboard.compound.compound_form',compact('user','site','faulty','staff'));
  242. }
  243. /**
  244. * Create generate kpd number controller.
  245. *
  246. * @return value
  247. */
  248. public function generateKPD(){
  249. $count = 0;
  250. do {
  251. $count = Compound::count();
  252. $count = $count + 1;
  253. } while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
  254. return $count;
  255. }
  256. public function storemanualCompound(Request $request){
  257. $id = Auth::guard('sadmin')->id();
  258. $user = Staff::with('StaffDetail')->find($id);
  259. $compound = Compound::where('kpd', $request->kpd)->first();
  260. if(empty($compound)){
  261. $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
  262. if(!empty($faulty)){
  263. $kpd = $request->kpd;
  264. $no_siri = date('yn',strtotime($request->tarikh_dikeluarkan)).'-'.$kpd;
  265. $fileData = [
  266. 'no_siri' => $no_siri,
  267. ];
  268. if($request->jenisKompaun == 'Parkir'){
  269. $compoundData = [
  270. 'jenis' => 'Parkir',
  271. 'kpd' => $kpd,
  272. 'nama' => '-',
  273. 'identity' => '-',
  274. 'alamat' => '-',
  275. "no_plate" => strtolower($request->no_plate),
  276. "no_cukai_jalan" => $request->noCukaijalan,
  277. "jenis_kenderaan" => $request->jenisKenderaan,
  278. "model_kenderaan" => $request->modelKenderaan,
  279. "warna_kenderaan" => $request->warnakenderaan,
  280. "nama_taman" => $request->namaTaman,
  281. "nama_jalan" => $request->namaJalan,
  282. "no_parking" => $request->noParking,
  283. "maklumat_tambahan" => $request->catatan,
  284. "catatan" => $request->butiran_kesalahan,
  285. "lokasi_kejadian" => '-',
  286. 'latlong' => $request->Latlong,
  287. 'jbkod' => $request->jabatan,
  288. 'akta' => $faulty->deed_law_id,
  289. 'seksyen_kesalahan' => $faulty->_id,
  290. 'jumlah_asal_kompaun' => $faulty->amount,
  291. 'jumlah_kemaskini_kompaun' => '',
  292. 'dikeluarkan' => $request->staff,
  293. "status" => 'Belum Bayar',
  294. "amount_payment" => '',
  295. "receipt" => '',
  296. "modul" => '03',
  297. "penguatkuasa" => '',
  298. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  299. ];
  300. }else if($request->jenisKompaun == 'Pelbagai'){
  301. $compoundData = [
  302. 'jenis' => 'Pelbagai',
  303. 'kpd' => $kpd,
  304. 'nama' => $request->namaP,
  305. 'identity' => $request->noIc,
  306. 'nama_syarikat' => $request->namaS,
  307. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  308. 'alamat' => $request->alamat,
  309. 'no_telefon' => $request->tel,
  310. 'no_akaun_lesen' =>$request->lesen,
  311. "no_plate" => strtolower($request->no_plate),
  312. "no_cukai_jalan" => $request->noCukaijalan,
  313. "maklumat_tambahan" => $request->catatan,
  314. "catatan" => $request->butiran_kesalahan,
  315. "lokasi_kejadian" => $request->lokasi_kejadian,
  316. 'latlong' => $request->Latlong,
  317. 'jbkod' => $request->jabatan,
  318. 'akta' => $faulty->deed_law_id,
  319. 'seksyen_kesalahan' => $faulty->_id,
  320. 'jumlah_asal_kompaun' => $faulty->amount,
  321. 'jumlah_kemaskini_kompaun' => '',
  322. 'dikeluarkan' => $request->staff,
  323. "status" => 'Belum Bayar',
  324. "amount_payment" => '',
  325. "receipt" => '',
  326. "modul" => '03',
  327. "penguatkuasa" => '',
  328. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  329. ];
  330. }
  331. $file = ConfidentialFile::create($fileData);
  332. $saved = $file->compound()->create($compoundData);
  333. if($saved){
  334. $this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
  335. return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
  336. }
  337. }else{
  338. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  339. }
  340. }else{
  341. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' telah wujud!');
  342. }
  343. }
  344. public function manualCompoundEdit($_id){
  345. $id = Auth::guard('sadmin')->id();
  346. $user = Staff::with('StaffDetail')->find($id);
  347. $site = SiteSetting::first();
  348. $faulty = Faulty::with('DeedLaw','Department')->get();
  349. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  350. $compound = Compound::with('Faulty','Department','Deedlaw')->find($_id);
  351. return view('main-dashboard.compound.compound_form_edit',compact('user','site','faulty','staff','compound'));
  352. }
  353. public function editmanualCompound(Request $request){
  354. $id = Auth::guard('sadmin')->id();
  355. $user = Staff::with('StaffDetail')->find($id);
  356. $compound = Compound::find($request->_id);
  357. if(!empty($compound)){
  358. if($compound->jenis == 'Parkir'){
  359. // $compound->kpd = $request->kpd;
  360. $compound->no_plate = strtolower($request->no_plate);
  361. $compound->no_cukai_jalan = $request->noCukaijalan;
  362. $compound->jenis_kenderaan = $request->jenisKenderaan;
  363. $compound->model_kenderaan = $request->modelKenderaan;
  364. $compound->warna_kenderaan = $request->warnakenderaan;
  365. $compound->nama_taman = $request->namaTaman;
  366. $compound->nama_jalan = $request->namaJalan;
  367. $compound->no_parking = $request->noParking;
  368. $compound->maklumat_tambahan = $request->catatan;
  369. $compound->catatan = $request->butiran_kesalahan;
  370. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  371. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  372. $compound->save();
  373. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  374. }else if($compound->jenis == 'Pelbagai'){
  375. // $compound->kpd = $request->kpd;
  376. $compound->nama = $request->namaP;
  377. $compound->identity = $request->noIc;
  378. $compound->nama_syarikat = $request->namaS;
  379. $compound->no_daftar_syarikat = strtolower($request->daftarNo);
  380. $compound->alamat = $request->alamat;
  381. $compound->no_telefon = $request->tel;
  382. $compound->no_akaun_lesen = $request->lesen;
  383. $compound->no_plate = strtolower($request->no_plate);
  384. $compound->no_cukai_jalan = $request->noCukaijalan;
  385. $compound->no_plate = strtolower($request->no_plate);
  386. $compound->maklumat_tambahan = $request->catatan;
  387. $compound->catatan = $request->butiran_kesalahan;
  388. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  389. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  390. $compound->save();
  391. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  392. }
  393. }else{
  394. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak wujud!');
  395. }
  396. }
  397. }