Merge remote-tracking branch 'composer/feature/senior-officer' into staging
This commit is contained in:
@@ -661,7 +661,7 @@ class PenilaiController extends Controller
|
||||
try {
|
||||
|
||||
if ($statusLpj) {
|
||||
return view('lpj::' . $viewLaporan, compact(
|
||||
$html= view('lpj::' . $viewLaporan, compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
@@ -675,6 +675,9 @@ class PenilaiController extends Controller
|
||||
'nomorLaporan'
|
||||
))->render();
|
||||
|
||||
return response($html, 200)->header('Content-Type', 'text/html');
|
||||
|
||||
|
||||
} else {
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
'permohonan',
|
||||
|
||||
@@ -319,13 +319,15 @@ class SurveyorController extends Controller
|
||||
$newPhotos = $this->processPhotoCategory(
|
||||
$request,
|
||||
$fields,
|
||||
$existingData[$category] ?? []
|
||||
$existingData[$category] ?? [],
|
||||
$category // Pass category to the function
|
||||
);
|
||||
|
||||
$formatFotojson[$category] = $newPhotos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process single files
|
||||
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
||||
foreach ($singleFiles as $file) {
|
||||
@@ -351,13 +353,19 @@ class SurveyorController extends Controller
|
||||
/**
|
||||
* Process a photo category and its subcategories
|
||||
*/
|
||||
private function processPhotoCategory(Request $request, array $fields, array $existingPhotos = [])
|
||||
private function processPhotoCategory(Request $request, array $fields, array $existingPhotos = [], $category = null)
|
||||
{
|
||||
$result = $existingPhotos; // Start with existing photos
|
||||
$photoField = $fields[0];
|
||||
$nameField = $fields[1];
|
||||
$descriptionField = $fields[2] ?? null;
|
||||
|
||||
if ($category === 'object_jaminan') {
|
||||
// If it's 'object_jaminan', do not overwrite existing photos, just add new ones
|
||||
$existingPhotos = $existingPhotos ?: [];
|
||||
$result = $existingPhotos;
|
||||
}
|
||||
|
||||
if ($request->hasFile($photoField)) {
|
||||
$newFiles = $request->file($photoField, []);
|
||||
$newNames = $request->input($nameField, []);
|
||||
@@ -367,7 +375,7 @@ class SurveyorController extends Controller
|
||||
foreach ($newFiles as $key => $file) {
|
||||
// Create new photo entry
|
||||
$newPhotoEntry = [
|
||||
$nameField => $newNames[$key] ?? '', // Use new name if provided
|
||||
$nameField => $newNames[$key] ?? '',
|
||||
$photoField => $this->uploadFile($file, $photoField . '.' . $key)
|
||||
];
|
||||
|
||||
@@ -384,6 +392,7 @@ class SurveyorController extends Controller
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function replaceFotoLantaiUnit(Request $request)
|
||||
{
|
||||
// Pastikan foto lantai unit ada dalam request
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
</div>
|
||||
|
||||
<!-- Iframe -->
|
||||
<iframe id="reportIframe" class="w-full h-full border rounded-lg hidden" frameborder="0"></iframe>
|
||||
<iframe id="reportIframe" style="display:none" width="100%" height="600px"></iframe>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -764,27 +764,6 @@
|
||||
const formElement = $('#formFoto')[0];
|
||||
const formData = new FormData(formElement);
|
||||
|
||||
const lantaiInputs = document.querySelectorAll('.lantai-input');
|
||||
lantaiInputs.forEach((input, index) => {
|
||||
const files = input.files;
|
||||
if (files.length > 0) {
|
||||
// Gunakan dot notation sesuai Laravel
|
||||
Array.from(files).forEach((file, fileIndex) => {
|
||||
formData.append(`foto_lantai_unit.${index}`, file);
|
||||
|
||||
// Nama lantai unit
|
||||
const namaLantai = document.querySelector(`[name="name_lantai_unit.${index}"]`);
|
||||
if (namaLantai && namaLantai.value) {
|
||||
formData.append(`name_lantai_unit.${index}`, namaLantai.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('surveyor.storeFoto') }}',
|
||||
type: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user