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 38KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. <?php
  2. namespace App\Http\Controllers\api;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Api\BaseController;
  5. use Config;
  6. use File;
  7. use Carbon\Carbon;
  8. use App\SiteSetting;
  9. use App\Model\Staff;
  10. use App\Model\StaffDetail;
  11. use App\Model\User;
  12. use App\Model\UserDetail;
  13. use App\Model\Module\Roles;
  14. use App\Model\Module\Compound;
  15. use App\Model\Module\Department;
  16. use App\Model\Module\DeedLaw;
  17. use App\Model\Module\Faulty;
  18. use App\Model\Module\ConfidentialFile;
  19. use App\Model\Module\History;
  20. use App\Model\Module\Memo;
  21. use App\Model\Module\Attachment;
  22. use App\Model\Module\ApiIntegration;
  23. use App\Jobs\StoreCompound;
  24. use App\Jobs\UpdateCompoundPrice;
  25. class CompoundController extends BaseController
  26. {
  27. /**
  28. * Create list compound for penguatkuasa controller.
  29. *
  30. * @return value
  31. */
  32. public function confidentialFileList(Request $request){
  33. $nested_data = array();
  34. $user = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
  35. if(!empty($user)){
  36. $no_badan = $user->no_badan; $modul = $request->modul;
  37. $compound = Compound::with('ConfidentialFile')->where('penguatkuasa', $no_badan)->where('modul', $modul)->orderBy('updated_at', 'desc')->get();
  38. foreach ($compound as $key => $a) {
  39. if(!empty($a->ConfidentialFile)){
  40. array_push($nested_data, array(
  41. 'kpd' => $a->kpd,
  42. 'tarikh' => $a->created_at->format('d/m/Y'),
  43. 'masa' => $a->created_at->format('h:i a'),
  44. 'no_siri' => $a->ConfidentialFile->no_siri,
  45. ));
  46. }
  47. }
  48. return $this->sendResponse($nested_data, 'Berjaya, dapatkan senarai file kulit');
  49. }else{
  50. return $this->sendError('', 'data kakitangan tidak ditemui');
  51. }
  52. }
  53. /**
  54. * Create generate kpd number controller.
  55. *
  56. * @return value
  57. */
  58. public function generateKPD(){
  59. // $allowedNumbers = range(0, 9);
  60. // shuffle($allowedNumbers);
  61. // $digits = array_rand($allowedNumbers, $range);
  62. // $number = '';
  63. // foreach($digits as $d){
  64. // $number .= $allowedNumbers[$d];
  65. // }
  66. $count = 0;
  67. do {
  68. $count = Compound::count();
  69. $count = $count + 1;
  70. } while (Compound::where("kpd", "=", 'KP'.$count)->first() instanceof Compound);
  71. return $count;
  72. }
  73. /**
  74. * Create compound list controller.
  75. *
  76. * @return json
  77. */
  78. public function storeCompound(Request $request)
  79. {
  80. $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
  81. if(empty($staff)){
  82. return $this->sendError('Invalid', 'Staff not existed');
  83. }else {
  84. $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
  85. if(!empty($faulty)){
  86. $countKPD = 0;
  87. do {
  88. $countKPD = Compound::withTrashed()->count();
  89. $countKPD = $countKPD + 1;
  90. } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
  91. $kpd = 'KP' . $countKPD;
  92. // $kpd = '';
  93. // do {
  94. // $kpd = 'KP' . $this->generateKPD();
  95. // } while (Compound::where("kpd", "=", $kpd)->first() instanceof Compound);
  96. if($kpd != ''){
  97. $no_siri = $this->generateKPD();
  98. $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
  99. $data = array();
  100. $dataExist = false;
  101. do {
  102. $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
  103. if(!empty($compound)){
  104. $tawaran = '';
  105. if($compound->jumlah_kemaskini_kompaun != ''){
  106. $tawaran = $compound->jumlah_kemaskini_kompaun;
  107. }else{
  108. $tawaran = $compound->jumlah_asal_kompaun;
  109. }
  110. array_push($data, array('kpd' => $kpd, 'jumlah_kompoun' => $tawaran));
  111. $dataExist = true;
  112. }
  113. }while(!$dataExist);
  114. return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
  115. }
  116. }else{
  117. return $this->sendError('Gagal', 'Rekod seksyen kesalahan tidak ditemui!');
  118. }
  119. }
  120. }
  121. public function storeCompoundAttachment(Request $request)
  122. {
  123. $staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
  124. if(empty($staff)){
  125. return $this->sendError('Invalid', 'Staff not existed');
  126. }else {
  127. $kpd = $request->get('kpd');
  128. $success_upload = 0; $count_upload = 0;
  129. $compound = Compound::with('ConfidentialFile')->where('kpd', $kpd)->orWhere('non', $kpd)->first();
  130. if(!empty($compound)){
  131. if($request->hasFile('file')) {
  132. $upload = [];
  133. foreach($request->file('file') as $f){
  134. $upload[] = [
  135. 'name' => 'file[]',
  136. 'contents' => fopen( $f->getPathname(), 'r' ),
  137. 'filename' => $f->getClientOriginalName()
  138. ];
  139. }
  140. $upload [] = [
  141. 'name' => 'kp',
  142. 'contents' => $kpd
  143. ];
  144. $upload [] = [
  145. 'name' => 'no_siri',
  146. 'contents' => $compound->ConfidentialFile->no_siri
  147. ];
  148. $upload [] = [
  149. 'name' => 'type',
  150. 'contents' => 'mbip'
  151. ];
  152. $client = new \GuzzleHttp\Client();
  153. $result = $client->request('POST', 'https://files.sipadu.my/api/upload/compound/picture', [
  154. 'multipart' => $upload
  155. ]);
  156. $response = json_decode($result->getBody()->getContents());
  157. if($response->success == true){
  158. foreach ($response->data as $key => $d) {
  159. $attach = new Attachment();
  160. $attach->path = $d;
  161. $compound->attachment()->save($attach);
  162. }
  163. return $this->sendResponse('', $response->message);
  164. }else if($response->success == false){
  165. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  166. }
  167. }else{
  168. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  169. }
  170. }else{
  171. return $this->sendError('Gagal', 'Kompaun '.$kpd.' tidak ditemui!');
  172. }
  173. }
  174. }
  175. public function storeAcceptanceCompound(Request $request)
  176. {
  177. $staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
  178. if(empty($staff)){
  179. return $this->sendError('Invalid', 'Staff not existed');
  180. }else {
  181. $kpd = $request->get('kpd');
  182. $success_upload = 0; $count_upload = 0;
  183. $compound = Compound::with('ConfidentialFile')->where('kpd', $kpd)->first();
  184. if(!empty($compound)){
  185. if($request->hasFile('file')) {
  186. $upload = [];
  187. foreach($request->file('file') as $f){
  188. $upload[] = [
  189. 'name' => 'file[]',
  190. 'contents' => fopen( $f->getPathname(), 'r' ),
  191. 'filename' => $f->getClientOriginalName()
  192. ];
  193. }
  194. $upload [] = [
  195. 'name' => 'kp',
  196. 'contents' => $kpd
  197. ];
  198. $upload [] = [
  199. 'name' => 'no_siri',
  200. 'contents' => $compound->ConfidentialFile->no_siri
  201. ];
  202. $upload [] = [
  203. 'name' => 'type',
  204. 'contents' => 'proxy'
  205. ];
  206. $client = new \GuzzleHttp\Client();
  207. $result = $client->request('POST', 'https://files.sipadu.my/api/upload/acceptance/compound', [
  208. 'multipart' => $upload
  209. ]);
  210. $response = json_decode($result->getBody()->getContents());
  211. if($response->success == true){
  212. foreach ($response->data as $key => $d) {
  213. $attach = new Attachment();
  214. $attach->path = $d;
  215. $compound->attachment()->save($attach);
  216. }
  217. return $this->sendResponse('', $response->message);
  218. }else if($response->success == false){
  219. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  220. }
  221. }else{
  222. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  223. }
  224. }else{
  225. return $this->sendError('Gagal', 'Kompaun '.$kpd.' tidak ditemui!');
  226. }
  227. }
  228. }
  229. public function compoundList($modul){
  230. $nested_data = array();
  231. if($modul == '06-07'){
  232. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  233. $q->where(function($query){
  234. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  235. });
  236. })->orderBy('updated_at', 'desc')->get();
  237. }else{
  238. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  239. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  240. })->orderBy('updated_at', 'desc')->get();
  241. }
  242. // $compound = Compound::with(['ConfidentialFile' => function($q){
  243. // $q->where('status', 'Belum Bayar');
  244. // }])->orderBy('updated_at', 'desc')->get();
  245. $class = '';
  246. if($modul == '03'){
  247. $class = "success/";
  248. }else if($a->modul == '04'){
  249. $class = $cat_modul."/primary/";
  250. }else if($a->modul == '05'){
  251. $class = $cat_modul."/warning/";
  252. }else if($a->modul == '06'){
  253. $class = $cat_modul."/info/";
  254. }else if($a->modul == '07'){
  255. $class = $cat_modul."/danger/";
  256. }else if($a->modul == '08'){
  257. $class = $cat_modul."/inverse/";
  258. }
  259. $cat_modul = '-';
  260. if($modul != '-'){
  261. $cat = Roles::where('kod',$modul)->first();
  262. if(!empty($cat)){
  263. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  264. $dump = explode(' ',trim($cat->name));
  265. $cat_modul = $dump[0];
  266. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  267. $dump = explode('- ',trim($cat->name));
  268. $cat_modul = $dump[1];
  269. }else{
  270. $cat_modul = $cat->name;
  271. }
  272. }
  273. }
  274. $curr = Carbon::now()->getTimestamp();
  275. $i = 1;
  276. foreach($compound as $a) {
  277. if(!empty($a->ConfidentialFile)){
  278. $n1 = ''; $faulty = ''; $tawaran = '';
  279. $reg_time = $a->updated_at;
  280. $expiry_date = $reg_time->addDays(3);
  281. $expiry_date = $expiry_date->getTimestamp();
  282. /*$cat_modul = '-';
  283. if($a->modul != '-'){
  284. $cat = Roles::where('kod',$a->modul)->first();
  285. if(!empty($cat)){
  286. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  287. $dump = explode(' ',trim($cat->name));
  288. $cat_modul = $dump[0];
  289. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  290. $dump = explode('- ',trim($cat->name));
  291. $cat_modul = $dump[1];
  292. }else{
  293. $cat_modul = $cat->name;
  294. }
  295. }
  296. }*/
  297. // if($curr < $expiry_date) {
  298. // if($a->modul == '03'){
  299. // $n1 = "Baru/success/";
  300. // }else if($a->modul == '04'){
  301. // $n1 = "Baru/".$cat_modul."/primary/";
  302. // }else if($a->modul == '05'){
  303. // $n1 = "Baru/".$cat_modul."/warning/";
  304. // }else if($a->modul == '06'){
  305. // $n1 = "Baru/".$cat_modul."/info/";
  306. // }else if($a->modul == '07'){
  307. // $n1 = "Baru/".$cat_modul."/danger/";
  308. // }else if($a->modul == '08'){
  309. // $n1 = "Baru/".$cat_modul."/inverse/";
  310. // }
  311. // }else{
  312. // if($a->modul == '03'){
  313. // $n1 = "";
  314. // }else if($a->modul == '04'){
  315. // $n1 = $cat_modul."/primary/";
  316. // }else if($a->modul == '05'){
  317. // $n1 = $cat_modul."/warning/";
  318. // }else if($a->modul == '06'){
  319. // $n1 = $cat_modul."/info/";
  320. // }else if($a->modul == '07'){
  321. // $n1 = $cat_modul."/danger/";
  322. // }else if($a->modul == '08'){
  323. // $n1 = $cat_modul."/inverse/";
  324. // }
  325. // }
  326. if($curr < $expiry_date) {
  327. $n1 = "Baru/".$class;
  328. }else{
  329. $n1 = $class;
  330. }
  331. if($a->jumlah_kemaskini_kompaun == ''){
  332. $tawaran = $a->jumlah_asal_kompaun;
  333. }else{
  334. $tawaran = $a->jumlah_kemaskini_kompaun;
  335. }
  336. $no_plate = '-';
  337. if($a->no_plate != '-'){
  338. $no_plate = $a->no_plate;
  339. }else{
  340. $no_plate = '-';
  341. }
  342. // $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  343. // if(!empty($faulty)){
  344. // $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  345. // }
  346. array_push($nested_data, array(
  347. 'kpd' => $n1.$a->kpd,
  348. 'jenis' => $a->jenis,
  349. 'no_plat' => $no_plate,
  350. 'tarikh' => $a->created_at->format('d/m/Y'),
  351. 'masa' => $a->created_at->format('h:i a'),
  352. 'nama' => $a->nama,
  353. 'nric' => $a->identity,
  354. 'seksyen' => '['.$a->Faulty->sketr.'] '.$a->Faulty->nama,
  355. 'jumlah' => 'RM '.$tawaran,
  356. 'status' => $a->status,
  357. 'tindakan' => $a->kpd
  358. ));
  359. $i++;
  360. }
  361. }
  362. return \DataTables::of($nested_data)->make(true);
  363. }
  364. public function compoundFilterList($jbkod,$akta,$sec,$modul){
  365. $nested_data = array();
  366. if($modul == '06-07'){
  367. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  368. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  369. $q->where(function($query){
  370. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  371. });
  372. })->orderBy('updated_at', 'desc')->get();
  373. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  374. if(strpos($jbkod, 'Pegawai') !== false) {
  375. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  376. $q->where(function($query){
  377. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  378. });
  379. })->orderBy('updated_at', 'desc')->get();
  380. }else{
  381. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  382. $q->where(function($query){
  383. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  384. });
  385. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  386. }
  387. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  388. if(strpos($jbkod, 'Pegawai') !== false) {
  389. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  390. $q->where(function($query){
  391. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  392. });
  393. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  394. }else {
  395. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  396. $q->where(function($query){
  397. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  398. });
  399. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  400. }
  401. }
  402. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  403. if(strpos($jbkod, 'Pegawai') !== false) {
  404. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  405. $q->where(function($query){
  406. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  407. });
  408. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  409. }else{
  410. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  411. $q->where(function($query){
  412. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  413. });
  414. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  415. }
  416. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  417. if(strpos($jbkod, 'Pegawai') !== false) {
  418. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  419. $q->where(function($query){
  420. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  421. });
  422. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  423. }else{
  424. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  425. $q->where(function($query){
  426. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  427. });
  428. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  429. }
  430. }
  431. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  432. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  433. $q->where(function($query){
  434. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  435. });
  436. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  437. }
  438. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  439. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  440. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  441. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  442. }
  443. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  444. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  445. $q->where(function($query){
  446. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  447. });
  448. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  449. }
  450. }else{
  451. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  452. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  453. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  454. })->orderBy('updated_at', 'desc')->get();
  455. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  456. if(strpos($jbkod, 'Pegawai') !== false) {
  457. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  458. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  459. })->orderBy('updated_at', 'desc')->get();
  460. }else{
  461. $compound = Compound::with('ConfidentialFile')->where(function($q) use($modul){
  462. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  463. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  464. }
  465. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  466. if(strpos($jbkod, 'Pegawai') !== false) {
  467. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  468. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  469. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  470. }else{
  471. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  472. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  473. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  474. }
  475. }
  476. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  477. if(strpos($jbkod, 'Pegawai') !== false) {
  478. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  479. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  480. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  481. }else{
  482. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  483. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  484. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  485. }
  486. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  487. if(strpos($jbkod, 'Pegawai') !== false) {
  488. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  489. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  490. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  491. }else{
  492. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  493. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  494. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  495. }
  496. }
  497. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  498. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  499. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  500. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  501. }
  502. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  503. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  504. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  505. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  506. }
  507. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  508. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  509. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  510. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  511. }
  512. }
  513. $class = '';
  514. if($modul == '03'){
  515. $class = "success/";
  516. }else if($a->modul == '04'){
  517. $class = $cat_modul."/primary/";
  518. }else if($a->modul == '05'){
  519. $class = $cat_modul."/warning/";
  520. }else if($a->modul == '06'){
  521. $class = $cat_modul."/info/";
  522. }else if($a->modul == '07'){
  523. $class = $cat_modul."/danger/";
  524. }else if($a->modul == '08'){
  525. $class = $cat_modul."/inverse/";
  526. }
  527. $cat_modul = '-';
  528. if($modul != '-'){
  529. $cat = Roles::where('kod',$modul)->first();
  530. if(!empty($cat)){
  531. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  532. $dump = explode(' ',trim($cat->name));
  533. $cat_modul = $dump[0];
  534. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  535. $dump = explode('- ',trim($cat->name));
  536. $cat_modul = $dump[1];
  537. }else{
  538. $cat_modul = $cat->name;
  539. }
  540. }
  541. }
  542. $curr = Carbon::now()->getTimestamp();
  543. $i = 1;
  544. foreach($compound as $a) {
  545. if(!empty($a->ConfidentialFile)){
  546. $n1 = ''; $faulty = ''; $tawaran = '';
  547. $reg_time = $a->updated_at;
  548. $expiry_date = $reg_time->addDays(3);
  549. $expiry_date = $expiry_date->getTimestamp();
  550. /*$cat_modul = '-';
  551. if($a->modul != '-'){
  552. $cat = Roles::where('kod',$a->modul)->first();
  553. if(!empty($cat)){
  554. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  555. $dump = explode(' ',trim($cat->name));
  556. $cat_modul = $dump[0];
  557. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  558. $dump = explode('- ',trim($cat->name));
  559. $cat_modul = $dump[1];
  560. }else{
  561. $cat_modul = $cat->name;
  562. }
  563. }
  564. }*/
  565. if($curr < $expiry_date) {
  566. $n1 = "Baru/".$class;
  567. }else{
  568. $n1 = $class;
  569. }
  570. if($a->jumlah_kemaskini_kompaun == ''){
  571. $tawaran = $a->jumlah_asal_kompaun;
  572. }else{
  573. $tawaran = $a->jumlah_kemaskini_kompaun;
  574. }
  575. $no_plate = '-';
  576. if($a->no_plate != '-'){
  577. $no_plate = $a->no_plate;
  578. }else{
  579. $no_plate = '-';
  580. }
  581. // $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  582. // if(!empty($faulty)){
  583. // $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  584. // }
  585. if(strpos($jbkod, 'Pegawai') !== false) {
  586. $temp = explode("|",$jbkod);
  587. $user = StaffDetail::with('Department')->where('_id', $temp[1])->first();
  588. if(!empty($user->Department)){
  589. if(in_array($a->jbkod, (array)$user->department_ids)) {
  590. array_push($nested_data, array(
  591. 'kpd' => $n1.$a->kpd,
  592. 'jenis' => $a->jenis,
  593. 'no_plat' => $no_plate,
  594. 'tarikh' => $a->created_at->format('d/m/Y'),
  595. 'masa' => $a->created_at->format('h:i a'),
  596. 'nama' => $a->nama,
  597. 'nric' => $a->identity,
  598. 'seksyen' => $faulty,
  599. 'jumlah' => 'RM '.$tawaran,
  600. 'status' => $a->status,
  601. 'tindakan' => $a->kpd
  602. ));
  603. $i++;
  604. }
  605. }
  606. }else {
  607. array_push($nested_data, array(
  608. 'kpd' => $n1.$a->kpd,
  609. 'jenis' => $a->jenis,
  610. 'no_plat' => $no_plate,
  611. 'tarikh' => $a->created_at->format('d/m/Y'),
  612. 'masa' => $a->created_at->format('h:i a'),
  613. 'nama' => $a->nama,
  614. 'nric' => $a->identity,
  615. 'seksyen' => '['.$a->Faulty->sketr.'] '.$a->Faulty->nama,
  616. 'jumlah' => 'RM '.$tawaran,
  617. 'status' => $a->status,
  618. 'tindakan' => $a->kpd
  619. ));
  620. $i++;
  621. }
  622. }
  623. }
  624. return \DataTables::of($nested_data)->make(true);
  625. }
  626. public function compoundCompleteLists(){
  627. $nested_data = array();
  628. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  629. $q->where('status', 'Berbayar');
  630. })->orderBy('updated_at', 'desc')->get();
  631. $curr = Carbon::now()->getTimestamp();
  632. $i = 1;
  633. foreach($compound as $a)
  634. {
  635. $n1 = ''; $faulty = '';
  636. $reg_time = $a->updated_at;
  637. $expiry_date = $reg_time->addDays(3);
  638. $expiry_date = $expiry_date->getTimestamp();
  639. if($curr < $expiry_date) {
  640. $n1 = "Baru/";
  641. }else{
  642. $n1 = "";
  643. }
  644. if(!empty($a->ConfidentialFile)){
  645. $cat_modul = '-';
  646. if($a->modul != '-'){
  647. $cat = Roles::where('kod',$a->modul)->first();
  648. if(!empty($cat)){
  649. $cat_modul = $cat->name;
  650. }
  651. }
  652. $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  653. if(!empty($faulty)){
  654. $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  655. }
  656. if($a->jumlah_kemaskini_kompaun == ''){
  657. $tawaran = $a->jumlah_asal_kompaun;
  658. }else{
  659. $tawaran = $a->jumlah_kemaskini_kompaun;
  660. }
  661. if($a->no_plate == '-'){
  662. $jenis = 'Pelbagai';
  663. }else{
  664. $jenis = 'Parkir';
  665. }
  666. array_push($nested_data, array(
  667. 'kpd' => $n1.$a->kpd,
  668. 'jenis' => $jenis,
  669. 'tarikh' => $a->created_at->format('d/m/Y'),
  670. 'masa' => $a->created_at->format('h:i a'),
  671. 'seksyen' => $faulty,
  672. 'jumlah' => 'RM '.$tawaran,
  673. 'bayaran' => 'RM '.$a->amount_payment,
  674. 'receipt' => $a->receipt,
  675. 'status' => $a->status,
  676. 'tindakan' => $a->kpd
  677. ));
  678. $i++;
  679. }
  680. }
  681. return \DataTables::of($nested_data)->make(true);
  682. }
  683. public function compoundCompleteFilterList($jbkod,$akta,$sec){
  684. $nested_data = array();
  685. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  686. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  687. $q->where('status', 'Berbayar');
  688. })->orderBy('updated_at', 'desc')->get();
  689. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  690. if(strpos($jbkod, 'Pegawai') !== false) {
  691. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  692. $q->where('status', 'Berbayar');
  693. })->orderBy('updated_at', 'desc')->get();
  694. }else{
  695. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  696. $q->where('status', 'Berbayar');
  697. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  698. }
  699. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  700. if(strpos($jbkod, 'Pegawai') !== false) {
  701. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  702. $q->where('status', 'Berbayar');
  703. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  704. }else{
  705. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  706. $q->where('status', 'Berbayar');
  707. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  708. }
  709. }
  710. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  711. if(strpos($jbkod, 'Pegawai') !== false) {
  712. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  713. $q->where('status', 'Berbayar');
  714. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  715. }else{
  716. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  717. $q->where('status', 'Berbayar');
  718. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  719. }
  720. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  721. if(strpos($jbkod, 'Pegawai') !== false) {
  722. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  723. $q->where('status', 'Berbayar');
  724. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  725. }else{
  726. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  727. $q->where('status', 'Berbayar');
  728. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  729. }
  730. }
  731. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  732. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  733. $q->where('status', 'Berbayar');
  734. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  735. }
  736. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  737. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  738. $q->where('status', 'Berbayar');
  739. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  740. }
  741. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  742. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  743. $q->where('status', 'Berbayar');
  744. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  745. }
  746. $curr = Carbon::now()->getTimestamp();
  747. $i = 1;
  748. foreach($compound as $a)
  749. {
  750. $n1 = ''; $faulty = ''; $tawaran = '';
  751. $reg_time = $a->updated_at;
  752. $expiry_date = $reg_time->addDays(3);
  753. $expiry_date = $expiry_date->getTimestamp();
  754. if($curr < $expiry_date) {
  755. $n1 = "Baru/";
  756. }else{
  757. $n1 = "";
  758. }
  759. if(!empty($a->ConfidentialFile)){
  760. $cat_modul = '-';
  761. if($a->modul != '-'){
  762. $cat = Roles::where('kod',$a->modul)->first();
  763. if(!empty($cat)){
  764. $cat_modul = $cat->name;
  765. }
  766. }
  767. $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  768. if(!empty($faulty)){
  769. $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  770. }
  771. if($a->jumlah_kemaskini_kompaun == ''){
  772. $tawaran = $a->jumlah_asal_kompaun;
  773. }else{
  774. $tawaran = $a->jumlah_kemaskini_kompaun;
  775. }
  776. if($a->no_plate == '-'){
  777. $jenis = 'Pelbagai';
  778. }else{
  779. $jenis = 'Parkir';
  780. }
  781. if(strpos($jbkod, 'Pegawai') !== false) {
  782. $temp = explode("|",$jbkod);
  783. $user = StaffDetail::with('Department')->where('_id', $temp[1])->first();
  784. if(!empty($user->Department)){
  785. if(in_array($a->jbkod, (array)$user->department_ids)) {
  786. array_push($nested_data, array(
  787. 'kpd' => $n1.$a->kpd,
  788. 'jenis' => $jenis,
  789. 'tarikh' => $a->created_at->format('d/m/Y'),
  790. 'masa' => $a->created_at->format('h:i a'),
  791. 'seksyen' => $faulty,
  792. 'jumlah' => 'RM '.$tawaran,
  793. 'bayaran' => 'RM '.$a->amount_payment,
  794. 'receipt' => $a->receipt,
  795. 'status' => $a->status,
  796. 'tindakan' => $a->kpd
  797. ));
  798. $i++;
  799. }
  800. }
  801. }else{
  802. array_push($nested_data, array(
  803. 'kpd' => $n1.$a->kpd,
  804. 'jenis' => $jenis,
  805. 'tarikh' => $a->created_at->format('d/m/Y'),
  806. 'masa' => $a->created_at->format('h:i a'),
  807. 'seksyen' => $faulty,
  808. 'jumlah' => 'RM '.$tawaran,
  809. 'bayaran' => 'RM '.$a->amount_payment,
  810. 'receipt' => $a->receipt,
  811. 'status' => $a->status,
  812. 'tindakan' => $a->kpd
  813. ));
  814. $i++;
  815. }
  816. }
  817. }
  818. return \DataTables::of($nested_data)->make(true);
  819. }
  820. public function viewCompoundToday(Request $request)
  821. {
  822. $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
  823. if(empty($staff)){
  824. return $this->sendError('Invalid', 'Staff not existed');
  825. }else {
  826. $data = array(); $timestamp = time();
  827. $start = Carbon::createFromTimestamp($timestamp)->startOfDay();
  828. $end = Carbon::createFromTimestamp($timestamp)->endOfDay();
  829. $compound = Compound::with('ConfidentialFile','Faulty','Department')->where('modul','03')->where('dikeluarkan',$staff->_id)->whereBetween('created_at', [$start, $end])->orderBy('created_at','DESC')->get();
  830. foreach($compound as $c){
  831. if(!empty($c->Faulty) && !empty($c->Department)){
  832. $tawaran = '';
  833. $akta = DeedLaw::where('_id',$c->akta)->first();
  834. $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first();
  835. if($c->jumlah_kemaskini_kompaun == ''){
  836. $tawaran = $c->jumlah_asal_kompaun;
  837. }else{
  838. $tawaran = $c->jumlah_kemaskini_kompaun;
  839. }
  840. if($c->jenis == 'Pelbagai'){
  841. array_push($data, array(
  842. "no_plate" => $c->no_plate,
  843. 'nama' => $c->nama,
  844. 'identity' => $c->identity,
  845. 'nama_syarikat' => $c->nama_syarikat,
  846. 'no_daftar_syarikat' => $c->no_daftar_syarikat,
  847. 'alamat' => $c->alamat,
  848. 'jumlah' => $tawaran,
  849. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  850. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  851. 'latlong' => $c->latlong,
  852. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  853. 'kpd' => $c->kpd,
  854. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  855. 'amount_before_14' => $c->Faulty->amount_before_14,
  856. 'amount_before_30' => $c->Faulty->amount_before_30,
  857. 'amount' => $c->Faulty->amount,
  858. 'jenis' => $c->jenis,
  859. 'keterangan'=> $c->catatan,
  860. 'no_telefon' => $c->no_telefon,
  861. 'no_lesen' => $c->no_akaun_lesen,
  862. 'lokasi_dikompaun' => $c->lokasi_kejadian,
  863. 'no_cukai_jalan' => $c->no_cukai_jalan,
  864. ));
  865. }else if($c->jenis == 'Parkir'){
  866. array_push($data, array(
  867. "no_plate" => $c->no_plate,
  868. "no_cukai_jalan" => $c->no_cukai_jalan,
  869. "jenis_kenderaan" => $c->jenis_kenderaan,
  870. "model_kenderaan" => $c->model_kenderaan,
  871. "warna_kenderaan" => $c->warna_kenderaan,
  872. "nama_taman" => $c->nama_taman,
  873. "nama_jalan" => $c->nama_jalan,
  874. "nama_kawasan" => $c->nama_kawasan,
  875. "no_parking" => $c->no_parking,
  876. 'jumlah' => $tawaran,
  877. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  878. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  879. 'latlong' => $c->latlong,
  880. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  881. 'kpd' => $c->kpd,
  882. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  883. 'amount_before_14' => $c->Faulty->amount_before_14,
  884. 'amount_before_30' => $c->Faulty->amount_before_30,
  885. 'amount' => $c->Faulty->amount,
  886. 'jenis' => $c->jenis,
  887. 'keterangan'=> $c->catatan
  888. ));
  889. }
  890. }
  891. }
  892. return $this->sendResponse($data, 'Senarai data kompaun');
  893. }
  894. }
  895. public function viewNoticeToday(Request $request)
  896. {
  897. $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
  898. if(empty($staff)){
  899. return $this->sendError('Invalid', 'Staff not existed');
  900. }else {
  901. $data = array();
  902. $start = Carbon::now()->startOfDay()->toDateTimeString();
  903. $end = Carbon::now()->endOfDay()->toDateTimeString();
  904. $compound = Compound::with('ConfidentialFile','Faulty','Department')->where('modul','02')
  905. ->where('dikeluarkan_n',$staff->_id)->whereBetween('created_n', [$start, $end])->orderBy('created_n','DESC')->get();
  906. foreach($compound as $c){
  907. if(!empty($c->Faulty) && !empty($c->Department)){
  908. $tawaran = '';
  909. $akta = DeedLaw::where('_id',$c->akta)->first();
  910. $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first();
  911. if($c->jumlah_kemaskini_kompaun == ''){
  912. $tawaran = $c->jumlah_asal_kompaun;
  913. }else{
  914. $tawaran = $c->jumlah_kemaskini_kompaun;
  915. }
  916. if($c->jenis == 'Pelbagai'){
  917. array_push($data, array(
  918. "no_plate" => $c->no_plate,
  919. 'nama' => $c->nama,
  920. 'identity' => $c->identity,
  921. 'nama_syarikat' => $c->nama_syarikat,
  922. 'no_daftar_syarikat' => $c->no_daftar_syarikat,
  923. 'alamat' => $c->alamat,
  924. 'jumlah' => $tawaran,
  925. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  926. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  927. 'latlong' => $c->latlong,
  928. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  929. 'kpd' => $c->kpd,
  930. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  931. 'amount_before_14' => $c->Faulty->amount_before_14,
  932. 'amount_before_30' => $c->Faulty->amount_before_30,
  933. 'amount' => $c->Faulty->amount,
  934. 'jenis' => $c->jenis,
  935. 'keterangan'=> $c->catatan,
  936. 'no_telefon' => $c->no_telefon,
  937. 'no_lesen' => $c->no_akaun_lesen,
  938. 'lokasi_dikompaun' => $c->lokasi_kejadian,
  939. 'no_cukai_jalan' => $c->no_cukai_jalan,
  940. ));
  941. }else if($c->jenis == 'Parkir'){
  942. array_push($data, array(
  943. "no_plate" => $c->no_plate,
  944. "no_cukai_jalan" => $c->no_cukai_jalan,
  945. "jenis_kenderaan" => $c->jenis_kenderaan,
  946. "model_kenderaan" => $c->model_kenderaan,
  947. "warna_kenderaan" => $c->warna_kenderaan,
  948. "nama_taman" => $c->nama_taman,
  949. "nama_jalan" => $c->nama_jalan,
  950. "nama_kawasan" => $c->nama_kawasan,
  951. "no_parking" => $c->no_parking,
  952. 'jumlah' => $tawaran,
  953. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  954. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  955. 'latlong' => $c->latlong,
  956. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  957. 'kpd' => $c->kpd,
  958. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  959. 'amount_before_14' => $c->Faulty->amount_before_14,
  960. 'amount_before_30' => $c->Faulty->amount_before_30,
  961. 'amount' => $c->Faulty->amount,
  962. 'jenis' => $c->jenis,
  963. 'keterangan'=> $c->catatan
  964. ));
  965. }
  966. }
  967. }
  968. return $this->sendResponse($data, 'Senarai data kompaun');
  969. }
  970. }
  971. }