stage file upload an

This commit is contained in:
Fiqh Pratama
2025-10-13 14:55:46 +07:00
parent dd5dbcab8f
commit 76d4aa9b90
9 changed files with 1081 additions and 226 deletions
@@ -82,28 +82,63 @@
<input type="text" class="form-control" name="status" value="{{ $form->status }}" readonly>
</div>
<div class="mb-3">
<label class="form-label">Bukti Allowance</label><br>
<a href="{{ $form->bukti_allowance }}" target="_blank">Lihat Bukti</a>
</div>
<div class="mb-3">
<label class="form-label">Bukti Transport Dalam Kota</label><br>
<a href="{{ $form->bukti_transport_dalkot }}" target="_blank">Lihat Bukti</a>
</div>
<div class="mb-3">
<label class="form-label">Bukti Transport Antar Kota</label><br>
<a href="{{ $form->bukti_transport_ankot }}" target="_blank">Lihat Bukti</a>
</div>
<div class="mb-3">
<label class="form-label">Bukti Hotel</label><br>
<a href="{{ $form->bukti_hotel }}" target="_blank">Lihat Bukti</a>
</div>
<div class="mb-3">
<label class="form-label">UC Plan</label><br>
<a href="{{ $form->uc_plan }}" target="_blank">Lihat Bukti</a>
</div>
</div>
<div class="col-12">
<div class="mb-4">
<label class="form-label">Lampiran</label>
<div class="table-responsive">
<table class="table table-bordered align-middle">
<thead class="table-light">
<tr>
<th style="width: 30%">Kategori</th>
<th style="width: 40%">Nama File</th>
<th style="width: 15%" class="text-center">Preview</th>
<th style="width: 15%" class="text-center">Download</th>
</tr>
</thead>
<tbody>
@forelse ($attachments as $attachment)
@php
$categoryValue = $attachment['file_category'] ?? null;
$categoryLabel = $categoryValue ? ucwords(str_replace('_', ' ', $categoryValue)) : '-';
@endphp
<tr>
<td>{{ $categoryLabel }}</td>
<td>{{ $attachment['filename'] ?? basename($attachment['file_path']) }}</td>
<td class="text-center">
<button type="button"
class="btn btn-sm btn-outline-secondary preview-attachment"
data-preview-url="{{ $attachment['preview_url'] }}"
data-download-url="{{ $attachment['download_url'] }}"
data-preview-type="{{ $attachment['preview_type'] }}"
data-category="{{ $categoryLabel }}">
Preview
</button>
</td>
<td class="text-center">
<a href="{{ $attachment['download_url'] }}"
target="_blank"
class="btn btn-sm btn-outline-primary">
Download
</a>
</td>
</tr>
@empty
<tr class="text-center text-muted">
<td colspan="4">Tidak ada lampiran.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-12">
<a href="{{ route('forms.up-country') }}" class="btn btn-secondary">Kembali</a>
@if (auth()->user()->can('approval.approve') && $form->status == 'On Progress')
@@ -133,6 +168,11 @@
</div>
</section>
<section>
@include('backend.components.attachment-preview-modal', [
'modalId' => 'viewAttachmentPreviewModal',
'title' => 'Attachment Preview',
])
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
@@ -408,6 +448,49 @@
</script>
<script>
function openAttachmentModal(modalSelector, title, type, source) {
const $modal = $(modalSelector);
const $image = $modal.find('.attachment-preview-image');
const $object = $modal.find('.attachment-preview-object');
const $placeholder = $modal.find('.attachment-preview-placeholder');
$modal.find('.attachment-preview-modal-title').text(title || 'Attachment');
$image.addClass('d-none').attr('src', '');
$object.addClass('d-none').attr('data', '').attr('src', '');
$placeholder.removeClass('d-none');
if (type === 'image' && source) {
$image.attr('src', source).removeClass('d-none');
$placeholder.addClass('d-none');
} else if (type === 'pdf' && source) {
$object.attr('data', source).attr('src', source).removeClass('d-none');
$placeholder.addClass('d-none');
}
if (window.bootstrap && bootstrap.Modal && typeof bootstrap.Modal.getOrCreateInstance === 'function') {
bootstrap.Modal.getOrCreateInstance($modal[0]).show();
} else {
$modal.modal('show');
}
}
$(document).on('click', '.preview-attachment', function () {
const button = $(this);
const previewType = button.data('preview-type');
const previewUrl = button.data('preview-url');
const downloadUrl = button.data('download-url');
const category = button.data('category') || 'Attachment';
if (!previewUrl) {
if (downloadUrl) {
window.open(downloadUrl, '_blank');
}
return;
}
openAttachmentModal('#viewAttachmentPreviewModal', category, previewType, previewUrl);
});
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
@@ -563,3 +646,4 @@
});
</script>
@endsection