Dashboard sipadu mbip
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CompoundController.php 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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\Model\Module\ReportOverallCompound;
  24. use App\Jobs\StoreCompound;
  25. use App\Jobs\StoreCompoundManual;
  26. use App\Jobs\UpdateCompoundPrice;
  27. class CompoundController extends Controller
  28. {
  29. /**
  30. * Create compound list interface controller.
  31. *
  32. * @return json
  33. */
  34. public function index(){
  35. $id = Auth::guard('sadmin')->id();
  36. $user = Staff::with('StaffDetail')->find($id);
  37. if(count($user->StaffDetail->department_ids) > 1){
  38. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  39. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  40. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  41. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  42. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  43. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  44. }else {
  45. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  46. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  47. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  48. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  49. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  50. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  51. }
  52. $semua = $overall->total;
  53. $baru = $b->total;
  54. $invest = $pk->total;
  55. $notice = $na->total;
  56. $inven = $si->total;
  57. $collap = 0;
  58. $comp = $by->total;
  59. $site = SiteSetting::first();
  60. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  61. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  62. $now = Carbon::now()->format('Y-m-d');
  63. $modul = 'All';
  64. return view('main-dashboard.compound.compound_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  65. }
  66. public function new_index(){
  67. $id = Auth::guard('sadmin')->id();
  68. $user = Staff::with('StaffDetail')->find($id);
  69. if(count($user->StaffDetail->department_ids) > 1){
  70. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  71. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  72. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  73. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  74. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  75. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  76. }else {
  77. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  78. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  79. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  80. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  81. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  82. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  83. }
  84. $semua = $overall->total;
  85. $baru = $b->total;
  86. $invest = $pk->total;
  87. $notice = $na->total;
  88. $inven = $si->total;
  89. $collap = 0;
  90. $comp = $by->total;
  91. $site = SiteSetting::first();
  92. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  93. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  94. $now = Carbon::now()->format('Y-m-d');
  95. $modul = '03';
  96. return view('main-dashboard.compound.new_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  97. }
  98. public function investigation_index(){
  99. $id = Auth::guard('sadmin')->id();
  100. $user = Staff::with('StaffDetail')->find($id);
  101. if(count($user->StaffDetail->department_ids) > 1){
  102. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  103. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  104. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  105. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  106. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  107. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  108. }else {
  109. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  110. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  111. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  112. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  113. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  114. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  115. }
  116. $semua = $overall->total;
  117. $baru = $b->total;
  118. $invest = $pk->total;
  119. $notice = $na->total;
  120. $inven = $si->total;
  121. $collap = 0;
  122. $comp = $by->total;
  123. $site = SiteSetting::first();
  124. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  125. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  126. $now = Carbon::now()->format('Y-m-d');
  127. $modul = '04';
  128. return view('main-dashboard.compound.investigation_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  129. }
  130. public function notice_index(){
  131. $id = Auth::guard('sadmin')->id();
  132. $user = Staff::with('StaffDetail')->find($id);
  133. if(count($user->StaffDetail->department_ids) > 1){
  134. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  135. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  136. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  137. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  138. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  139. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  140. }else {
  141. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  142. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  143. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  144. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  145. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  146. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  147. }
  148. $semua = $overall->total;
  149. $baru = $b->total;
  150. $invest = $pk->total;
  151. $notice = $na->total;
  152. $inven = $si->total;
  153. $collap = 0;
  154. $comp = $by->total;
  155. $site = SiteSetting::first();
  156. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  157. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  158. $now = Carbon::now()->format('Y-m-d');
  159. $modul = '05';
  160. return view('main-dashboard.compound.notice_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  161. }
  162. public function confiscated_index(){
  163. $id = Auth::guard('sadmin')->id();
  164. $user = Staff::with('StaffDetail')->find($id);
  165. if(count($user->StaffDetail->department_ids) > 1){
  166. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  167. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  168. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  169. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  170. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  171. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  172. }else {
  173. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  174. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  175. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  176. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  177. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  178. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  179. }
  180. $semua = $overall->total;
  181. $baru = $b->total;
  182. $invest = $pk->total;
  183. $notice = $na->total;
  184. $inven = $si->total;
  185. $collap = 0;
  186. $comp = $by->total;
  187. $site = SiteSetting::first();
  188. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  189. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  190. $now = Carbon::now()->format('Y-m-d');
  191. $modul = '06-07';
  192. return view('main-dashboard.compound.confiscated_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  193. }
  194. public function collapsed_index(){
  195. $id = Auth::guard('sadmin')->id();
  196. $user = Staff::with('StaffDetail')->find($id);
  197. if(count($user->StaffDetail->department_ids) > 1){
  198. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  199. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  200. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  201. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  202. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  203. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  204. }else {
  205. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  206. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  207. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  208. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  209. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  210. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  211. }
  212. $semua = $overall->total;
  213. $baru = $b->total;
  214. $invest = $pk->total;
  215. $notice = $na->total;
  216. $inven = $si->total;
  217. $collap = 0;
  218. $comp = $by->total;
  219. $site = SiteSetting::first();
  220. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  221. $faulty = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  222. return view('main-dashboard.compound.collapsed_index', compact('user','site','staff','faulty','baru','invest','notice','inven','collap','comp'));
  223. }
  224. public function completed_index(){
  225. $id = Auth::guard('sadmin')->id();
  226. $user = Staff::with('StaffDetail')->find($id);
  227. if(count($user->StaffDetail->department_ids) > 1){
  228. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  229. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  230. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  231. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  232. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  233. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  234. }else {
  235. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  236. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  237. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  238. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  239. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  240. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  241. }
  242. $semua = $overall->total;
  243. $baru = $b->total;
  244. $invest = $pk->total;
  245. $notice = $na->total;
  246. $inven = $si->total;
  247. $collap = 0;
  248. $comp = $by->total;
  249. $site = SiteSetting::first();
  250. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  251. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  252. $now = Carbon::now()->format('Y-m-d');
  253. $modul = 'All';
  254. return view('main-dashboard.compound.completed_index', compact('user','site','staff','deedlaw','now','modul','semua','baru','invest','notice','inven','collap','comp'));
  255. }
  256. public function viewCompoundHistoryDetail($kpd){
  257. $id = Auth::guard('sadmin')->id();
  258. $user = Staff::with('StaffDetail')->find($id);
  259. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  260. $file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  261. $role = Roles::where('kod',$file->modul)->first();
  262. $site = SiteSetting::first();
  263. return view('main-dashboard.compound_detail.history_detail', compact('user','compound','file','role','site'));
  264. }
  265. public function viewCompoundDetail($kpd){
  266. $id = Auth::guard('sadmin')->id();
  267. $user = Staff::with('StaffDetail')->find($id);
  268. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  269. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  270. $faulty = Faulty::with(['DeedLaw' => function($q){
  271. $q->with('Department');
  272. }])->where('_id',$compound->seksyen_kesalahan)->first();
  273. $role = Roles::where('kod',$compound->modul)->first();
  274. $total = ''; $enforcer = '';
  275. if($compound->jumlah_kemaskini_kompaun == ''){
  276. $total = $compound->jumlah_asal_kompaun;
  277. }else{
  278. $total = $compound->jumlah_kemaskini_kompaun;
  279. }
  280. $site = SiteSetting::first();
  281. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  282. return view('main-dashboard.compound_detail.compound_detail', compact('user','compound','file','faulty','role','total','enforcer','site'));
  283. }
  284. public function viewCompoundMemoDetail($kpd){
  285. $id = Auth::guard('sadmin')->id();
  286. $user = Staff::with('StaffDetail')->find($id);
  287. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  288. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  289. $roles = Roles::all();
  290. $role = Roles::where('kod',$compound->modul)->first();
  291. $site = SiteSetting::first();
  292. return view('main-dashboard.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
  293. }
  294. public function viewCompoundEditMemoDetail($kpd, $memo){
  295. $id = Auth::guard('sadmin')->id();
  296. $user = Staff::with('StaffDetail')->find($id);
  297. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  298. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  299. $memo = Memo::where('_id',$memo)->first();
  300. $roles = Roles::all();
  301. $role = Roles::where('kod',$compound->modul)->first();
  302. $site = SiteSetting::first();
  303. return view('main-dashboard.compound_detail.compound_memo_edit', compact('user','compound','file','roles','role','memo','site'));
  304. }
  305. public function viewCompoundInvestigationDetail($kpd){
  306. $id = Auth::guard('sadmin')->id();
  307. $user = Staff::with('StaffDetail')->find($id);
  308. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  309. $investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
  310. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  311. $faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
  312. $akta = DeedLaw::where('akkod',$faulty->akkod)->first();
  313. $role = Roles::where('kod',$compound->modul)->first();
  314. $total = ''; $enforcer = '';
  315. if($compound->jumlah_kemaskini_kompaun == ''){
  316. $total = $compound->jumlah_asal_kompaun;
  317. }else{
  318. $total = $compound->jumlah_kemaskini_kompaun;
  319. }
  320. $site = SiteSetting::first();
  321. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  322. return view('main-dashboard.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
  323. }
  324. public function viewCompoundNoticeDetail($kpd){
  325. $id = Auth::guard('sadmin')->id();
  326. $user = Staff::with('StaffDetail')->find($id);
  327. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  328. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  329. $role = Roles::where('kod',$compound->modul)->first();
  330. $site = SiteSetting::first();
  331. return view('main-dashboard.compound_detail.notice_detail', compact('user','compound','file','role','site'));
  332. }
  333. public function viewCompoundInventoryDetail($kpd){
  334. $id = Auth::guard('sadmin')->id();
  335. $user = Staff::with('StaffDetail')->find($id);
  336. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  337. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  338. $role = Roles::where('kod',$compound->modul)->first();
  339. $site = SiteSetting::first();
  340. return view('main-dashboard.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
  341. }
  342. public function viewCompoundAuctionDetail($kpd){
  343. $id = Auth::guard('sadmin')->id();
  344. $user = Staff::with('StaffDetail')->find($id);
  345. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  346. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  347. $role = Roles::where('kod',$compound->modul)->first();
  348. $site = SiteSetting::first();
  349. return view('main-dashboard.compound_detail.auction_detail', compact('user','compound','file','role','site'));
  350. }
  351. public function viewTaskIndex($kpd){
  352. $id = Auth::guard('sadmin')->id();
  353. $user = Staff::with('StaffDetail')->find($id);
  354. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  355. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  356. $staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('department_ids',$compound->jbkod)->get();
  357. $roles = Roles::get();
  358. $role = Roles::where('kod',$compound->modul)->first();
  359. $department = Department::get();
  360. $site = SiteSetting::first();
  361. $currentS = '';
  362. $s = StaffDetail::where('roles_access','PenguatKuasa')->where('_id',$compound->penguatkuasa)->first();
  363. if(!empty($s)){
  364. $currentS = '['.$s->no_badan.'] '.$s->full_name;
  365. }
  366. return view('main-dashboard.compound_detail.compound_job',compact('user','compound','file','roles','staffs','role','department','currentS','site'));
  367. }
  368. public function manualCompound(){
  369. $id = Auth::guard('sadmin')->id();
  370. $user = Staff::with('StaffDetail')->find($id);
  371. $site = SiteSetting::first();
  372. $faulty = Faulty::with('DeedLaw','Department')->get();
  373. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  374. return view('main-dashboard.compound.compound_form',compact('user','site','faulty','staff'));
  375. }
  376. /**
  377. * Create generate kpd number controller.
  378. *
  379. * @return value
  380. */
  381. public function generateKPD(){
  382. $count = 0;
  383. do {
  384. $count = Compound::count();
  385. $count = $count + 1;
  386. } while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
  387. return $count;
  388. }
  389. public function storemanualCompound(Request $request){
  390. $id = Auth::guard('sadmin')->id();
  391. $user = Staff::with('StaffDetail')->find($id);
  392. $compound = Compound::where('kpd', $request->kpd)->first();
  393. if(empty($compound)){
  394. $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
  395. if(!empty($faulty)){
  396. $kpd = $request->kpd;
  397. $no_siri = date('yn',strtotime($request->tarikh_dikeluarkan)).'-'.$kpd;
  398. $fileData = [
  399. 'no_siri' => $no_siri,
  400. ];
  401. if($request->jenisKompaun == 'Parkir'){
  402. $compoundData = [
  403. 'jenis' => 'Parkir',
  404. 'kpd' => $kpd,
  405. 'nama' => '-',
  406. 'identity' => '-',
  407. 'alamat' => '-',
  408. "no_plate" => strtolower($request->no_plate),
  409. "no_cukai_jalan" => $request->noCukaijalan,
  410. "jenis_kenderaan" => $request->jenisKenderaan,
  411. "model_kenderaan" => $request->modelKenderaan,
  412. "warna_kenderaan" => $request->warnakenderaan,
  413. "nama_taman" => $request->namaTaman,
  414. "nama_jalan" => $request->namaJalan,
  415. "no_parking" => $request->noParking,
  416. "maklumat_tambahan" => $request->catatan,
  417. "catatan" => $request->butiran_kesalahan,
  418. "lokasi_kejadian" => '-',
  419. 'latlong' => $request->Latlong,
  420. 'jbkod' => $request->jabatan,
  421. 'akta' => $faulty->deed_law_id,
  422. 'seksyen_kesalahan' => $faulty->_id,
  423. 'jumlah_asal_kompaun' => $faulty->amount,
  424. 'jumlah_kemaskini_kompaun' => '',
  425. 'dikeluarkan' => $request->staff,
  426. "status" => 'Belum Bayar',
  427. "amount_payment" => '',
  428. "receipt" => '',
  429. "modul" => '03',
  430. "penguatkuasa" => '',
  431. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  432. ];
  433. }else if($request->jenisKompaun == 'Pelbagai'){
  434. $compoundData = [
  435. 'jenis' => 'Pelbagai',
  436. 'kpd' => $kpd,
  437. 'nama' => $request->namaP,
  438. 'identity' => $request->noIc,
  439. 'nama_syarikat' => $request->namaS,
  440. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  441. 'alamat' => $request->alamat,
  442. 'no_telefon' => $request->tel,
  443. 'no_akaun_lesen' =>$request->lesen,
  444. "no_plate" => strtolower($request->no_plate),
  445. "no_cukai_jalan" => $request->noCukaijalan,
  446. "maklumat_tambahan" => $request->catatan,
  447. "catatan" => $request->butiran_kesalahan,
  448. "lokasi_kejadian" => $request->lokasi_kejadian,
  449. 'latlong' => $request->Latlong,
  450. 'jbkod' => $request->jabatan,
  451. 'akta' => $faulty->deed_law_id,
  452. 'seksyen_kesalahan' => $faulty->_id,
  453. 'jumlah_asal_kompaun' => $faulty->amount,
  454. 'jumlah_kemaskini_kompaun' => '',
  455. 'dikeluarkan' => $request->staff,
  456. "status" => 'Belum Bayar',
  457. "amount_payment" => '',
  458. "receipt" => '',
  459. "modul" => '03',
  460. "penguatkuasa" => '',
  461. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  462. ];
  463. }
  464. $file = ConfidentialFile::create($fileData);
  465. $saved = $file->compound()->create($compoundData);
  466. if($saved){
  467. $this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
  468. return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
  469. }
  470. }else{
  471. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  472. }
  473. }else{
  474. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' telah wujud!');
  475. }
  476. }
  477. public function manualCompoundEdit($_id){
  478. $id = Auth::guard('sadmin')->id();
  479. $user = Staff::with('StaffDetail')->find($id);
  480. $site = SiteSetting::first();
  481. $faulty = Faulty::with('DeedLaw','Department')->get();
  482. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  483. $compound = Compound::with('Faulty','Department','Deedlaw')->find($_id);
  484. return view('main-dashboard.compound.compound_form_edit',compact('user','site','faulty','staff','compound'));
  485. }
  486. public function editmanualCompound(Request $request){
  487. $id = Auth::guard('sadmin')->id();
  488. $user = Staff::with('StaffDetail')->find($id);
  489. $compound = Compound::find($request->_id);
  490. if(!empty($compound)){
  491. if($compound->jenis == 'Parkir'){
  492. // $compound->kpd = $request->kpd;
  493. $compound->no_plate = strtolower($request->no_plate);
  494. $compound->no_cukai_jalan = $request->noCukaijalan;
  495. $compound->jenis_kenderaan = $request->jenisKenderaan;
  496. $compound->model_kenderaan = $request->modelKenderaan;
  497. $compound->warna_kenderaan = $request->warnakenderaan;
  498. $compound->nama_taman = $request->namaTaman;
  499. $compound->nama_jalan = $request->namaJalan;
  500. $compound->no_parking = $request->noParking;
  501. $compound->maklumat_tambahan = $request->catatan;
  502. $compound->catatan = $request->butiran_kesalahan;
  503. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  504. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  505. $compound->save();
  506. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  507. }else if($compound->jenis == 'Pelbagai'){
  508. // $compound->kpd = $request->kpd;
  509. $compound->nama = $request->namaP;
  510. $compound->identity = $request->noIc;
  511. $compound->nama_syarikat = $request->namaS;
  512. $compound->no_daftar_syarikat = strtolower($request->daftarNo);
  513. $compound->alamat = $request->alamat;
  514. $compound->no_telefon = $request->tel;
  515. $compound->no_akaun_lesen = $request->lesen;
  516. $compound->no_plate = strtolower($request->no_plate);
  517. $compound->no_cukai_jalan = $request->noCukaijalan;
  518. $compound->no_plate = strtolower($request->no_plate);
  519. $compound->maklumat_tambahan = $request->catatan;
  520. $compound->catatan = $request->butiran_kesalahan;
  521. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  522. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  523. $compound->save();
  524. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  525. }
  526. }else{
  527. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak wujud!');
  528. }
  529. }
  530. }