fix(so/penilai) : perbaikkan paparan dan resume

This commit is contained in:
majid
2025-02-27 10:18:31 +07:00
parent 6102205900
commit 2a475a9ea7
18 changed files with 960 additions and 888 deletions

View File

@@ -27,11 +27,13 @@
return view('lpj::pembayaran.index');
}
public function approval() {
public function approval()
{
return view('lpj::pembayaran.approval');
}
public function dataApprovalForDatatables(Request $request) {
public function dataApprovalForDatatables(Request $request)
{
if (is_null($this->user) || !$this->user->can('noc.view')) {
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
}
@@ -105,7 +107,7 @@
]);
}
function edit($id)
public function edit($id)
{
$permohonan = Permohonan::find($id);
return view('lpj::pembayaran.form', compact('permohonan'));
@@ -157,8 +159,8 @@
->route('pembayaran.index')->with('success', 'Pembayaran berhasil disimpan.');
}
public function update(Request $request, $id)
: JsonResponse {
public function update(Request $request, $id): JsonResponse
{
// init
$data = [];
$output = [];
@@ -184,6 +186,20 @@
$data['status'] = 'spk';
}
if ($permohonan->jenis_penilaian_id == 1) {
unset(
$data['approval_so'],
$data['approval_so_at'],
$data['approval_eo'],
$data['approval_eo_at'],
$data['approval_dd'],
$data['approval_dd_at'],
$data['keterangan']
);
$data['status'] = 'proses-laporan';
}
$permohonan->update($data);
if ($permohonan->jenis_penilaian_id == 2) {

View File

@@ -497,7 +497,7 @@ class PenilaiController extends Controller
});
}
$query->whereRaw('LOWER(status) IN (?, ?, ?, ?, ?, ?,?)', ['assign','survey-completed', 'proses-laporan', 'paparan', 'proses-paparan','paparan', 'revisi-laporan', 'done']);
$query->whereRaw('LOWER(status) IN (?, ?, ?, ?, ?, ?,?)', ['assign','survey-completed', 'proses-laporan', 'paparan', 'proses-paparan','paparan', 'revisi-laporan']);
if (!Auth::user()->hasRole('administrator')) {
$query->whereHas('penilaian.userPenilai', function ($q) {

View File

@@ -27,7 +27,6 @@ use Modules\Lpj\Http\Controllers\SurveyorController;
use Modules\Lpj\Http\Controllers\PenilaiController;
use Modules\Lpj\Http\Requests\FormSurveyorRequest;
class PenilaianController extends Controller
{
public $user;

View File

@@ -674,6 +674,51 @@ class SurveyorController extends Controller
]);
}
public function saveEditedImage(Request $request)
{
try {
$request->validate([
'edited_image' => 'required|string',
'original_path' => 'required|string',
]);
// Decode base64 image
$base64Image = $request->input('edited_image');
if (str_contains($base64Image, ';base64,')) {
[$metadata, $base64Image] = explode(';base64,', $base64Image);
}
$decodedImage = base64_decode($base64Image);
if (!$decodedImage) {
return response()->json([
'status' => 'error',
'message' => 'Gambar tidak valid',
], 400);
}
// Path asli
$originalPath = $request->input('original_path');
$fileName = basename($originalPath);
$newFilePath = 'edited_images/' . $fileName;
// Simpan file ke storage
Storage::disk('public')->put($newFilePath, $decodedImage);
return response()->json([
'status' => 'success',
'message' => 'Gambar berhasil disimpan',
'file_path' => $newFilePath,
], 200);
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => 'Terjadi kesalahan: ' . $e->getMessage(),
], 500);
}
}
private function findFotoByParamName($fotoForm, $paramName)
{
// Mapping parameter name ke struktur JSON

View File

@@ -103,6 +103,7 @@
"roles": [
"administrator",
"senior-officer",
"EO Appraisal",
"DD Appraisal"
]
}

View File

