stage Form Vehicle Running Cost
This commit is contained in:
@@ -30,9 +30,38 @@ use App\Helpers\OutstandingHelper;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\BrevoService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use App\Services\AttachmentService;
|
||||
use App\Enums\AttachmentTableName;
|
||||
use App\Models\AttachmentForm;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class FormVehicleController extends Controller
|
||||
{
|
||||
protected AttachmentService $attachmentService;
|
||||
|
||||
/**
|
||||
* Standardized attachment categories for Vehicle Running Cost.
|
||||
*/
|
||||
protected array $attachmentCategories = [
|
||||
'bukti_total',
|
||||
'bukti_invoice',
|
||||
'bukti_bbm',
|
||||
'bukti_service',
|
||||
'bukti_lainnya',
|
||||
];
|
||||
|
||||
/**
|
||||
* Blocked file extensions (case insensitive) to guard against dangerous uploads.
|
||||
*/
|
||||
protected array $blockedExtensions = ['exe', 'bat', 'sh', 'cmd', 'dll', 'msi'];
|
||||
|
||||
public function __construct(AttachmentService $attachmentService)
|
||||
{
|
||||
$this->attachmentService = $attachmentService;
|
||||
view()->share('vehicleAttachmentCategories', $this->attachmentCategories);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
|
||||
@@ -120,21 +149,27 @@ class FormVehicleController extends Controller
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
|
||||
|
||||
$form = FormVehicleRunningCost::with('user')->findOrFail($id);
|
||||
$form = FormVehicleRunningCost::with(['user', 'attachments'])->findOrFail($id);
|
||||
$attachments = $this->formatAttachmentCollection($form);
|
||||
|
||||
$form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null;
|
||||
|
||||
return response()->json($form);
|
||||
return response()->json(array_merge($form->toArray(), [
|
||||
'attachments' => $attachments,
|
||||
]));
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
|
||||
|
||||
$form = FormVehicleRunningCost::with('user')->findOrFail($id);
|
||||
$form = FormVehicleRunningCost::with(['user', 'attachments'])->findOrFail($id);
|
||||
$attachments = $this->formatAttachmentCollection($form);
|
||||
$form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null;
|
||||
|
||||
return view('backend.pages.forms.vehicle.view', [
|
||||
'form' => $form,
|
||||
'attachments' => $attachments,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -142,13 +177,15 @@ class FormVehicleController extends Controller
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
|
||||
|
||||
return view('backend.pages.forms.vehicle.create');
|
||||
return view('backend.pages.forms.vehicle.create', [
|
||||
'attachmentCategories' => $this->attachmentCategories,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
|
||||
$request->validate([
|
||||
$validator = Validator::make($request->all(), [
|
||||
'tanggal' => 'required',
|
||||
'type' => 'required',
|
||||
'liter' => 'nullable|numeric|min:0',
|
||||
@@ -157,9 +194,37 @@ class FormVehicleController extends Controller
|
||||
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||
'nopol' => 'nullable',
|
||||
'keterangan' => 'required',
|
||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||
'attachments' => 'nullable|array',
|
||||
'attachments.*.file_category' => 'required|string|in:' . implode(',', $this->attachmentCategories),
|
||||
'attachments.*.file_path' => [
|
||||
'nullable',
|
||||
'file',
|
||||
'max:10240', // 10 MB
|
||||
'mimetypes:image/jpeg,image/png,image/webp,application/pdf,text/plain,text/csv,application/zip,application/x-zip-compressed,application/x-7z-compressed,application/vnd.rar,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/octet-stream'
|
||||
],
|
||||
]);
|
||||
|
||||
$validator->after(function ($validator) use ($request) {
|
||||
$inputAttachments = $request->input('attachments', []);
|
||||
$fileAttachments = $request->file('attachments', []);
|
||||
|
||||
foreach ($inputAttachments as $index => $input) {
|
||||
$category = $input['file_category'] ?? null;
|
||||
$file = $fileAttachments[$index]['file_path'] ?? null;
|
||||
|
||||
if ($category && !$file) {
|
||||
$validator->errors()->add("attachments.{$index}.file_path", 'Attachment file is required.');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($file && $this->isBlockedExtension($file->getClientOriginalExtension())) {
|
||||
$validator->errors()->add("attachments.{$index}.file_path", 'File type is not allowed.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$validator->validate();
|
||||
|
||||
$tanggal = Carbon::parse($request->tanggal);
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||
@@ -207,43 +272,54 @@ class FormVehicleController extends Controller
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Vehicle Running Cost')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle';
|
||||
|
||||
if ($request->hasFile('bukti_total')) {
|
||||
$bukti_total = $request->file('bukti_total');
|
||||
$filename = Str::uuid() . '.' . $bukti_total->extension();
|
||||
|
||||
$filePaths['bukti_total'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti_total->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
$attachmentsPayload = $this->buildAttachmentPayload($request, $folderPath);
|
||||
|
||||
// Generate sequence number and expense number
|
||||
$sequence_number = FormVehicleRunningCost::withTrashed()->where('expense_number', 'like', $region->code . '-' . $cabang->code . '-VHC-' . date('ym') . '%')->count() + 1;
|
||||
$formatted_sequence_number = str_pad($sequence_number, 4, '0', STR_PAD_LEFT);
|
||||
$expense_number = $region->code . '-' . $cabang->code . '-VHC-' . date('ym') . $formatted_sequence_number;
|
||||
|
||||
// Save the form data
|
||||
$form = FormVehicleRunningCost::create([
|
||||
'expense_number' => $expense_number,
|
||||
'user_id' => auth()->user()->id,
|
||||
'tanggal' => $request->tanggal,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => $filePaths['bukti_total'] ?? null,
|
||||
'account_number' => $kategori->account_number,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$form = FormVehicleRunningCost::create([
|
||||
'expense_number' => $expense_number,
|
||||
'user_id' => auth()->user()->id,
|
||||
'tanggal' => $request->tanggal,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => null,
|
||||
'account_number' => $kategori->account_number,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
if (!empty($attachmentsPayload)) {
|
||||
$this->attachmentService->addMultipleAttachments(
|
||||
$form->id,
|
||||
AttachmentTableName::FORM_VEHICLE_RUNNING_COST,
|
||||
$attachmentsPayload
|
||||
);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
Log::error('Failed to store Vehicle Running Cost form', [
|
||||
'message' => $th->getMessage(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
]);
|
||||
|
||||
session()->flash('error', 'Terjadi kesalahan saat menyimpan data, silakan coba lagi.');
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
$form->load('user');
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $form->tanggal;
|
||||
@@ -330,14 +406,16 @@ class FormVehicleController extends Controller
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.edit']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$form = FormVehicleRunningCost::with('attachments')->findOrfail($id);
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
return view('backend.pages.forms.vehicle.edit', [
|
||||
'form' => $form
|
||||
'form' => $form,
|
||||
'attachments' => $this->formatAttachmentCollection($form),
|
||||
'attachmentCategories' => $this->attachmentCategories,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -345,7 +423,7 @@ class FormVehicleController extends Controller
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.edit']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
$form = FormVehicleRunningCost::findOrFail($id);
|
||||
$form = FormVehicleRunningCost::with('attachments')->findOrFail($id);
|
||||
|
||||
// Ambil cabang ID dari user yang mengisi form
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()?->cabang_id;
|
||||
@@ -371,7 +449,7 @@ class FormVehicleController extends Controller
|
||||
$availableBudget = BudgetHelper::getAvailableBudget($cabang_id, $periodeMonth, $periodeYear);
|
||||
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
$validator = Validator::make($request->all(), [
|
||||
'tanggal' => 'required',
|
||||
'type' => 'required',
|
||||
'liter' => 'nullable|numeric|min:0',
|
||||
@@ -380,9 +458,37 @@ class FormVehicleController extends Controller
|
||||
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||
'nopol' => 'nullable',
|
||||
'keterangan' => 'required',
|
||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||
'attachments' => 'nullable|array',
|
||||
'attachments.*.file_category' => 'required|string|in:' . implode(',', $this->attachmentCategories),
|
||||
'attachments.*.file_path' => [
|
||||
'nullable',
|
||||
'file',
|
||||
'max:10240',
|
||||
'mimetypes:image/jpeg,image/png,image/webp,application/pdf,text/plain,text/csv,application/zip,application/x-zip-compressed,application/x-7z-compressed,application/vnd.rar,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/octet-stream'
|
||||
],
|
||||
]);
|
||||
|
||||
$validator->after(function ($validator) use ($request) {
|
||||
$inputAttachments = $request->input('attachments', []);
|
||||
$fileAttachments = $request->file('attachments', []);
|
||||
|
||||
foreach ($inputAttachments as $index => $input) {
|
||||
$category = $input['file_category'] ?? null;
|
||||
$file = $fileAttachments[$index]['file_path'] ?? null;
|
||||
|
||||
if ($category && !$file) {
|
||||
$validator->errors()->add("attachments.{$index}.file_path", 'Attachment file is required.');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($file && $this->isBlockedExtension($file->getClientOriginalExtension())) {
|
||||
$validator->errors()->add("attachments.{$index}.file_path", 'File type is not allowed.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$validator->validate();
|
||||
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
return redirect()->back();
|
||||
@@ -392,42 +498,79 @@ class FormVehicleController extends Controller
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Vehicle Running Cost')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle';
|
||||
|
||||
if ($request->hasFile('bukti_total')) {
|
||||
$bukti_total = $request->file('bukti_total');
|
||||
$filename = Str::uuid() . '.' . $bukti_total->extension();
|
||||
$attachmentsPayload = $this->buildAttachmentPayload($request, $folderPath);
|
||||
|
||||
$filePaths['bukti_total'] = $folderPath . '/' . $filename;
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$form->update([
|
||||
'tanggal' => $request->tanggal,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => $form->bukti_total,
|
||||
'account_number' => $kategori->account_number,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti_total->getContent(),
|
||||
$filename
|
||||
);
|
||||
if (!empty($attachmentsPayload)) {
|
||||
$this->attachmentService->addMultipleAttachments(
|
||||
$form->id,
|
||||
AttachmentTableName::FORM_VEHICLE_RUNNING_COST,
|
||||
$attachmentsPayload
|
||||
);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
Log::error('Failed to update Vehicle Running Cost form', [
|
||||
'form_id' => $form->id,
|
||||
'message' => $th->getMessage(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
]);
|
||||
|
||||
session()->flash('error', 'Terjadi kesalahan saat memperbarui data, silakan coba lagi.');
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
// Save the form data
|
||||
$form->update([
|
||||
'tanggal' => $request->tanggal,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total,
|
||||
'account_number' => $kategori->account_number,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Update', 'Update Record at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been updated.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function deleteAttachment(Request $request, $formId, $attachmentId)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.edit']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrFail($formId);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
if (($form->status !== 'On Progress' && $form->status !== 'Rejected') && $role === 'Medical Representatif') {
|
||||
return response()->json(['message' => 'You cannot modify attachments once the form is approved or closed.'], 403);
|
||||
}
|
||||
|
||||
$attachment = AttachmentForm::where('id', $attachmentId)
|
||||
->where('form_id', $form->id)
|
||||
->where('table_name', AttachmentTableName::FORM_VEHICLE_RUNNING_COST)
|
||||
->first();
|
||||
|
||||
if (!$attachment) {
|
||||
return response()->json(['message' => 'Attachment not found.'], 404);
|
||||
}
|
||||
|
||||
$this->attachmentService->deleteAttachment($attachment->id);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Delete Attachment', 'Delete Attachment at Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
|
||||
return response()->json(['message' => 'Attachment deleted successfully.']);
|
||||
}
|
||||
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
@@ -820,7 +963,7 @@ class FormVehicleController extends Controller
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.delete']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
@@ -834,4 +977,106 @@ class FormVehicleController extends Controller
|
||||
session()->flash('success', 'Form has been deleted.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
protected function formatAttachmentCollection(FormVehicleRunningCost $form): array
|
||||
{
|
||||
$attachments = $form->attachments->map(function ($attachment) {
|
||||
return $this->formatAttachmentData(
|
||||
$attachment->id,
|
||||
$attachment->file_category,
|
||||
$attachment->file_path
|
||||
);
|
||||
});
|
||||
|
||||
if ($attachments->isEmpty() && $form->bukti_total) {
|
||||
$attachments->push($this->formatAttachmentData(null, 'bukti_total', $form->bukti_total));
|
||||
}
|
||||
|
||||
return $attachments->values()->all();
|
||||
}
|
||||
|
||||
protected function formatAttachmentData(?int $id, ?string $category, string $filePath): array
|
||||
{
|
||||
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$previewType = $this->determinePreviewType($extension);
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'file_category' => $category,
|
||||
'file_path' => $filePath,
|
||||
'download_url' => NextCloudHelper::getFileUrl($filePath),
|
||||
'preview_url' => in_array($previewType, ['image', 'pdf'], true) ? NextCloudHelper::getPreviewUrl($filePath) : null,
|
||||
'preview_type' => $previewType,
|
||||
'filename' => basename($filePath),
|
||||
'extension' => $extension,
|
||||
'can_delete' => !is_null($id),
|
||||
];
|
||||
}
|
||||
|
||||
protected function determinePreviewType(?string $extension): string
|
||||
{
|
||||
$extension = strtolower((string) $extension);
|
||||
$imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
|
||||
if (in_array($extension, $imageExtensions, true)) {
|
||||
return 'image';
|
||||
}
|
||||
|
||||
if ($extension === 'pdf') {
|
||||
return 'pdf';
|
||||
}
|
||||
|
||||
return 'other';
|
||||
}
|
||||
|
||||
protected function isBlockedExtension(?string $extension): bool
|
||||
{
|
||||
return in_array(strtolower((string) $extension), $this->blockedExtensions, true);
|
||||
}
|
||||
|
||||
protected function buildAttachmentPayload(Request $request, string $folderPath): array
|
||||
{
|
||||
$payload = [];
|
||||
$inputs = $request->input('attachments', []);
|
||||
$files = $request->file('attachments', []);
|
||||
|
||||
foreach ($inputs as $index => $input) {
|
||||
$category = $input['file_category'] ?? null;
|
||||
$file = $files[$index]['file_path'] ?? null;
|
||||
|
||||
if (!$category || !$file) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$extension = strtolower($file->getClientOriginalExtension());
|
||||
|
||||
if ($this->isBlockedExtension($extension)) {
|
||||
throw ValidationException::withMessages([
|
||||
"attachments.{$index}.file_path" => 'File type is not allowed.',
|
||||
]);
|
||||
}
|
||||
|
||||
$filename = Str::uuid() . '.' . $extension;
|
||||
$filePath = $folderPath . '/' . $filename;
|
||||
|
||||
$uploadResponse = NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$file->getContent(),
|
||||
$filename
|
||||
);
|
||||
|
||||
if (is_array($uploadResponse) && isset($uploadResponse['success']) && $uploadResponse['success'] === false) {
|
||||
throw ValidationException::withMessages([
|
||||
"attachments.{$index}.file_path" => $uploadResponse['message'] ?? 'Failed to upload attachment.',
|
||||
]);
|
||||
}
|
||||
|
||||
$payload[] = [
|
||||
'file_category' => $category,
|
||||
'file_path' => $filePath,
|
||||
];
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@
|
||||
const row = $(`
|
||||
<tr class="attachment-row" data-index="${index}">
|
||||
<td>
|
||||
<select class="form-select attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<select class="form-control attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<option value="">${categoryToLabel('')}</option>
|
||||
${buildCategoryOptions()}
|
||||
</select>
|
||||
|
||||
@@ -308,7 +308,7 @@
|
||||
const row = $(`
|
||||
<tr class="attachment-row" data-index="${index}">
|
||||
<td>
|
||||
<select class="form-select attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<select class="form-control attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<option value="">${categoryToLabel('')}</option>
|
||||
${buildCategoryOptions()}
|
||||
</select>
|
||||
|
||||
@@ -69,10 +69,6 @@
|
||||
<label class="form-label">Total Harga <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="string" class="form-control" name="total" id="total" required value="{{ old('total') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total Harga <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="file" class="form-control" name="bukti_total" value="{{ old('bukti_total') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
@@ -97,10 +93,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="mb-3">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<label class="form-label mb-0">Lampiran</label>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="vehicle-add-attachment-row">
|
||||
<i class="fas fa-plus mr-1"></i> Add attachment
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-muted small mt-1 mb-2">
|
||||
Maksimal 10 MB per file. Semua tipe file diperbolehkan kecuali <code>.exe</code>, <code>.bat</code>, <code>.sh</code>, <code>.cmd</code>, <code>.dll</code>, dan <code>.msi</code>.
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered align-middle" id="vehicle-attachments-table">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 30%">Kategori</th>
|
||||
<th style="width: 45%">Lampiran</th>
|
||||
<th style="width: 15%" class="text-center">Preview</th>
|
||||
<th style="width: 10%" class="text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="vehicle-attachments-empty text-center text-muted">
|
||||
<td colspan="4">Belum ada lampiran.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@include('backend.components.attachment-preview-modal', [
|
||||
'modalId' => 'vehicleNewAttachmentPreviewModal',
|
||||
'title' => 'Preview Lampiran',
|
||||
])
|
||||
|
||||
<div id="loading-spinner-overlay" class="d-none">
|
||||
<div class="spinner-wrapper">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
@@ -115,20 +147,21 @@
|
||||
|
||||
<script>
|
||||
new AutoNumeric('#total', {
|
||||
digitGroupSeparator: '.', // Pemisah ribuan
|
||||
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
||||
currencySymbol: 'Rp.', // Simbol mata uang
|
||||
decimalPlaces: 0, // Tidak ada angka desimal
|
||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||
digitGroupSeparator: '.',
|
||||
decimalCharacter: ',',
|
||||
currencySymbol: 'Rp.',
|
||||
decimalPlaces: 0,
|
||||
unformatOnSubmit: true
|
||||
});
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function () {
|
||||
spinnerOverlay.classList.remove('d-none');
|
||||
spinnerOverlay.classList.add('d-flex');
|
||||
});
|
||||
|
||||
// JavaScript for dynamic field visibility and clearing values
|
||||
// Toggle gasoline specific fields
|
||||
const expenseTypeSelect = document.getElementById('expense_type');
|
||||
const gasolineFields = document.querySelectorAll('.gasoline-fields');
|
||||
const literInput = document.querySelector('input[name="liter"]');
|
||||
@@ -138,24 +171,17 @@
|
||||
|
||||
function toggleGasolineFields() {
|
||||
if (expenseTypeSelect.value === 'gasoline') {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'block';
|
||||
});
|
||||
gasolineFields.forEach(field => field.style.display = 'block');
|
||||
literInput.setAttribute('required', 'required');
|
||||
jarakInput.setAttribute('required', 'required');
|
||||
tipeBensinSelect.setAttribute('required', 'required');
|
||||
nopolInput.setAttribute('required', 'required');
|
||||
} else {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'none';
|
||||
});
|
||||
// --- NEW ADDITION: Clear values when fields are hidden ---
|
||||
gasolineFields.forEach(field => field.style.display = 'none');
|
||||
literInput.value = '';
|
||||
jarakInput.value = '';
|
||||
tipeBensinSelect.value = ''; // Clears selected option
|
||||
tipeBensinSelect.value = '';
|
||||
nopolInput.value = '';
|
||||
// --------------------------------------------------------
|
||||
|
||||
literInput.removeAttribute('required');
|
||||
jarakInput.removeAttribute('required');
|
||||
tipeBensinSelect.removeAttribute('required');
|
||||
@@ -163,10 +189,257 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set visibility based on initial select value (e.g., from old('expense_type'))
|
||||
toggleGasolineFields();
|
||||
|
||||
// Add event listener for when the select box changes
|
||||
expenseTypeSelect.addEventListener('change', toggleGasolineFields);
|
||||
|
||||
const attachmentCategories = @json($attachmentCategories ?? ($vehicleAttachmentCategories ?? []));
|
||||
const blockedExtensions = ['exe', 'bat', 'sh', 'cmd', 'dll', 'msi'];
|
||||
const maxFileSizeBytes = 10 * 1024 * 1024;
|
||||
const vehicleAttachmentEmptyRow = '<tr class="vehicle-attachments-empty text-center text-muted"><td colspan="4">Belum ada lampiran.</td></tr>';
|
||||
let vehicleAttachmentIndex = 0;
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function categoryToLabel(value) {
|
||||
if (!value) {
|
||||
return 'Pilih Kategori';
|
||||
}
|
||||
return value.replace(/_/g, ' ').replace(/\b\w/g, function (char) {
|
||||
return char.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function detectPreviewType(extension) {
|
||||
const images = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
if (images.indexOf(extension) !== -1) {
|
||||
return 'image';
|
||||
}
|
||||
if (extension === 'pdf') {
|
||||
return 'pdf';
|
||||
}
|
||||
return 'other';
|
||||
}
|
||||
|
||||
function buildCategoryOptions() {
|
||||
return attachmentCategories.map(function (category) {
|
||||
return '<option value="' + category + '">' + escapeHtml(categoryToLabel(category)) + '</option>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function setInlinePreview($row, type, source) {
|
||||
const $box = $row.find('.vehicle-attachment-inline-preview');
|
||||
$box.removeClass('bg-light').html('<i class="fas fa-file-upload text-muted"></i>');
|
||||
|
||||
if (type === 'image' && source) {
|
||||
$box.addClass('bg-light').html(
|
||||
'<img src="' + source + '" class="img-thumbnail" style="width:100%;height:100%;object-fit:cover;" alt="Preview">'
|
||||
);
|
||||
} else if (type === 'pdf') {
|
||||
$box.addClass('bg-light').html('<i class="fas fa-file-pdf text-danger fa-lg"></i>');
|
||||
} else if (type === 'other') {
|
||||
$box.addClass('bg-light').html('<i class="fas fa-file-alt text-secondary fa-lg"></i>');
|
||||
}
|
||||
}
|
||||
|
||||
function resetAttachmentRowData($row, clearInput = true) {
|
||||
const existingUrl = $row.data('objectUrl');
|
||||
if (existingUrl) {
|
||||
URL.revokeObjectURL(existingUrl);
|
||||
}
|
||||
|
||||
$row.removeData('objectUrl')
|
||||
.removeData('previewType')
|
||||
.removeData('previewSource')
|
||||
.removeData('previewFileName')
|
||||
.removeData('downloadUrl');
|
||||
|
||||
setInlinePreview($row, null, null);
|
||||
$row.find('.vehicle-preview-new-attachment').addClass('d-none');
|
||||
$row.find('.vehicle-preview-filename').text('');
|
||||
|
||||
if (clearInput) {
|
||||
$row.find('.vehicle-attachment-file').val('');
|
||||
}
|
||||
}
|
||||
|
||||
function openAttachmentModal(modalSelector, options) {
|
||||
const settings = Object.assign({
|
||||
title: 'Lampiran',
|
||||
type: 'other',
|
||||
source: null,
|
||||
downloadUrl: null,
|
||||
fileName: 'Lampiran'
|
||||
}, options || {});
|
||||
|
||||
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(settings.title || 'Lampiran');
|
||||
|
||||
$image.addClass('d-none').attr('src', '');
|
||||
$object.addClass('d-none').attr('data', '').attr('src', '');
|
||||
$placeholder.removeClass('d-none').html('Tidak ada file untuk ditampilkan.');
|
||||
|
||||
if (settings.type === 'image' && settings.source) {
|
||||
$image.attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else if (settings.type === 'pdf' && settings.source) {
|
||||
$object.attr('data', settings.source).attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else {
|
||||
const safeName = escapeHtml(settings.fileName || 'Lampiran');
|
||||
let message = '<p class="mb-2">' + safeName + '</p><p class="text-muted mb-0">Preview tidak tersedia. Silakan unduh file untuk melihat konten.</p>';
|
||||
if (settings.downloadUrl) {
|
||||
message += '<div class="mt-3"><a href="' + settings.downloadUrl + '" target="_blank" class="btn btn-sm btn-outline-primary">Download</a></div>';
|
||||
}
|
||||
$placeholder.html(message);
|
||||
}
|
||||
|
||||
if (window.bootstrap && bootstrap.Modal && typeof bootstrap.Modal.getOrCreateInstance === 'function') {
|
||||
bootstrap.Modal.getOrCreateInstance($modal[0]).show();
|
||||
} else {
|
||||
$modal.modal('show');
|
||||
}
|
||||
}
|
||||
|
||||
function addVehicleAttachmentRow() {
|
||||
const $tbody = $('#vehicle-attachments-table tbody');
|
||||
|
||||
if ($tbody.find('.vehicle-attachments-empty').length) {
|
||||
$tbody.empty();
|
||||
}
|
||||
|
||||
const index = vehicleAttachmentIndex++;
|
||||
const rowHtml = `
|
||||
<tr class="vehicle-attachment-row" data-index="${index}">
|
||||
<td>
|
||||
<select class="form-control vehicle-attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<option value="">${escapeHtml(categoryToLabel(''))}</option>
|
||||
${buildCategoryOptions()}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="vehicle-attachment-inline-preview border rounded d-flex align-items-center justify-content-center bg-white mr-2" style="width:56px;height:56px;">
|
||||
<i class="fas fa-file-upload text-muted"></i>
|
||||
</div>
|
||||
<input type="file" class="form-control vehicle-attachment-file" name="attachments[${index}][file_path]">
|
||||
</div>
|
||||
<div class="small text-muted mt-1 vehicle-preview-filename"></div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary vehicle-preview-new-attachment d-none">
|
||||
Preview
|
||||
</button>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-sm btn-outline-danger vehicle-remove-attachment-row">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
$tbody.append(rowHtml);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#vehicle-add-attachment-row').on('click', function () {
|
||||
addVehicleAttachmentRow();
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-remove-attachment-row', function () {
|
||||
const $row = $(this).closest('tr');
|
||||
const $tbody = $('#vehicle-attachments-table tbody');
|
||||
resetAttachmentRowData($row, true);
|
||||
$row.remove();
|
||||
|
||||
if (!$tbody.find('.vehicle-attachment-row').length) {
|
||||
$tbody.html(vehicleAttachmentEmptyRow);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '.vehicle-attachment-file', function () {
|
||||
const $input = $(this);
|
||||
const $row = $input.closest('tr');
|
||||
const previewButton = $row.find('.vehicle-preview-new-attachment');
|
||||
const filenameHolder = $row.find('.vehicle-preview-filename');
|
||||
|
||||
resetAttachmentRowData($row, false);
|
||||
filenameHolder.text('');
|
||||
|
||||
const file = this.files && this.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.size > maxFileSizeBytes) {
|
||||
alert('Ukuran file melebihi 10 MB.');
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
const extension = (file.name.split('.').pop() || '').toLowerCase();
|
||||
if (blockedExtensions.indexOf(extension) !== -1) {
|
||||
alert('Tipe file tidak diperbolehkan.');
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
filenameHolder.text(escapeHtml(file.name));
|
||||
|
||||
const previewType = detectPreviewType(extension);
|
||||
$row.data('previewType', previewType);
|
||||
$row.data('previewFileName', file.name);
|
||||
$row.data('downloadUrl', null);
|
||||
|
||||
if (previewType === 'image') {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
const source = event.target.result;
|
||||
$row.data('previewSource', source);
|
||||
setInlinePreview($row, previewType, source);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else if (previewType === 'pdf') {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
$row.data('previewSource', objectUrl);
|
||||
$row.data('objectUrl', objectUrl);
|
||||
setInlinePreview($row, previewType, null);
|
||||
} else {
|
||||
$row.data('previewSource', null);
|
||||
setInlinePreview($row, 'other', null);
|
||||
}
|
||||
|
||||
previewButton.removeClass('d-none');
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-preview-new-attachment', function () {
|
||||
const $row = $(this).closest('tr');
|
||||
const previewType = $row.data('previewType') || 'other';
|
||||
const previewSource = $row.data('previewSource') || null;
|
||||
const fileName = $row.data('previewFileName') || 'Lampiran';
|
||||
|
||||
openAttachmentModal('#vehicleNewAttachmentPreviewModal', {
|
||||
title: fileName,
|
||||
type: previewType,
|
||||
source: previewSource,
|
||||
downloadUrl: null,
|
||||
fileName: fileName
|
||||
});
|
||||
});
|
||||
|
||||
// Add initial attachment row for user convenience
|
||||
addVehicleAttachmentRow();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
@@ -71,17 +71,6 @@
|
||||
<label class="form-label">Total Harga <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="string" class="form-control" name="total" id="total" required value="{{ old('total', $form->total) }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total Harga <span class="font-italic font-weight-normal">(optional)</span></label>
|
||||
{{-- Display current proof if exists --}}
|
||||
@if($form->bukti_total)
|
||||
<div class="mb-2">
|
||||
<a href="{{ \App\Helpers\NextCloudHelper::getFileUrl($form->bukti_total) }}" target="_blank" class="btn btn-sm btn-info">Lihat Bukti Saat Ini</a>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" class="form-control" name="bukti_total">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
@@ -107,10 +96,106 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="mb-4">
|
||||
<label class="form-label mb-0">Lampiran Saat Ini</label>
|
||||
<p class="text-muted small mt-1 mb-2">Gunakan tombol preview untuk melihat lampiran.</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered align-middle" id="vehicle-existing-attachments-table">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 30%">Kategori</th>
|
||||
<th style="width: 35%">Nama File</th>
|
||||
<th style="width: 15%" class="text-center">Preview</th>
|
||||
<th style="width: 20%" class="text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($attachments as $attachment)
|
||||
<tr class="vehicle-existing-attachment-row" data-attachment-id="{{ $attachment['id'] }}">
|
||||
<td>{{ $attachment['file_category'] ? ucwords(str_replace('_', ' ', $attachment['file_category'])) : '-' }}</td>
|
||||
<td>{{ $attachment['filename'] ?? basename($attachment['file_path']) }}</td>
|
||||
<td class="text-center">
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-secondary vehicle-preview-existing-attachment"
|
||||
data-preview-url="{{ $attachment['preview_url'] }}"
|
||||
data-download-url="{{ $attachment['download_url'] }}"
|
||||
data-preview-type="{{ $attachment['preview_type'] }}"
|
||||
data-file-name="{{ $attachment['filename'] ?? basename($attachment['file_path']) }}">
|
||||
Preview
|
||||
</button>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ $attachment['download_url'] }}"
|
||||
target="_blank"
|
||||
class="btn btn-sm btn-outline-primary mr-1">
|
||||
Download
|
||||
</a>
|
||||
@if($attachment['can_delete'])
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-danger vehicle-delete-attachment"
|
||||
data-delete-url="{{ route('forms.vehicle.attachments.destroy', [$form->id, $attachment['id']]) }}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr class="vehicle-existing-attachments-empty text-center text-muted">
|
||||
<td colspan="4">Belum ada lampiran.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="mb-3">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<label class="form-label mb-0">Tambah Lampiran Baru</label>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="vehicle-add-new-attachment-row">
|
||||
<i class="fas fa-plus mr-1"></i> Tambah Lampiran
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-muted small mt-1 mb-2">
|
||||
Maksimal 10 MB per file. Semua tipe file diperbolehkan kecuali <code>.exe</code>, <code>.bat</code>, <code>.sh</code>, <code>.cmd</code>, <code>.dll</code>, dan <code>.msi</code>.
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered align-middle" id="vehicle-new-attachments-table">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 30%">Kategori</th>
|
||||
<th style="width: 45%">Lampiran</th>
|
||||
<th style="width: 15%" class="text-center">Preview</th>
|
||||
<th style="width: 10%" class="text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="vehicle-new-attachments-empty text-center text-muted">
|
||||
<td colspan="4">Belum ada lampiran baru.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary ml-2">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@include('backend.components.attachment-preview-modal', [
|
||||
'modalId' => 'vehicleExistingAttachmentPreviewModal',
|
||||
'title' => 'Preview Lampiran',
|
||||
])
|
||||
|
||||
@include('backend.components.attachment-preview-modal', [
|
||||
'modalId' => 'vehicleNewAttachmentPreviewModal',
|
||||
'title' => 'Preview Lampiran',
|
||||
])
|
||||
|
||||
<div id="loading-spinner-overlay" class="d-none">
|
||||
<div class="spinner-wrapper">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
@@ -123,23 +208,25 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
new AutoNumeric('#total', {
|
||||
digitGroupSeparator: '.', // Pemisah ribuan
|
||||
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
||||
currencySymbol: 'Rp.', // Simbol mata uang
|
||||
decimalPlaces: 0, // Tidak ada angka desimal
|
||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||
digitGroupSeparator: '.',
|
||||
decimalCharacter: ',',
|
||||
currencySymbol: 'Rp.',
|
||||
decimalPlaces: 0,
|
||||
unformatOnSubmit: true
|
||||
});
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function () {
|
||||
spinnerOverlay.classList.remove('d-none');
|
||||
spinnerOverlay.classList.add('d-flex');
|
||||
});
|
||||
|
||||
// JavaScript for dynamic field visibility and clearing values
|
||||
const expenseTypeSelect = document.getElementById('expense_type'); // Still uses the ID for selection
|
||||
// Toggle gasoline specific fields
|
||||
const expenseTypeSelect = document.getElementById('expense_type');
|
||||
const gasolineFields = document.querySelectorAll('.gasoline-fields');
|
||||
const literInput = document.querySelector('input[name="liter"]');
|
||||
const jarakInput = document.querySelector('input[name="jarak"]');
|
||||
@@ -148,23 +235,17 @@
|
||||
|
||||
function toggleGasolineFields() {
|
||||
if (expenseTypeSelect.value === 'gasoline') {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'block';
|
||||
});
|
||||
gasolineFields.forEach(field => field.style.display = 'block');
|
||||
literInput.setAttribute('required', 'required');
|
||||
jarakInput.setAttribute('required', 'required');
|
||||
tipeBensinSelect.setAttribute('required', 'required');
|
||||
nopolInput.setAttribute('required', 'required');
|
||||
} else {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'none';
|
||||
});
|
||||
// Clear values when fields are hidden
|
||||
gasolineFields.forEach(field => field.style.display = 'none');
|
||||
literInput.value = '';
|
||||
jarakInput.value = '';
|
||||
tipeBensinSelect.value = ''; // Clears selected option
|
||||
tipeBensinSelect.value = '';
|
||||
nopolInput.value = '';
|
||||
|
||||
literInput.removeAttribute('required');
|
||||
jarakInput.removeAttribute('required');
|
||||
tipeBensinSelect.removeAttribute('required');
|
||||
@@ -172,10 +253,333 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set visibility based on the retrieved form data
|
||||
toggleGasolineFields();
|
||||
|
||||
// Add event listener for when the select box changes
|
||||
expenseTypeSelect.addEventListener('change', toggleGasolineFields);
|
||||
|
||||
const attachmentCategories = @json($attachmentCategories ?? ($vehicleAttachmentCategories ?? []));
|
||||
const blockedExtensions = ['exe', 'bat', 'sh', 'cmd', 'dll', 'msi'];
|
||||
const maxFileSizeBytes = 10 * 1024 * 1024;
|
||||
const existingEmptyRow = '<tr class="vehicle-existing-attachments-empty text-center text-muted"><td colspan="4">Belum ada lampiran.</td></tr>';
|
||||
const newEmptyRow = '<tr class="vehicle-new-attachments-empty text-center text-muted"><td colspan="4">Belum ada lampiran baru.</td></tr>';
|
||||
let vehicleNewAttachmentIndex = 0;
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function categoryToLabel(value) {
|
||||
if (!value) {
|
||||
return 'Pilih Kategori';
|
||||
}
|
||||
return value.replace(/_/g, ' ').replace(/\b\w/g, function (char) {
|
||||
return char.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function detectPreviewType(extension) {
|
||||
const images = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
if (images.indexOf(extension) !== -1) {
|
||||
return 'image';
|
||||
}
|
||||
if (extension === 'pdf') {
|
||||
return 'pdf';
|
||||
}
|
||||
return 'other';
|
||||
}
|
||||
|
||||
function buildCategoryOptions() {
|
||||
return attachmentCategories.map(function (category) {
|
||||
return '<option value="' + category + '">' + escapeHtml(categoryToLabel(category)) + '</option>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function setInlinePreview($row, type, source) {
|
||||
const $box = $row.find('.vehicle-new-attachment-inline-preview');
|
||||
$box.removeClass('bg-light').html('<i class="fas fa-file-upload text-muted"></i>');
|
||||
|
||||
if (type === 'image' && source) {
|
||||
$box.addClass('bg-light').html(
|
||||
'<img src="' + source + '" class="img-thumbnail" style="width:100%;height:100%;object-fit:cover;" alt="Preview">'
|
||||
);
|
||||
} else if (type === 'pdf') {
|
||||
$box.addClass('bg-light').html('<i class="fas fa-file-pdf text-danger fa-lg"></i>');
|
||||
} else if (type === 'other') {
|
||||
$box.addClass('bg-light').html('<i class="fas fa-file-alt text-secondary fa-lg"></i>');
|
||||
}
|
||||
}
|
||||
|
||||
function resetNewAttachmentRowData($row, clearInput = true) {
|
||||
const existingUrl = $row.data('objectUrl');
|
||||
if (existingUrl) {
|
||||
URL.revokeObjectURL(existingUrl);
|
||||
}
|
||||
|
||||
$row.removeData('objectUrl')
|
||||
.removeData('previewType')
|
||||
.removeData('previewSource')
|
||||
.removeData('previewFileName')
|
||||
.removeData('downloadUrl');
|
||||
|
||||
setInlinePreview($row, null, null);
|
||||
$row.find('.vehicle-preview-new-attachment').addClass('d-none');
|
||||
$row.find('.vehicle-new-preview-filename').text('');
|
||||
|
||||
if (clearInput) {
|
||||
$row.find('.vehicle-new-attachment-file').val('');
|
||||
}
|
||||
}
|
||||
|
||||
function openAttachmentModal(modalSelector, options) {
|
||||
const settings = Object.assign({
|
||||
title: 'Lampiran',
|
||||
type: 'other',
|
||||
source: null,
|
||||
downloadUrl: null,
|
||||
fileName: 'Lampiran'
|
||||
}, options || {});
|
||||
|
||||
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(settings.title || 'Lampiran');
|
||||
|
||||
$image.addClass('d-none').attr('src', '');
|
||||
$object.addClass('d-none').attr('data', '').attr('src', '');
|
||||
$placeholder.removeClass('d-none').html('Tidak ada file untuk ditampilkan.');
|
||||
|
||||
if (settings.type === 'image' && settings.source) {
|
||||
$image.attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else if (settings.type === 'pdf' && settings.source) {
|
||||
$object.attr('data', settings.source).attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else {
|
||||
const safeName = escapeHtml(settings.fileName || 'Lampiran');
|
||||
let message = '<p class="mb-2">' + safeName + '</p><p class="text-muted mb-0">Preview tidak tersedia. Silakan unduh file untuk melihat konten.</p>';
|
||||
if (settings.downloadUrl) {
|
||||
message += '<div class="mt-3"><a href="' + settings.downloadUrl + '" target="_blank" class="btn btn-sm btn-outline-primary">Download</a></div>';
|
||||
}
|
||||
$placeholder.html(message);
|
||||
}
|
||||
|
||||
if (window.bootstrap && bootstrap.Modal && typeof bootstrap.Modal.getOrCreateInstance === 'function') {
|
||||
bootstrap.Modal.getOrCreateInstance($modal[0]).show();
|
||||
} else {
|
||||
$modal.modal('show');
|
||||
}
|
||||
}
|
||||
|
||||
function refreshExistingEmptyState() {
|
||||
const $tbody = $('#vehicle-existing-attachments-table tbody');
|
||||
if (!$tbody.find('.vehicle-existing-attachment-row').length) {
|
||||
$tbody.html(existingEmptyRow);
|
||||
}
|
||||
}
|
||||
|
||||
function refreshNewEmptyState() {
|
||||
const $tbody = $('#vehicle-new-attachments-table tbody');
|
||||
if (!$tbody.find('.vehicle-new-attachment-row').length) {
|
||||
$tbody.html(newEmptyRow);
|
||||
}
|
||||
}
|
||||
|
||||
function addVehicleNewAttachmentRow() {
|
||||
const $tbody = $('#vehicle-new-attachments-table tbody');
|
||||
|
||||
if ($tbody.find('.vehicle-new-attachments-empty').length) {
|
||||
$tbody.empty();
|
||||
}
|
||||
|
||||
const index = vehicleNewAttachmentIndex++;
|
||||
const rowHtml = `
|
||||
<tr class="vehicle-new-attachment-row" data-index="${index}">
|
||||
<td>
|
||||
<select class="form-control vehicle-new-attachment-category" name="attachments[${index}][file_category]" required>
|
||||
<option value="">${escapeHtml(categoryToLabel(''))}</option>
|
||||
${buildCategoryOptions()}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="vehicle-new-attachment-inline-preview border rounded d-flex align-items-center justify-content-center bg-white mr-2" style="width:56px;height:56px;">
|
||||
<i class="fas fa-file-upload text-muted"></i>
|
||||
</div>
|
||||
<input type="file" class="form-control vehicle-new-attachment-file" name="attachments[${index}][file_path]">
|
||||
</div>
|
||||
<div class="small text-muted mt-1 vehicle-new-preview-filename"></div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary vehicle-preview-new-attachment d-none">
|
||||
Preview
|
||||
</button>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-sm btn-outline-danger vehicle-remove-new-attachment-row">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
$tbody.append(rowHtml);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#vehicle-add-new-attachment-row').on('click', function () {
|
||||
addVehicleNewAttachmentRow();
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-remove-new-attachment-row', function () {
|
||||
const $row = $(this).closest('tr');
|
||||
const $tbody = $('#vehicle-new-attachments-table tbody');
|
||||
resetNewAttachmentRowData($row, true);
|
||||
$row.remove();
|
||||
refreshNewEmptyState();
|
||||
});
|
||||
|
||||
$(document).on('change', '.vehicle-new-attachment-file', function () {
|
||||
const $input = $(this);
|
||||
const $row = $input.closest('tr');
|
||||
const previewButton = $row.find('.vehicle-preview-new-attachment');
|
||||
const filenameHolder = $row.find('.vehicle-new-preview-filename');
|
||||
|
||||
resetNewAttachmentRowData($row, false);
|
||||
filenameHolder.text('');
|
||||
|
||||
const file = this.files && this.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.size > maxFileSizeBytes) {
|
||||
alert('Ukuran file melebihi 10 MB.');
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
const extension = (file.name.split('.').pop() || '').toLowerCase();
|
||||
if (blockedExtensions.indexOf(extension) !== -1) {
|
||||
alert('Tipe file tidak diperbolehkan.');
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
filenameHolder.text(escapeHtml(file.name));
|
||||
|
||||
const previewType = detectPreviewType(extension);
|
||||
$row.data('previewType', previewType);
|
||||
$row.data('previewFileName', file.name);
|
||||
$row.data('downloadUrl', null);
|
||||
|
||||
if (previewType === 'image') {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
const source = event.target.result;
|
||||
$row.data('previewSource', source);
|
||||
setInlinePreview($row, previewType, source);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else if (previewType === 'pdf') {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
$row.data('previewSource', objectUrl);
|
||||
$row.data('objectUrl', objectUrl);
|
||||
setInlinePreview($row, previewType, null);
|
||||
} else {
|
||||
$row.data('previewSource', null);
|
||||
setInlinePreview($row, 'other', null);
|
||||
}
|
||||
|
||||
previewButton.removeClass('d-none');
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-preview-new-attachment', function () {
|
||||
const $row = $(this).closest('tr');
|
||||
const previewType = $row.data('previewType') || 'other';
|
||||
const previewSource = $row.data('previewSource') || null;
|
||||
const fileName = $row.data('previewFileName') || 'Lampiran';
|
||||
|
||||
openAttachmentModal('#vehicleNewAttachmentPreviewModal', {
|
||||
title: fileName,
|
||||
type: previewType,
|
||||
source: previewSource,
|
||||
downloadUrl: null,
|
||||
fileName: fileName
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-preview-existing-attachment', function () {
|
||||
const $button = $(this);
|
||||
const previewType = $button.data('preview-type') || 'other';
|
||||
const previewUrl = $button.data('preview-url') || null;
|
||||
const downloadUrl = $button.data('download-url') || null;
|
||||
const fileName = $button.data('file-name') || 'Lampiran';
|
||||
|
||||
let type = previewType;
|
||||
let source = previewUrl;
|
||||
|
||||
if (!previewUrl || (previewType !== 'image' && previewType !== 'pdf')) {
|
||||
type = 'other';
|
||||
source = null;
|
||||
}
|
||||
|
||||
openAttachmentModal('#vehicleExistingAttachmentPreviewModal', {
|
||||
title: fileName,
|
||||
type: type,
|
||||
source: source,
|
||||
downloadUrl: downloadUrl,
|
||||
fileName: fileName
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.vehicle-delete-attachment', function () {
|
||||
const $button = $(this);
|
||||
const deleteUrl = $button.data('delete-url');
|
||||
const $row = $button.closest('tr');
|
||||
|
||||
if (!deleteUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Hapus lampiran?',
|
||||
text: 'Lampiran yang dihapus tidak dapat dikembalikan.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya, hapus',
|
||||
cancelButtonText: 'Batal'
|
||||
}).then((result) => {
|
||||
if (!result.isConfirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: deleteUrl,
|
||||
type: 'DELETE',
|
||||
success: function (response) {
|
||||
$row.remove();
|
||||
refreshExistingEmptyState();
|
||||
Swal.fire('Berhasil', response?.message || 'Lampiran berhasil dihapus.', 'success');
|
||||
},
|
||||
error: function (xhr) {
|
||||
const message = xhr?.responseJSON?.message || 'Gagal menghapus lampiran.';
|
||||
Swal.fire('Error', message, 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
refreshExistingEmptyState();
|
||||
refreshNewEmptyState();
|
||||
|
||||
// Provide an initial row for new attachments
|
||||
addVehicleNewAttachmentRow();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
@@ -47,10 +47,6 @@
|
||||
<label class="form-label">Total</label>
|
||||
<input type="string" class="form-control" name="total" id="total" readonly value="{{ $form->total }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total</label><br>
|
||||
<a href="{{ $form->bukti_total }}" target="_blank">Lihat Bukti</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
@@ -82,6 +78,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="mb-4">
|
||||
<label class="form-label mb-0">Lampiran</label>
|
||||
<p class="text-muted small mt-1 mb-2">Gunakan tombol preview untuk melihat lampiran.</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered align-middle" id="vehicle-view-attachments-table">
|
||||
<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)
|
||||
<tr class="vehicle-view-attachment-row">
|
||||
<td>{{ $attachment['file_category'] ? ucwords(str_replace('_', ' ', $attachment['file_category'])) : '-' }}</td>
|
||||
<td>{{ $attachment['filename'] ?? basename($attachment['file_path']) }}</td>
|
||||
<td class="text-center">
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-secondary vehicle-preview-attachment"
|
||||
data-preview-url="{{ $attachment['preview_url'] }}"
|
||||
data-download-url="{{ $attachment['download_url'] }}"
|
||||
data-preview-type="{{ $attachment['preview_type'] }}"
|
||||
data-file-name="{{ $attachment['filename'] ?? basename($attachment['file_path']) }}">
|
||||
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="vehicle-view-attachments-empty text-center text-muted">
|
||||
<td colspan="4">Tidak ada lampiran.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Status</label>
|
||||
@@ -117,6 +161,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@include('backend.components.attachment-preview-modal', [
|
||||
'modalId' => 'vehicleViewAttachmentPreviewModal',
|
||||
'title' => 'Preview Lampiran',
|
||||
])
|
||||
|
||||
<section>
|
||||
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
@@ -304,6 +354,93 @@
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function escapeHtml(value) {
|
||||
return String(value || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function openAttachmentModal(modalSelector, options) {
|
||||
const settings = Object.assign({
|
||||
title: 'Lampiran',
|
||||
type: 'other',
|
||||
source: null,
|
||||
downloadUrl: null,
|
||||
fileName: 'Lampiran'
|
||||
}, options || {});
|
||||
|
||||
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(settings.title || 'Lampiran');
|
||||
|
||||
$image.addClass('d-none').attr('src', '');
|
||||
$object.addClass('d-none').attr('data', '').attr('src', '');
|
||||
$placeholder.removeClass('d-none').html('Tidak ada file untuk ditampilkan.');
|
||||
|
||||
if (settings.type === 'image' && settings.source) {
|
||||
$image.attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else if (settings.type === 'pdf' && settings.source) {
|
||||
$object.attr('data', settings.source).attr('src', settings.source).removeClass('d-none');
|
||||
$placeholder.addClass('d-none');
|
||||
} else {
|
||||
const safeName = escapeHtml(settings.fileName || 'Lampiran');
|
||||
let message = '<p class="mb-2">' + safeName + '</p><p class="text-muted mb-0">Preview tidak tersedia. Silakan unduh file untuk melihat konten.</p>';
|
||||
if (settings.downloadUrl) {
|
||||
message += '<div class="mt-3"><a href="' + settings.downloadUrl + '" target="_blank" class="btn btn-sm btn-outline-primary">Download</a></div>';
|
||||
}
|
||||
$placeholder.html(message);
|
||||
}
|
||||
|
||||
if (window.bootstrap && bootstrap.Modal && typeof bootstrap.Modal.getOrCreateInstance === 'function') {
|
||||
bootstrap.Modal.getOrCreateInstance($modal[0]).show();
|
||||
} else {
|
||||
$modal.modal('show');
|
||||
}
|
||||
}
|
||||
|
||||
function buildAttachmentLinks(attachments) {
|
||||
if (!attachments || !attachments.length) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return attachments.map(function (item, index) {
|
||||
const label = escapeHtml(item.filename || item.file_category || ('Lampiran ' + (index + 1)));
|
||||
const downloadUrl = item.download_url || '#';
|
||||
return '<div><a href="' + downloadUrl + '" target="_blank">' + label + '</a></div>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
$(document).on('click', '.vehicle-preview-attachment', function () {
|
||||
const $button = $(this);
|
||||
const previewType = $button.data('preview-type') || 'other';
|
||||
const previewUrl = $button.data('preview-url') || null;
|
||||
const downloadUrl = $button.data('download-url') || null;
|
||||
const fileName = $button.data('file-name') || 'Lampiran';
|
||||
|
||||
let type = previewType;
|
||||
let source = previewUrl;
|
||||
|
||||
if (!previewUrl || (previewType !== 'image' && previewType !== 'pdf')) {
|
||||
type = 'other';
|
||||
source = null;
|
||||
}
|
||||
|
||||
openAttachmentModal('#vehicleViewAttachmentPreviewModal', {
|
||||
title: fileName,
|
||||
type: type,
|
||||
source: source,
|
||||
downloadUrl: downloadUrl,
|
||||
fileName: fileName
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.open-reject-modal', function () {
|
||||
const rejectUrl = $(this).data('action');
|
||||
$('#rejectForm').attr('action', rejectUrl);
|
||||
@@ -357,7 +494,7 @@
|
||||
$('#tipe_bensin').text(data.tipe_bensin);
|
||||
$('#nopol').text(data.nopol);
|
||||
|
||||
$('#bukti_total').html(data.total ? '<a href="' + data.total + '" target="_blank">Download</a>' : '-');
|
||||
$('#bukti_total').html(buildAttachmentLinks(data.attachments));
|
||||
|
||||
// Hide spinner and show content
|
||||
$('#loadingSpinner').hide();
|
||||
@@ -412,7 +549,7 @@
|
||||
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||
$('#final_nopol').text(data.nopol);
|
||||
|
||||
$('#final_bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
||||
$('#final_bukti_total').html(buildAttachmentLinks(data.attachments));
|
||||
|
||||
// Hide spinner and show content
|
||||
$('#finalLoadingSpinner').hide();
|
||||
|
||||
@@ -147,6 +147,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
||||
Route::post('/vehicle-running-cost/store', [FormVehicleController::class, 'store'])->name('forms.vehicle.store');
|
||||
Route::get('/vehicle-running-cost/edit/{id}', [FormVehicleController::class, 'edit'])->name('forms.vehicle.edit');
|
||||
Route::put('/vehicle-running-cost/update/{id}', [FormVehicleController::class, 'update'])->name('forms.vehicle.update');
|
||||
Route::delete('/vehicle-running-cost/{form}/attachments/{attachment}', [FormVehicleController::class, 'deleteAttachment'])->name('forms.vehicle.attachments.destroy');
|
||||
Route::delete('/vehicle-running-cost/destroy/{id}', [FormVehicleController::class, 'destroy'])->name('forms.vehicle.destroy');
|
||||
Route::put('/vehicle-running-cost/approve/{id}', [FormVehicleController::class, 'approve'])->name('forms.vehicle.approve');
|
||||
Route::put('/vehicle-running-cost/approve2/{id}', [FormVehicleController::class, 'approve2'])->name('forms.vehicle.approve2');
|
||||
|
||||
Reference in New Issue
Block a user