Dashboard sipadu mbip
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CompoundController.php 49KB

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