@@ -1,82 +1,5 @@
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
{{-- <div class="card border border-agi-100 min-w-full">
<div class="card border border-agi-100 min-w-full">
<div class="card-header bg-agi-50">
<h3 class="card-title">
{{ $title ?? 'Data Jaminan' }}
</h3>
@php
use Illuminate\Support\Facades\Route;
@endphp
<div class="flex items-center gap-2">
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer', 'EO Appraisal', 'DD Appraisal']) &&
Route::currentRouteName('otorisator.show'))
<a href="{{ route('otorisator.show', ['id' => $permohonan->id, 'type' => 'Pelaporan']) }}"
class="btn btn-xs btn-info">
<i class="ki-filled ki-exit-left"></i> Back
</a>
@elseif (Auth::user()->hasAnyRole(['administrator', 'surveyor']) && Route::currentRouteName('penilai.show'))
<a href="{{ route('penilai.show', $permohonan->id) }}" class="btn btn-xs btn-info">
<i class="ki-filled ki-exit-left"></i> Back
</a>
@endif
</div>
</div>
<div class="card-body grid gap-5 grid-cols-2">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Nama Debitur</label>
<div class="flex flex-wrap items-baseline w-full">
@if (isset($permohonan->debiture))
<p class="text-2sm text-gray-700">{{ $permohonan->debiture->name }}</p>
@endif
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Alamat Object</label>
<div class="flex flex-wrap items-baseline w-full">
@foreach ($permohonan->documents as $dokumen)
<span class="text-2sm text-gray-700">
{{ formatAlamat($dokumen->pemilik) }}
{{ formatAlamat($dokumen->pemilik) }}
</span>
@endforeach
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Nomor Registrasi</label>
<div class="flex flex-wrap items-base line w-full">
<p class="text-2sm text-gray-700">{{ $permohonan->nomor_registrasi }}</p>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Cab/Direktorat</label>
<div class="flex flex-wrap items-baseline w-full">
@if (isset($permohonan->branch))
<p class="text-2sm text-gray-700">{{ $permohonan->branch->name }}</p>
@endif
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Nomor Laporan</label>
<div class="flex flex-wrap items-base line w-full">
<p class="text-2sm text-gray-700">{{ $permohonan->nomor_registrasi }}</p>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">AO</label>
<div class="flex flex-wrap items-baseline w-full">
@if (isset($permohonan->user))
<p class="text-2sm text-gray-700">{{ $permohonan->user->name }}</p>
@endif
</div>
</div>
</div>
</div>
</div> --}}
@foreach ($permohonan->documents as $dokumen)
@if ($dokumen->jenisJaminan)
@@ -290,60 +213,12 @@
</div>
</div>
<div class="card">
<div class="card-header bg-agi-50">
<h3 class="card-title uppercase">
nilai asuransi
</h3>
</div>
<div class="card-body">
<div>
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI ASURANSI</label>
<div class="card-body grid gap-2.5 w-full">
<div class="flex grid-col-3 gap-2.5 w-full">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province" class="form-label">Luas Bangunan</label>
<input type="text" class="input w-full" id="asuransi_luas_bangunan"
name="asuransi_luas_bangunan"
value="{{ old('asuransi_luas_bangunan', $lpjData['asuransi_luas_bangunan'] ?? null) }}"
oninput="calculateTotal()">
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province" class="">X</label>
<label class="input">
<i class="">Rp
</i>
<input type="text" class="input w-full currency" id="asuransi_nilai_1"
name="asuransi_nilai_1"
value="{{ old('asuransi_nilai_1', $lpjData['asuransi_nilai_1'] ?? null) }}"
oninput="calculateTotal()">
</label>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label class="input">
<i class="">Rp
</i>
<input type="text" class="input w-full currency-format" name="asuransi_nilai_2"
value="{{ old('asuransi_nilai_2', $lpjData['asuransi_nilai_2'] ?? null) }}">
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
const datas = @json($forminspeksi);
console.log(datas);
document.addEventListener('DOMContentLoaded', function() {
const tambahNPWButton = document.getElementById('tambah-npw');
const addPasarWajarContainer = document.getElementById('add_pasar_wajar');
let npwCounter = 0;

View File

@@ -8,7 +8,7 @@
Input Nilai Liquidasi (LPJ)
</div>
<div class="flex items-center gap-2">
<a href="{{ route('pembayaran.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
<a href="{{ route('laporan.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
</div>
</div>
<div class="card-body">

View File

@@ -16,17 +16,17 @@
<tr>
<td style=" width:25%; padding: 2px; vertical-align: top;">Jarak Jalan Utama</td>
<td style=" width:1%; padding: 2px; vertical-align: top;">:</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jarak_jalan_utama'] ?? '-' }} m</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jarak_jalan_utama'] ?? '-' }}</td>
</tr>
<tr>
<td style="padding: 2px; vertical-align: top;">Jalan Lingkungan</td>
<td style="padding: 2px; vertical-align: top;">:</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jalan_linkungan'] ?? '-' }} m</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jalan_linkungan'] ?? '-' }}</td>
<tr>
<td style="padding: 2px; vertical-align: top;">Jarak CBD</td>
<td style="padding: 2px; vertical-align: top;">:</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jarak_cbd_point'] ?? '-' }} m
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jarak_cbd_point'] ?? '-' }}
({{ $lingkungan['nama_cbd_point'] ?? '-' }})</td>
</tr>
<tr>

