fix(suveyor/penilai/so): perbaikan print out, form survey dan laporan dan paparan

This commit is contained in:
majid
2025-02-26 05:07:25 +07:00
parent 2045da36d8
commit 7766d127e0
21 changed files with 1317 additions and 550 deletions

View File

@@ -16,37 +16,57 @@
$dokumentName = null;
@endphp
<form id="dataPembandingForm" method="POST" enctype="multipart/form-data">
<form id="dataPembandingForm" method="POST" enctype="multipart/form-data" class="grid gap-5">
@csrf
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
<input type="hidden" name="type" value="tanah">
<input type="hidden" name="dokument_id" value="{{ request('dokument') }}">
<input type="hidden" name="nomor_registrasi" value="{{ $permohonan->nomor_registrasi }}">
<div class="card">
@foreach ($permohonan->documents as $dokumen)
@if ($dokumen->jenisJaminan)
@php
$dokumentName = $dokumen->jenisJaminan->name;
$formKategori = json_decode($dokumen->jenisJaminan->form_kategori, true);
@endphp
<input type="hidden" name="action"
value="{{ is_array($formKategori) ? implode(',', $formKategori) : $formKategori }}">
@if (!in_array(strtoupper($dokumentName), $tanahBangunanTypes))
@include('lpj::surveyor.components.pembanding-tanah-bangunan-unit')
@else
@include('lpj::surveyor.components.pembanding-kendaraan')
<div class="card-body">
@foreach ($permohonan->documents as $dokumen)
@if ($dokumen->jenisJaminan)
@php
$dokumentName = $dokumen->jenisJaminan->name;
$formKategori = json_decode($dokumen->jenisJaminan->form_kategori, true);
@endphp
<input type="hidden" name="action"
value="{{ is_array($formKategori) ? implode(',', $formKategori) : $formKategori }}">
@if (!in_array(strtoupper($dokumentName), $tanahBangunanTypes))
@include('lpj::surveyor.components.pembanding-tanah-bangunan-unit')
@else
@include('lpj::surveyor.components.pembanding-kendaraan')
@endif
@endif
@endif
@endforeach
<div class="card-footer">
<div class="flex justify-end gap-2">
<button type="button" onclick="submitData()" class="btn btn-primary">
<i class="ki-duotone ki-save-2 fs-2"></i>
Simpan
</button>
@endforeach
</div>
</div>
<div class="card">
<div class="card-body ">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin: 20px">
<label class="form-label lg:form-label max-w-56 ">Catatan yang Perlu Diperhatikan
</label>
<div class="w-full">
<div id="keterangan-container" class="flex items-baseline flex-wrap gap-2.5 w-full">
<div class="keterangan flex items-center gap-2 mt-2 textarea-group w-full">
<textarea name="keterangan" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="10">{{ $comparisons['keterangan'] ?? old('keterangan') }}</textarea>
<em id="error-keterangan" class="alert text-danger text-sm"></em>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<div class="flex justify-end gap-2">
<button type="button" onclick="submitData()" class="btn btn-primary">
<i class="ki-duotone ki-save-2 fs-2"></i>
Simpan
</button>
</div>
</div>
</form>
</div>
</div>
@@ -125,7 +145,7 @@
}
} else {
// Format currency untuk input harga
if (name.includes('diskon')) {
if (name.includes('diskon')) {
element.value = value || '0';
} else {
element.value = value || '';

View File

@@ -271,264 +271,279 @@
<script>
let jsonDataContoh = @json($formFoto);
Dropzone.autoDiscover = false;
document.addEventListener('DOMContentLoaded', function() {
let myDropzone = null;
let uploadQueue = 0;
let uploadBatch = [];
document.addEventListener('DOMContentLoaded', function() {
let myDropzone = null;
let uploadQueue = 0;
let uploadBatch = [];
function initDropzone(selector, paramName) {
try {
const dropzoneElement = document.querySelector(selector);
if (!dropzoneElement) {
console.error(`Dropzone element not found: ${selector}`);
return null;
function initDropzone(selector, paramName) {
try {
const dropzoneElement = document.querySelector(selector);
if (!dropzoneElement) {
console.error(`Dropzone element not found: ${selector}`);
return null;
}
const processedFiles = new Set();
// Track files that are already on the server
const existingFiles = new Set();
myDropzone = new Dropzone(selector, {
url: "{{ route('surveyor.storeFoto') }}",
paramName: paramName,
acceptedFiles: 'image/*',
uploadMultiple: false,
parallelUploads: 1,
autoProcessQueue: true,
dictDefaultMessage: 'Seret foto atau klik untuk unggah',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
params: {
permohonan_id: {{ $permohonan->id ?? 0 }},
dokument_id: '{{ request('dokument') ?? '' }}',
param_name: paramName,
nomor_registrasi: '{{ $permohonan->nomor_registrasi ?? '' }}',
},
accept: function(file, done) {
// Generate a unique identifier for the file - use hash or content-based ID if possible
const fileId = file.name + '_' + file.size;
// If file is already being processed, reject it
if (processedFiles.has(fileId)) {
done('File sudah dalam antrian upload.');
return;
}
const processedFiles = new Set();
myDropzone = new Dropzone(selector, {
url: "{{ route('surveyor.storeFoto') }}",
paramName: paramName,
acceptedFiles: 'image/*',
uploadMultiple: false,
parallelUploads: 1,
autoProcessQueue: true,
dictDefaultMessage: 'Seret foto atau klik untuk unggah',
// Check if file already exists on server
if (existingFiles.has(file.name)) {
done('File dengan nama ini sudah ada.');
return;
}
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
params: {
permohonan_id: {{ $permohonan->id ?? 0 }},
dokument_id: '{{ request('dokument') ?? '' }}',
param_name: paramName,
nomor_registrasi: '{{ $permohonan->nomor_registrasi ?? '' }}',
},
accept: function(file, done) {
// Generate a unique identifier for the file
const fileId = file.name + '_' + file.size;
// If file is already being processed, reject it
if (processedFiles.has(fileId)) {
done('File sudah dalam antrian upload.');
return;
}
// Add file to processed set
processedFiles.add(fileId);
done();
},
addedfiles: function(files) {
const validFiles = Array.from(files).filter(file => {
// Generate a unique ID for this file
const fileId = file.name + '_' + file.size;
// Only count files that haven't been rejected
return !file.rejected;
});
uploadQueue += validFiles.length;
uploadBatch = validFiles;
if (validFiles.length > 0) showLoadingOverlay();
},
error: function(file, response) {
// Remove file from processed list on error
const fileId = file.name + '_' + file.size;
processedFiles.delete(fileId);
handleUploadComplete(file, false, response.message);
},
success: function(file, response) {
if (response.success) {
const fileData = {
path: response.path || file.path,
name: file.name,
description: '',
category: 'lainnya',
sub: '',
param_name: paramName
};
addEditAndDeleteButtons(file, fileData);
handleUploadComplete(file, true);
} else {
handleUploadComplete(file, false, response.message);
}
},
init: function() {
const dz = this;
// Clear processed files when all uploads complete
this.on("queuecomplete", function() {
processedFiles.clear();
});
// Load existing photos
loadExistingPhotos(this, paramName);
}
// Add file to processed set
processedFiles.add(fileId);
done();
},
addedfiles: function(files) {
const validFiles = Array.from(files).filter(file => {
// Only count files that haven't been rejected
return !file.rejected;
});
return myDropzone;
} catch (error) {
console.error('Dropzone initialization error:', error);
return null;
}
}
uploadQueue += validFiles.length;
uploadBatch = validFiles;
function loadExistingPhotos(dropzone, paramName) {
showLoadingOverlay();
if (validFiles.length > 0) showLoadingOverlay();
},
$.ajax({
url: "{{ route('surveyor.getFoto') }}",
method: 'GET',
data: {
permohonan_id: {{ $permohonan->id ?? 0 }},
dokument_id: '{{ request('dokument') ?? '' }}',
param_name: paramName
},
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
success: function(response) {
if (response.fotos && response.fotos.length) {
response.fotos.forEach(function(foto) {
var mockFile = {
name: foto.name,
size: foto.size || 12345,
originalPath: foto.path
};
error: function(file, response) {
// Remove file from processed list on error
const fileId = file.name + '_' + file.size;
processedFiles.delete(fileId);
dropzone.emit("addedfile", mockFile);
dropzone.emit("thumbnail", mockFile, foto.path);
dropzone.emit("complete", mockFile);
addEditAndDeleteButtons(mockFile, {
path: foto.path,
name: foto.name,
description: foto.description || '',
category: foto.category || 'lainnya',
sub: foto.sub || '',
param_name: paramName
});
});
}
},
error: function(xhr, status, error) {
console.error('Gagal memuat foto:', error);
showErrorMessage('Gagal memuat foto yang ada');
},
complete: function() {
hideLoadingOverlay();
}
});
}
// Format error message
let errorMsg = typeof response === 'string' ? response :
(response.message || 'Gagal mengupload file');
function handleUploadComplete(file, isSuccess, errorMessage = null) {
uploadQueue--;
const index = uploadBatch.indexOf(file);
if (index > -1) {
uploadBatch.splice(index, 1);
}
handleUploadComplete(file, false, errorMsg);
},
// Show individual error if any
if (!isSuccess && errorMessage) {
showErrorMessage(errorMessage);
}
success: function(file, response) {
if (response.success) {
const fileData = {
path: response.path || file.path,
name: file.name,
description: '',
category: 'lainnya',
sub: '',
param_name: paramName
};
// If all uploads are complete
if (uploadQueue === 0) {
hideLoadingOverlay();
// Add file to existing files set to prevent duplicates
existingFiles.add(file.name);
// Show final status message
const totalFiles = uploadBatch.length + 1; // +1 for current file
if (totalFiles === 1) {
// Single file upload
if (isSuccess) {
showSuccessMessage('Foto berhasil diupload');
}
addEditAndDeleteButtons(file, fileData);
handleUploadComplete(file, true);
} else {
// Multiple files upload
showSuccessMessage(`${totalFiles} foto berhasil diupload`);
handleUploadComplete(file, false, response.message);
}
},
// Reset batch
uploadBatch = [];
init: function() {
const dz = this;
// Clear processed files when all uploads complete
this.on("queuecomplete", function() {
processedFiles.clear();
});
// Load existing photos
loadExistingPhotos(this, paramName, existingFiles);
}
}
});
function showLoadingOverlay() {
const overlay = document.querySelector('.loading-overlay');
if (!overlay) {
// Buat elemen overlay
const loadingOverlay = document.createElement('div');
loadingOverlay.className = 'loading-overlay';
loadingOverlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
`;
return myDropzone;
} catch (error) {
console.error('Dropzone initialization error:', error);
return null;
}
}
// Tambahkan loader di dalam overlay
loadingOverlay.innerHTML = '<div class="loader"></div>';
function loadExistingPhotos(dropzone, paramName, existingFilesSet) {
showLoadingOverlay();
// Tambahkan overlay ke dalam <body>
document.body.appendChild(loadingOverlay);
} else {
// Tampilkan overlay jika sudah ada
overlay.style.display = 'flex';
$.ajax({
url: "{{ route('surveyor.getFoto') }}",
method: 'GET',
data: {
permohonan_id: {{ $permohonan->id ?? 0 }},
dokument_id: '{{ request('dokument') ?? '' }}',
param_name: paramName
},
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
success: function(response) {
if (response.fotos && response.fotos.length) {
response.fotos.forEach(function(foto) {
var mockFile = {
name: foto.name,
size: foto.size || 12345,
originalPath: foto.path
};
// Add to existing files set to prevent duplicates
existingFilesSet.add(foto.name);
dropzone.emit("addedfile", mockFile);
dropzone.emit("thumbnail", mockFile, foto.path);
dropzone.emit("complete", mockFile);
addEditAndDeleteButtons(mockFile, {
path: foto.path,
name: foto.name,
description: foto.description || '',
category: foto.category || 'lainnya',
sub: foto.sub || '',
param_name: paramName
});
});
}
},
error: function(xhr, status, error) {
console.error('Gagal memuat foto:', error);
showErrorMessage('Gagal memuat foto yang ada');
},
complete: function() {
hideLoadingOverlay();
}
function hideLoadingOverlay() {
const overlay = document.querySelector('.loading-overlay');
if (overlay) overlay.style.display = 'none';
}
function showSuccessMessage(message) {
Swal.fire({
icon: 'success',
title: message,
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 1500
});
}
function showErrorMessage(message) {
Swal.fire({
icon: 'error',
title: 'Upload Gagal',
text: message || 'Error tidak diketahui'
});
}
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan
function safeInitDropzone(selector, paramName) {
setTimeout(() => {
const dropzone = initDropzone(selector, paramName);
if (!dropzone) {
console.error(`Failed to initialize Dropzone for ${selector}`);
}
}, 100);
}
// Inisialisasi dropzone untuk elemen awal
safeInitDropzone('#upload-dropzone', 'upload_foto');
});
}
function handleUploadComplete(file, isSuccess, errorMessage = null) {
uploadQueue--;
const index = uploadBatch.indexOf(file);
if (index > -1) {
uploadBatch.splice(index, 1);
}
// Show individual error if any
if (!isSuccess && errorMessage) {
showErrorMessage(errorMessage);
}
// If all uploads are complete
if (uploadQueue === 0) {
hideLoadingOverlay();
// Show final status message
const totalFiles = uploadBatch.length + 1; // +1 for current file
if (totalFiles === 1) {
// Single file upload
if (isSuccess) {
showSuccessMessage('Foto berhasil diupload');
}
} else {
// Multiple files upload
showSuccessMessage(`${totalFiles} foto berhasil diupload`);
}
// Reset batch
uploadBatch = [];
}
}
function showLoadingOverlay() {
const overlay = document.querySelector('.loading-overlay');
if (!overlay) {
// Buat elemen overlay
const loadingOverlay = document.createElement('div');
loadingOverlay.className = 'loading-overlay';
loadingOverlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
`;
// Tambahkan loader di dalam overlay
loadingOverlay.innerHTML = '<div class="loader"></div>';
// Tambahkan overlay ke dalam <body>
document.body.appendChild(loadingOverlay);
} else {
// Tampilkan overlay jika sudah ada
overlay.style.display = 'flex';
}
}
function hideLoadingOverlay() {
const overlay = document.querySelector('.loading-overlay');
if (overlay) overlay.style.display = 'none';
}
function showSuccessMessage(message) {
Swal.fire({
icon: 'success',
title: message,
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 1500
});
}
function showErrorMessage(message) {
Swal.fire({
icon: 'error',
title: 'Upload Gagal',
text: message || 'Error tidak diketahui'
});
}
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan
function safeInitDropzone(selector, paramName) {
setTimeout(() => {
const dropzone = initDropzone(selector, paramName);
if (!dropzone) {
console.error(`Failed to initialize Dropzone for ${selector}`);
}
}, 100);
}
// Inisialisasi dropzone untuk elemen awal
safeInitDropzone('#upload-dropzone', 'upload_foto');
});
let fotoObjekJaminan = @json($fotoObjekJaminan);

View File

@@ -138,18 +138,17 @@
}
@endphp
@if (isset($inspectionData['bangunan']))
<tr>
<td class="px-4 py-2">Luas Bangunan ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_tanah_bagunan" class="input"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? ($inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_bangunan_pembanding[]" class="input ">
</td>
</tr>
@endif
<tr>
<td class="px-4 py-2">Luas Bangunan ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_tanah_bagunan" class="input"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? ($inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_bangunan_pembanding[]" class="input ">
</td>
</tr>
<!-- Informasi Harga -->

View File

@@ -124,12 +124,12 @@
<td>
<label>
<input type="radio" name="tusuk_sate" value="yes"
{{ $forminspeksi['tanah']['tusuk_sate'] == 'yes' ? 'checked' : '' }}>
{{ isset($forminspeksi['tanah']['tusuk_sate']) && $forminspeksi['tanah']['tusuk_sate'] == 'yes' ? 'Ya' : 'Tidak' }}
Ya
</label>
<label>
<input type="radio" name="tusuk_sate" value="no"
{{ $forminspeksi['tanah']['tusuk_sate'] == 'no' ? 'checked' : '' }}>
{{isset($forminspeksi['tanah']['tusuk_sate']) && $forminspeksi['tanah']['tusuk_sate'] == 'no' ? 'checked' : '' }}>
Tidak
</label>
</td>
@@ -139,12 +139,12 @@
<td>
<label>
<input type="radio" name="lockland" value="yes"
{{ $forminspeksi['tanah']['lockland'] == 'yes' ? 'checked' : '' }}>
{{ isset($forminspeksi['tanah']['lockland']) && $forminspeksi['tanah']['lockland'] == 'yes' ? 'checked' : '' }}>
Ya
</label>
<label>
<input type="radio" name="lockland" value="no"
{{ $forminspeksi['tanah']['lockland'] == 'no' ? 'checked' : '' }}>
{{ isset($forminspeksi['tanah']['lockland']) && $forminspeksi['tanah']['lockland'] == 'no' ? 'checked' : '' }}>
Tidak
</label>
</td>

View File

@@ -22,6 +22,21 @@
@include('lpj::component.detail-jaminan',['backLink'=>'surveyor.index'])
@if ($permohonan->status == 'revisi-survey')
<div class="card border border-agi-100 min-w-full">
<div class="card-header bg-agi-50" id="basic_settings">
<div class="card-title flex flex-row gap-1.5">
Catatan Revisi
</div>
</div>
<div class="card-body">
<p>{{ $permohonan->keterangan ?? '' }}</p>
</div>
</div>
@endif
<div class="card border border-agi-100 min-w-full">
<div class="card-header bg-agi-50" id="basic_settings">
<div class="card-title flex flex-row gap-1.5">

View File

@@ -410,12 +410,10 @@
render: (item, data) => {
let tooltip = '';
if (data.status === 'revisi-laporan') {
if (data.status === 'revisi-laporan' || data.status === 'revisi-survey') {
tooltip = data.keterangan || '';
} else if (data.status === 'reschedule') {
tooltip = data.penilaian?.reschedule_note || '';
} else {
tooltip = '';
}
return `