Download All Salur dan Belanja
This commit is contained in:
@@ -25,14 +25,11 @@ class JadwalSalurdanaController extends Controller
|
||||
return view('jadwal_salurdana.index');
|
||||
}
|
||||
|
||||
public function datatable(Request $request)
|
||||
protected function filterJadwalSalur($request)
|
||||
{
|
||||
$ta = getTA();
|
||||
|
||||
$post = $request->all();
|
||||
$offset = $post["start"];
|
||||
$limit = $post["length"];
|
||||
$src = isset($post["src"]) ? $post["src"]:"";
|
||||
$ta = $post["ta"];
|
||||
$dataFilter = 0;
|
||||
$typeDana = isset($post["type_dana"])?$post["type_dana"]:"";
|
||||
$idSPS = isset($post["id_sps"])?$post["id_sps"]:"";
|
||||
$sqlstr = Sps_pendapatan::queryJadwalSalurDana($ta);
|
||||
@@ -41,8 +38,6 @@ class JadwalSalurdanaController extends Controller
|
||||
$sqlstr.=" AND x.KODE_REKENING='$idSPS'";
|
||||
}
|
||||
|
||||
$dataTotal = count(DB::select(DB::raw($sqlstr)));
|
||||
|
||||
if (!empty($typeDana)){
|
||||
if ($typeDana == "cht"){
|
||||
$sqlstr.=" AND x.kode_rekening='4.2.01.01.01.0004'";
|
||||
@@ -50,7 +45,46 @@ class JadwalSalurdanaController extends Controller
|
||||
$sqlstr.=" AND SUBSTR(x.kode_rekening,1,12) IN ('4.2.01.01.03','4.2.01.01.04')";
|
||||
}
|
||||
}
|
||||
|
||||
return $sqlstr;
|
||||
}
|
||||
|
||||
protected function filterBelanja($request, $typeDana)
|
||||
{
|
||||
$ta = getTA();
|
||||
|
||||
$post = $request->all();
|
||||
$src = isset($post["src"]) ? $post["src"]:"";
|
||||
$typeDanaFilter = $typeDana == "cht" ? " AND x.jenis_dana = 'DBH' AND lower(x.NAMA_SUBJENIS_DANA) = 'cht' ": " AND x.jenis_dana = 'DAK'";
|
||||
$idSPS = isset($post["id_sps"])?$post["id_sps"]:"";
|
||||
$skpd = isset($post["skpd"])?$post["skpd"]:"";
|
||||
|
||||
$sqlstr = 'SELECT x.kode_skpd, x.nama_skpd, x.kode_rsk, x.nama_rsk, x.jumlah_anggaran, y.*
|
||||
FROM SAMASA.VW_BELANJA_REALISASI x
|
||||
LEFT JOIN SAMASA.MV_ASYNC_AKB_REALISASI y
|
||||
ON x.KODE_RSK = y.I_IDRSK AND x.TAHUN_ANGGARAN = y.C_ANGG_TAHUN
|
||||
WHERE x.TAHUN_ANGGARAN = \''.$ta.'\''.$typeDanaFilter;
|
||||
|
||||
if (getRole()=="skpd"){
|
||||
$sqlstr.=" AND KODE_SKPD='".Auth::user()->nrk."'";
|
||||
}else{
|
||||
if ($skpd){
|
||||
$sqlstr.=" AND KODE_SKPD='$skpd'";
|
||||
}
|
||||
}
|
||||
|
||||
return $sqlstr;
|
||||
}
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$offset = $post["start"];
|
||||
$limit = $post["length"];
|
||||
|
||||
$sqlstr = $this->filterJadwalSalur($request);
|
||||
$dataTotal = count(DB::select(DB::raw($sqlstr)));
|
||||
|
||||
$sqlLimit = $limit > 0?" OFFSET ".$offset." ROWS FETCH NEXT ".$limit." ROWS ONLY ":"";
|
||||
$data = DB::select(DB::raw($sqlstr.'ORDER BY x.kode_rekening '.$sqlLimit));
|
||||
$dataFilter = count(DB::select(DB::raw($sqlstr)));
|
||||
@@ -64,35 +98,7 @@ class JadwalSalurdanaController extends Controller
|
||||
|
||||
public function index_cht_dak(Request $request, $typeDana)
|
||||
{
|
||||
$judul = strtoupper($typeDana);
|
||||
$this->setTitle("Jadwal Salur Dana $judul");
|
||||
$filter = $typeDana == "cht" ? " AND x.jenis_dana = 'DBH' AND x.sub_jenis_dana = 3 ": " AND x.jenis_dana = 'DAK'";
|
||||
if (getRole()=="skpd"){
|
||||
$filter.=" AND x.kode_skpd='".Auth::user()->nrk."'";
|
||||
}
|
||||
$idSPS = 0;
|
||||
if ($request->has("id_sps"))
|
||||
{
|
||||
if ($request->id_sps > 0)
|
||||
{
|
||||
$filter.=" AND x.kode_rekening='".$request->id_sps."'";
|
||||
$idSPS = $request->id_sps;
|
||||
}
|
||||
}
|
||||
|
||||
$dataAkbRealisasi = DB::select(DB::raw("SELECT x.kode_skpd, x.nama_skpd, x.kode_rsk, x.nama_rsk, x.jumlah_anggaran, y.*
|
||||
FROM SAMASA.BELANJA_REALISASI x
|
||||
LEFT JOIN (".BelanjaRealisasi::akbRealisasi().") y
|
||||
ON x.KODE_RSK = y.I_IDRSK
|
||||
-- AND x.TAHUN_ANGGARAN = y.C_ANGG_TAHUN
|
||||
WHERE x.TAHUN_ANGGARAN = ".getTa()." $filter ORDER BY x.kode_skpd,x.nama_skpd,x.kode_rsk "));
|
||||
|
||||
|
||||
$dataAkbRealisasi = array_map(function ($value) {
|
||||
return (array)$value;
|
||||
}, $dataAkbRealisasi);
|
||||
|
||||
return view("jadwal_salurdana.index_".$typeDana, compact("dataAkbRealisasi","idSPS"));
|
||||
return view("jadwal_salurdana.index_cht_dak", compact("typeDana"));
|
||||
}
|
||||
|
||||
public function datatable_cht_dak(Request $request, $typeDana)
|
||||
@@ -100,25 +106,12 @@ class JadwalSalurdanaController extends Controller
|
||||
$post = $request->all();
|
||||
$offset = $post["start"];
|
||||
$limit = $post["length"];
|
||||
// $src = $post["src"];
|
||||
$ta = $post["ta"];
|
||||
$typeDanaFilter = $typeDana == "cht" ? " AND x.jenis_dana = 'DBH' AND x.sub_jenis_dana = 'CHT' ": " AND x.jenis_dana = 'DAK'";
|
||||
$dataFilter=0;
|
||||
$sqlstr = 'SELECT x.kode_skpd, x.nama_skpd, x.kode_rsk, x.nama_rsk, x.jumlah_anggaran, y.*
|
||||
FROM SAMASA.BELANJA_REALISASI x
|
||||
LEFT JOIN SAMASA.MV_ASYNC_AKB_REALISASI y
|
||||
ON x.KODE_RSK = y.I_IDRSK AND x.TAHUN_ANGGARAN = y.C_ANGG_TAHUN
|
||||
WHERE x.TAHUN_ANGGARAN = \''.$ta.'\''.$typeDanaFilter;
|
||||
|
||||
if (getRole()=="skpd"){
|
||||
$sqlstr.=" AND KODE_SKPD='".Auth::user()->nrk."'";
|
||||
}
|
||||
|
||||
$sqlstr = $this->filterBelanja($request, $typeDana);
|
||||
|
||||
$sqlLimit = $limit > 0?" OFFSET ".$offset." ROWS FETCH NEXT ".$limit." ROWS ONLY ":"";
|
||||
$data = DB::select(DB::raw($sqlstr.' ORDER BY x.kode_skpd,x.kode_rsk '.$sqlLimit));
|
||||
$dataTotal = count(DB::select(DB::raw($sqlstr)));
|
||||
// if (!empty($src)){
|
||||
//$data->whereRaw("(LOWER(NAMA_REKENING) LIKE '%".strtolower($src)."%' OR LOWER(KODE_REKENING) LIKE '%".strtolower($src)."%')");
|
||||
// }
|
||||
$dataFilter = count(DB::select(DB::raw($sqlstr)));
|
||||
|
||||
return response()->json([
|
||||
@@ -128,33 +121,18 @@ class JadwalSalurdanaController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function download(Request $request)
|
||||
protected function exportJadwalSalur($request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$typeDana = isset($post["type_dana"])?$post["type_dana"]:"";
|
||||
$idSPS = isset($post["id_sps"])?$post["id_sps"]:"";
|
||||
$ta = $post["ta"];
|
||||
$sqlstr = Sps_pendapatan::queryJadwalSalurDana($ta);
|
||||
|
||||
if (!empty($idSPS)){
|
||||
$sqlstr.=" AND x.ID=$idSPS";
|
||||
}
|
||||
|
||||
if (!empty($typeDana)){
|
||||
if ($typeDana == "cht"){
|
||||
$sqlstr.=" AND kode_rekening='4.2.01.01.01.0004'";
|
||||
}else{
|
||||
$sqlstr.=" AND SUBSTR(kode_rekening,1,12) IN ('4.2.01.01.03','4.2.01.01.04')";
|
||||
}
|
||||
}
|
||||
|
||||
$sqlstr = $this->filterJadwalSalur($request);
|
||||
$sqlstr .= " ORDER BY kode_rekening";
|
||||
|
||||
$data = DB::select(DB::raw($sqlstr));
|
||||
$data = json_decode(json_encode($data),true);
|
||||
|
||||
$fileName = 'Jadwal-salur-dana.xlsx';
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setTitle('Jadwal Salur');
|
||||
|
||||
$sheet->setCellValue('A1', 'Kode Rekening');
|
||||
$sheet->setCellValue('B1', 'Nama Rekening');
|
||||
$alpha = range("A","Z");
|
||||
@@ -211,6 +189,101 @@ class JadwalSalurdanaController extends Controller
|
||||
$sheet->setCellValue($strAlpha.$rows , "=SUM($SUMRANGE)");
|
||||
}
|
||||
|
||||
return $spreadsheet;
|
||||
}
|
||||
|
||||
public function download(Request $request)
|
||||
{
|
||||
$spreadsheet = $this->exportJadwalSalur($request);
|
||||
|
||||
$fileName = 'Jadwal-salur-dana.xlsx';
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
public function downloadAll(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
|
||||
$fileName = 'Jadwal-salur-belanja-'.date("Ymd").'.xlsx';
|
||||
|
||||
$spreadsheet = $this->exportJadwalSalur($request);
|
||||
$spreadsheet->createSheet();
|
||||
$spreadsheet->setActiveSheetIndex(1);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$sheet->setTitle('Akb dan Realisasi');
|
||||
$sheet->setCellValue('A1', 'SKPD');
|
||||
$sheet->setCellValue('B1', 'RSK');
|
||||
$alpha = range("A","Z");
|
||||
$colIndex = 2;
|
||||
// Nama Kolom bulan
|
||||
$bulans = GetBulan();
|
||||
foreach($bulans as $bulan){
|
||||
$sheet->setCellValue($alpha[$colIndex].'1', $bulan);
|
||||
$colIndex++;
|
||||
$sheet->mergeCells($alpha[$colIndex].'1'.':'.$alpha[$colIndex].'1');
|
||||
$colIndex++;
|
||||
}
|
||||
$sheet->setCellValue(getAlphabetCell($colIndex).'1', "Total");
|
||||
$sheet->mergeCells(getAlphabetCell($colIndex).'1'.':'.getAlphabetCell($colIndex+1).'1');
|
||||
$sheet->mergeCells('A1:A2');
|
||||
$sheet->mergeCells('B1:B2');
|
||||
$colIndex++;
|
||||
|
||||
// Nama Kolom Jadwal dan Realisasi
|
||||
$colName = "Realisasi";
|
||||
for($i=2;$i<=$colIndex;$i++){
|
||||
$colName = $colName == "AKB" ? "Realisasi":"AKB";
|
||||
$sheet->setCellValue(getAlphabetCell($i).'2', $colName);
|
||||
}
|
||||
|
||||
|
||||
$sqlstr = $this->filterBelanja($request, $post["type_dana"]);
|
||||
|
||||
$data = DB::select(DB::raw($sqlstr));
|
||||
$data = json_decode(json_encode($data),true);
|
||||
|
||||
// Data Kolom Bulan dan Realisasi
|
||||
$rows = 3;
|
||||
foreach ($data as $val){
|
||||
$sheet->setCellValue('A' . $rows, $val["kode_skpd"]." | ".$val["nama_skpd"]);
|
||||
$sheet->setCellValue('B' . $rows, $val["kode_rsk"]." | ".$val["nama_rsk"]);
|
||||
$totalJadwalSalur = 0;
|
||||
$totalRealisasi = 0;
|
||||
$currIndex = 2;
|
||||
for($i=1;$i<=12;$i++){
|
||||
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $val["v_akb_".substr("00".$i,-2)]);
|
||||
$totalJadwalSalur += $val["v_akb_".substr("00".$i,-2)];
|
||||
$currIndex++;
|
||||
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $val["v_bku_".substr("00".$i,-2)]);
|
||||
$totalRealisasi += $val["v_bku_".substr("00".$i,-2)];
|
||||
$currIndex++;
|
||||
}
|
||||
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $totalJadwalSalur);
|
||||
$sheet->setCellValue(getAlphabetCell($currIndex+1).$rows, $totalRealisasi);
|
||||
|
||||
$rows++;
|
||||
}
|
||||
|
||||
// TOTAL BAWAH
|
||||
$sheet->setCellValue("A".$rows , "TOTAL");
|
||||
$sheet->mergeCells('A'.$rows.':'.'B'.$rows);
|
||||
for ($x=2;$x<=$colIndex;$x++){
|
||||
$strAlpha = getAlphabetCell($x);
|
||||
$SUMRANGE = $strAlpha."3:".$strAlpha.($rows-1);
|
||||
$sheet->setCellValue($strAlpha.$rows , "=SUM($SUMRANGE)");
|
||||
}
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save("downloadFiles/".$fileName);
|
||||
$headers = [
|
||||
|
||||
@@ -249,7 +249,7 @@ class RealisasiBelanjaController extends Controller
|
||||
public function submit_akb_spd(VwBelanjaRealisasi $BelanjaRealisasi)
|
||||
{
|
||||
|
||||
$vwAKB = DB::select(DB::raw("SELECT * FROM (".BelanjaRealisasi::akbRealisasi().") x WHERE I_IDRSK = ".$BelanjaRealisasi->kode_rsk));
|
||||
$vwAKB = DB::select(DB::raw("SELECT * FROM SAMASA.MV_ASYNC_AKB_REALISASI x WHERE I_IDRSK = ".$BelanjaRealisasi->kode_rsk));
|
||||
$vwAKB = json_decode(json_encode($vwAKB[0]), true);
|
||||
|
||||
$vwSPD = [];
|
||||
|
||||
@@ -108,13 +108,7 @@ class BelanjaRealisasi extends Eloquent
|
||||
public function akbRealisasi()
|
||||
{
|
||||
$ta = getTA();
|
||||
$sqlstr = "SELECT I_IDRSK,SUM(V_AKB_01) AS V_AKB_01,SUM(V_AKB_02) AS V_AKB_02,SUM(V_AKB_03) AS V_AKB_03,SUM(V_AKB_04) AS V_AKB_04,SUM(V_AKB_05) AS V_AKB_05,
|
||||
SUM(V_AKB_06) AS V_AKB_06,SUM(V_AKB_07) AS V_AKB_07,SUM(V_AKB_08) AS V_AKB_08,SUM(V_AKB_09) AS V_AKB_09,SUM(V_AKB_10) AS V_AKB_10,
|
||||
SUM(V_AKB_11) AS V_AKB_11,SUM(V_AKB_12) AS V_AKB_12,
|
||||
SUM(V_BKU_01) AS V_BKU_01,SUM(V_BKU_02) AS V_BKU_02,SUM(V_BKU_03) AS V_BKU_03,SUM(V_BKU_04) AS V_BKU_04,SUM(V_BKU_05) AS V_BKU_05,
|
||||
SUM(V_BKU_06) AS V_BKU_06,SUM(V_BKU_07) AS V_BKU_07,SUM(V_BKU_08) AS V_BKU_08,SUM(V_BKU_09) AS V_BKU_09,SUM(V_BKU_10) AS V_BKU_10,
|
||||
SUM(V_BKU_11) AS V_BKU_11,SUM(V_BKU_12) AS V_BKU_12
|
||||
FROM MV_ASYNC_AKB_REALISASI GROUP BY I_IDRSK";
|
||||
$sqlstr = "SELECT * FROM MV_ASYNC_AKB_REALISASI WHERE TAHUN = $ta";
|
||||
|
||||
return $sqlstr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user