Download Jadwal Salur

This commit is contained in:
Pusdatin BPKD Jkt
2022-08-05 11:31:57 +07:00
parent d981418604
commit 1e877fa951
3 changed files with 95 additions and 54 deletions
@@ -190,38 +190,56 @@ class JadwalSalurdanaController extends Controller
]); ]);
} }
public function download() public function download(Request $request)
{ {
$sqlstr = $this->queryJadwalSalurDana("2022"); $post = $request->all();
$data = DB::select(DB::raw($sqlstr)); $typeDana = isset($post["type_dana"])?$post["type_dana"]:"";
//var_dump($data); exit; $idSPS = isset($post["id_sps"])?$post["id_sps"]:"";
$data = json_decode(json_encode($data),true); $ta = $post["ta"];
$fileName = 'Jadwal-salur-dana.xlsx'; $sqlstr = $this->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 .= " 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(); $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Kode Rekening'); $sheet->setCellValue('A1', 'Kode Rekening');
$sheet->setCellValue('B1', 'Nama Rekening'); $sheet->setCellValue('B1', 'Nama Rekening');
$alpha = range("A","Z"); $alpha = range("A","Z");
$alphaIndex = 2; $colIndex = 2;
// Nama Kolom bulan // Nama Kolom bulan
$bulans = GetBulan(); $bulans = GetBulan();
foreach($bulans as $bulan){ foreach($bulans as $bulan){
$sheet->setCellValue($alpha[$alphaIndex].'1', $bulan); $sheet->setCellValue($alpha[$colIndex].'1', $bulan);
$sheet->mergeCells($alpha[$alphaIndex].'1'.':'.$alpha[$alphaIndex+1].'1'); $colIndex++;
$alphaIndex+=2; $sheet->mergeCells($alpha[$colIndex].'1'.':'.$alpha[$colIndex].'1');
$colIndex++;
} }
$sheet->setCellValue(getAlphabetCell($alphaIndex).'1', "TOTAL"); $sheet->setCellValue(getAlphabetCell($colIndex).'1', "Total");
$sheet->mergeCells(getAlphabetCell($alphaIndex).'1'.':'.getAlphabetCell($alphaIndex+1).'1'); $sheet->mergeCells(getAlphabetCell($colIndex).'1'.':'.getAlphabetCell($colIndex+1).'1');
$sheet->mergeCells('A1:A2'); $sheet->mergeCells('A1:A2');
$sheet->mergeCells('B1:B2'); $sheet->mergeCells('B1:B2');
$colIndex++;
// Nama Kolom Jadwal dan Realisasi // Nama Kolom Jadwal dan Realisasi
$alphaIndex = 2; $colName = "Realisasi";
for($i=1;$i<=13;$i++){ for($i=2;$i<=$colIndex;$i++){
$sheet->setCellValue(getAlphabetCell($alphaIndex).'2', 'Jadwal'); $colName = $colName == "Jadwal" ? "Realisasi":"Jadwal";
$sheet->setCellValue(getAlphabetCell($alphaIndex+1).'2', 'Realisasi'); $sheet->setCellValue(getAlphabetCell($i).'2', $colName);
$alphaIndex+=2;
} }
// Data Kolom Bulan dan Realisasi // Data Kolom Bulan dan Realisasi
@@ -229,31 +247,30 @@ class JadwalSalurdanaController extends Controller
foreach ($data as $val){ foreach ($data as $val){
$sheet->setCellValue('A' . $rows, $val["kode_rekening"]); $sheet->setCellValue('A' . $rows, $val["kode_rekening"]);
$sheet->setCellValue('B' . $rows, $val["nama_rekening"]); $sheet->setCellValue('B' . $rows, $val["nama_rekening"]);
$alphaIndex = 2;
$totalJadwalSalur = 0; $totalJadwalSalur = 0;
$totalRealisasi = 0; $totalRealisasi = 0;
$currIndex = 2;
for($i=1;$i<=12;$i++){ for($i=1;$i<=12;$i++){
$sheet->setCellValue($alpha[$alphaIndex].$rows, $val["spsbulan".$i]); $sheet->setCellValue(getAlphabetCell($currIndex).$rows, $val["spsbulan".$i]);
$sheet->setCellValue($alpha[$alphaIndex+1].$rows, $val['real'.$i]);
$alphaIndex+=2;
$totalJadwalSalur += $val["spsbulan".$i]; $totalJadwalSalur += $val["spsbulan".$i];
$totalRealisasi += $val['real'.$i]; $currIndex++;
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $val["real".$i]);
$totalRealisasi += $val["real".$i];
$currIndex++;
} }
$sheet->setCellValue(getAlphabetCell($alphaIndex).$rows, $totalJadwalSalur); $sheet->setCellValue(getAlphabetCell($currIndex).$rows, $totalJadwalSalur);
$sheet->setCellValue(getAlphabetCell($alphaIndex+1).$rows, $totalRealisasi); $sheet->setCellValue(getAlphabetCell($currIndex+1).$rows, $totalRealisasi);
$rows++; $rows++;
} }
// TOTAL BAWAH // TOTAL BAWAH
$alphaIndex = 2;
$sheet->setCellValue("A".$rows , "TOTAL"); $sheet->setCellValue("A".$rows , "TOTAL");
$sheet->mergeCells('A'.$rows.':'.'B'.$rows); $sheet->mergeCells('A'.$rows.':'.'B'.$rows);
for ($x=1;$x<=13;$x++){ for ($x=2;$x<=$colIndex;$x++){
$strAlpha = getAlphabetCell($alphaIndex); $strAlpha = getAlphabetCell($x);
$SUMRANGE = $strAlpha."3:".$strAlpha.($rows-1); $SUMRANGE = $strAlpha."3:".$strAlpha.($rows-1);
$sheet->setCellValue($strAlpha.$rows , "=SUM($SUMRANGE)"); $sheet->setCellValue($strAlpha.$rows , "=SUM($SUMRANGE)");
$alphaIndex++;
} }
$writer = new Xlsx($spreadsheet); $writer = new Xlsx($spreadsheet);
+2
View File
@@ -391,6 +391,8 @@ if($.fn.dataTable != undefined){
$.extend( $.fn.dataTable.ext.classes, { $.extend( $.fn.dataTable.ext.classes, {
sProcessing: "dataTables_processing", sProcessing: "dataTables_processing",
}); });
$($.fn.dataTable.tables( true )).DataTable().columns.adjust().draw();
} }
$(window).resize(function(){ $(window).resize(function(){
@@ -25,11 +25,13 @@
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<form id="frmJadwalSalur" action="{{ url("/jadwal-salurdana") }}" method="post">
@csrf
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<div class="form-group"> <div class="form-group">
<label>Periode</label> <label>Periode</label>
<select class="form-control form-control-sm" id="srcTA"> <select class="form-control form-control-sm" id="srcTA" name="ta">
@php @php
$listTA = Session::get('listTA'); $listTA = Session::get('listTA');
foreach($listTA as $rowTA){ foreach($listTA as $rowTA){
@@ -39,19 +41,15 @@
</select> </select>
</div> </div>
</div> </div>
{{-- <div class="col-11">
<div class="form-group">
<label>Berdasarkan Kata</label>
<input class="form-control form-control-sm" type="text" id="src">
</div>
</div> --}}
<div class="col-11"> <div class="col-11">
<div class="form-group"> <div class="form-group">
<label for="txt_simtrad4_kotor">DBH/DAK</label> <label for="txt_simtrad4_kotor">DBH/DAK</label>
<select id="txt_id_sps" name="txt_id_sps" class="form-control sps_search" required></select> <input type="hidden" name="type_dana" value="dak">
<select id="txt_id_sps" name="id_sps" class="form-control sps_search" required></select>
</div> </div>
</div> </div>
</div> </div>
</form>
<table id="dtTableJadwalPendapatan" class="table table-bordered table-striped jambo_table tblClickRow" style="width:150%"> <table id="dtTableJadwalPendapatan" class="table table-bordered table-striped jambo_table tblClickRow" style="width:150%">
<thead> <thead>
<tr class="headings"> <tr class="headings">
@@ -242,10 +240,10 @@
"columnDefs": [ "columnDefs": [
//{ className: "td-nowrap", "targets": [ 1 ] } //{ className: "td-nowrap", "targets": [ 1 ] }
], ],
"dom": "<\"top\" <\"row\"<\"col-md-6\"><\"col-md-6 text-right\">>>rt<\"bottom\" <\"row\"<\"col-md-6\"i><\"col-md-6\"p>> ><\"clear\">", "dom": "<\"top\" <\"row\"<\"col-md-6\"l><\"col-md-6 text-right\"B>>>rt<\"bottom\" <\"row\"<\"col-md-6\"i><\"col-md-6\"p>> ><\"clear\">",
"lengthMenu": [ "lengthMenu": [
[ 10, 20, 50 ], [ 10, 20, 50 ],
[ "20", "20", "50" ] [ "10", "20", "50" ]
], ],
"paging": true, // Table pagination "paging": true, // Table pagination
"columns": [ "columns": [
@@ -310,7 +308,7 @@
"zeroRecords": "Data tidak ditemukan!", "zeroRecords": "Data tidak ditemukan!",
"info": "Halaman _PAGE_ dari _PAGES_ Halaman", "info": "Halaman _PAGE_ dari _PAGES_ Halaman",
"infoEmpty": "Data tidak tersedia", "infoEmpty": "Data tidak tersedia",
"infoFiltered": "(Disaring dari _MAX_ Data)", "infoFiltered": "",
"paginate": { "paginate": {
"previous": "<i class='fas fa-angle-double-left'></i>", "previous": "<i class='fas fa-angle-double-left'></i>",
"next": "<i class='fas fa-angle-double-right'></i>", "next": "<i class='fas fa-angle-double-right'></i>",
@@ -386,6 +384,30 @@
dataSrc: ["groupall"] dataSrc: ["groupall"]
}, },
scrollX:true, scrollX:true,
buttons: [
{
extend: "collection",
text: "Export",
buttons: [
{
text: "<i class=\'fas fa-file-excel\'></i> Excel",
className: "export-data link-excel",
attr: {
formid: "frmJadwalSalur",
extype: "excel"
}
},
// {
// text: "<i class=\'fas fa-file-pdf\'></i> Pdf",
// className: "export-data link-pdf",
// attr: {
// formid: "frm_proses_spm_sp2d",
// extype: "pdf"
// }
// }
],
}
],
}); });
$('#txt_id_sps').select2({ $('#txt_id_sps').select2({