diff --git a/app/Http/Controllers/RealisasiPendapatanController.php b/app/Http/Controllers/RealisasiPendapatanController.php index 0731f73..1a7c44f 100644 --- a/app/Http/Controllers/RealisasiPendapatanController.php +++ b/app/Http/Controllers/RealisasiPendapatanController.php @@ -205,7 +205,7 @@ class RealisasiPendapatanController extends Controller $file = $request->file('file_sts'); if ($file){ $fileName = $req["rkud_no_sts"].".".$file->getClientOriginalExtension(); - $tujuan_upload = config('constants.upload_path_sts'); + $tujuan_upload = config('constants.upload_path_sts').getTA(); File::isDirectory($tujuan_upload) or File::makeDirectory($tujuan_upload, 0777, true, true); $file->move($tujuan_upload, $fileName); $data["file_sts"] = $fileName; @@ -231,55 +231,75 @@ class RealisasiPendapatanController extends Controller public function download(Request $request) { $post = $request->all(); + $sps = isset($post["sps"])?$post["sps"]:""; $ta = $post["ta"]; - $data = PendapatanRealisasi::orderBy("created_at","ASC"); - if (!empty($sps)){ - $data->where("id_sps",$sps); + if ($post["export-type"]=="excel") + { + + $data = PendapatanRealisasi::orderBy("created_at","ASC"); + if (!empty($sps)){ + $data->where("id_sps",$sps); + } + + $fileName = 'Realisasi-pendapatan.xlsx'; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue(getAlphabetCell(0).'1', 'Uraian'); + $sheet->setCellValue(getAlphabetCell(1).'1', 'Kotor'); + $sheet->setCellValue(getAlphabetCell(2).'1', 'Potongan'); + $sheet->setCellValue(getAlphabetCell(3).'1', 'Bersih'); + $sheet->setCellValue(getAlphabetCell(4).'1', 'Retur'); + $sheet->setCellValue(getAlphabetCell(5).'1', 'Jumlah Bersih'); + $sheet->setCellValue(getAlphabetCell(6).'1', 'SP2D BUN'); + $sheet->setCellValue(getAlphabetCell(7).'1', 'TGL SP2D BUN'); + $sheet->setCellValue(getAlphabetCell(8).'1', 'TGL STS'); + $sheet->setCellValue(getAlphabetCell(9).'1', 'NO STS'); + $sheet->setCellValue(getAlphabetCell(10).'1', 'Kode Akun'); + $sheet->setCellValue(getAlphabetCell(11).'1', 'Nama Akun'); + $sheet->setCellValue(getAlphabetCell(12).'1', 'Jumlah'); + + $rows = 2; + foreach ($data->get() as $val){ + $sheet->setCellValue(getAlphabetCell(0) . $rows, $val["simtrad4_uraian"]); + $sheet->setCellValue(getAlphabetCell(1) . $rows, $val["simtrad4_kotor"]); + $sheet->setCellValue(getAlphabetCell(2) . $rows, $val["simtrad4_potongan"]); + $sheet->setCellValue(getAlphabetCell(3) . $rows, $val["simtrad4_bersih"]); + $sheet->setCellValue(getAlphabetCell(4) . $rows, $val["retur"]); + $sheet->setCellValue(getAlphabetCell(5) . $rows, $val["bersih"]); + $sheet->setCellValue(getAlphabetCell(6) . $rows, $val["simtrad4_sp2d_bun"]); + $sheet->setCellValue(getAlphabetCell(7) . $rows, $val["simtrad4_tgl_sp2d_bun"]); + $sheet->setCellValue(getAlphabetCell(8) . $rows, $val["rkud_tgl"]); + $sheet->setCellValue(getAlphabetCell(9) . $rows, $val["rkud_no_sts"]); + $sheet->setCellValue(getAlphabetCell(10) . $rows, $val["kode_rekening_sps"]); + $sheet->setCellValue(getAlphabetCell(11) . $rows, $val["nama_rekening_sps"]); + $sheet->setCellValue(getAlphabetCell(12) . $rows, $val["rkud_jumlah"]); + $rows++; + } + + $writer = new Xlsx($spreadsheet); + $writer->save("downloadFiles/".$fileName); + + }else if($post["export-type"]=="all_sts"){ + $zip = new \ZipArchive(); + $fileName = "STS_ALL_".getTA().".zip"; + if ($zip->open(public_path("downloadFiles/".$fileName), \ZipArchive::CREATE)== TRUE) + { + $files = File::files(public_path(config('constants.upload_path_sts').getTA())); + foreach ($files as $key => $value){ + $relativeName = basename($value); + $zip->addFile($value, $relativeName); + } + $zip->close(); + } } - - $fileName = 'Realisasi-pendapatan.xlsx'; - $spreadsheet = new Spreadsheet(); - $sheet = $spreadsheet->getActiveSheet(); - $sheet->setCellValue(getAlphabetCell(0).'1', 'Uraian'); - $sheet->setCellValue(getAlphabetCell(1).'1', 'Kotor'); - $sheet->setCellValue(getAlphabetCell(2).'1', 'Potongan'); - $sheet->setCellValue(getAlphabetCell(3).'1', 'Bersih'); - $sheet->setCellValue(getAlphabetCell(4).'1', 'Retur'); - $sheet->setCellValue(getAlphabetCell(5).'1', 'Jumlah Bersih'); - $sheet->setCellValue(getAlphabetCell(6).'1', 'SP2D BUN'); - $sheet->setCellValue(getAlphabetCell(7).'1', 'TGL SP2D BUN'); - $sheet->setCellValue(getAlphabetCell(8).'1', 'TGL STS'); - $sheet->setCellValue(getAlphabetCell(9).'1', 'NO STS'); - $sheet->setCellValue(getAlphabetCell(10).'1', 'Kode Akun'); - $sheet->setCellValue(getAlphabetCell(11).'1', 'Nama Akun'); - $sheet->setCellValue(getAlphabetCell(12).'1', 'Jumlah'); - - $rows = 2; - foreach ($data->get() as $val){ - $sheet->setCellValue(getAlphabetCell(0) . $rows, $val["simtrad4_uraian"]); - $sheet->setCellValue(getAlphabetCell(1) . $rows, $val["simtrad4_kotor"]); - $sheet->setCellValue(getAlphabetCell(2) . $rows, $val["simtrad4_potongan"]); - $sheet->setCellValue(getAlphabetCell(3) . $rows, $val["simtrad4_bersih"]); - $sheet->setCellValue(getAlphabetCell(4) . $rows, $val["retur"]); - $sheet->setCellValue(getAlphabetCell(5) . $rows, $val["bersih"]); - $sheet->setCellValue(getAlphabetCell(6) . $rows, $val["simtrad4_sp2d_bun"]); - $sheet->setCellValue(getAlphabetCell(7) . $rows, $val["simtrad4_tgl_sp2d_bun"]); - $sheet->setCellValue(getAlphabetCell(8) . $rows, $val["rkud_tgl"]); - $sheet->setCellValue(getAlphabetCell(9) . $rows, $val["rkud_no_sts"]); - $sheet->setCellValue(getAlphabetCell(10) . $rows, $val["kode_rekening_sps"]); - $sheet->setCellValue(getAlphabetCell(11) . $rows, $val["nama_rekening_sps"]); - $sheet->setCellValue(getAlphabetCell(12) . $rows, $val["rkud_jumlah"]); - $rows++; - } - $writer = new Xlsx($spreadsheet); - $writer->save("downloadFiles/".$fileName); $headers = [ 'Content-Type' => 'application/vnd.ms-excel', 'Content-Disposition' => 'attachment;filename='.$fileName ]; + return response()->download("downloadFiles/".$fileName, $fileName, $headers); } @@ -289,6 +309,7 @@ class RealisasiPendapatanController extends Controller 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment;filename='.$realisasi->file_sts ]; - return response()->download(config('constants.upload_path_sts').$realisasi->file_sts, $realisasi->file_sts, $headers); + return response()->download(config('constants.upload_path_sts').getTA()."/".$realisasi->file_sts, $realisasi->file_sts, $headers); } + } diff --git a/resources/views/realisasi_pendapatan/index.blade.php b/resources/views/realisasi_pendapatan/index.blade.php index 01f6067..38f1f0e 100644 --- a/resources/views/realisasi_pendapatan/index.blade.php +++ b/resources/views/realisasi_pendapatan/index.blade.php @@ -32,6 +32,7 @@
+
@@ -210,14 +211,14 @@ extype: "excel" } }, - // { - // text: " Pdf", - // className: "export-data link-pdf", - // attr: { - // formid: "frm_proses_spm_sp2d", - // extype: "pdf" - // } - // } + { + text: " File(s) STS", + className: "export-data", + attr: { + formid: "frmRealisasi", + extype: "all_sts" + } + } ], } ],