View File

@@ -391,10 +391,12 @@
</div>
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
@if (Auth::user()->hasAnyRole(['senior-officer', 'surveyor', 'administrator']))
<button type="button" class="btn btn-primary" id="saveButton" onclick="submitData()">
<i class="ki-filled ki-save-2"></i>
<span id="saveButtonText">Save</span>
</button>
@endif
@if (Auth::user()->hasAnyRole(['senior-officer', 'EO Appraisal', 'DD Appraisal']))
<a class="btn btn-info"
href="{{ route('penilai.lampiran') }}?permohonanId={{ request('permohonanId') }}&documentId={{ request('documentId') }}&inspeksiId={{ request('inspeksiId') }}&jaminanId={{ request('jaminanId') }}&statusLpj=1">

View File

@@ -44,10 +44,12 @@
</div>
</div>
<div class="flex card-footer justify-end gap-5">
@if (Auth::user()->hasAnyRole(['senior-officer', 'surveyor', 'administrator']))
<button type="button" class="btn btn-primary" id="saveButton" onclick="saveLpjSederhanadanStandard()">
<i class="ki-filled ki-save-2"></i>
<span id="saveButtonText">Save</span>
</button>
@endif
@if (Auth::user()->hasAnyRole(['senior-officer', 'EO Appraisal', 'DD Appraisal', 'administrator']))
<a class="btn btn-info"
href="{{ route('penilai.lampiran') }}?permohonanId={{ request('permohonanId') }}&documentId={{ request('documentId') }}&inspeksiId={{ request('inspeksiId') }}&jaminanId={{ request('jaminanId') }}&statusLpj=1">

View File

@@ -292,10 +292,12 @@
{{-- @include('lpj::penilai.components.foto-lampiran') --}}
<div class="flex card-footer justify-end gap-5">
@if (Auth::user()->hasAnyRole(['senior-officer', 'surveyor', 'administrator']))
<a class="btn btn-primary" onclick="saveMemo()">
<i class="ki-filled ki-save-2"></i>
SAVE
</a>
@endif
@if (Auth::user()->hasAnyRole(['senior-officer', 'EO Appraisal', 'DD Appraisal']))
<a class="btn btn-info"
href="{{ route('penilai.lampiran') }}?permohonanId={{ request('permohonanId') }}&documentId={{ request('documentId') }}&inspeksiId={{ request('inspeksiId') }}&jaminanId={{ request('jaminanId') }}&statusLpj=1">

View File

@@ -109,7 +109,7 @@
</td>
</tr>
<tr>
<td style="width: 25%; padding: 2px; vertical-align: top;">Pihak Bank selain Apraisal</td>
<td style="width: 25%; padding: 2px; vertical-align: top;">Pihak Bank selain Appraisal</td>
<td style="width: 1%; vertical-align: top;">:</td>
<td style="vertical-align: top;">{{ $forminspeksi['asset']['pihak_bank'] ?? '' }}
</td>
@@ -231,7 +231,7 @@
? $forminspeksi['asset']['hub_cadeb']['tidak sesuai']
: $forminspeksi['asset']['hub_cadeb']['sesuai'];
@endphp
<td style="width:25%; padding: 2px; vertical-align: top;">Hubungan Pemilik Jaminan dengan Debitu</td>
<td style="width:25%; padding: 2px; vertical-align: top;">Hubungan Pemilik Jaminan dengan Debitur</td>
<td style="width:1%; padding: 2px; vertical-align: top;">:</td>
<td style=" padding: 2px; vertical-align: top;">{{ $hubCadeb ?? '' }}</td>
</tr>

View File

