Files
database-pertani-web/resources/views/program/realisasi/list.blade.php
T

83 lines
3.6 KiB
PHP

<div
class="offcanvas offcanvas-end"
tabindex="-1"
id="offcanvasListRealisasi"
aria-labelledby="offcanvasListRealisasiLabel">
<div class="offcanvas-header border-bottom">
<h5 id="offcanvasListRealisasiLabel" class="offcanvas-title">Riwayat Capaian Realisasi</h5>
<button
type="button"
class="btn-close text-reset"
data-bs-dismiss="offcanvas"
aria-label="Tutup"></button>
</div>
<div class="offcanvas-body mx-0 flex-grow-0 p-6 h-100">
<form class="t-0" id="historyRealisasiForm">
<input type="hidden" id="list-target-transformasi-id" name="transformasi_id"/>
<input type="hidden" id="list-target-aktivitas-id" name="aktivitas_id"/>
<input type="hidden" id="list-target-id" name="target_id"/>
<div class="mb-6 form-control-validation">
<label class="form-label" for="list-target-variabel">Variabel Target<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="list-target-variabel" name="variabel" placeholder="Cth: AK1" readonly />
</div>
<table class="table table-hover">
<thead>
<tr>
<th>Nilai Realisasi</th>
<th>Update</th>
</tr>
</thead>
<tbody id="historyRealisasiTableBody">
</tbody>
</table>
<button type="reset" class="btn btn-label-danger" data-bs-dismiss="offcanvas">Tutup</button>
</form>
</div>
</div>
@push('scripts')
<script>
$(document).ready(function() {
const offcanvasListRealisasi = new bootstrap.Offcanvas(document.getElementById('offcanvasListRealisasi'));
$(".history-realisasi").click(function () {
const targetId = $(this).data('target-id');
const aktivitasId = $(this).data('aktivitas-id');
const transformasiId = $(this).data('transformasi-id');
console.log('Add target, target id: ' + targetId);
$('#list-target-aktivitas-id').val(aktivitasId);
$('#list-target-transformasi-id').val(transformasiId);
$('#list-target-id').val(targetId);
$.get("{{ route('framework.transformasi.aktivitas.target.show', [$framework->id, ':transformasiId', ':aktivitasId', ':id']) }}"
.replace(':aktivitasId', aktivitasId)
.replace(':transformasiId', transformasiId)
.replace(':id', targetId), function (res) {
if (res.status === 'success') {
$('#list-target-variabel').val(res.data.variabel);
let rows = '';
res.data.realisasi.forEach(function (realisasi) {
let realisasiValue = '';
if (res.data.tipe === 'integer') {
realisasiValue = realisasi.realisasi_integer;
} else if (res.data.tipe === 'float') {
realisasiValue = realisasi.realisasi_float;
} else if (res.data.tipe === 'boolean') {
realisasiValue = realisasi.realisasi_boolean ? 'Ya' : 'Tidak';
}
rows += '<tr><td>' + realisasiValue + '</td><td>' + new Date(realisasi.updated_at).toLocaleString() + '</td></tr>';
});
$('#historyRealisasiTableBody').html(rows);
offcanvasListRealisasi.show();
}
});
});
});
</script>
@endpush