Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompoundController.php 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  40. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  41. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  42. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  43. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  44. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  45. }else {
  46. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  47. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  48. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  49. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  50. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  51. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  52. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  53. }
  54. $semua = $overall->total;
  55. $pre_notice = $n->total;
  56. $baru = $b->total;
  57. $invest = $pk->total;
  58. $notice = $na->total;
  59. $inven = $si->total;
  60. $collap = 0;
  61. $comp = $by->total;
  62. $site = SiteSetting::first();
  63. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  64. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  65. $now = Carbon::now()->format('Y-m-d');
  66. $modul = 'All';
  67. return view('main-dashboard.compound.compound_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  68. }
  69. public function preNoticeIndex(){
  70. $id = Auth::guard('sadmin')->id();
  71. $user = Staff::with('StaffDetail')->find($id);
  72. if(count($user->StaffDetail->department_ids) > 1){
  73. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  74. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  75. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  76. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  77. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  78. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  79. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  80. }else {
  81. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  82. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  83. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  84. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  85. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  86. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  87. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  88. }
  89. $semua = $overall->total;
  90. $pre_notice = $n->total;
  91. $baru = $b->total;
  92. $invest = $pk->total;
  93. $notice = $na->total;
  94. $inven = $si->total;
  95. $collap = 0;
  96. $comp = $by->total;
  97. $site = SiteSetting::first();
  98. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  99. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  100. $now = Carbon::now()->format('Y-m-d');
  101. $modul = '02';
  102. return view('main-dashboard.compound.prenotice_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  103. }
  104. public function new_index(){
  105. $id = Auth::guard('sadmin')->id();
  106. $user = Staff::with('StaffDetail')->find($id);
  107. if(count($user->StaffDetail->department_ids) > 1){
  108. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  109. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  110. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  111. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  112. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  113. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  114. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  115. }else {
  116. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  117. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  118. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  119. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  120. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  121. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  122. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  123. }
  124. $semua = $overall->total;
  125. $pre_notice = $n->total;
  126. $baru = $b->total;
  127. $invest = $pk->total;
  128. $notice = $na->total;
  129. $inven = $si->total;
  130. $collap = 0;
  131. $comp = $by->total;
  132. $site = SiteSetting::first();
  133. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  134. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  135. $now = Carbon::now()->format('Y-m-d');
  136. $modul = '03';
  137. return view('main-dashboard.compound.new_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  138. }
  139. public function investigation_index(){
  140. $id = Auth::guard('sadmin')->id();
  141. $user = Staff::with('StaffDetail')->find($id);
  142. if(count($user->StaffDetail->department_ids) > 1){
  143. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  144. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  145. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  146. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  147. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  148. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  149. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  150. }else {
  151. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  152. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  153. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  154. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  155. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  156. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  157. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  158. }
  159. $semua = $overall->total;
  160. $pre_notice = $n->total;
  161. $baru = $b->total;
  162. $invest = $pk->total;
  163. $notice = $na->total;
  164. $inven = $si->total;
  165. $collap = 0;
  166. $comp = $by->total;
  167. $site = SiteSetting::first();
  168. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  169. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  170. $now = Carbon::now()->format('Y-m-d');
  171. $modul = '04';
  172. return view('main-dashboard.compound.investigation_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  173. }
  174. public function notice_index(){
  175. $id = Auth::guard('sadmin')->id();
  176. $user = Staff::with('StaffDetail')->find($id);
  177. if(count($user->StaffDetail->department_ids) > 1){
  178. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  179. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  180. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  181. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  182. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  183. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  184. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  185. }else {
  186. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  187. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  188. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  189. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  190. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  191. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  192. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  193. }
  194. $semua = $overall->total;
  195. $pre_notice = $n->total;
  196. $baru = $b->total;
  197. $invest = $pk->total;
  198. $notice = $na->total;
  199. $inven = $si->total;
  200. $collap = 0;
  201. $comp = $by->total;
  202. $site = SiteSetting::first();
  203. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  204. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  205. $now = Carbon::now()->format('Y-m-d');
  206. $modul = '05';
  207. return view('main-dashboard.compound.notice_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  208. }
  209. public function confiscated_index(){
  210. $id = Auth::guard('sadmin')->id();
  211. $user = Staff::with('StaffDetail')->find($id);
  212. if(count($user->StaffDetail->department_ids) > 1){
  213. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  214. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  215. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  216. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  217. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  218. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  219. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  220. }else {
  221. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  222. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  223. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  224. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  225. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  226. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  227. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  228. }
  229. $semua = $overall->total;
  230. $pre_notice = $n->total;
  231. $baru = $b->total;
  232. $invest = $pk->total;
  233. $notice = $na->total;
  234. $inven = $si->total;
  235. $collap = 0;
  236. $comp = $by->total;
  237. $site = SiteSetting::first();
  238. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  239. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  240. $now = Carbon::now()->format('Y-m-d');
  241. $modul = '06-07';
  242. return view('main-dashboard.compound.confiscated_index', compact('user','site','staff','deedlaw','now','modul','semua','pre_notice','baru','invest','notice','inven','collap','comp'));
  243. }
  244. public function collapsed_index(){
  245. $id = Auth::guard('sadmin')->id();
  246. $user = Staff::with('StaffDetail')->find($id);
  247. if(count($user->StaffDetail->department_ids) > 1){
  248. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  249. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  250. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  251. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  252. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  253. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  254. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  255. }else {
  256. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  257. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  258. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  259. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  260. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  261. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  262. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  263. }
  264. $semua = $overall->total;
  265. $pre_notice = $n->total;
  266. $baru = $b->total;
  267. $invest = $pk->total;
  268. $notice = $na->total;
  269. $inven = $si->total;
  270. $collap = 0;
  271. $comp = $by->total;
  272. $site = SiteSetting::first();
  273. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  274. $faulty = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  275. return view('main-dashboard.compound.collapsed_index', compact('user','site','staff','faulty','pre_notice','baru','invest','notice','inven','collap','comp'));
  276. }
  277. public function completed_index(){
  278. $id = Auth::guard('sadmin')->id();
  279. $user = Staff::with('StaffDetail')->find($id);
  280. if(count($user->StaffDetail->department_ids) > 1){
  281. $overall = ReportOverallCompound::where('department','all')->where('modul','all')->where('status','all')->first();
  282. $n = ReportOverallCompound::where('department','all')->where('modul','02')->where('status','Belum Bayar')->first();
  283. $b = ReportOverallCompound::where('department','all')->where('modul','03')->where('status','Belum Bayar')->first();
  284. $pk = ReportOverallCompound::where('department','all')->where('modul','04')->where('status','Belum Bayar')->first();
  285. $na = ReportOverallCompound::where('department','all')->where('modul','05')->where('status','Belum Bayar')->first();
  286. $si = ReportOverallCompound::where('department','all')->where('modul','06-07')->where('status','Belum Bayar')->first();
  287. $by = ReportOverallCompound::where('department','all')->where('status','Berbayar')->first();
  288. }else {
  289. $overall = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','all')->where('status','all')->first();
  290. $n = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','02')->where('status','Belum Bayar')->first();
  291. $b = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','03')->where('status','Belum Bayar')->first();
  292. $pk = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','04')->where('status','Belum Bayar')->first();
  293. $na = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','05')->where('status','Belum Bayar')->first();
  294. $si = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('modul','06-07')->where('status','Belum Bayar')->first();
  295. $by = ReportOverallCompound::where('department',$user->StaffDetail->department_ids[0])->where('status','Berbayar')->first();
  296. }
  297. $semua = $overall->total;
  298. $pre_notice = $n->total;
  299. $baru = $b->total;
  300. $invest = $pk->total;
  301. $notice = $na->total;
  302. $inven = $si->total;
  303. $collap = 0;
  304. $comp = $by->total;
  305. $site = SiteSetting::first();
  306. $staff = StaffDetail::where('roles_access','PenguatKuasa')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  307. $deedlaw = Deedlaw::with('Faulty')->whereIn('department_ids',$user->StaffDetail->department_ids)->get();
  308. $now = Carbon::now()->format('Y-m-d');
  309. $modul = 'All';
  310. return view('main-dashboard.compound.completed_index', compact('user','site','staff','deedlaw','now','modul','semua', 'pre_notice','baru','invest','notice','inven','collap','comp'));
  311. }
  312. public function viewCompoundHistoryDetail($kpd){
  313. $id = Auth::guard('sadmin')->id();
  314. $user = Staff::with('StaffDetail')->find($id);
  315. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->orWhere('non',$kpd)->first();
  316. if(empty($compound))
  317. {
  318. $kpd = (int)$kpd;
  319. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->orWhere('non',$kpd)->first();
  320. }
  321. $file = ConfidentialFile::with('History','History.SubHistory')->where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  322. $role = Roles::where('kod',$file->modul)->first();
  323. $site = SiteSetting::first();
  324. return view('main-dashboard.compound_detail.history_detail', compact('user','compound','file','role','site'));
  325. }
  326. public function viewCompoundDetail($kpd){
  327. $id = Auth::guard('sadmin')->id();
  328. $user = Staff::with('StaffDetail')->find($id);
  329. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->orWhere('non',$kpd)->first();
  330. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  331. $faulty = Faulty::with(['DeedLaw' => function($q){
  332. $q->with('Department');
  333. }])->where('_id',$compound->seksyen_kesalahan)->first();
  334. $role = Roles::where('kod',$compound->modul)->first();
  335. $total = ''; $enforcer = '';
  336. if($compound->jumlah_kemaskini_kompaun == ''){
  337. $total = $compound->jumlah_asal_kompaun;
  338. }else{
  339. $total = $compound->jumlah_kemaskini_kompaun;
  340. }
  341. $site = SiteSetting::first();
  342. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  343. return view('main-dashboard.compound_detail.compound_detail', compact('user','compound','file','faulty','role','total','enforcer','site'));
  344. }
  345. public function viewCompoundMemoDetail($kpd){
  346. $id = Auth::guard('sadmin')->id();
  347. $user = Staff::with('StaffDetail')->find($id);
  348. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  349. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  350. $roles = Roles::all();
  351. $role = Roles::where('kod',$compound->modul)->first();
  352. $site = SiteSetting::first();
  353. return view('main-dashboard.compound_detail.memo_detail', compact('user','compound','file','roles','role','site'));
  354. }
  355. public function viewCompoundEditMemoDetail($kpd, $memo){
  356. $id = Auth::guard('sadmin')->id();
  357. $user = Staff::with('StaffDetail')->find($id);
  358. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  359. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  360. $memo = Memo::where('_id',$memo)->first();
  361. $roles = Roles::all();
  362. $role = Roles::where('kod',$compound->modul)->first();
  363. $site = SiteSetting::first();
  364. return view('main-dashboard.compound_detail.compound_memo_edit', compact('user','compound','file','roles','role','memo','site'));
  365. }
  366. public function viewCompoundInvestigationDetail($kpd){
  367. $id = Auth::guard('sadmin')->id();
  368. $user = Staff::with('StaffDetail')->find($id);
  369. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  370. $investigation = Compound::with('CompoundInvestigation')->where('kpd',$kpd)->first();
  371. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  372. $faulty = Faulty::where('_id',$compound->seksyen_kesalahan)->first();
  373. $akta = DeedLaw::where('akkod',$faulty->akkod)->first();
  374. $role = Roles::where('kod',$compound->modul)->first();
  375. $total = ''; $enforcer = '';
  376. if($compound->jumlah_kemaskini_kompaun == ''){
  377. $total = $compound->jumlah_asal_kompaun;
  378. }else{
  379. $total = $compound->jumlah_kemaskini_kompaun;
  380. }
  381. $site = SiteSetting::first();
  382. $enforcer = Staff::with('StaffDetail')->where('_id',$compound->dikeluarkan)->first();
  383. return view('main-dashboard.compound_detail.investigation_detail', compact('user','compound','investigation','file','akta','faulty','role','total','enforcer','site'));
  384. }
  385. public function viewCompoundNoticeDetail($kpd){
  386. $id = Auth::guard('sadmin')->id();
  387. $user = Staff::with('StaffDetail')->find($id);
  388. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  389. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  390. $role = Roles::where('kod',$compound->modul)->first();
  391. $site = SiteSetting::first();
  392. return view('main-dashboard.compound_detail.notice_detail', compact('user','compound','file','role','site'));
  393. }
  394. public function viewCompoundInventoryDetail($kpd){
  395. $id = Auth::guard('sadmin')->id();
  396. $user = Staff::with('StaffDetail')->find($id);
  397. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  398. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  399. $role = Roles::where('kod',$compound->modul)->first();
  400. $site = SiteSetting::first();
  401. return view('main-dashboard.compound_detail.inventory_detail', compact('user','compound','file','role','site'));
  402. }
  403. public function viewCompoundAuctionDetail($kpd){
  404. $id = Auth::guard('sadmin')->id();
  405. $user = Staff::with('StaffDetail')->find($id);
  406. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  407. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  408. $role = Roles::where('kod',$compound->modul)->first();
  409. $site = SiteSetting::first();
  410. return view('main-dashboard.compound_detail.auction_detail', compact('user','compound','file','role','site'));
  411. }
  412. public function viewTaskIndex($kpd){
  413. $id = Auth::guard('sadmin')->id();
  414. $user = Staff::with('StaffDetail')->find($id);
  415. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->orWhere('non', $kpd)->first();
  416. $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
  417. $staffs = StaffDetail::where('roles_access','PenguatKuasa')->where('department_ids',$compound->jbkod)->get();
  418. $roles = Roles::get();
  419. $role = Roles::where('kod',$compound->modul)->first();
  420. $department = Department::get();
  421. $site = SiteSetting::first();
  422. $currentS = '';
  423. $s = StaffDetail::where('roles_access','PenguatKuasa')->where('_id',$compound->penguatkuasa)->first();
  424. if(!empty($s)){
  425. $currentS = '['.$s->no_badan.'] '.$s->full_name;
  426. }
  427. return view('main-dashboard.compound_detail.compound_job',compact('user','compound','file','roles','staffs','role','department','currentS','site'));
  428. }
  429. public function manualCompound(){
  430. $id = Auth::guard('sadmin')->id();
  431. $user = Staff::with('StaffDetail')->find($id);
  432. $site = SiteSetting::first();
  433. $faulty = Faulty::with('DeedLaw','Department')->get();
  434. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  435. return view('main-dashboard.compound.compound_form',compact('user','site','faulty','staff'));
  436. }
  437. /**
  438. * Create generate kpd number controller.
  439. *
  440. * @return value
  441. */
  442. public function generateKPD(){
  443. $count = 0;
  444. do {
  445. $count = Compound::count();
  446. $count = $count + 1;
  447. } while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
  448. return $count;
  449. }
  450. public function storemanualCompound(Request $request){
  451. $id = Auth::guard('sadmin')->id();
  452. $user = Staff::with('StaffDetail')->find($id);
  453. $compound = Compound::where('kpd', $request->kpd)->first();
  454. if(empty($compound)){
  455. $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
  456. if(!empty($faulty)){
  457. $kpd = $request->kpd;
  458. $no_siri = date('yn',strtotime($request->tarikh_dikeluarkan)).'-'.$kpd;
  459. $fileData = [
  460. 'no_siri' => $no_siri,
  461. ];
  462. if($request->jenisKompaun == 'Parkir'){
  463. $compoundData = [
  464. 'jenis' => 'Parkir',
  465. 'kpd' => $kpd,
  466. 'nama' => '-',
  467. 'identity' => '-',
  468. 'alamat' => '-',
  469. "no_plate" => strtolower($request->no_plate),
  470. "no_cukai_jalan" => $request->noCukaijalan,
  471. "jenis_kenderaan" => $request->jenisKenderaan,
  472. "model_kenderaan" => $request->modelKenderaan,
  473. "warna_kenderaan" => $request->warnakenderaan,
  474. "nama_taman" => $request->namaTaman,
  475. "nama_jalan" => $request->namaJalan,
  476. "no_parking" => $request->noParking,
  477. "catatan" => $request->catatan,
  478. "lokasi_kejadian" => '-',
  479. 'latlong' => $request->Latlong,
  480. 'jbkod' => $request->jabatan,
  481. 'akta' => $faulty->deed_law_id,
  482. 'seksyen_kesalahan' => $faulty->_id,
  483. 'jumlah_asal_kompaun' => $faulty->amount,
  484. 'jumlah_kemaskini_kompaun' => '',
  485. 'dikeluarkan' => $request->staff,
  486. "status" => 'Belum Bayar',
  487. "amount_payment" => '',
  488. "receipt" => '',
  489. "modul" => '03',
  490. "penguatkuasa" => '',
  491. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  492. ];
  493. }else if($request->jenisKompaun == 'Pelbagai_KT'){
  494. $compoundData = [
  495. 'jenis' => 'Pelbagai_KT',
  496. 'kpd' => $kpd,
  497. 'nama' => $request->namaP,
  498. 'identity' => $request->noIc,
  499. 'nama_syarikat' => $request->namaS,
  500. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  501. 'alamat' => $request->alamat,
  502. 'no_telefon' => $request->tel,
  503. 'no_akaun_lesen' =>$request->lesen,
  504. "no_plate" => strtolower($request->no_plate),
  505. "no_cukai_jalan" => $request->noCukaijalan,
  506. // "maklumat_tambahan" => $request->catatan,
  507. "catatan" => $request->catatan,
  508. "lokasi_kejadian" => $request->lokasi_kejadian,
  509. 'latlong' => $request->Latlong,
  510. 'jbkod' => $request->jabatan,
  511. 'akta' => $faulty->deed_law_id,
  512. 'seksyen_kesalahan' => $faulty->_id,
  513. 'jumlah_asal_kompaun' => $faulty->amount,
  514. 'jumlah_kemaskini_kompaun' => '',
  515. 'dikeluarkan' => $request->staff,
  516. "status" => 'Belum Bayar',
  517. "amount_payment" => '',
  518. "receipt" => '',
  519. "modul" => '03',
  520. "penguatkuasa" => '',
  521. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  522. ];
  523. }else if($request->jenisKompaun == 'Pelbagai_JPB'){
  524. $compoundData = [
  525. 'jenis' => 'Pelbagai_JPB',
  526. 'kpd' => $kpd,
  527. 'nama' => $request->namaP,
  528. 'identity' => $request->noIc,
  529. 'nama_syarikat' => $request->namaS,
  530. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  531. 'alamat' => $request->alamat,
  532. 'no_telefon' => $request->tel,
  533. 'no_akaun_lesen' =>$request->lesen,
  534. "no_plate" => strtolower($request->no_plate),
  535. "no_cukai_jalan" => $request->noCukaijalan,
  536. // "maklumat_tambahan" => $request->catatan,
  537. "catatan" => $request->catatan,
  538. "lokasi_kejadian" => $request->lokasi_kejadian,
  539. 'latlong' => $request->Latlong,
  540. 'jbkod' => $request->jabatan,
  541. 'akta' => $faulty->deed_law_id,
  542. 'seksyen_kesalahan' => $faulty->_id,
  543. 'jumlah_asal_kompaun' => $faulty->amount,
  544. 'jumlah_kemaskini_kompaun' => '',
  545. 'dikeluarkan' => $request->staff,
  546. "status" => 'Belum Bayar',
  547. "amount_payment" => '',
  548. "receipt" => '',
  549. "modul" => '03',
  550. "penguatkuasa" => '',
  551. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  552. ];
  553. }else if($request->jenisKompaun == 'Pelbagai_PA'){
  554. $compoundData = [
  555. 'jenis' => 'Pelbagai_PA',
  556. 'kpd' => $kpd,
  557. 'nama' => $request->namaP,
  558. 'identity' => $request->noIc,
  559. 'nama_syarikat' => $request->namaS,
  560. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  561. 'alamat' => $request->alamat,
  562. 'no_telefon' => $request->tel,
  563. 'no_akaun_lesen' =>$request->lesen,
  564. "no_plate" => strtolower($request->no_plate),
  565. "no_cukai_jalan" => $request->noCukaijalan,
  566. // "maklumat_tambahan" => $request->catatan,
  567. "catatan" => $request->catatan,
  568. "lokasi_kejadian" => $request->lokasi_kejadian,
  569. 'latlong' => $request->Latlong,
  570. 'jbkod' => $request->jabatan,
  571. 'akta' => $faulty->deed_law_id,
  572. 'seksyen_kesalahan' => $faulty->_id,
  573. 'jumlah_asal_kompaun' => $faulty->amount,
  574. 'jumlah_kemaskini_kompaun' => '',
  575. 'dikeluarkan' => $request->staff,
  576. "status" => 'Belum Bayar',
  577. "amount_payment" => '',
  578. "receipt" => '',
  579. "modul" => '03',
  580. "penguatkuasa" => '',
  581. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  582. ];
  583. }else if($request->jenisKompaun == 'Pelbagai_LESEN'){
  584. $compoundData = [
  585. 'jenis' => 'Pelbagai_LESEN',
  586. 'kpd' => $kpd,
  587. 'nama' => $request->namaP,
  588. 'identity' => $request->noIc,
  589. 'nama_syarikat' => $request->namaS,
  590. 'no_daftar_syarikat' => strtolower($request->daftarNo),
  591. 'alamat' => $request->alamat,
  592. 'no_telefon' => $request->tel,
  593. 'no_akaun_lesen' =>$request->lesen,
  594. "no_plate" => strtolower($request->no_plate),
  595. "no_cukai_jalan" => $request->noCukaijalan,
  596. // "maklumat_tambahan" => $request->catatan,
  597. "catatan" => $request->catatan,
  598. "lokasi_kejadian" => $request->lokasi_kejadian,
  599. 'latlong' => $request->Latlong,
  600. 'jbkod' => $request->jabatan,
  601. 'akta' => $faulty->deed_law_id,
  602. 'seksyen_kesalahan' => $faulty->_id,
  603. 'jumlah_asal_kompaun' => $faulty->amount,
  604. 'jumlah_kemaskini_kompaun' => '',
  605. 'dikeluarkan' => $request->staff,
  606. "status" => 'Belum Bayar',
  607. "amount_payment" => '',
  608. "receipt" => '',
  609. "modul" => '03',
  610. "penguatkuasa" => '',
  611. "created_at" => new Carbon($request->tarikh_dikeluarkan),
  612. ];
  613. }
  614. $file = ConfidentialFile::create($fileData);
  615. $saved = $file->compound()->create($compoundData);
  616. if($saved){
  617. $this->dispatch(new StoreCompoundManual($request->all(), $kpd, $request->staff, $no_siri));
  618. return redirect()->back()->with('success_msg', 'Berjaya simpan rekod kompaun!');
  619. }
  620. }else{
  621. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  622. }
  623. }else{
  624. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' telah wujud!');
  625. }
  626. }
  627. public function manualCompoundEdit($_id){
  628. $id = Auth::guard('sadmin')->id();
  629. $user = Staff::with('StaffDetail')->find($id);
  630. $site = SiteSetting::first();
  631. $faulty = Faulty::with('DeedLaw','Department')->get();
  632. $staff = StaffDetail::where('roles_access','PenguatKuasa')->get();
  633. $compound = Compound::with('Faulty','Department','Deedlaw')->find($_id);
  634. return view('main-dashboard.compound.compound_form_edit',compact('user','site','faulty','staff','compound'));
  635. }
  636. public function editmanualCompound(Request $request){
  637. $id = Auth::guard('sadmin')->id();
  638. $user = Staff::with('StaffDetail')->find($id);
  639. $compound = Compound::find($request->_id);
  640. if(!empty($compound)){
  641. $faulty = Faulty::with('DeedLaw','Department')->where('_id',$request->get('seksyen'))->first();
  642. if(!empty($faulty) && !empty($faulty->Deedlaw) && !empty($faulty->Department)){
  643. if($compound->jenis == 'Parkir'){
  644. $compound->kpd = $request->kpd;
  645. $compound->jbkod = $faulty->Department[0]->_id;
  646. $compound->akta = $faulty->DeedLaw->_id;
  647. $compound->seksyen_kesalahan = $faulty->_id;
  648. $compound->no_plate = strtolower($request->no_plate);
  649. $compound->no_cukai_jalan = $request->noCukaijalan;
  650. $compound->jenis_kenderaan = $request->jenisKenderaan;
  651. $compound->model_kenderaan = $request->modelKenderaan;
  652. $compound->warna_kenderaan = $request->warnakenderaan;
  653. $compound->nama_taman = $request->namaTaman;
  654. $compound->nama_jalan = $request->namaJalan;
  655. $compound->no_parking = $request->noParking;
  656. $compound->maklumat_tambahan = $request->catatan;
  657. $compound->catatan = $request->butiran_kesalahan;
  658. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  659. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  660. $compound->save();
  661. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  662. }else if($compound->jenis == 'Pelbagai'){
  663. $compound->kpd = $request->kpd;
  664. $compound->jbkod = $faulty->Department[0]->_id;
  665. $compound->akta = $faulty->DeedLaw->_id;
  666. $compound->seksyen_kesalahan = $faulty->_id;
  667. $compound->nama = $request->namaP;
  668. $compound->identity = $request->noIc;
  669. $compound->nama_syarikat = $request->namaS;
  670. $compound->no_daftar_syarikat = strtolower($request->daftarNo);
  671. $compound->alamat = $request->alamat;
  672. $compound->no_telefon = $request->tel;
  673. $compound->no_akaun_lesen = $request->lesen;
  674. $compound->no_plate = strtolower($request->no_plate);
  675. $compound->no_cukai_jalan = $request->noCukaijalan;
  676. $compound->no_plate = strtolower($request->no_plate);
  677. $compound->maklumat_tambahan = $request->catatan;
  678. $compound->catatan = $request->butiran_kesalahan;
  679. $compound->lokasi_kejadian = $request->lokasi_kejadian;
  680. $compound->created_at = new Carbon($request->tarikh_dikeluarkan);
  681. $compound->save();
  682. return redirect()->back()->with('success_msg', 'Berjaya kemasikini!');
  683. }
  684. }else {
  685. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod seksyen kesalahan tidak ditemui!');
  686. }
  687. }else{
  688. return redirect()->back()->withInput()->with('error_msg', '<strong>Tidak Berjaya!</strong> Rekod kompaun '.$request->kpd.' tidak wujud!');
  689. }
  690. }
  691. }