513 lines
22 KiB
PHP
513 lines
22 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use App\Models\BelanjaRealisasi;
|
|
use App\Models\BelanjaRealisasiKontrak;
|
|
use App\Models\TempRealisasiBelanja;
|
|
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
|
|
{
|
|
public function __construct(){
|
|
$this->siteTitle = "Realisasi Belanja";
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return view('realisasi_belanja.index');
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
}
|
|
|
|
public function edit(BelanjaRealisasi $realisasi_belanja)
|
|
{
|
|
}
|
|
|
|
public function update(Request $request, BelanjaRealisasi $realisasi_belanja)
|
|
{
|
|
}
|
|
|
|
public function submit(Request $request, $id)
|
|
{
|
|
$BelanjaRealisasi = BelanjaRealisasi::where("id", $id)->firstOrNew();
|
|
// var_dump($BelanjaRealisasi->kode_rsk,$BelanjaRealisasi->kode_sub_kegiatan); exit;
|
|
$this->setTitle("Realisasi Belanja");
|
|
$this->setSubtitle("Realisasi Belanja :: ".$BelanjaRealisasi->jenis_dana." ".$BelanjaRealisasi->sub_jenis_dana);
|
|
$vwAKB = VwAkbSpdRealRsk::where("I_IDRSK",$BelanjaRealisasi->kode_rsk)->firstorNew();
|
|
$BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where("belanja_realisasi_id",$id)->get();
|
|
$vwSPD = DB::select(DB::raw(
|
|
'SELECT x.I_SPDNO_DOK,x.D_SPDNO,sum(y.V_SPD) AS JML
|
|
FROM NEWSIPKD.TMSPD x
|
|
LEFT JOIN NEWSIPKD.TMSPDRINCIBLJ y
|
|
ON x.I_ID = y.I_IDSPD
|
|
LEFT JOIN NEWSIPKD.TMDPASUBGIAT z
|
|
ON y.I_IDSUBGIAT = z.I_ID
|
|
LEFT JOIN NEWSIPKD.TROPD a
|
|
ON x.I_IDOPD = a.I_ID
|
|
WHERE z.C_SUBGIAT = \''.$BelanjaRealisasi->kode_sub_kegiatan.'\'
|
|
AND a.C_OPD = \''.$BelanjaRealisasi->kode_skpd.'\'
|
|
AND x.C_ANGG_TAHUN = \''.$BelanjaRealisasi->tahun_anggaran.'\'
|
|
GROUP BY x.I_SPDNO_DOK,x.D_SPDNO
|
|
ORDER BY x.D_SPDNO '
|
|
));
|
|
|
|
$vwSP2D = DB::select(DB::raw('SELECT x.I_ID as IDSP2D, x.I_IDOPD,x.I_SP2DNO_DOK,
|
|
TO_CHAR(x.D_SP2D_SAH,\'DD-MM-YYYY\') AS D_SP2D_SAH,x.V_SPP
|
|
FROM NEWSIPKD.TMSP2D x
|
|
LEFT JOIN NEWSIPKD.TMSPPRINCIBLJRSK y
|
|
ON x.I_IDSPP = y.I_IDSPP
|
|
WHERE y.I_IDRSK='.$BelanjaRealisasi->kode_rsk.' ORDER BY x.D_SP2D_SAH ' )
|
|
);
|
|
|
|
return view('realisasi_belanja.submit', compact("BelanjaRealisasi","BelanjaRealisasiKontrak","vwAKB","vwSPD","vwSP2D"));
|
|
}
|
|
|
|
public function datatable(Request $request)
|
|
{
|
|
$post = $request->all();
|
|
$offset = $post["start"];
|
|
$limit = $post["length"];
|
|
//$src = $post["src"];
|
|
$ta = $post["ta"];
|
|
$JenisDana = $post["jenis_dana"];
|
|
$SubJenisDana = $post["sub_jenis_dana"];
|
|
|
|
$sqlStr = "SELECT x.*,y.JML_REALISASI_SP2D
|
|
FROM BELANJA_REALISASI x
|
|
LEFT JOIN (
|
|
SELECT I_IDRSK,SUM(y.V_SPP) AS JML_REALISASI_SP2D
|
|
FROM NEWSIPKD.TMSP2D x
|
|
LEFT JOIN NEWSIPKD.TMSPPRINCIBLJRSK y
|
|
ON x.I_IDSPP = y.I_IDSPP
|
|
GROUP BY I_IDRSK
|
|
) y ON x.KODE_RSK = y.I_IDRSK
|
|
WHERE x.tahun_anggaran='$ta'";
|
|
|
|
if (getRole()=="skpd"){
|
|
$sqlStr.=" AND KODE_SKPD='".Auth::user()->nrk."'";
|
|
}
|
|
|
|
$filter="";
|
|
if (!empty($JenisDana)){
|
|
$filter.= " AND x.JENIS_DANA = '".$JenisDana."'";
|
|
}
|
|
|
|
if (!empty($SubJenisDana)){
|
|
$filter.= " AND x.SUB_JENIS_DANA = '".$SubJenisDana."'";
|
|
}
|
|
|
|
$dataFilter = DB::select(DB::raw("SELECT COUNT(ID) as JML FROM ($sqlStr $filter) x"));
|
|
$dataTotal = DB::select(DB::raw("SELECT COUNT(ID) as JML FROM ($sqlStr) x"));
|
|
$data = DB::select(DB::raw($sqlStr.$filter.' ORDER BY x.ID OFFSET '.$offset.' ROWS FETCH NEXT '.$limit.' ROWS ONLY'));
|
|
|
|
return response()->json([
|
|
"recordsTotal" => $dataTotal[0]->jml,
|
|
"recordsFiltered" => $dataFilter[0]->jml,
|
|
"data"=> $data
|
|
]);
|
|
}
|
|
|
|
public function destroy(BelanjaRealisasi $realisasi_belanja)
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
$realisasi_belanja->delete();
|
|
DB::commit();
|
|
return redirect('/realisasi-belanja')
|
|
->with('success','Data Realisasi Belanja berhasil dihapus!');
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return redirect('/realisasi-belanja')
|
|
->with('error','Data Realisasi Belanja gagal dihapus.');
|
|
}
|
|
}
|
|
|
|
public function show(BelanjaRealisasi $realisasi_belanja)
|
|
{
|
|
// if (!Auth::user()->can("Lihat SKPP")){
|
|
// abort(403, 'Youre not allowed to visit this page!');
|
|
// }
|
|
$this->setSubtitle("Detail Data");
|
|
return view('realisasi_belanja.show',compact("realisasi_belanja"));
|
|
}
|
|
|
|
public function upload(Request $request, $typeDana)
|
|
{
|
|
$method = $request->method();
|
|
$this->setTitle("Upload Rencana Belanja ".strtoupper($typeDana));
|
|
$this->setSubtitle("Upload File");
|
|
$this->setIconTitle("fas fa-upload");
|
|
if ($request->isMethod('post')) {
|
|
$req = $request->all();
|
|
try{
|
|
$this->validate($request, [
|
|
'file' => 'required|mimes:xls,xlsx',
|
|
]);
|
|
|
|
$file = $request->file('file');
|
|
$subJenisDana = $request->optJenisDana;
|
|
// echo 'File Name: '.$file->getClientOriginalName();
|
|
// echo 'File Extension: '.$file->getClientOriginalExtension();
|
|
// echo 'File Real Path: '.$file->getRealPath();
|
|
// echo 'File Size: '.$file->getSize();
|
|
// echo 'File Mime Type: '.$file->getMimeType();
|
|
$tujuan_upload = 'uploadFiles';
|
|
$file->move($tujuan_upload,$file->getClientOriginalName());
|
|
// var_dump($file->getRealPath()); exit;
|
|
DB::beginTransaction();
|
|
TempRealisasiBelanja::where("userid",Auth::user()->id)->truncate();
|
|
Excel::import(new RealisasiBelanjaImport(strtoupper($typeDana),$subJenisDana), $tujuan_upload."/".$file->getClientOriginalName());
|
|
DB::commit();
|
|
return redirect('/upload-realisasi-belanja/'.$typeDana)->with('success','Data Rencana belanja berhasil diupload, Silahkan validasi data!');
|
|
}catch(\Exception $e){
|
|
throw new \Exception($e->getMessage());
|
|
DB::rollBack();
|
|
return redirect('/upload-realisasi-belanja/'.$typeDana)->with('error',$e->getMessage());
|
|
}
|
|
}
|
|
$this->siteTitle = "Rencana Belanja";
|
|
return view('realisasi_belanja.upload',compact("typeDana"));
|
|
}
|
|
|
|
public function uploadDatatable(Request $request)
|
|
{
|
|
$post = $request->all();
|
|
$offset = $post["start"];
|
|
$limit = $post["length"];
|
|
$src = isset($post["search"])?$post["search"]["value"]:"";
|
|
|
|
$dataFilter=0;
|
|
$data = TempRealisasiBelanja::orderBy("id","ASC");
|
|
if (!empty($src)){
|
|
$data->whereRaw("(LOWER(jenis_belanja) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(sub_jenis_belanja) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_program) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_skpd) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_kegiatan) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_sub_kegiatan) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_rsk) LIKE '%".strtolower($src)."%'
|
|
OR LOWER(nama_rekening) LIKE '%".strtolower($src)."%'
|
|
)");
|
|
}
|
|
$dataFilter = $data->count();
|
|
$dataTotal = TempRealisasiBelanja::count();
|
|
|
|
return response()->json([
|
|
"recordsTotal" => $dataTotal,
|
|
"recordsFiltered" => $dataFilter,
|
|
"data"=> $data->skip($offset)->take($limit)->get()
|
|
]);
|
|
}
|
|
|
|
public function uploadValidate(Request $request, $typeDana)
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
$datas = TempRealisasiBelanja::orderBy("id","ASC")->get();
|
|
for($i=0;$i<$datas->count();$i++){
|
|
$cekData = BelanjaRealisasi::where([
|
|
"kode_rsk"=>$datas[$i]["kode_rsk"],
|
|
// "kode_rekening"=>$datas[$i]["kode_rekening"]
|
|
])->firstOrNew();
|
|
|
|
if (!$cekData==null){
|
|
$cekData->delete();
|
|
// BelanjaRealisasi::where(["kode_rsk"=>$datas[$i]["kode_rsk"],"kode_rekening"=>$datas[$i]["kode_rekening"]])->delete();
|
|
}
|
|
$input = [
|
|
"tahun_anggaran"=>$datas[$i]["tahun_anggaran"],
|
|
"jenis_belanja"=>$datas[$i]["jenis_belanja"],
|
|
"sub_jenis_belanja"=>$datas[$i]["sub_jenis_belanja"],
|
|
"kode_program"=>$datas[$i]["kode_program"],
|
|
"nama_program"=>$datas[$i]["nama_program"],
|
|
"kode_skpd"=>$datas[$i]["kode_skpd"],
|
|
"nama_skpd"=>$datas[$i]["nama_skpd"],
|
|
"kode_kegiatan"=>$datas[$i]["kode_kegiatan"],
|
|
"nama_kegiatan"=>$datas[$i]["nama_kegiatan"],
|
|
"kode_sub_kegiatan"=>$datas[$i]["kode_sub_kegiatan"],
|
|
"nama_sub_kegiatan"=>$datas[$i]["nama_sub_kegiatan"],
|
|
"kode_rsk"=>$datas[$i]["kode_rsk"],
|
|
"nama_rsk"=>$datas[$i]["nama_rsk"],
|
|
"jumlah_anggaran"=>$datas[$i]["jumlah_anggaran"],
|
|
"volume_satuan"=>$datas[$i]["volume_satuan"],
|
|
"unit_satuan"=>$datas[$i]["unit_satuan"],
|
|
"jenis_dana"=>$datas[$i]["jenis_dana"],
|
|
"sub_jenis_dana"=>$datas[$i]["sub_jenis_dana"],
|
|
"created_by"=>$datas[$i]["userid"]
|
|
];
|
|
BelanjaRealisasi::create($input);
|
|
}
|
|
TempRealisasiBelanja::where("userid",Auth::user()->id)->truncate();
|
|
DB::commit();
|
|
return redirect('/upload-realisasi-belanja/'.$typeDana)->with('success','Data Realisasi belanja berhasil diupload.');
|
|
}catch(\Exception $e){
|
|
throw new \Exception($e->getMessage());
|
|
DB::rollBack();
|
|
return redirect('/upload-realisasi-belanja/'.$typeDana)->with('error',$e->getMessage());
|
|
}
|
|
return view('realisasi_belanja.upload');
|
|
}
|
|
|
|
public function inputRealisasi(Request $request, $id)
|
|
{
|
|
$BelanjaRealisasi = BelanjaRealisasi::where("id", $id)->firstOrNew();
|
|
$req = $request->all();
|
|
$redirect = isset($req["redirect_link"])?$req["redirect_link"]:"realisasi-belanja";
|
|
if ($request->isMethod('post')) {
|
|
try{
|
|
DB::beginTransaction();
|
|
$data["volume_satuan_realisasi"] = $req["vol_realisasi"];
|
|
$data["unit_satuan_realisasi"] = $req["unit_realisasi"];
|
|
$data["realisasi_by"] = Auth::user()->id;
|
|
$BelanjaRealisasi->update($data);
|
|
DB::commit();
|
|
|
|
return redirect($redirect)->with('success','Data Realisasi berhasil di input!');
|
|
}catch(\Exception $e){
|
|
throw new \Exception($e->getMessage());
|
|
DB::rollBack();
|
|
return redirect($redirect)->with('error',$e->getMessage());
|
|
}
|
|
}
|
|
|
|
$unitSatuan = UnitSatuan::orderBy("id")->get();
|
|
return view('realisasi_belanja.form_input_realisasi',compact("BelanjaRealisasi", "unitSatuan","redirect"));
|
|
}
|
|
|
|
public function datatableInputRealisasi(Request $request)
|
|
{
|
|
$post = $request->all();
|
|
$offset = $post["start"];
|
|
$limit = $post["length"];
|
|
$src = isset($post["search"])?$post["search"]["value"]:"";
|
|
|
|
$dataFilter=0;
|
|
//$data = BelanjaRealisasiDetail::where(["DBH_BELANJA_REALISASI_ID"=>$request->id])->orderBy("id","ASC");
|
|
$data = DB::select(
|
|
DB::raw('SELECT x.I_ID as IDSP2D, x.I_IDOPD,x.I_SP2DNO_DOK,TO_CHAR(x.D_SP2D_SAH,\'DD-MM-YYYY\') AS D_SP2D_SAH,x.V_SPP,
|
|
a.no_sp2d,a.jumlah_realisasi,a.VOLUME_SATUAN_REALISASI,a.UNIT_SATUAN_REALISASI,a.ID
|
|
FROM NEWSIPKD.TMSP2D x
|
|
LEFT JOIN NEWSIPKD.TMSPPRINCIBLJRSK y
|
|
ON x.I_IDSPP = y.I_IDSPP
|
|
LEFT JOIN SAMASA.DBH_BELANJA_REALISASI_DETAIL a
|
|
ON x.I_SP2DNO_DOK = a.NO_SP2D
|
|
WHERE y.I_IDRSK = '.$request->id.' ORDER BY x.D_SP2D_SAH ' )
|
|
);
|
|
$dataFilter = count($data);
|
|
$dataTotal = $dataFilter;
|
|
|
|
return response()->json([
|
|
"recordsTotal" => $dataTotal,
|
|
"recordsFiltered" => $dataFilter,
|
|
"data"=> $data
|
|
]);
|
|
}
|
|
|
|
public function deleteDetail($id)
|
|
{
|
|
$data = BelanjaRealisasiDetail::where('id', $id)->firstorNew();
|
|
try{
|
|
DB::beginTransaction();
|
|
$data->delete();
|
|
DB::commit();
|
|
return redirect('/realisasi-belanja/'.$data->dbh_belanja_realisasi_id."/submit")->with('success','Data detail Realisasi belanja berhasil dihapus!');
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return redirect('/realisasi-belanja/'.$data->dbh_belanja_realisasi_id."/submit")->with('error','Data detail Realisasi belanja gagal dihapus.');
|
|
}
|
|
}
|
|
|
|
protected function uploadFileKontrak($request)
|
|
{
|
|
$file = $request->file('file_kontrak');
|
|
if ($file){
|
|
$fileName = $file->getClientOriginalName();
|
|
$tujuan_upload = 'uploadFiles/kontrak';
|
|
$file->move($tujuan_upload, $fileName);
|
|
return $fileName;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function kontrak(Request $request, $id)
|
|
{
|
|
$BelanjaRealisasi = BelanjaRealisasi::where("id", $id)->firstOrNew();
|
|
$req = $request->all();
|
|
$redirect = "/realisasi-belanja/".$id."/submit";
|
|
$action = "/realisasi-belanja/".$id."/kontrak";
|
|
// var_dump("WOY"); exit;
|
|
if ($request->isMethod('post')) {
|
|
try{
|
|
DB::beginTransaction();
|
|
$this->validate($request, [
|
|
'file_kontrak' => 'required|mimes:pdf',
|
|
]);
|
|
$fileName = $this->uploadFileKontrak($request);
|
|
|
|
BelanjaRealisasiKontrak::where("belanja_realisasi_id",$id)->where("nomor_kontrak",$req["nomor_kontrak"])->firstOrNew()->delete();
|
|
$data["belanja_realisasi_id"] = $id;
|
|
$data["nomor_kontrak"] = $req["nomor_kontrak"];
|
|
$data["tgl_kontrak"] = ConvertIndoDate($req["tgl_kontrak"]);
|
|
$data["nominal_kontrak"] = replaceMoney($req["nominal_kontrak"]);
|
|
$data["file_kontrak"] = $fileName;
|
|
$data["created_by"] = Auth::user()->id;
|
|
BelanjaRealisasiKontrak::create($data);
|
|
|
|
DB::commit();
|
|
|
|
return redirect($redirect)->with('success','Data Kontrak berhasil di input!');
|
|
}catch(\Exception $e){
|
|
throw new \Exception($e->getMessage());
|
|
DB::rollBack();
|
|
return redirect($redirect)->with('error',$e->getMessage());
|
|
}
|
|
}
|
|
|
|
return view('realisasi_belanja.form_kontrak',compact("BelanjaRealisasi","action"));
|
|
}
|
|
|
|
public function kontrakUpdate(Request $request, $idKontrak)
|
|
{
|
|
$BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where("id",$idKontrak)->firstorNew();
|
|
$BelanjaRealisasi = BelanjaRealisasi::where("id", $BelanjaRealisasiKontrak->belanja_realisasi_id)->firstOrNew();
|
|
$req = $request->all();
|
|
$redirect = "/realisasi-belanja/".$BelanjaRealisasiKontrak->belanja_realisasi_id."/submit";
|
|
$action = "/realisasi-belanja/".$idKontrak."/kontrak";
|
|
if ($request->isMethod('put')) {
|
|
try{
|
|
DB::beginTransaction();
|
|
$data["nomor_kontrak"] = $req["nomor_kontrak"];
|
|
$data["tgl_kontrak"] = ConvertIndoDate($req["tgl_kontrak"]);
|
|
$data["nominal_kontrak"] = replaceMoney($req["nominal_kontrak"]);
|
|
$fileName = $this->uploadFileKontrak($request);
|
|
if ($fileName){
|
|
$data["file_kontrak"] = $fileName;
|
|
}
|
|
$BelanjaRealisasiKontrak->update($data);
|
|
DB::commit();
|
|
|
|
return redirect($redirect)->with('success','Data Kontrak berhasil di input!');
|
|
}catch(\Exception $e){
|
|
throw new \Exception($e->getMessage());
|
|
DB::rollBack();
|
|
return redirect($redirect)->with('error',$e->getMessage());
|
|
}
|
|
}
|
|
|
|
return view('realisasi_belanja.form_kontrak',compact("BelanjaRealisasi","BelanjaRealisasiKontrak","action"));
|
|
}
|
|
|
|
public function destroyKontrak($id)
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
$BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where("id",$id)->firstorNew();
|
|
unlink("uploadFiles/kontrak/".$BelanjaRealisasiKontrak->file_kontrak);
|
|
BelanjaRealisasiKontrak::where("id",$id)->delete();
|
|
DB::commit();
|
|
return redirect('/realisasi-belanja/'.$BelanjaRealisasiKontrak->belanja_realisasi_id.'/submit')
|
|
->with('success','Data Kontrak Realisasi Belanja berhasil dihapus!');
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return redirect('/realisasi-belanja/'.$BelanjaRealisasiKontrak->belanja_realisasi_id.'/submit')
|
|
->with('error','Data Kontrak Realisasi Belanja gagal dihapus.');
|
|
}
|
|
}
|
|
|
|
public function downloadKontrak($kode)
|
|
{
|
|
$kode = explode("__",$kode);
|
|
$BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where(["belanja_realisasi_id"=>$kode[0], "id"=>$kode[1]])->firstorNew();
|
|
$headers = [
|
|
'Content-Type' => 'application/pdf',
|
|
'Content-Disposition' => 'attachment;filename='.$BelanjaRealisasiKontrak->file_kontrak
|
|
];
|
|
if ($BelanjaRealisasiKontrak){
|
|
return response()->download("uploadFiles/kontrak/".$BelanjaRealisasiKontrak->file_kontrak, $BelanjaRealisasiKontrak->file_kontrak, $headers);
|
|
}else{
|
|
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);
|
|
}
|
|
}
|