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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Exports\CompoundExport;
  5. use Maatwebsite\Excel\Facades\Excel;
  6. class ExportCompound extends Controller
  7. {
  8. /**
  9. * @return \Illuminate\Support\Collection
  10. */
  11. public function importExportView()
  12. {
  13. return view('import');
  14. }
  15. /**
  16. * @return \Illuminate\Support\Collection
  17. */
  18. public function export($file, $jenis)
  19. {
  20. $location = 'public/uploads/cache/'.$file.'.json';
  21. $data = json_decode(file_get_contents(base_path($location), true), true);
  22. $final_data = array();
  23. if($jenis != 'Parkir'){
  24. foreach ($data as $key => $d) {
  25. $kemaskini_oleh = '';
  26. if($d['status'] == 'Berbayar'){
  27. if(!empty($d['updated_by'])){
  28. $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
  29. }else {
  30. $kemaskini_oleh = 'PahangGo App';
  31. }
  32. }else {
  33. if(!empty($d['updated_by'])){
  34. $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
  35. }
  36. }
  37. $tarikh_kemaskini = '';
  38. if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
  39. $tarikh_bayar = $d['tarikh_bayar'];
  40. }else{
  41. $tarikh_bayar = $d['updated_at'];
  42. }
  43. array_push($final_data, array(
  44. '#' => $key+1,
  45. 'Kpd' => $d['kpd'],
  46. 'Jenis' => $d['jenis'],
  47. 'Tarikh_Masa' => $d['tarikh_masa'],
  48. 'Kesalahan' => 'Seksyen '.$d['faulty_skter'].', '.$d['faulty_name'],
  49. 'Nric' => $d['nric'],
  50. 'Nama' => $d['nama'],
  51. 'No_Daftar' => $d['no_daftar_syarikat'],
  52. 'Akaun_Lesen' => $d['lesen'],
  53. 'No_Plate' => $d['no_plate'],
  54. 'Penguatkuasa' => $d['enforcer'],
  55. 'Status' => $d['status'],
  56. 'Catatan_Dari_Admin' => $d['catatan_dari_admin'],
  57. 'Amaun_Bayaran' => $d['amount_payment'],
  58. 'Kemaskini_oleh' => $kemaskini_oleh,
  59. 'Tarikh_kemaskini' => $tarikh_kemaskini,
  60. ));
  61. }
  62. }else if($jenis == 'Parkir'){
  63. foreach ($data as $key => $d) {
  64. $kemaskini_oleh = '';
  65. if($d['status'] == 'Berbayar'){
  66. if(!empty($d['updated_by'])){
  67. $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
  68. }else {
  69. $kemaskini_oleh = $d['updates_by'];
  70. }
  71. }else {
  72. if(!empty($d['updated_by'])){
  73. $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
  74. }
  75. }
  76. $tarikh_kemaskini = '';
  77. if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
  78. $tarikh_bayar = $d['tarikh_bayar'];
  79. }else{
  80. $tarikh_bayar = $d['updated_at'];
  81. }
  82. array_push($final_data, array(
  83. '#' => $key+1,
  84. 'Kpd' => $d['kpd'],
  85. 'Jenis' => $d['jenis'],
  86. 'Tarikh_Masa' => $d['tarikh_masa'],
  87. 'Kesalahan' => 'Seksyen '.$d['faulty_skter'].', '.$d['faulty_name'],
  88. 'No_Plate' => $d['no_plate'],
  89. 'Penguatkuasa' => $d['enforcer'],
  90. 'Status' => $d['status'],
  91. 'Catatan_Dari_Admin' => $d['catatan_dari_admin'],
  92. 'Amaun_Bayaran' => $d['amount_payment'],
  93. 'Kemaskini_oleh' => $kemaskini_oleh,
  94. 'Tarikh_kemaskini' => $tarikh_kemaskini,
  95. ));
  96. }
  97. }
  98. $filename = 'Report_Saman_'.$jenis;
  99. return Excel::download(new CompoundExport($final_data,$jenis), $filename.'.xlsx');
  100. }
  101. /**
  102. * @return \Illuminate\Support\Collection
  103. */
  104. public function import()
  105. {
  106. Excel::import(new UsersImport,request()->file('file'));
  107. return back();
  108. }
  109. public function getData(Request $request)
  110. {
  111. $data = $request->data;
  112. $filename = time();
  113. $location = 'public/uploads/cache/'.$filename.'.json';
  114. file_put_contents(base_path($location), stripslashes($data));
  115. return $filename;
  116. }
  117. public function export_compound_enforcer(){
  118. }
  119. }