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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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)->first();
  130. dd($kpd);
  131. if(!empty($compound)){
  132. if($request->hasFile('file')) {
  133. $upload = [];
  134. foreach($request->file('file') as $f){
  135. $upload[] = [
  136. 'name' => 'file[]',
  137. 'contents' => fopen( $f->getPathname(), 'r' ),
  138. 'filename' => $f->getClientOriginalName()
  139. ];
  140. }
  141. $upload [] = [
  142. 'name' => 'kp',
  143. 'contents' => $kpd
  144. ];
  145. $upload [] = [
  146. 'name' => 'no_siri',
  147. 'contents' => $compound->ConfidentialFile->no_siri
  148. ];
  149. $upload [] = [
  150. 'name' => 'type',
  151. 'contents' => 'mbip'
  152. ];
  153. $client = new \GuzzleHttp\Client();
  154. $result = $client->request('POST', 'https://files.sipadu.my/api/upload/compound/picture', [
  155. 'multipart' => $upload
  156. ]);
  157. $response = json_decode($result->getBody()->getContents());
  158. if($response->success == true){
  159. foreach ($response->data as $key => $d) {
  160. $attach = new Attachment();
  161. $attach->path = $d;
  162. $compound->attachment()->save($attach);
  163. }
  164. return $this->sendResponse('', $response->message);
  165. }else if($response->success == false){
  166. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  167. }
  168. }else{
  169. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  170. }
  171. }else{
  172. return $this->sendError('Gagal', 'Kompaun '.$kpd.' tidak ditemui!');
  173. }
  174. }
  175. }
  176. public function storeAcceptanceCompound(Request $request)
  177. {
  178. $staff = Staff::with('StaffDetail')->where('api_token', $request->api_token)->first();
  179. if(empty($staff)){
  180. return $this->sendError('Invalid', 'Staff not existed');
  181. }else {
  182. $kpd = $request->get('kpd');
  183. $success_upload = 0; $count_upload = 0;
  184. $compound = Compound::with('ConfidentialFile')->where('kpd', $kpd)->first();
  185. if(!empty($compound)){
  186. if($request->hasFile('file')) {
  187. $upload = [];
  188. foreach($request->file('file') as $f){
  189. $upload[] = [
  190. 'name' => 'file[]',
  191. 'contents' => fopen( $f->getPathname(), 'r' ),
  192. 'filename' => $f->getClientOriginalName()
  193. ];
  194. }
  195. $upload [] = [
  196. 'name' => 'kp',
  197. 'contents' => $kpd
  198. ];
  199. $upload [] = [
  200. 'name' => 'no_siri',
  201. 'contents' => $compound->ConfidentialFile->no_siri
  202. ];
  203. $upload [] = [
  204. 'name' => 'type',
  205. 'contents' => 'proxy'
  206. ];
  207. $client = new \GuzzleHttp\Client();
  208. $result = $client->request('POST', 'https://files.sipadu.my/api/upload/acceptance/compound', [
  209. 'multipart' => $upload
  210. ]);
  211. $response = json_decode($result->getBody()->getContents());
  212. if($response->success == true){
  213. foreach ($response->data as $key => $d) {
  214. $attach = new Attachment();
  215. $attach->path = $d;
  216. $compound->attachment()->save($attach);
  217. }
  218. return $this->sendResponse('', $response->message);
  219. }else if($response->success == false){
  220. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  221. }
  222. }else{
  223. return $this->sendError('Gagal', 'Gambar kompaun '.$kpd.' tidak dimuatnaik!');
  224. }
  225. }else{
  226. return $this->sendError('Gagal', 'Kompaun '.$kpd.' tidak ditemui!');
  227. }
  228. }
  229. }
  230. public function compoundList($modul){
  231. $nested_data = array();
  232. if($modul == '06-07'){
  233. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  234. $q->where(function($query){
  235. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  236. });
  237. })->orderBy('updated_at', 'desc')->get();
  238. }else{
  239. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  240. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  241. })->orderBy('updated_at', 'desc')->get();
  242. }
  243. // $compound = Compound::with(['ConfidentialFile' => function($q){
  244. // $q->where('status', 'Belum Bayar');
  245. // }])->orderBy('updated_at', 'desc')->get();
  246. $class = '';
  247. if($modul == '03'){
  248. $class = "success/";
  249. }else if($a->modul == '04'){
  250. $class = $cat_modul."/primary/";
  251. }else if($a->modul == '05'){
  252. $class = $cat_modul."/warning/";
  253. }else if($a->modul == '06'){
  254. $class = $cat_modul."/info/";
  255. }else if($a->modul == '07'){
  256. $class = $cat_modul."/danger/";
  257. }else if($a->modul == '08'){
  258. $class = $cat_modul."/inverse/";
  259. }
  260. $cat_modul = '-';
  261. if($modul != '-'){
  262. $cat = Roles::where('kod',$modul)->first();
  263. if(!empty($cat)){
  264. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  265. $dump = explode(' ',trim($cat->name));
  266. $cat_modul = $dump[0];
  267. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  268. $dump = explode('- ',trim($cat->name));
  269. $cat_modul = $dump[1];
  270. }else{
  271. $cat_modul = $cat->name;
  272. }
  273. }
  274. }
  275. $curr = Carbon::now()->getTimestamp();
  276. $i = 1;
  277. foreach($compound as $a) {
  278. if(!empty($a->ConfidentialFile)){
  279. $n1 = ''; $faulty = ''; $tawaran = '';
  280. $reg_time = $a->updated_at;
  281. $expiry_date = $reg_time->addDays(3);
  282. $expiry_date = $expiry_date->getTimestamp();
  283. /*$cat_modul = '-';
  284. if($a->modul != '-'){
  285. $cat = Roles::where('kod',$a->modul)->first();
  286. if(!empty($cat)){
  287. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  288. $dump = explode(' ',trim($cat->name));
  289. $cat_modul = $dump[0];
  290. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  291. $dump = explode('- ',trim($cat->name));
  292. $cat_modul = $dump[1];
  293. }else{
  294. $cat_modul = $cat->name;
  295. }
  296. }
  297. }*/
  298. // if($curr < $expiry_date) {
  299. // if($a->modul == '03'){
  300. // $n1 = "Baru/success/";
  301. // }else if($a->modul == '04'){
  302. // $n1 = "Baru/".$cat_modul."/primary/";
  303. // }else if($a->modul == '05'){
  304. // $n1 = "Baru/".$cat_modul."/warning/";
  305. // }else if($a->modul == '06'){
  306. // $n1 = "Baru/".$cat_modul."/info/";
  307. // }else if($a->modul == '07'){
  308. // $n1 = "Baru/".$cat_modul."/danger/";
  309. // }else if($a->modul == '08'){
  310. // $n1 = "Baru/".$cat_modul."/inverse/";
  311. // }
  312. // }else{
  313. // if($a->modul == '03'){
  314. // $n1 = "";
  315. // }else if($a->modul == '04'){
  316. // $n1 = $cat_modul."/primary/";
  317. // }else if($a->modul == '05'){
  318. // $n1 = $cat_modul."/warning/";
  319. // }else if($a->modul == '06'){
  320. // $n1 = $cat_modul."/info/";
  321. // }else if($a->modul == '07'){
  322. // $n1 = $cat_modul."/danger/";
  323. // }else if($a->modul == '08'){
  324. // $n1 = $cat_modul."/inverse/";
  325. // }
  326. // }
  327. if($curr < $expiry_date) {
  328. $n1 = "Baru/".$class;
  329. }else{
  330. $n1 = $class;
  331. }
  332. if($a->jumlah_kemaskini_kompaun == ''){
  333. $tawaran = $a->jumlah_asal_kompaun;
  334. }else{
  335. $tawaran = $a->jumlah_kemaskini_kompaun;
  336. }
  337. $no_plate = '-';
  338. if($a->no_plate != '-'){
  339. $no_plate = $a->no_plate;
  340. }else{
  341. $no_plate = '-';
  342. }
  343. // $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  344. // if(!empty($faulty)){
  345. // $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  346. // }
  347. array_push($nested_data, array(
  348. 'kpd' => $n1.$a->kpd,
  349. 'jenis' => $a->jenis,
  350. 'no_plat' => $no_plate,
  351. 'tarikh' => $a->created_at->format('d/m/Y'),
  352. 'masa' => $a->created_at->format('h:i a'),
  353. 'nama' => $a->nama,
  354. 'nric' => $a->identity,
  355. 'seksyen' => '['.$a->Faulty->sketr.'] '.$a->Faulty->nama,
  356. 'jumlah' => 'RM '.$tawaran,
  357. 'status' => $a->status,
  358. 'tindakan' => $a->kpd
  359. ));
  360. $i++;
  361. }
  362. }
  363. return \DataTables::of($nested_data)->make(true);
  364. }
  365. public function compoundFilterList($jbkod,$akta,$sec,$modul){
  366. $nested_data = array();
  367. if($modul == '06-07'){
  368. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  369. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  370. $q->where(function($query){
  371. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  372. });
  373. })->orderBy('updated_at', 'desc')->get();
  374. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  375. if(strpos($jbkod, 'Pegawai') !== false) {
  376. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) {
  377. $q->where(function($query){
  378. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  379. });
  380. })->orderBy('updated_at', 'desc')->get();
  381. }else{
  382. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  383. $q->where(function($query){
  384. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  385. });
  386. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  387. }
  388. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  389. if(strpos($jbkod, 'Pegawai') !== false) {
  390. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  391. $q->where(function($query){
  392. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  393. });
  394. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  395. }else {
  396. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  397. $q->where(function($query){
  398. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  399. });
  400. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  401. }
  402. }
  403. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  404. if(strpos($jbkod, 'Pegawai') !== false) {
  405. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  406. $q->where(function($query){
  407. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  408. });
  409. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  410. }else{
  411. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  412. $q->where(function($query){
  413. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  414. });
  415. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  416. }
  417. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  418. if(strpos($jbkod, 'Pegawai') !== false) {
  419. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  420. $q->where(function($query){
  421. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  422. });
  423. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  424. }else{
  425. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  426. $q->where(function($query){
  427. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  428. });
  429. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  430. }
  431. }
  432. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  433. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  434. $q->where(function($query){
  435. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  436. });
  437. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  438. }
  439. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  440. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  441. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  442. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  443. }
  444. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  445. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  446. $q->where(function($query){
  447. $query->where('modul', '06')->orWhere('modul','07')->where('status', 'Belum Bayar');
  448. });
  449. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  450. }
  451. }else{
  452. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  453. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  454. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  455. })->orderBy('updated_at', 'desc')->get();
  456. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  457. if(strpos($jbkod, 'Pegawai') !== false) {
  458. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  459. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  460. })->orderBy('updated_at', 'desc')->get();
  461. }else{
  462. $compound = Compound::with('ConfidentialFile')->where(function($q) use($modul){
  463. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  464. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  465. }
  466. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  467. if(strpos($jbkod, 'Pegawai') !== false) {
  468. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  469. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  470. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  471. }else{
  472. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  473. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  474. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  475. }
  476. }
  477. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  478. if(strpos($jbkod, 'Pegawai') !== false) {
  479. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  480. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  481. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  482. }else{
  483. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  484. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  485. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  486. }
  487. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  488. if(strpos($jbkod, 'Pegawai') !== false) {
  489. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  490. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  491. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  492. }else{
  493. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  494. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  495. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  496. }
  497. }
  498. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  499. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  500. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  501. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  502. }
  503. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  504. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  505. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  506. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  507. }
  508. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  509. $compound = Compound::with('ConfidentialFile','Faulty')->where(function($q) use($modul){
  510. $q->where('modul', $modul)->where('status', 'Belum Bayar');
  511. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  512. }
  513. }
  514. $class = '';
  515. if($modul == '03'){
  516. $class = "success/";
  517. }else if($a->modul == '04'){
  518. $class = $cat_modul."/primary/";
  519. }else if($a->modul == '05'){
  520. $class = $cat_modul."/warning/";
  521. }else if($a->modul == '06'){
  522. $class = $cat_modul."/info/";
  523. }else if($a->modul == '07'){
  524. $class = $cat_modul."/danger/";
  525. }else if($a->modul == '08'){
  526. $class = $cat_modul."/inverse/";
  527. }
  528. $cat_modul = '-';
  529. if($modul != '-'){
  530. $cat = Roles::where('kod',$modul)->first();
  531. if(!empty($cat)){
  532. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  533. $dump = explode(' ',trim($cat->name));
  534. $cat_modul = $dump[0];
  535. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  536. $dump = explode('- ',trim($cat->name));
  537. $cat_modul = $dump[1];
  538. }else{
  539. $cat_modul = $cat->name;
  540. }
  541. }
  542. }
  543. $curr = Carbon::now()->getTimestamp();
  544. $i = 1;
  545. foreach($compound as $a) {
  546. if(!empty($a->ConfidentialFile)){
  547. $n1 = ''; $faulty = ''; $tawaran = '';
  548. $reg_time = $a->updated_at;
  549. $expiry_date = $reg_time->addDays(3);
  550. $expiry_date = $expiry_date->getTimestamp();
  551. /*$cat_modul = '-';
  552. if($a->modul != '-'){
  553. $cat = Roles::where('kod',$a->modul)->first();
  554. if(!empty($cat)){
  555. if ( preg_match('/\s/',$cat->name) && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name)){
  556. $dump = explode(' ',trim($cat->name));
  557. $cat_modul = $dump[0];
  558. }else if( preg_match('/\s/',$cat->name) && preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $cat->name) ){
  559. $dump = explode('- ',trim($cat->name));
  560. $cat_modul = $dump[1];
  561. }else{
  562. $cat_modul = $cat->name;
  563. }
  564. }
  565. }*/
  566. if($curr < $expiry_date) {
  567. $n1 = "Baru/".$class;
  568. }else{
  569. $n1 = $class;
  570. }
  571. if($a->jumlah_kemaskini_kompaun == ''){
  572. $tawaran = $a->jumlah_asal_kompaun;
  573. }else{
  574. $tawaran = $a->jumlah_kemaskini_kompaun;
  575. }
  576. $no_plate = '-';
  577. if($a->no_plate != '-'){
  578. $no_plate = $a->no_plate;
  579. }else{
  580. $no_plate = '-';
  581. }
  582. // $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  583. // if(!empty($faulty)){
  584. // $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  585. // }
  586. if(strpos($jbkod, 'Pegawai') !== false) {
  587. $temp = explode("|",$jbkod);
  588. $user = StaffDetail::with('Department')->where('_id', $temp[1])->first();
  589. if(!empty($user->Department)){
  590. if(in_array($a->jbkod, (array)$user->department_ids)) {
  591. array_push($nested_data, array(
  592. 'kpd' => $n1.$a->kpd,
  593. 'jenis' => $a->jenis,
  594. 'no_plat' => $no_plate,
  595. 'tarikh' => $a->created_at->format('d/m/Y'),
  596. 'masa' => $a->created_at->format('h:i a'),
  597. 'nama' => $a->nama,
  598. 'nric' => $a->identity,
  599. 'seksyen' => $faulty,
  600. 'jumlah' => 'RM '.$tawaran,
  601. 'status' => $a->status,
  602. 'tindakan' => $a->kpd
  603. ));
  604. $i++;
  605. }
  606. }
  607. }else {
  608. array_push($nested_data, array(
  609. 'kpd' => $n1.$a->kpd,
  610. 'jenis' => $a->jenis,
  611. 'no_plat' => $no_plate,
  612. 'tarikh' => $a->created_at->format('d/m/Y'),
  613. 'masa' => $a->created_at->format('h:i a'),
  614. 'nama' => $a->nama,
  615. 'nric' => $a->identity,
  616. 'seksyen' => '['.$a->Faulty->sketr.'] '.$a->Faulty->nama,
  617. 'jumlah' => 'RM '.$tawaran,
  618. 'status' => $a->status,
  619. 'tindakan' => $a->kpd
  620. ));
  621. $i++;
  622. }
  623. }
  624. }
  625. return \DataTables::of($nested_data)->make(true);
  626. }
  627. public function compoundCompleteLists(){
  628. $nested_data = array();
  629. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  630. $q->where('status', 'Berbayar');
  631. })->orderBy('updated_at', 'desc')->get();
  632. $curr = Carbon::now()->getTimestamp();
  633. $i = 1;
  634. foreach($compound as $a)
  635. {
  636. $n1 = ''; $faulty = '';
  637. $reg_time = $a->updated_at;
  638. $expiry_date = $reg_time->addDays(3);
  639. $expiry_date = $expiry_date->getTimestamp();
  640. if($curr < $expiry_date) {
  641. $n1 = "Baru/";
  642. }else{
  643. $n1 = "";
  644. }
  645. if(!empty($a->ConfidentialFile)){
  646. $cat_modul = '-';
  647. if($a->modul != '-'){
  648. $cat = Roles::where('kod',$a->modul)->first();
  649. if(!empty($cat)){
  650. $cat_modul = $cat->name;
  651. }
  652. }
  653. $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  654. if(!empty($faulty)){
  655. $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  656. }
  657. if($a->jumlah_kemaskini_kompaun == ''){
  658. $tawaran = $a->jumlah_asal_kompaun;
  659. }else{
  660. $tawaran = $a->jumlah_kemaskini_kompaun;
  661. }
  662. if($a->no_plate == '-'){
  663. $jenis = 'Pelbagai';
  664. }else{
  665. $jenis = 'Parkir';
  666. }
  667. array_push($nested_data, array(
  668. 'kpd' => $n1.$a->kpd,
  669. 'jenis' => $jenis,
  670. 'tarikh' => $a->created_at->format('d/m/Y'),
  671. 'masa' => $a->created_at->format('h:i a'),
  672. 'seksyen' => $faulty,
  673. 'jumlah' => 'RM '.$tawaran,
  674. 'bayaran' => 'RM '.$a->amount_payment,
  675. 'receipt' => $a->receipt,
  676. 'status' => $a->status,
  677. 'tindakan' => $a->kpd
  678. ));
  679. $i++;
  680. }
  681. }
  682. return \DataTables::of($nested_data)->make(true);
  683. }
  684. public function compoundCompleteFilterList($jbkod,$akta,$sec){
  685. $nested_data = array();
  686. if($jbkod == "null" && $akta == "null" && $sec == "null"){
  687. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  688. $q->where('status', 'Berbayar');
  689. })->orderBy('updated_at', 'desc')->get();
  690. }else if($jbkod != "null" && $akta == "null" && $sec == "null"){
  691. if(strpos($jbkod, 'Pegawai') !== false) {
  692. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  693. $q->where('status', 'Berbayar');
  694. })->orderBy('updated_at', 'desc')->get();
  695. }else{
  696. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  697. $q->where('status', 'Berbayar');
  698. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->get();
  699. }
  700. }else if($jbkod != "null" && $akta != "null" && $sec == "null"){
  701. if(strpos($jbkod, 'Pegawai') !== false) {
  702. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  703. $q->where('status', 'Berbayar');
  704. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  705. }else{
  706. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  707. $q->where('status', 'Berbayar');
  708. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->get();
  709. }
  710. }
  711. else if($jbkod != "null" && $akta != "null" && $sec != "null"){
  712. if(strpos($jbkod, 'Pegawai') !== false) {
  713. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  714. $q->where('status', 'Berbayar');
  715. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  716. }else{
  717. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  718. $q->where('status', 'Berbayar');
  719. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  720. }
  721. }else if($jbkod != "null" && $akta == "null" && $sec != "null"){
  722. if(strpos($jbkod, 'Pegawai') !== false) {
  723. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  724. $q->where('status', 'Berbayar');
  725. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  726. }else{
  727. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  728. $q->where('status', 'Berbayar');
  729. })->orderBy('updated_at', 'desc')->where('jbkod',$jbkod)->where('seksyen_kesalahan',$sec)->get();
  730. }
  731. }
  732. else if($jbkod == "null" && $akta != "null" && $sec == "null"){
  733. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  734. $q->where('status', 'Berbayar');
  735. })->orderBy('updated_at', 'desc')->where('akta',$akta)->get();
  736. }
  737. else if($jbkod == "null" && $akta != "null" && $sec != "null"){
  738. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  739. $q->where('status', 'Berbayar');
  740. })->orderBy('updated_at', 'desc')->where('akta',$akta)->where('seksyen_kesalahan',$sec)->get();
  741. }
  742. else if($jbkod == "null" && $akta == "null" && $sec != "null"){
  743. $compound = Compound::with('ConfidentialFile')->where(function($q) {
  744. $q->where('status', 'Berbayar');
  745. })->orderBy('updated_at', 'desc')->where('seksyen_kesalahan',$sec)->get();
  746. }
  747. $curr = Carbon::now()->getTimestamp();
  748. $i = 1;
  749. foreach($compound as $a)
  750. {
  751. $n1 = ''; $faulty = ''; $tawaran = '';
  752. $reg_time = $a->updated_at;
  753. $expiry_date = $reg_time->addDays(3);
  754. $expiry_date = $expiry_date->getTimestamp();
  755. if($curr < $expiry_date) {
  756. $n1 = "Baru/";
  757. }else{
  758. $n1 = "";
  759. }
  760. if(!empty($a->ConfidentialFile)){
  761. $cat_modul = '-';
  762. if($a->modul != '-'){
  763. $cat = Roles::where('kod',$a->modul)->first();
  764. if(!empty($cat)){
  765. $cat_modul = $cat->name;
  766. }
  767. }
  768. $faulty = Faulty::where('_id',$a->seksyen_kesalahan)->first();
  769. if(!empty($faulty)){
  770. $faulty = '['.$faulty->sketr.'] '.$faulty->nama;
  771. }
  772. if($a->jumlah_kemaskini_kompaun == ''){
  773. $tawaran = $a->jumlah_asal_kompaun;
  774. }else{
  775. $tawaran = $a->jumlah_kemaskini_kompaun;
  776. }
  777. if($a->no_plate == '-'){
  778. $jenis = 'Pelbagai';
  779. }else{
  780. $jenis = 'Parkir';
  781. }
  782. if(strpos($jbkod, 'Pegawai') !== false) {
  783. $temp = explode("|",$jbkod);
  784. $user = StaffDetail::with('Department')->where('_id', $temp[1])->first();
  785. if(!empty($user->Department)){
  786. if(in_array($a->jbkod, (array)$user->department_ids)) {
  787. array_push($nested_data, array(
  788. 'kpd' => $n1.$a->kpd,
  789. 'jenis' => $jenis,
  790. 'tarikh' => $a->created_at->format('d/m/Y'),
  791. 'masa' => $a->created_at->format('h:i a'),
  792. 'seksyen' => $faulty,
  793. 'jumlah' => 'RM '.$tawaran,
  794. 'bayaran' => 'RM '.$a->amount_payment,
  795. 'receipt' => $a->receipt,
  796. 'status' => $a->status,
  797. 'tindakan' => $a->kpd
  798. ));
  799. $i++;
  800. }
  801. }
  802. }else{
  803. array_push($nested_data, array(
  804. 'kpd' => $n1.$a->kpd,
  805. 'jenis' => $jenis,
  806. 'tarikh' => $a->created_at->format('d/m/Y'),
  807. 'masa' => $a->created_at->format('h:i a'),
  808. 'seksyen' => $faulty,
  809. 'jumlah' => 'RM '.$tawaran,
  810. 'bayaran' => 'RM '.$a->amount_payment,
  811. 'receipt' => $a->receipt,
  812. 'status' => $a->status,
  813. 'tindakan' => $a->kpd
  814. ));
  815. $i++;
  816. }
  817. }
  818. }
  819. return \DataTables::of($nested_data)->make(true);
  820. }
  821. public function viewCompoundToday(Request $request)
  822. {
  823. $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
  824. if(empty($staff)){
  825. return $this->sendError('Invalid', 'Staff not existed');
  826. }else {
  827. $data = array(); $timestamp = time();
  828. $start = Carbon::createFromTimestamp($timestamp)->startOfDay();
  829. $end = Carbon::createFromTimestamp($timestamp)->endOfDay();
  830. $compound = Compound::with('ConfidentialFile','Faulty','Department')->where('modul','03')->where('dikeluarkan',$staff->_id)->whereBetween('created_at', [$start, $end])->orderBy('created_at','DESC')->get();
  831. foreach($compound as $c){
  832. if(!empty($c->Faulty) && !empty($c->Department)){
  833. $tawaran = '';
  834. $akta = DeedLaw::where('_id',$c->akta)->first();
  835. $faulty = Faulty::where('_id',$c->seksyen_kesalahan)->first();
  836. if($c->jumlah_kemaskini_kompaun == ''){
  837. $tawaran = $c->jumlah_asal_kompaun;
  838. }else{
  839. $tawaran = $c->jumlah_kemaskini_kompaun;
  840. }
  841. if($c->jenis == 'Pelbagai'){
  842. array_push($data, array(
  843. "no_plate" => $c->no_plate,
  844. 'nama' => $c->nama,
  845. 'identity' => $c->identity,
  846. 'nama_syarikat' => $c->nama_syarikat,
  847. 'no_daftar_syarikat' => $c->no_daftar_syarikat,
  848. 'alamat' => $c->alamat,
  849. 'jumlah' => $tawaran,
  850. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  851. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  852. 'latlong' => $c->latlong,
  853. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  854. 'kpd' => $c->kpd,
  855. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  856. 'amount_before_14' => $c->Faulty->amount_before_14,
  857. 'amount_before_30' => $c->Faulty->amount_before_30,
  858. 'amount' => $c->Faulty->amount,
  859. 'jenis' => $c->jenis,
  860. 'keterangan'=> $c->catatan,
  861. 'no_telefon' => $c->no_telefon,
  862. 'no_lesen' => $c->no_akaun_lesen,
  863. 'lokasi_dikompaun' => $c->lokasi_kejadian,
  864. 'no_cukai_jalan' => $c->no_cukai_jalan,
  865. ));
  866. }else if($c->jenis == 'Parkir'){
  867. array_push($data, array(
  868. "no_plate" => $c->no_plate,
  869. "no_cukai_jalan" => $c->no_cukai_jalan,
  870. "jenis_kenderaan" => $c->jenis_kenderaan,
  871. "model_kenderaan" => $c->model_kenderaan,
  872. "warna_kenderaan" => $c->warna_kenderaan,
  873. "nama_taman" => $c->nama_taman,
  874. "nama_jalan" => $c->nama_jalan,
  875. "nama_kawasan" => $c->nama_kawasan,
  876. "no_parking" => $c->no_parking,
  877. 'jumlah' => $tawaran,
  878. 'akta' => '['.$akta->akkod.'] '.$akta->nama,
  879. 'seksyen_kesalahan' => '['.$c->Faulty->sketr.'] '.$c->Faulty->nama,
  880. 'latlong' => $c->latlong,
  881. 'created_at' => $c->created_at->format('d/m/Y h:i:s A'),
  882. 'kpd' => $c->kpd,
  883. 'jabatan' => '['.$c->Department->jbkod.'] '.$c->Department->jnama,
  884. 'amount_before_14' => $c->Faulty->amount_before_14,
  885. 'amount_before_30' => $c->Faulty->amount_before_30,
  886. 'amount' => $c->Faulty->amount,
  887. 'jenis' => $c->jenis,
  888. 'keterangan'=> $c->catatan
  889. ));
  890. }
  891. }
  892. }
  893. return $this->sendResponse($data, 'Senarai data kompaun');
  894. }
  895. }
  896. public function viewNoticeToday(Request $request)
  897. {
  898. $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
  899. if(empty($staff)){
  900. return $this->sendError('Invalid', 'Staff not existed');
  901. }else {
  902. $data = array(); $timestamp = time();
  903. $start = Carbon::createFromTimestamp($timestamp)->startOfDay();
  904. $end = Carbon::createFromTimestamp($timestamp)->endOfDay();
  905. $compound = Compound::with('ConfidentialFile','Faulty','Department')->where('modul','02')->where('dikeluarkan',$staff->_id)->whereBetween('created_at', [$start, $end])->orderBy('created_at','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. }