Develop production

This commit is contained in:
Pusdatin BPKD Jkt
2022-08-08 14:20:35 +07:00
parent 1e877fa951
commit 4c306dfe3c
16 changed files with 539 additions and 338 deletions
@@ -14,6 +14,8 @@ use App\Models\VwAkbSpdRealRsk;
use App\Models\UnitSatuan;
use App\Models\Sp2d;
use App\Imports\RealisasiBelanjaImport;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class RealisasiBelanjaController extends Controller
{
@@ -83,7 +85,7 @@ class RealisasiBelanjaController extends Controller
$post = $request->all();
$offset = $post["start"];
$limit = $post["length"];
$src = $post["src"];
//$src = $post["src"];
$ta = $post["ta"];
$JenisDana = $post["jenis_dana"];
$SubJenisDana = $post["sub_jenis_dana"];
@@ -450,4 +452,61 @@ class RealisasiBelanjaController extends Controller
echo "File tidak ditemukan!";
}
}
public function download(Request $request)
{
$post = $request->all();
$sps = isset($post["sps"])?$post["sps"]:"";
$ta = $post["ta"];
$data = BelanjaRealisasi::orderBy("created_at","ASC");
if (!empty($sps)){
$data->where("id_sps",$sps);
}
$fileName = 'Realisasi-belanja.xlsx';
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue(getAlphabetCell(0).'1', 'Kode SKPD');
$sheet->setCellValue(getAlphabetCell(1).'1', 'Nama SKPD');
$sheet->setCellValue(getAlphabetCell(2).'1', 'Kode Program');
$sheet->setCellValue(getAlphabetCell(3).'1', 'Nama Program');
$sheet->setCellValue(getAlphabetCell(4).'1', 'Kode Sub Kegiatan');
$sheet->setCellValue(getAlphabetCell(5).'1', 'Sub Kegiatan');
$sheet->setCellValue(getAlphabetCell(6).'1', 'Kode Rinci Sub Kegiatan');
$sheet->setCellValue(getAlphabetCell(7).'1', 'Rinci Sub Kegiatan');
$sheet->setCellValue(getAlphabetCell(8).'1', 'Anggaran');
$sheet->setCellValue(getAlphabetCell(9).'1', 'Volume');
$sheet->setCellValue(getAlphabetCell(10).'1', 'Unit');
$sheet->setCellValue(getAlphabetCell(11).'1', 'Realisasi');
$sheet->setCellValue(getAlphabetCell(12).'1', 'Volume');
$sheet->setCellValue(getAlphabetCell(13).'1', 'Unit');
$rows = 2;
foreach ($data->get() as $val){
$sheet->setCellValue(getAlphabetCell(0) . $rows, $val["kode_skpd"]);
$sheet->setCellValue(getAlphabetCell(1) . $rows, $val["nama_skpd"]);
$sheet->setCellValue(getAlphabetCell(2) . $rows, $val["kode_program"]);
$sheet->setCellValue(getAlphabetCell(3) . $rows, $val["nama_program"]);
$sheet->setCellValue(getAlphabetCell(4) . $rows, $val["kode_sub_kegiatan"]);
$sheet->setCellValue(getAlphabetCell(5) . $rows, $val["nama_sub_kegiatan"]);
$sheet->setCellValue(getAlphabetCell(6) . $rows, $val["kode_rsk"]);
$sheet->setCellValue(getAlphabetCell(7) . $rows, $val["nama_rsk"]);
$sheet->setCellValue(getAlphabetCell(8) . $rows, $val["jumlah_anggaran"]);
$sheet->setCellValue(getAlphabetCell(9) . $rows, $val["volume_satuan"]);
$sheet->setCellValue(getAlphabetCell(10) . $rows, $val["unit_satuan"]);
$sheet->setCellValue(getAlphabetCell(11) . $rows, $val["jumlah_realisasi"]);
$sheet->setCellValue(getAlphabetCell(12) . $rows, $val["volume_satuan_realisasi"]);
$sheet->setCellValue(getAlphabetCell(13) . $rows, $val["unit_satuan_realisasi"]);
$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);
}
}