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();
$typeDana = isset($post["type_dana"])?$post["type_dana"]:"";
$idSPS = isset($post["id_sps"])?$post["id_sps"]:"";
$ta = $post["ta"];
$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));
//var_dump($data); exit;
$data = json_decode(json_encode($data),true);
$fileName = 'Jadwal-salur-dana.xlsx';
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Kode Rekening');
$sheet->setCellValue('B1', 'Nama Rekening');
$alpha = range("A","Z");
$alphaIndex = 2;
$colIndex = 2;
// Nama Kolom bulan
$bulans = GetBulan();
foreach($bulans as $bulan){
$sheet->setCellValue($alpha[$alphaIndex].'1', $bulan);
$sheet->mergeCells($alpha[$alphaIndex].'1'.':'.$alpha[$alphaIndex+1].'1');
$alphaIndex+=2;
$sheet->setCellValue($alpha[$colIndex].'1', $bulan);
$colIndex++;
$sheet->mergeCells($alpha[$colIndex].'1'.':'.$alpha[$colIndex].'1');
$colIndex++;
}
$sheet->setCellValue(getAlphabetCell($alphaIndex).'1', "TOTAL");
$sheet->mergeCells(getAlphabetCell($alphaIndex).'1'.':'.getAlphabetCell($alphaIndex+1).'1');
$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
$alphaIndex = 2;
for($i=1;$i<=13;$i++){
$sheet->setCellValue(getAlphabetCell($alphaIndex).'2', 'Jadwal');
$sheet->setCellValue(getAlphabetCell($alphaIndex+1).'2', 'Realisasi');
$alphaIndex+=2;
$colName = "Realisasi";
for($i=2;$i<=$colIndex;$i++){
$colName = $colName == "Jadwal" ? "Realisasi":"Jadwal";
$sheet->setCellValue(getAlphabetCell($i).'2', $colName);
}
// Data Kolom Bulan dan Realisasi
@@ -229,31 +247,30 @@ class JadwalSalurdanaController extends Controller
foreach ($data as $val){
$sheet->setCellValue('A' . $rows, $val["kode_rekening"]);
$sheet->setCellValue('B' . $rows, $val["nama_rekening"]);
$alphaIndex = 2;
$totalJadwalSalur = 0;
$totalRealisasi = 0;
$currIndex = 2;
for($i=1;$i<=12;$i++){
$sheet->setCellValue($alpha[$alphaIndex].$rows, $val["spsbulan".$i]);
$sheet->setCellValue($alpha[$alphaIndex+1].$rows, $val['real'.$i]);
$alphaIndex+=2;
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $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($alphaIndex+1).$rows, $totalRealisasi);
$sheet->setCellValue(getAlphabetCell($currIndex).$rows, $totalJadwalSalur);
$sheet->setCellValue(getAlphabetCell($currIndex+1).$rows, $totalRealisasi);
$rows++;
}
// TOTAL BAWAH
$alphaIndex = 2;
$sheet->setCellValue("A".$rows , "TOTAL");
$sheet->mergeCells('A'.$rows.':'.'B'.$rows);
for ($x=1;$x<=13;$x++){
$strAlpha = getAlphabetCell($alphaIndex);
for ($x=2;$x<=$colIndex;$x++){
$strAlpha = getAlphabetCell($x);
$SUMRANGE = $strAlpha."3:".$strAlpha.($rows-1);
$sheet->setCellValue($strAlpha.$rows , "=SUM($SUMRANGE)");
$alphaIndex++;
}
$writer = new Xlsx($spreadsheet);
+2
View File
@@ -391,6 +391,8 @@ if($.fn.dataTable != undefined){
$.extend( $.fn.dataTable.ext.classes, {
sProcessing: "dataTables_processing",
});
$($.fn.dataTable.tables( true )).DataTable().columns.adjust().draw();
}
$(window).resize(function(){
@@ -25,33 +25,31 @@
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-1">
<div class="form-group">
<label>Periode</label>
<select class="form-control form-control-sm" id="srcTA">
@php
$listTA = Session::get('listTA');
foreach($listTA as $rowTA){
echo "<option>$rowTA</option>";
}
@endphp
</select>
<form id="frmJadwalSalur" action="{{ url("/jadwal-salurdana") }}" method="post">
@csrf
<div class="row">
<div class="col-1">
<div class="form-group">
<label>Periode</label>
<select class="form-control form-control-sm" id="srcTA" name="ta">
@php
$listTA = Session::get('listTA');
foreach($listTA as $rowTA){
echo "<option>$rowTA</option>";
}
@endphp
</select>
</div>
</div>
<div class="col-11">
<div class="form-group">
<label for="txt_simtrad4_kotor">DBH/DAK</label>
<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 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="form-group">
<label for="txt_simtrad4_kotor">DBH/DAK</label>
<select id="txt_id_sps" name="txt_id_sps" class="form-control sps_search" required></select>
</div>
</div>
</div>
</form>
<table id="dtTableJadwalPendapatan" class="table table-bordered table-striped jambo_table tblClickRow" style="width:150%">
<thead>
<tr class="headings">
@@ -242,10 +240,10 @@
"columnDefs": [
//{ 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": [
[ 10, 20, 50 ],
[ "20", "20", "50" ]
[ "10", "20", "50" ]
],
"paging": true, // Table pagination
"columns": [
@@ -310,7 +308,7 @@
"zeroRecords": "Data tidak ditemukan!",
"info": "Halaman _PAGE_ dari _PAGES_ Halaman",
"infoEmpty": "Data tidak tersedia",
"infoFiltered": "(Disaring dari _MAX_ Data)",
"infoFiltered": "",
"paginate": {
"previous": "<i class='fas fa-angle-double-left'></i>",
"next": "<i class='fas fa-angle-double-right'></i>",
@@ -386,6 +384,30 @@
dataSrc: ["groupall"]
},
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({