@@ -332,101 +332,8 @@
</td>
</tr>
<tr>
<td>Demikian Kami Sampaikan, atas perhatiannya kami ucapkan terimakasih</td>
<td>Resume ini sudah di setujui</td>
</tr>
<table style="width: 100%;">
<tr>
<td>
<table style="width: 100%; border-collapse: collapse; text-align: center;">
@php
use Modules\Usermanagement\Models\User;
$penilaiUser = User::where('id', $penilai->userPenilaiTeam->id)->first();
$imagePathPenilai = storage_path(
'app/public/signatures/' . $penilaiUser->id . '/' . $penilaiUser->sign,
);
$soUser = User::where('id', $senior_officer->id)->first();
$imagePathSo = storage_path('app/public/signatures/' . $soUser->id . '/' . $soUser->sign);
$imagePathEO = storage_path(
'app/public/signatures/' .
User::role('EO Appraisal')->first()->id .
'/' .
User::role('EO Appraisal')->first()->sign,
);
$imagePathDD = storage_path(
'app/public/signatures/' .
User::role('DD Appraisal')->first()->id .
'/' .
User::role('DD Appraisal')->first()->sign,
);
@endphp
<tr>
<td style=" padding: 4px;height: 50px">
@if (file_exists($imagePathPenilai))
<img src="{{ $imagePathPenilai }}" alt="{{ $imagePathPenilai }}" width="80px">
@endif
</td>
@if ($permohonan->approval_so != null)
<td style=" padding: 4px;height: 50px">
@if (file_exists($imagePathSo))
<img src="{{ $imagePathSo }}" alt="{{ $imagePathSo }}" width="80px">
@endif
</td>
@endif
@if ($permohonan->approval_eo != null)
<td style=" padding: 4px;height: 50px">
@if (file_exists($imagePathEO))
<img src="{{ $imagePathEO }}" alt="{{ $imagePathEO }}" width="80px">
@endif
</td>
@endif
@if ($permohonan->approval_dd != null)
<td style=" padding: 4px;height: 50px">
@if (file_exists($imagePathDD))
<img src="{{ $imagePathDD }}" alt="{{ $imagePathDD }}" width="80px">
@endif
</td>
@endif
</tr>
<tr>
<td style=" padding: 4px;">{{ $penilai->userPenilaiTeam->name ?? '' }}</br>
<span>
{{ ucwords(strtolower('PENILAI')) }}
</span>
</td>
@if ($permohonan->approval_so != null)
<td style=" padding: 4px;">
{{ $senior_officer->name ?? '' }}</br>
<span>
{{ ucwords(strtolower('SENIOR OFFICER')) }}
</span>
</td>
@endif
@if ($permohonan->approval_eo != null)
<td style=" padding: 4px;">
{{ User::role('EO Appraisal')->first()->name ?? '' }}</br>
<span>
{{ ucwords(strtolower('EXECUTIVE OFFICER')) }}
</span>
</td>
@endif
@if ($permohonan->approval_dd != null)
<td style=" padding: 4px;">
{{ User::role('DD Appraisal')->first()->name ?? '' }}</br>
<span>
{{ ucwords(strtolower('DEPUTY DIRECTOR')) }}
</span>
</td>
@endif
</tr>
</table>
</td>
</tr>
</table>
</table>
<div class="page-break"></div>

View File

@@ -65,6 +65,7 @@
</div>
</div>
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
@if (Auth::user()->hasAnyRole(['senior-officer', 'surveyor', 'administrator']))
<button type="button" class="btn btn-primary" id="saveButton" onclick="submitData()">
<i class="ki-filled ki-save-2"></i>
<span id="saveButtonText">Save</span>
@@ -73,6 +74,7 @@
</div>
</button>
@endif
@if (Auth::user()->hasAnyRole(['senior-officer', 'EO Appraisal', 'DD Appraisal', 'administrator']))
<a class="btn btn-info"
href="{{ route('penilai.lampiran') }}?permohonanId={{ request('permohonanId') }}&documentId={{ request('documentId') }}&inspeksiId={{ request('inspeksiId') }}&jaminanId={{ request('jaminanId') }}&statusLpj=1">

View File

@@ -423,10 +423,11 @@
<div class="flex card-footer justify-end gap-5">
@if (Auth::user()->hasAnyRole(['senior-officer', 'surveyor', 'administrator']))
<button type="button" class="btn btn-primary" onclick="saveResume()">
<i class="ki-filled ki-save-2"></i>
Save</button>
@endif
@if (Auth::user()->hasAnyRole(['senior-officer', 'EO Appraisal', 'DD Appraisal', 'administrator']))
<a class="btn btn-info"

