Dashboard sipadu mbip
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CompoundController.php 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. if(empty($compound))
  261. {
  262. $kpd = (int)$kpd;
  263. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  264. }
  265. $file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  266. $role = Roles::where('kod',$file->modul)->first();
  267. $site = SiteSetting::first();
  268. return view('main-dashboard.compound_detail.history_detail', compact('user','compound','file','role','site'));
  269. }
  270. public function viewCompoundDetail($kpd){
  271. $id = Auth::guard('sadmin')->id();
  272. $user = Staff::with('StaffDetail')->find($id);
  273. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  274. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  275. $faulty = Faulty::with(['DeedLaw' => function($q){
  276. $q->with('Department');
  277. }])->where('_id',$compound->seksyen_kesalahan)->first();
  278. $role = Roles::where('kod',$compound->modul)->first();
  279. $total = ''; $enforcer = '';
  280. if($compound->jumlah_kemaskini_kompaun == ''){
  281. $total = $compound->jumlah_asal_kompaun;
  282. }else{
  283. $total = $compound->jumlah_kemaskini_kompaun;
  284. }
  285. $site = SiteSetting::first();
  286. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  287. return view('main-dashboard.compound_detail.compound_detail', compact('user','compound','file','faulty','role','total','enforcer','site'));
  288. }
  289. public function viewCompoundMemoDetail($kpd){
  290. $id = Auth::guard('sadmin')->id();
  291. $user = Staff::with('StaffDetail')->find($id);
  292. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  293. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  294. $roles = Roles::all();
  295. $role = Roles::where('kod',$compound->modul)->first();
  296. $site = SiteSetting::first();
  297. return view('main-dashboard.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
  298. }
  299. public function viewCompoundEditMemoDetail($kpd, $memo){
  300. $id = Auth::guard('sadmin')->id();
  301. $user = Staff::with('StaffDetail')->find($id);
  302. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  303. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  304. $memo = Memo::where('_id',$memo)->first();
  305. $roles = Roles::all();
  306. $role = Roles::where('kod',$compound->modul)->first();
  307. $site = SiteSetting::first();
  308. return view('main-dashboard.compound_detail.compound_memo_edit', compact('user','compound','file','roles','role','memo','site'));
  309. }
  310. public function viewCompoundInvestigationDetail($kpd){
  311. $id = Auth::guard('sadmin')->id();
  312. $user = Staff::with('StaffDetail')->find($id);
  313. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  314. $investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
  315. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  316. $faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
  317. $akta = DeedLaw::where('akkod',$faulty->akkod)->first();
  318. $role = Roles::where('kod',$compound->modul)->first();
  319. $total = ''; $enforcer = '';
  320. if($compound->jumlah_kemaskini_kompaun == ''){
  321. $total = $compound->jumlah_asal_kompaun;
  322. }else{
  323. $total = $compound->jumlah_kemaskini_kompaun;
  324. }
  325. $site = SiteSetting::first();
  326. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  327. return view('main-dashboard.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
  328. }
  329. public function viewCompoundNoticeDetail($kpd){
  330. $id = Auth::guard('sadmin')->id();
  331. $user = Staff::with('StaffDetail')->find($id);
  332. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  333. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  334. $role = Roles::where('kod',$compound->modul)->first();
  335. $site = SiteSetting::first();
  336. return view('main-dashboard.compound_detail.notice_detail', compact('user','compound','file','role','site'));
  337. }
  338. public function viewCompoundInventoryDetail($kpd){
  339. $id = Auth::guard('sadmin')->id();
  340. $user = Staff::with('StaffDetail')->find($id);
  341. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  342. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  343. $role = Roles::where('kod',$compound->modul)->first();
  344. $site = SiteSetting::first();
  345. return view('main-dashboard.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
  346. }
  347. public function viewCompoundAuctionDetail($kpd){
  348. $id = Auth::guard('sadmin')->id();
  349. $user = Staff::with('StaffDetail')->find($id);
  350. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  351. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  352. $role = Roles::where('kod',$compound->modul)->first();
  353. $site = SiteSetting::first();
  354. return view('main-dashboard.compound_detail.auction_detail', compact('user','compound','file','role','site'));
  355. }
  356. public function viewTaskIndex($kpd){
  357. $id = Auth::guard('sadmin')->id();
  358. $user = Staff::with('StaffDetail')->find($id);
  359. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  360. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  361. $staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('department_ids',$compound->jbkod)->get();
  362. $roles = Roles::get();
  363. $role = Roles::where('kod',$compound->modul)->first();
  364. $department = Department::get();
  365. $site = SiteSetting::first();
  366. $currentS = '';
  367. $s = StaffDetail::where('roles_access','PenguatKuasa')->where('_id',$compound->penguatkuasa)->first();
  368. if(!empty($s)){
  369. $currentS = '['.$s->no_badan.'] '.$s->full_name;
  370. }
  371. return view('main-dashboard.compound_detail.compound_job',compact('user','compound','file','roles','staffs','role','department','currentS','site'));
  372. }
  373. public function manualCompound(){
  374. $id = Auth::guard('sadmin')->id();
  375. $user = Staff::with('StaffDetail')->find($id);
  376. $site = SiteSetting::first();
  377. $faulty = Faulty::with('DeedLaw','Department')->get();
  378. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  379. return view('main-dashboard.compound.compound_form',compact('user','site','faulty','staff'));
  380. }
  381. /**
  382. * Create generate kpd number controller.
  383. *
  384. * @return value
  385. */
  386. public function generateKPD(){
  387. $count = 0;
  388. do {
  389. $count = Compound::count();
  390. $count = $count + 1;
  391. } while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
  392. return $count;
  393. }
  394. public function storemanualCompound(Request $request){
  395. $id = Auth::guard('sadmin')->id();
  396. $user = Staff::with('StaffDetail')->find($id);
  397. $compound = Compound::where('kpd', $request->kpd)->first();
  398. if(empty($compound)){
  399. $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
  400. if(!empty($faulty)){
  401. $kpd = $request->kpd;
  402. $no_siri = date('yn',strtotime($request->tarikh_dikeluarkan)).'-'.$kpd;
  403. $fileData = [
  404. 'no_siri' => $no_siri,
  405. ];
  406. if($request->jenisKompaun == 'Parkir'){
  407. $compoundData = [
  408. 'jenis' => 'Parkir',
  409. 'kpd' => $kpd,
  410. 'nama' => '-',
  411. 'identity' => '-',
  412. 'alamat' => '-',
  413. "no_plate" => strtolower($request->no_plate),
  414. "no_cukai_jalan" => $request->noCukaijalan,
  415. "jenis_kenderaan" => $request->jenisKenderaan,
  416. "model_kenderaan" => $request->modelKenderaan,
  417. "warna_kenderaan" => $request->warnakenderaan,
  418. "nama_taman" => $request->namaTaman,
  419. "nama_jalan" => $request->namaJalan,
  420. "no_parking" => $request->noParking,
  421. "maklumat_tambahan" => $request->catatan,
  422. "catatan" => $request->butiran_kesalahan,
  423. "lokasi_kejadian" => '-',
  424. 'latlong' => $request->Latlong,
  425. 'jbkod' => $request->jabatan,
  426. 'akta' => $faulty->deed_law_id,
  427. 'seksyen_kesalahan' => $faulty->_id,
  428. 'jumlah_asal_kompaun' => $faulty->amount,
  429. 'jumlah_kemaskini_kompaun' => '',
  430. 'dikeluarkan' => $request->staff,
  431. "status" => 'Belum Bayar',
  432. "amount_payment" => '',
  433. "receipt" => '',
  434. "modul" => '03',
  435. "penguatkuasa" => '',
  436. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  437. ];
  438. }else if($request->jenisKompaun == 'Pelbagai'){
  439. $compoundData = [
  440. 'jenis' => 'Pelbagai',
  441. 'kpd' => $kpd,
  442. 'nama' => $request->namaP,
  443. 'identity' => $request->noIc,
  444. 'nama_syarikat' => $request->namaS,
  445. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  446. 'alamat' => $request->alamat,
  447. 'no_telefon' => $request->tel,
  448. 'no_akaun_lesen' =>$request->lesen,
  449. "no_plate" => strtolower($request->no_plate),
  450. "no_cukai_jalan" => $request->noCukaijalan,
  451. "maklumat_tambahan" => $request->catatan,
  452. "catatan" => $request->butiran_kesalahan,
  453. "lokasi_kejadian" => $request->lokasi_kejadian,
  454. 'latlong' => $request->Latlong,
  455. 'jbkod' => $request->jabatan,
  456. 'akta' => $faulty->deed_law_id,
  457. 'seksyen_kesalahan' => $faulty->_id,
  458. 'jumlah_asal_kompaun' => $faulty->amount,
  459. 'jumlah_kemaskini_kompaun' => '',
  460. 'dikeluarkan' => $request->staff,
  461. "status" => 'Belum Bayar',
  462. "amount_payment" => '',
  463. "receipt" => '',
  464. "modul" => '03',
  465. "penguatkuasa" => '',
  466. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  467. ];
  468. }
  469. $file = ConfidentialFile::create($fileData);
  470. $saved = $file->compound()->create($compoundData);
  471. if($saved){
  472. $this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
  473. return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
  474. }
  475. }else{
  476. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  477. }
  478. }else{
  479. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' telah wujud!');
  480. }
  481. }
  482. public function manualCompoundEdit($_id){
  483. $id = Auth::guard('sadmin')->id();
  484. $user = Staff::with('StaffDetail')->find($id);
  485. $site = SiteSetting::first();
  486. $faulty = Faulty::with('DeedLaw','Department')->get();
  487. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  488. $compound = Compound::with('Faulty','Department','Deedlaw')->find($_id);
  489. return view('main-dashboard.compound.compound_form_edit',compact('user','site','faulty','staff','compound'));
  490. }
  491. public function editmanualCompound(Request $request){
  492. $id = Auth::guard('sadmin')->id();
  493. $user = Staff::with('StaffDetail')->find($id);
  494. $compound = Compound::find($request->_id);
  495. if(!empty($compound)){
  496. $faulty = Faulty::with('DeedLaw','Department')->where('_id',$request->get('seksyen'))->first();
  497. if(!empty($faulty) && !empty($faulty->Deedlaw) && !empty($faulty->Department)){
  498. if($compound->jenis == 'Parkir'){
  499. $compound->kpd = $request->kpd;
  500. $compound->jbkod = $faulty->Department[0]->_id;
  501. $compound->akta = $faulty->DeedLaw->_id;
  502. $compound->seksyen_kesalahan = $faulty->_id;
  503. $compound->no_plate = strtolower($request->no_plate);
  504. $compound->no_cukai_jalan = $request->noCukaijalan;
  505. $compound->jenis_kenderaan = $request->jenisKenderaan;
  506. $compound->model_kenderaan = $request->modelKenderaan;
  507. $compound->warna_kenderaan = $request->warnakenderaan;
  508. $compound->nama_taman = $request->namaTaman;
  509. $compound->nama_jalan = $request->namaJalan;
  510. $compound->no_parking = $request->noParking;
  511. $compound->maklumat_tambahan = $request->catatan;
  512. $compound->catatan = $request->butiran_kesalahan;
  513. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  514. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  515. $compound->save();
  516. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  517. }else if($compound->jenis == 'Pelbagai'){
  518. $compound->kpd = $request->kpd;
  519. $compound->jbkod = $faulty->Department[0]->_id;
  520. $compound->akta = $faulty->DeedLaw->_id;
  521. $compound->seksyen_kesalahan = $faulty->_id;
  522. $compound->nama = $request->namaP;
  523. $compound->identity = $request->noIc;
  524. $compound->nama_syarikat = $request->namaS;
  525. $compound->no_daftar_syarikat = strtolower($request->daftarNo);
  526. $compound->alamat = $request->alamat;
  527. $compound->no_telefon = $request->tel;
  528. $compound->no_akaun_lesen = $request->lesen;
  529. $compound->no_plate = strtolower($request->no_plate);
  530. $compound->no_cukai_jalan = $request->noCukaijalan;
  531. $compound->no_plate = strtolower($request->no_plate);
  532. $compound->maklumat_tambahan = $request->catatan;
  533. $compound->catatan = $request->butiran_kesalahan;
  534. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  535. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  536. $compound->save();
  537. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  538. }
  539. }else {
  540. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  541. }
  542. }else{
  543. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak wujud!');
  544. }
  545. }
  546. }