Merge remote-tracking branch 'composer/feature/senior-officer' into staging
This commit is contained in:
@@ -661,7 +661,7 @@ class PenilaiController extends Controller
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
if ($statusLpj) {
|
if ($statusLpj) {
|
||||||
return view('lpj::' . $viewLaporan, compact(
|
$html= view('lpj::' . $viewLaporan, compact(
|
||||||
'permohonan',
|
'permohonan',
|
||||||
'forminspeksi',
|
'forminspeksi',
|
||||||
'lpjData',
|
'lpjData',
|
||||||
@@ -675,6 +675,9 @@ class PenilaiController extends Controller
|
|||||||
'nomorLaporan'
|
'nomorLaporan'
|
||||||
))->render();
|
))->render();
|
||||||
|
|
||||||
|
return response($html, 200)->header('Content-Type', 'text/html');
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||||
'permohonan',
|
'permohonan',
|
||||||
|
|||||||
@@ -319,13 +319,15 @@ class SurveyorController extends Controller
|
|||||||
$newPhotos = $this->processPhotoCategory(
|
$newPhotos = $this->processPhotoCategory(
|
||||||
$request,
|
$request,
|
||||||
$fields,
|
$fields,
|
||||||
$existingData[$category] ?? []
|
$existingData[$category] ?? [],
|
||||||
|
$category // Pass category to the function
|
||||||
);
|
);
|
||||||
|
|
||||||
$formatFotojson[$category] = $newPhotos;
|
$formatFotojson[$category] = $newPhotos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Process single files
|
// Process single files
|
||||||
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
||||||
foreach ($singleFiles as $file) {
|
foreach ($singleFiles as $file) {
|
||||||
@@ -351,13 +353,19 @@ class SurveyorController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Process a photo category and its subcategories
|
* 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
|
$result = $existingPhotos; // Start with existing photos
|
||||||
$photoField = $fields[0];
|
$photoField = $fields[0];
|
||||||
$nameField = $fields[1];
|
$nameField = $fields[1];
|
||||||
$descriptionField = $fields[2] ?? null;
|
$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)) {
|
if ($request->hasFile($photoField)) {
|
||||||
$newFiles = $request->file($photoField, []);
|
$newFiles = $request->file($photoField, []);
|
||||||
$newNames = $request->input($nameField, []);
|
$newNames = $request->input($nameField, []);
|
||||||
@@ -367,7 +375,7 @@ class SurveyorController extends Controller
|
|||||||
foreach ($newFiles as $key => $file) {
|
foreach ($newFiles as $key => $file) {
|
||||||
// Create new photo entry
|
// Create new photo entry
|
||||||
$newPhotoEntry = [
|
$newPhotoEntry = [
|
||||||
$nameField => $newNames[$key] ?? '', // Use new name if provided
|
$nameField => $newNames[$key] ?? '',
|
||||||
$photoField => $this->uploadFile($file, $photoField . '.' . $key)
|
$photoField => $this->uploadFile($file, $photoField . '.' . $key)
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -384,6 +392,7 @@ class SurveyorController extends Controller
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function replaceFotoLantaiUnit(Request $request)
|
public function replaceFotoLantaiUnit(Request $request)
|
||||||
{
|
{
|
||||||
// Pastikan foto lantai unit ada dalam request
|
// Pastikan foto lantai unit ada dalam request
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Iframe -->
|
<!-- 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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -764,27 +764,6 @@
|
|||||||
const formElement = $('#formFoto')[0];
|
const formElement = $('#formFoto')[0];
|
||||||
const formData = new FormData(formElement);
|
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({
|
$.ajax({
|
||||||
url: '{{ route('surveyor.storeFoto') }}',
|
url: '{{ route('surveyor.storeFoto') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user