View File

@@ -157,7 +157,6 @@
Otorisator {{ $header ?? '' }}
</button>
@endif
@elseif($dataHeader == 'paparan')
@if ($permohonan->penilai->file_paparan)
<span class="btn btn-success btn-outline"
@@ -174,21 +173,30 @@
<a class="btn btn-success"
href="{{ route('otorisator.view-laporan') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}&statusLpj={{ true }}">
Lihat Laporan
Lihat resume
</a>
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer']) && $authorization->approve_so == null)
<button onclick="otorisatorData({{ $authorization->id }},'SO')" type="button" class="btn btn-primary">
<button onclick="otorisatorData({{ $authorization->id }},'SO')" type="button"
class="btn btn-primary">
<i class="ki-filled ki-double-check"></i>
Otorisator {{ $header ?? '' }}
</button>
@endif
@if(Auth::user()->hasAnyRole(['administrator', 'DD Appraisal']) &&
$authorization->approve_so &&
$authorization->approve_dd == null)
<button onclick="otorisatorData({{ $authorization->id }},'DD')" type="button" class="btn btn-primary">
@if (Auth::user()->hasAnyRole(['administrator', 'EO Appraisal']) &&
$authorization->approve_eo == null)
<button onclick="otorisatorData({{ $authorization->id }},'EO')" type="button"
class="btn btn-primary">
<i class="ki-filled ki-double-check"></i>
Otorisator {{ $header ?? '' }}
</button>
@endif
@if (Auth::user()->hasAnyRole(['administrator', 'DD Appraisal']) && $authorization->approve_dd == null)
<button onclick="otorisatorData({{ $authorization->id }},'DD')" type="button"
class="btn btn-primary">
<i class="ki-filled ki-double-check"></i>
Otorisator {{ $header ?? '' }}
</button>
@@ -204,112 +212,188 @@
function otorisatorData(dataId, role = '') {
const dataHeader = @json($header);
if (dataHeader == 'Paparan') {
if(role == 'SO'){
Swal.fire({
title: 'Apakah Anda yakin?',
text: `Untuk melakukan otorisator ${dataHeader}!`,
icon: 'warning',
html: `
<input id="swal-keterangan" class="swal2-input input" placeholder="Keterangan">
<input id="swal-tanggal-paparan" class="swal2-input input" type="date" placeholder="Tanggal paparan">
`,
const showSwalConfirmation = (title, text, html, confirmText, denyText, cancelText, preConfirm) => {
return Swal.fire({
title: title,
text: text,
html: html,
focusConfirm: false,
preConfirm: () => {
preConfirm: preConfirm,
showCancelButton: true,
showDenyButton: !!denyText,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
denyButtonColor: '#f39c12',
confirmButtonText: confirmText,
denyButtonText: denyText,
cancelButtonText: cancelText,
});
};
const handleAjaxRequest = (url, data, successMessage, errorMessage) => {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
});
$.ajax({
url: url,
type: 'POST',
data: data,
success: (response) => {
Swal.fire('Berhasil!', successMessage, 'success').then(() => {
window.location.reload();
});
console.log(response);
},
error: (error) => {
console.error('Error:', error);
Swal.fire('Gagal!', errorMessage, 'error');
}
});
};
const handleRejection = (dataId) => {
Swal.fire({
title: 'Masukkan alasan penolakan:',
input: 'textarea',
inputPlaceholder: 'Tuliskan alasan...',
showCancelButton: true,
confirmButtonColor: '#f39c12',
cancelButtonColor: '#d33',
confirmButtonText: 'Kirim',
cancelButtonText: 'Batal',
preConfirm: (alasan) => {
if (!alasan) {
Swal.showValidationMessage('Alasan harus diisi!');
return false;
}
return alasan;
}
}).then((rejectResult) => {
if (rejectResult.isConfirmed) {
handleAjaxRequest(
`/otorisator/revisi/${dataId}`, {
message: rejectResult.value
},
'Data berhasil ditolak.',
'Terjadi kesalahan saat melakukan penolakan.'
);
}
});
};
// Main logic based on role
if (role === 'SO') {
showSwalConfirmation(
'Apakah Anda yakin?',
`Untuk melakukan otorisator ${dataHeader}!`,
`
<div class="text-left space-y-4">
<p class="text-gray-700 text-center">Untuk melakukan otorisator ${dataHeader}!</p>
<div>
<label for="swal-keterangan" class="block text-sm font-medium text-gray-700 mb-1">Keterangan</label>
<input id="swal-keterangan" class="input" placeholder="Masukkan Keterangan">
</div>
<div>
<label for="swal-tanggal-paparan" class="block text-sm font-medium text-gray-700 mb-1">Tanggal Paparan</label>
<input id="swal-tanggal-paparan" class="input" type="date" placeholder="Tanggal paparan">
</div>
</div>
`,
'Ya, Lanjutkan!', 'Rejected', 'Batal',
() => {
const keterangan = document.getElementById('swal-keterangan').value;
const tanggalPaparan = document.getElementById('swal-tanggal-paparan').value;
if (!keterangan || !tanggalPaparan) {
Swal.showValidationMessage('Keterangan atau Tanggal Paparan Harus diisi!');
return false;
}
return { keterangan, tanggalPaparan };
},
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Lanjutkan!',
cancelButtonText: 'Batal',
}).then((result) => {
return {
keterangan,
tanggalPaparan
};
}
).then((result) => {
if (result.isConfirmed) {
const keterangan = result.value.keterangan || '';
const tanggalPaparan = result.value.tanggalPaparan || '';
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
handleAjaxRequest(
`/otorisator/otorisator/${dataId}/${dataHeader}`, {
message: result.value.keterangan,
tanggalPaparan: result.value.tanggalPaparan
},
});
$.ajax({
url: `/otorisator/otorisator/${dataId}/${dataHeader}`,
type: 'POST',
data: {
message: keterangan,
tanggalPaparan: tanggalPaparan
},
success: (response) => {
Swal.fire('Berhasil!',
'Data berhasil diotorisasi.',
'success').then(() => {
window.location.reload();
});
console.log(response);
},
error: (error) => {
console.error('Error:', error);
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan otorisator.',
'error');
'Terjadi kesalahan saat melakukan otorisator.'
);
} else if (result.isDenied) {
handleRejection(dataId);
}
});
} else if (role === 'EO') {
showSwalConfirmation(
'Apakah Yakin?',
'Anda akan menyetujui data ini?',
`
<p class="text-gray-700 text-center">Anda akan menyetujui data ini?</p>
<textarea id="swal-keterangan" class="block w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm" placeholder="Masukkan keterangan..."></textarea>
`,
'Ya, Lanjutkan!', 'Rejected', 'Batal',
() => {
const keterangan = document.getElementById('swal-keterangan').value;
if (!keterangan) {
Swal.showValidationMessage('Keterangan harus diisi!');
return false;
}
return {
keterangan
};
}
).then((result) => {
if (result.isConfirmed) {
handleAjaxRequest(
`/otorisator/otorisator/${dataId}/${dataHeader}`, {
message: result.value.keterangan
},
'Data berhasil diotorisasi.',
'Terjadi kesalahan saat melakukan otorisator.'
);
} else if (result.isDenied) {
handleRejection(dataId);
}
});
} else {
Swal.fire({
title: 'Apakah Yakin?',
text: `Pastikan bahwa paparan sudah dilakukan!`,
icon: 'warning',
input: 'textarea',
inputLabel: 'Keterangan',
inputPlaceholder: 'Masukkan keterangan...',
inputAttributes: {
'aria-label': 'Masukkan keterangan'
},
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Lanjutkan!',
cancelButtonText: 'Batal',
}).then((result) => {
showSwalConfirmation(
'Apakah Yakin?',
'Pastikan bahwa paparan sudah dilakukan!',
`
<p class="text-gray-700 text-center">Pastikan bahwa paparan sudah dilakukan!</p>
<textarea id="swal-keterangan" class="block w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm" placeholder="Masukkan keterangan..."></textarea>
`,
'Ya, Lanjutkan!', 'Rejected', 'Batal',
() => {
const keterangan = document.getElementById('swal-keterangan').value;
if (!keterangan) {
Swal.showValidationMessage('Keterangan harus diisi!');
return false;
}
return {
keterangan
};
}
).then((result) => {
if (result.isConfirmed) {
const userMessage = result.value || ''; // Ambil pesan dari textarea
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
handleAjaxRequest(
`/otorisator/otorisator/${dataId}/${dataHeader}`, {
message: result.value.keterangan
},
});
$.ajax({
url: `/otorisator/otorisator/${dataId}/${dataHeader}`,
type: 'POST',
data: {
message: userMessage
},
success: (response) => {
Swal.fire('Berhasil!',
'Data berhasil diotorisasi',
'success').then(() => {
window.location.reload();
});
console.log(response);
},
error: (error) => {
console.error('Error:', error);
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan otorisator.',
'error');
}
});
'Data berhasil diotorisasi.',
'Terjadi kesalahan saat melakukan otorisator.'
);
} else if (result.isDenied) {
handleRejection(dataId);
}
});
}
} else {
Swal.fire({
title: 'Apakah Anda yakin?',

View File

@@ -82,6 +82,10 @@
<span class="sort"> <span class="sort-label"> Approval SO </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[150px]" data-datatable-column="approval_eo">
<span class="sort"> <span class="sort-label"> Approval EO </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[150px]" data-datatable-column="approval_dd">
<span class="sort"> <span class="sort-label"> Approval DD </span>
<span class="sort-icon"> </span> </span>
@@ -251,6 +255,15 @@
return '';
},
},
approval_eo: {
title: 'Approval EO',
render: (item, data) => {
if (data.approve_eo) {
return `${data.approve_eo.name} | ${window.formatTanggalIndonesia(data.approval_eo_at)}`;
}
return '';
},
},
approval_dd: {
title: 'Approval DD',
render: (item, data) => {

View File

@@ -234,8 +234,8 @@
<div class="flex gap-2.5">
<button id="saveEditDataButton" type="button" class="btn btn-primary"
onclick="saveEditedFoto()">Simpan</button>
{{-- <button type="button" class="btn btn-light" data-modal-toggle="#modal_10"
data-drawer-dismiss="true" onclick="openEditPhotoModal(file)">Edit Foto</button> --}}
<button type="button" class="btn btn-light" data-modal-toggle="#modal_10"
data-drawer-dismiss="true">Edit Foto</button>
<button type="button" class="btn btn-danger" data-drawer-dismiss="true">Batal</button>
</div>
</form>
@@ -244,7 +244,7 @@
<div class="modal" data-modal="true" id="modal_10">
<div class="modal-content modal-overlay">
<div class="modal-header">
{{-- <div class="modal-header">
<h3 class="modal-title">
Edit Foto
</h3>
@@ -252,9 +252,9 @@
<i class="ki-outline ki-cross">
</i>
</button>
</div>
</div> --}}
<div class="modal-body scrollable-y-auto">
<div id="tui-image-editor"></div>
<div id="editor_container" class="w-full h-full"></div>
</div>
</div>
</div>
@@ -266,8 +266,9 @@
@include('lpj::surveyor.js.fotojs')
@include('lpj::surveyor.js.utils')
@push('scripts')
{{-- <script src="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.js"></script> --}}
<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
<script src="https://scaleflex.cloudimg.io/v7/plugins/filerobot-image-editor/latest/filerobot-image-editor.min.js">
</script>
<script>
let jsonDataContoh = @json($formFoto);
Dropzone.autoDiscover = false;
@@ -589,35 +590,109 @@ document.addEventListener('DOMContentLoaded', function() {
}
}
document.addEventListener('DOMContentLoaded', function() {
// Create container for Filerobot editor
const editorContainer = document.createElement('div');
editorContainer.id = 'editor_container';
editorContainer.style.width = '100%';
editorContainer.style.height = '100%';
function openEditPhotoModal() {
const imageEditorContainer = document.getElementById('tui-image-editor');
// Add container to modal body
const modalBody = document.querySelector('#modal_10 .modal-body');
modalBody.innerHTML = '';
modalBody.appendChild(editorContainer);
// Inisialisasi TUI Image Editor
const imageEditor = new tui.ImageEditor(imageEditorContainer, {
includeUI: {
loadImage: {
path: file.dataURL,
name: 'Uploaded Photo'
},
theme: {
'common.bi.image': '',
'common.bisize.width': '25px',
'common.bisize.height': '25px',
'common.backgroundImage': 'none',
'common.backgroundColor': '#fff',
'common.border': '1px solid #ccc'
},
menu: ['crop', 'flip', 'rotate', 'draw', 'shape', 'icon', 'text', 'filter'],
initMenu: 'filter'
},
cssMaxWidth: 700,
cssMaxHeight: 500
// Update the Edit Foto button event handler
const editFotoButton = document.querySelector('[data-modal-toggle="#modal_10"]');
if (editFotoButton) {
editFotoButton.addEventListener('click', function(e) {
e.preventDefault();
// Get the file path from hidden input
const filePath = document.getElementById('editDataFilePath').value;
if (filePath) {
openFilerobotEditor(filePath);
} else {
alert('Tidak ada foto untuk diedit');
}
});
}
});
// openModal('editPhotoModal');
}
function openFilerobotEditor(imagePath) {
// Get the editor container
const editorContainer = document.getElementById('editor_container');
if (!editorContainer) {
console.error('Editor container not found');
return;
}
// Configuration for the editor
const config = {
source: imagePath || '',
onSave: (editedImageObject, designState) => {
console.log('Image saved', editedImageObject);
// Save the edited image
saveEditedImage(editedImageObject, document.getElementById('editDataFilePath').value);
// Close the editor
FilerobotImageEditor.terminate();
// Hide the modal
document.getElementById('modal_10').setAttribute('data-modal-dismiss', 'true');
// Update the preview if needed
updateImagePreview(editedImageObject.imageBase64 || editedImageObject.imageCanvas.toDataURL());
},
annotationsCommon: {
fill: '#ff0000'
},
Text: {
text: 'Tambahkan teks...'
},
Rotate: {
angle: 90,
componentType: 'slider'
},
tabsIds: [
window.FilerobotImageEditor.TABS.ADJUST,
window.FilerobotImageEditor.TABS.FILTERS,
window.FilerobotImageEditor.TABS.FINETUNE,
window.FilerobotImageEditor.TABS.ANNOTATE,
window.FilerobotImageEditor.TABS.WATERMARK,
window.FilerobotImageEditor.TABS.RESIZE,
],
defaultTabId: window.FilerobotImageEditor.TABS.ADJUST,
Language: {
Save: 'Simpan',
Cancel: 'Batal',
Reset: 'Reset',
Edit: 'Edit',
Delete: 'Hapus'
}
};
// Initialize the Filerobot Image Editor
const filerobotImageEditor = new FilerobotImageEditor(
editorContainer,
config
);
// Render the editor
filerobotImageEditor.render({
onClose: (closingReason) => {
console.log('Editor closed:', closingReason);
filerobotImageEditor.terminate();
// Hide the modal
document.querySelector('#modal_10').setAttribute('data-modal-dismiss', 'true');
}
});
}
window.addEditAndDeleteButtons = function(file, response) {
const filePreviewElement = file.previewElement;
@@ -694,8 +769,6 @@ document.addEventListener('DOMContentLoaded', function() {
filePreviewElement.appendChild(buttonContainer);
}
async function saveEditedFoto() {
$.ajax({
url: `{{ route('surveyor.updateFoto') }}`,
@@ -736,6 +809,56 @@ document.addEventListener('DOMContentLoaded', function() {
}
});
}
function saveEditedImage(editedImageObject, originalFilePath) {
// Get the image data (base64 or canvas)
const imageData = editedImageObject.imageBase64 ||
(editedImageObject.imageCanvas ? editedImageObject.imageCanvas.toDataURL() : null);
if (!imageData) {
Swal.fire({
icon: 'error',
title: 'Gagal Menyimpan',
text: 'Tidak ada data gambar untuk disimpan',
});
return;
}
const formData = new FormData();
formData.append('edited_image', imageData);
formData.append('original_path', originalFilePath);
formData.forEach((value, key) => {
console.log(`${key}:`, value);
});
fetch('/api/save-edited-image', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
Swal.fire({
icon: 'success',
title: 'Perubahan Disimpan',
text: response.message,
confirmButtonText: 'OK'
}).then((response) => {
if (response.isConfirmed) {
window.location.reload();
}
});;
})
.catch(error => {
const errorMessage = xhr.responseJSON?.message || 'Terjadi kesalahan';
Swal.fire({
icon: 'error',
title: 'Gagal Menyimpan',
text: errorMessage,
});
});
}
</script>
@include('lpj::surveyor.js.camera-editor')
@endpush