Download File STS per-TA
This commit is contained in:
@@ -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,9 +231,13 @@ class RealisasiPendapatanController extends Controller
|
||||
public function download(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
|
||||
$sps = isset($post["sps"])?$post["sps"]:"";
|
||||
$ta = $post["ta"];
|
||||
|
||||
if ($post["export-type"]=="excel")
|
||||
{
|
||||
|
||||
$data = PendapatanRealisasi::orderBy("created_at","ASC");
|
||||
if (!empty($sps)){
|
||||
$data->where("id_sps",$sps);
|
||||
@@ -276,10 +280,26 @@ class RealisasiPendapatanController extends Controller
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<div class="col-1">
|
||||
<div class="form-group">
|
||||
<label>Periode</label>
|
||||
<input type="hidden" id="export-type">
|
||||
<input class="form-control form-control-sm" id="srcTA" name="ta" value="{{ getTA() }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
@@ -210,14 +211,14 @@
|
||||
extype: "excel"
|
||||
}
|
||||
},
|
||||
// {
|
||||
// text: "<i class=\'fas fa-file-pdf\'></i> Pdf",
|
||||
// className: "export-data link-pdf",
|
||||
// attr: {
|
||||
// formid: "frm_proses_spm_sp2d",
|
||||
// extype: "pdf"
|
||||
// }
|
||||
// }
|
||||
{
|
||||
text: "<i class=\'fas fa-file-archive\'></i> File(s) STS",
|
||||
className: "export-data",
|
||||
attr: {
|
||||
formid: "frmRealisasi",
|
||||
extype: "all_sts"
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user