123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
-
- namespace App\Http\Controllers;
-
- use Illuminate\Http\Request;
- use App\Exports\CompoundExport;
- use Maatwebsite\Excel\Facades\Excel;
-
- class ExportCompound extends Controller
- {
- /**
- * @return \Illuminate\Support\Collection
- */
- public function importExportView()
- {
- return view('import');
- }
-
- /**
- * @return \Illuminate\Support\Collection
- */
- public function export($file, $jenis)
- {
- $location = 'public/uploads/cache/'.$file.'.json';
- $data = json_decode(file_get_contents(base_path($location), true), true);
-
- dd($location);
-
- $final_data = array();
-
- if($jenis != 'Parkir'){
- foreach ($data as $key => $d) {
- $kemaskini_oleh = '';
-
- if($d['status'] == 'Berbayar'){
- if(!empty($d['updated_by'])){
- $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
- }else {
- $kemaskini_oleh = 'PahangGo App';
- }
- }else {
- if(!empty($d['updated_by'])){
- $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
- }
- }
-
- $tarikh_kemaskini = '';
- if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
- $tarikh_bayar = $d['tarikh_bayar'];
- }else{
- $tarikh_bayar = $d['updated_at'];
- }
-
- array_push($final_data, array(
- '#' => $key+1,
- 'Kpd' => $d['kpd'],
- 'Jenis' => $d['jenis'],
- 'Tarikh_Masa' => $d['tarikh_masa'],
- 'Kesalahan' => 'Seksyen '.$d['faulty_skter'].', '.$d['faulty_name'],
- 'Nric' => $d['nric'],
- 'Nama' => $d['nama'],
- 'No_Daftar' => $d['no_daftar_syarikat'],
- 'Akaun_Lesen' => $d['lesen'],
- 'No_Plate' => $d['no_plate'],
- 'Penguatkuasa' => $d['enforcer'],
- 'Status' => $d['status'],
- 'Catatan_Dari_Admin' => $d['catatan_dari_admin'],
- 'Amaun_Bayaran' => $d['amount_payment'],
- 'Kemaskini_oleh' => $kemaskini_oleh,
- 'Tarikh_kemaskini' => $tarikh_kemaskini,
-
- ));
- }
- }else if($jenis == 'Parkir'){
- foreach ($data as $key => $d) {
- $kemaskini_oleh = '';
-
- if($d['status'] == 'Berbayar'){
- if(!empty($d['updated_by'])){
- $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
- }else {
- $kemaskini_oleh = $d['updates_by'];
- }
- }else {
- if(!empty($d['updated_by'])){
- $kemaskini_oleh = $d['updated_by']['no_badan'] .', '. $d['updated_by']['full_name'];
- }
- }
-
- $tarikh_kemaskini = '';
- if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
- $tarikh_bayar = $d['tarikh_bayar'];
- }else{
- $tarikh_bayar = $d['updated_at'];
- }
-
- array_push($final_data, array(
- '#' => $key+1,
- 'Kpd' => $d['kpd'],
- 'Jenis' => $d['jenis'],
- 'Tarikh_Masa' => $d['tarikh_masa'],
- 'Kesalahan' => 'Seksyen '.$d['faulty_skter'].', '.$d['faulty_name'],
- 'No_Plate' => $d['no_plate'],
- 'Penguatkuasa' => $d['enforcer'],
- 'Status' => $d['status'],
- 'Catatan_Dari_Admin' => $d['catatan_dari_admin'],
- 'Amaun_Bayaran' => $d['amount_payment'],
- 'Kemaskini_oleh' => $kemaskini_oleh,
- 'Tarikh_kemaskini' => $tarikh_kemaskini,
- ));
- }
- }
-
- $filename = 'Report_Saman_'.$jenis;
- return Excel::download(new CompoundExport($final_data,$jenis), $filename.'.xlsx');
- }
-
- /**
- * @return \Illuminate\Support\Collection
- */
- public function import()
- {
- Excel::import(new UsersImport,request()->file('file'));
-
- return back();
- }
-
- public function getData(Request $request)
- {
- info('encode request ' . json_encode($request->data));
- $data = $request->data;
- $filename = time();
- $location = 'public/uploads/cache/'.$filename.'.json';
- info('filename location ' . $location);
- file_put_contents(base_path($location), stripslashes($data));
-
- return $filename;
- }
-
-
- public function export_compound_enforcer(){
-
- }
- }
|