Merge remote-tracking branch 'composer/feature/senior-officer' into staging
# Conflicts: # app/Http/Controllers/PenilaianController.php # resources/views/penilai/components/lpj-sederhana-standard.blade.php
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('content')
|
||||
<div class="card w-full bg-white rounded-lg shadow-md h-100vh">
|
||||
<div class="card-header flex justify-between items-center">
|
||||
<h3 class="card-title uppercase">Laporan</h3>
|
||||
<a href="{{ url()->previous() }}" class="btn btn-xs btn-info flex items-center">
|
||||
<i class="ki-filled ki-exit-left"></i> Back
|
||||
</a>
|
||||
</div>
|
||||
@include('lpj::assetsku.includenya')
|
||||
@php
|
||||
$inspeksiId = null;
|
||||
$documentId = null;
|
||||
@@ -21,89 +15,154 @@
|
||||
$jenisJaminanId = $item->jenis_jaminan_id;
|
||||
}
|
||||
@endphp
|
||||
<div class="card-body relative flex flex-col h-[calc(100vh-4rem)] overflow-hidden">
|
||||
<!-- Loading Spinner -->
|
||||
<div id="loading" class="absolute inset-0 flex items-center justify-center bg-opacity-50">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
<form id="form-lpj" method="post" class="w-full grid gap-5">
|
||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||
<input type="hidden" name="dokument_id" value="{{ request('documentId') }}">
|
||||
|
||||
<div id="pdf-container" class="mt-4" style="width: 100%; height: 800px; border: 1px solid #ccc; margin: 10px;"></div>
|
||||
@include('lpj::component.form-penilai', ['title' => 'Laporan'])
|
||||
<div class="flex card-footer justify-end gap-5">
|
||||
<button type="button" class="btn btn-success" id="saveButton" onclick="saveLpjSederhanadanStandard()">
|
||||
<span id="saveButtonText">Save</span>
|
||||
</button>
|
||||
|
||||
<div class="card-footer flex justify-end">
|
||||
<a href="{{ route('penilai.print-out') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}&statusLpj=0" class="btn btn-primary">
|
||||
<a href="{{ route('penilai.print-out') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}&statusLpj=0"
|
||||
class="btn btn-primary">
|
||||
<i class="ki-filled ki-printer"></i> Print
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.3.0/pdfobject.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const loading = document.getElementById('loading');
|
||||
const pdfContainer = document.getElementById('pdf-container');
|
||||
|
||||
const pdfUrl = `{{ route('penilai.print-out') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&jaminanId={{ $jenisJaminanId }}&statusLpj=true`;
|
||||
|
||||
// Display the loading spinner
|
||||
loading.style.display = 'flex';
|
||||
|
||||
// Fetch the PDF URL to ensure it loads properly
|
||||
fetch(pdfUrl)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch the PDF file.');
|
||||
}
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
const url = URL.createObjectURL(blob);
|
||||
// Embed PDF using PDFObject
|
||||
PDFObject.embed(url, pdfContainer, {
|
||||
height: "100%",
|
||||
fallbackLink: `<p class="text-red-500">It appears you don't have a PDF plugin for this browser. You can <a href="${url}">click here to download the PDF file.</a></p>`
|
||||
});
|
||||
loading.style.display = 'none';
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
loading.innerHTML = `<p class="text-red-500">Failed to load the report. Please try again later.</p>`;
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.currency-format').forEach(input => {
|
||||
input.addEventListener('input', function() {
|
||||
formatCurrency(this);
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.number-format').forEach(input => {
|
||||
input.addEventListener('input', function() {
|
||||
formatNumber(this);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function calculateTotal() {
|
||||
// Fungsi untuk menghapus format ribuan/koma
|
||||
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
||||
|
||||
// Ambil elemen input dan parse nilainya
|
||||
let luasTanah = parseInput(document.getElementById('luas_tanah').value);
|
||||
let hargaPerMeterTanah = parseInput(document.querySelector('input[name="nilai_tanah_1"]').value);
|
||||
let totalLuasTanah = document.querySelector('input[name="nilai_tanah_2"]');
|
||||
|
||||
let luasBangunan = parseInput(document.getElementById('luas_bangunan').value);
|
||||
let hargaPerMeterBangunan = parseInput(document.querySelector('input[name="nilai_bangunan_1"]').value);
|
||||
let totalLuasBangunan = document.querySelector('input[name="nilai_bangunan_2"]');
|
||||
|
||||
let saranaPelengkap = parseInput(document.getElementById('sarana_pelengkap_penilai').value);
|
||||
let hargaPerMeterSarana = parseInput(document.querySelector('input[name="nilai_sarana_pelengkap_1"]').value);
|
||||
let totalLuasSarana = document.querySelector('input[name="nilai_sarana_pelengkap_2"]');
|
||||
|
||||
// Bagian Likuidasi
|
||||
let persentaseLikuidasi = parseInput(document.getElementById('likuidasi').value);
|
||||
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
||||
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
||||
|
||||
// Bagian Asuransi
|
||||
let luasBangunanAsuransi = parseInput(document.getElementById('asuransi_luas_bangunan').value);
|
||||
let hargaPerMeterAsuransi = parseInput(document.querySelector('input[name="asuransi_nilai_1"]').value);
|
||||
let totalNilaiAsuransi = document.querySelector('input[name="asuransi_nilai_2"]');
|
||||
|
||||
let total = document.querySelector('input[name="total_nilai_pasar_wajar"]');
|
||||
|
||||
// Hitung hasil
|
||||
const hasilTanah = luasTanah * hargaPerMeterTanah;
|
||||
const hasilBangunan = luasBangunan * hargaPerMeterBangunan;
|
||||
const hasilSarana = saranaPelengkap * hargaPerMeterSarana;
|
||||
|
||||
const totalNilaiPasarWajar = hasilTanah + hasilBangunan + hasilSarana;
|
||||
|
||||
// Perhitungan Likuidasi
|
||||
const hasilLikuidasi = (persentaseLikuidasi / 100) * totalNilaiPasarWajar;
|
||||
|
||||
// Perhitungan Asuransi
|
||||
const hasilAsuransi = luasBangunanAsuransi * hargaPerMeterAsuransi;
|
||||
|
||||
// Tampilkan hasil dalam format currency
|
||||
totalLuasTanah.value = formatCurrency(hasilTanah.toString());
|
||||
totalLuasBangunan.value = formatCurrency(hasilBangunan.toString());
|
||||
totalLuasSarana.value = formatCurrency(hasilSarana.toString());
|
||||
total.value = formatCurrency(totalNilaiPasarWajar.toString());
|
||||
|
||||
// Tampilkan nilai likuidasi dan asuransi
|
||||
totalNilaiPasarLikuidasi.value = formatCurrency(totalNilaiPasarWajar.toString());
|
||||
totalNilaiAsuransi.value = formatCurrency(hasilAsuransi.toString());
|
||||
|
||||
// Total likuidasi (total nilai pasar wajar + nilai likuidasi)
|
||||
// const totalPasarWajarDenganLikuidasi = totalNilaiPasarWajar + hasilLikuidasi;
|
||||
totalLikuidasi.value = formatCurrency(hasilLikuidasi.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
function saveLpjSederhanadanStandard() {
|
||||
const form = document.getElementById('form-lpj');
|
||||
const formData = new FormData(form);
|
||||
showLoadingSwal('Mengirim data ke server...');
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const permohonanId = {{ $permohonan->id }};
|
||||
const documentId = urlParams.get('documentId');
|
||||
const inspeksiId = urlParams.get('inspeksiId');
|
||||
|
||||
const requestUrl = `{{ route('penilaian.storePenilaiLaporan') }}?permohonanId=${permohonanId}&inspeksiId=${inspeksiId}&documentId=${documentId}`;
|
||||
$.ajax({
|
||||
url: requestUrl,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
hideLoadingSwal();
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: response.message || 'Terjadi kesalahan',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
console.log(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
let errors = xhr.responseJSON?.errors;
|
||||
$('.alert').text('');
|
||||
if (errors) {
|
||||
$.each(errors, function(key, value) {
|
||||
$(`#error-${key}`).text(value[0]);
|
||||
toastrErrorBuild(value[0]);
|
||||
});
|
||||
}
|
||||
hideLoadingSwal();
|
||||
console.log(errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.loader {
|
||||
width: 100px;
|
||||
display: grid;
|
||||
background: radial-gradient(farthest-side, #35C1D0 98%, #0000) center/30px 100%
|
||||
no-repeat;
|
||||
--mask:
|
||||
radial-gradient(12px at left 15px top 50%, #0000 95%, #000),
|
||||
radial-gradient(12px at center, #0000 95%, #000),
|
||||
radial-gradient(12px at right 15px top 50%, #0000 95%, #000);
|
||||
-webkit-mask: var(--mask);
|
||||
mask: var(--mask);
|
||||
-webkit-mask-composite: source-in;
|
||||
mask-composite: intersect;
|
||||
animation: l2 1s infinite alternate;
|
||||
}
|
||||
.loader:before,
|
||||
.loader:after {
|
||||
content: "";
|
||||
grid-area: 1/1;
|
||||
height: 30px;
|
||||
aspect-ratio: 1;
|
||||
background: #35C1D0;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.loader:after {
|
||||
margin-left: auto;
|
||||
}
|
||||
@keyframes l2 {
|
||||
to {
|
||||
width: 50px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@include('lpj::surveyor.js.utils')
|
||||
|
||||
@@ -13,6 +13,60 @@
|
||||
|
||||
@include('lpj::component.detail-jaminan', ['backLink' => 'otorisator.' . $dataHeader . '.index'])
|
||||
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
Team
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@php
|
||||
$surveyor = $permohonan->penilaian->userPenilai->where('role', 'surveyor')->first();
|
||||
$penilai = $permohonan->penilaian->userPenilai->where('role', 'penilai')->first();
|
||||
|
||||
@endphp
|
||||
<label class="form-label max-w-56">
|
||||
Surveyor
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
|
||||
<p class="flex w-full text-gray-600 font-medium text-sm">
|
||||
{{ $surveyor->userPenilaiTeam->name }}
|
||||
</p>
|
||||
|
||||
<p class="flex w-full text-gray-600 font-medium text-sm">{{ checkRegionUserName($surveyor->userPenilaiTeam->id) }}
|
||||
</p>
|
||||
</div>
|
||||
<label class="form-label max-w-56">
|
||||
Penilai
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
|
||||
<p class="flex w-full text-gray-600 font-medium text-sm">
|
||||
{{ $penilai->userPenilaiTeam->name }}
|
||||
</p>
|
||||
|
||||
<p class="flex w-full text-gray-600 font-medium text-sm">
|
||||
{{ checkRegionUserName($penilai->userPenilaiTeam->id) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@php
|
||||
$inspeksiId = null;
|
||||
foreach ($dokumen->inspeksi as $item) {
|
||||
$inspeksiId = $item->id;
|
||||
}
|
||||
@endphp
|
||||
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
|
||||
@if($permohonan->approval_so)
|
||||
|
||||
Reference in New Issue
Block a user