diff --git a/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php index 9740c46..19f1b07 100644 --- a/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php +++ b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php @@ -65,6 +65,28 @@ class FormEntertainmentPresentationController extends Controller ]); } + public function detail($id) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.view']); + + $form = FormEntertaimentPresentation::with('user')->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return response()->json($form); + } + + public function view($id) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.view']); + + $form = FormEntertaimentPresentation::with('user')->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return view('backend.pages.forms.entertainment.view', [ + 'form' => $form, + ]); + } + public function create() { $this->checkAuthorization(auth()->user(), ['forms.entertainment.create']); @@ -84,9 +106,7 @@ class FormEntertainmentPresentationController extends Controller 'name' => 'required', 'alamat' => 'required', 'nik_or_npwp' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; @@ -96,43 +116,19 @@ class FormEntertainmentPresentationController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Generate sequence number and expense number $sequence_number = FormEntertaimentPresentation::withTrashed()->where('expense_number', 'like', $region->code . '-' . $cabang->code . '-ETY-' . date('ym') . '%')->count() + 1; @@ -150,9 +146,7 @@ class FormEntertainmentPresentationController extends Controller 'name' => $request->name, 'alamat' => $request->alamat, 'nik_or_npwp' => $request->nik_or_npwp, - 'bukti1' => $filePaths['bukti1'] ?? null, - 'bukti2' => $filePaths['bukti2'] ?? null, - 'bukti3' => $filePaths['bukti3'] ?? null, + 'bukti_total' => $filePaths['bukti_total'] ?? null, 'account_number' => $kategori->account_number, 'status' => 'On Progress', ]); @@ -189,9 +183,7 @@ class FormEntertainmentPresentationController extends Controller 'name' => 'required', 'alamat' => 'required', 'nik_or_npwp' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $form = FormEntertaimentPresentation::findOrfail($id); @@ -207,43 +199,19 @@ class FormEntertainmentPresentationController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Save the form data $form->update([ @@ -254,9 +222,7 @@ class FormEntertainmentPresentationController extends Controller 'name' => $request->name, 'alamat' => $request->alamat, 'nik_or_npwp' => $request->nik_or_npwp, - 'bukti1' => $filePaths['bukti1'] ?? null, - 'bukti2' => $filePaths['bukti2'] ?? null, - 'bukti3' => $filePaths['bukti3'] ?? null, + 'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total, 'account_number' => $kategori->account_number, ]); @@ -265,15 +231,20 @@ class FormEntertainmentPresentationController extends Controller return redirect()->back(); } - public function approve($id) + public function approve(Request $request, $id) { $this->checkAuthorization(auth()->user(), ['approval.approve']); + $request->validate([ + 'total' => 'required', + ]); $form = FormEntertaimentPresentation::findOrfail($id); $form->update([ 'approved_at' => now(), 'approved_by' => auth()->user()->id, - 'status' => 'Approved' + 'status' => 'Approved', + + 'approved_total' => $form->total, ]); $heads = $form->user->getCabangAndRegionHead(); @@ -301,15 +272,16 @@ class FormEntertainmentPresentationController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseApproved( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseApproved( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk whatsapp - WhatsappHelper::approveExpense($phoneNumbers, $expense_number); + $url = route('forms.entertainment.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Approve', 'Approved Expense at Form Entertainment Presentation (' . $expense_number . ')'); session()->flash('success', 'Form has been approved.'); @@ -357,15 +329,16 @@ class FormEntertainmentPresentationController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new FinalApprove( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new FinalApprove( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // send whatsapp message - WhatsappHelper::finalApprove($phoneNumbers, $expense_number); + $url = route('forms.entertainment.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approved Expense at Form Entertainment Presentation (' . $expense_number . ')'); session()->flash('success', 'Form has been final approved.'); @@ -422,15 +395,16 @@ class FormEntertainmentPresentationController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseRejected( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseRejected( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk whatsapp - WhatsappHelper::rejectExpense($phoneNumbers, $expense_number); + $url = route('forms.entertainment.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $expense_number . ')'); session()->flash('success', 'Form has been rejected.'); diff --git a/app/Http/Controllers/Forms/FormOtherController.php b/app/Http/Controllers/Forms/FormOtherController.php index af75f24..c6e6c61 100644 --- a/app/Http/Controllers/Forms/FormOtherController.php +++ b/app/Http/Controllers/Forms/FormOtherController.php @@ -65,6 +65,28 @@ class FormOtherController extends Controller ]); } + public function detail($id) + { + $this->checkAuthorization(auth()->user(), ['forms.other.view']); + + $form = FormOthers::with(['user', 'kategori'])->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return response()->json($form); + } + + public function view($id) + { + $this->checkAuthorization(auth()->user(), ['forms.other.view']); + + $form = FormOthers::with(['user', 'kategori'])->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return view('backend.pages.forms.other.view', [ + 'form' => $form, + ]); + } + public function create() { $this->checkAuthorization(auth()->user(), ['forms.other.create']); @@ -83,9 +105,7 @@ class FormOtherController extends Controller 'tanggal' => 'required|date', 'keterangan' => 'required', 'total' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; @@ -95,43 +115,19 @@ class FormOtherController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/other'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Generate sequence number and expense number $sequence_number = FormOthers::withTrashed()->where('expense_number', 'like', $region->code . '-' . $cabang->code . '-OTH-' . date('ym') . '%')->count() + 1; @@ -146,9 +142,7 @@ class FormOtherController extends Controller 'tanggal' => $request->tanggal, 'keterangan' => $request->keterangan, 'total' => $request->total, - 'bukti1' => $filePaths['bukti1'] ?? null, - 'bukti2' => $filePaths['bukti2'] ?? null, - 'bukti3' => $filePaths['bukti3'] ?? null, + 'bukti_total' => $filePaths['bukti_total'] ?? null, 'account_number' => $kategori->account_number, 'status' => 'On Progress', ]); @@ -183,9 +177,7 @@ class FormOtherController extends Controller 'tanggal' => 'required|date', 'keterangan' => 'required', 'total' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $form = FormOthers::findOrfail($id); @@ -201,43 +193,19 @@ class FormOtherController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/other'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Save the form data $form->update([ @@ -245,9 +213,7 @@ class FormOtherController extends Controller 'tanggal' => $request->tanggal, 'keterangan' => $request->keterangan, 'total' => $request->total, - 'bukti1' => $filePaths['bukti1'] ?? $form->bukti1, - 'bukti2' => $filePaths['bukti2'] ?? $form->bukti2, - 'bukti3' => $filePaths['bukti3'] ?? $form->bukti3, + 'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total, 'account_number' => $kategori->account_number, ]); @@ -256,15 +222,21 @@ class FormOtherController extends Controller return redirect()->back(); } - public function approve($id) + public function approve(Request $request, $id) { $this->checkAuthorization(auth()->user(), ['approval.approve']); + $request->validate([ + 'total' => 'required', + ]); + $form = FormOthers::findOrfail($id); $form->update([ 'approved_at' => now(), 'approved_by' => auth()->user()->id, - 'status' => 'Approved' + 'status' => 'Approved', + + 'approved_total' => $form->total, ]); $heads = $form->user->getCabangAndRegionHead(); @@ -292,15 +264,16 @@ class FormOtherController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseApproved( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseApproved( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk WhatsApp message - WhatsappHelper::approveExpense($phoneNumbers, $expense_number); + $url = route('forms.other.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been approved.'); @@ -348,15 +321,16 @@ class FormOtherController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new FinalApprove( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new FinalApprove( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // send whatsapp message - WhatsappHelper::finalApprove($phoneNumbers, $expense_number); + $url = route('forms.other.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been final approved.'); @@ -413,15 +387,16 @@ class FormOtherController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseRejected( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseRejected( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk WhatsApp message - WhatsappHelper::rejectExpense($phoneNumbers, $expense_number); + $url = route('forms.other.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been rejected.'); diff --git a/app/Http/Controllers/Forms/FormVehicleController.php b/app/Http/Controllers/Forms/FormVehicleController.php index 558c136..07c1d95 100644 --- a/app/Http/Controllers/Forms/FormVehicleController.php +++ b/app/Http/Controllers/Forms/FormVehicleController.php @@ -65,6 +65,28 @@ class FormVehicleController extends Controller ]); } + public function detail($id) + { + $this->checkAuthorization(auth()->user(), ['forms.vehicle.view']); + + $form = FormVehicleRunningCost::with('user')->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return response()->json($form); + } + + public function view($id) + { + $this->checkAuthorization(auth()->user(), ['forms.vehicle.view']); + + $form = FormVehicleRunningCost::with('user')->findOrFail($id); + $form->bukti_total = $form->bukti_total ? NextCloudHelper::getFileUrl($form->bukti_total) : null; + + return view('backend.pages.forms.vehicle.view', [ + 'form' => $form, + ]); + } + public function create() { $this->checkAuthorization(auth()->user(), ['forms.vehicle.create']); @@ -84,9 +106,7 @@ class FormVehicleController extends Controller 'tipe_bensin' => 'required|in:pertalite,pertamax', 'nopol' => 'required', 'keterangan' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; @@ -96,43 +116,19 @@ class FormVehicleController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Generate sequence number and expense number $sequence_number = FormVehicleRunningCost::withTrashed()->where('expense_number', 'like', $region->code . '-' . $cabang->code . '-VHC-' . date('ym') . '%')->count() + 1; @@ -150,9 +146,7 @@ class FormVehicleController extends Controller 'tipe_bensin' => $request->tipe_bensin, 'nopol' => $request->nopol, 'keterangan' => $request->keterangan, - 'bukti1' => $filePaths['bukti1'] ?? null, - 'bukti2' => $filePaths['bukti2'] ?? null, - 'bukti3' => $filePaths['bukti3'] ?? null, + 'bukti_total' => $filePaths['bukti_total'] ?? null, 'account_number' => $kategori->account_number, 'status' => 'On Progress', ]); @@ -189,9 +183,7 @@ class FormVehicleController extends Controller 'tipe_bensin' => 'required|in:pertalite,pertamax', 'nopol' => 'required', 'keterangan' => 'required', - 'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], - 'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], + 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], ]); $form = FormVehicleRunningCost::findOrfail($id); @@ -207,43 +199,19 @@ class FormVehicleController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle'; - if ($request->hasFile('bukti1')) { - $bukti1 = $request->file('bukti1'); - $filename = Str::uuid() . '.' . $bukti1->extension(); + if ($request->hasFile('bukti_total')) { + $bukti_total = $request->file('bukti_total'); + $filename = Str::uuid() . '.' . $bukti_total->extension(); - $filePaths['bukti1'] = $folderPath . '/' . $filename; + $filePaths['bukti_total'] = $folderPath . '/' . $filename; NextCloudHelper::uploadFile( $folderPath, - $bukti1->getContent(), + $bukti_total->getContent(), $filename ); } - if ($request->hasFile('bukti2')) { - $bukti2 = $request->file('bukti2'); - $filename = Str::uuid() . '.' . $bukti2->extension(); - - $filePaths['bukti2'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti2->getContent(), - $filename - ); - } - if ($request->hasFile('bukti3')) { - $bukti3 = $request->file('bukti3'); - $filename = Str::uuid() . '.' . $bukti3->extension(); - - $filePaths['bukti3'] = $folderPath . '/' . $filename; - - NextCloudHelper::uploadFile( - $folderPath, - $bukti3->getContent(), - $filename - ); - } // Save the form data $form->update([ @@ -254,9 +222,7 @@ class FormVehicleController extends Controller 'tipe_bensin' => $request->tipe_bensin, 'nopol' => $request->nopol, 'keterangan' => $request->keterangan, - 'bukti1' => $filePaths['bukti1'] ?? $form->bukti1, - 'bukti2' => $filePaths['bukti2'] ?? $form->bukti2, - 'bukti3' => $filePaths['bukti3'] ?? $form->bukti3, + 'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total, 'account_number' => $kategori->account_number, 'status' => 'On Progress', ]); @@ -266,15 +232,20 @@ class FormVehicleController extends Controller return redirect()->back(); } - public function approve($id) + public function approve(Request $request, $id) { $this->checkAuthorization(auth()->user(), ['approval.approve']); + $request->validate([ + 'total' => 'required', + ]); $form = FormVehicleRunningCost::findOrfail($id); $form->update([ 'approved_at' => now(), 'approved_by' => auth()->user()->id, - 'status' => 'Approved' + 'status' => 'Approved', + + 'approved_total' => $form->total, ]); $heads = $form->user->getCabangAndRegionHead(); @@ -302,15 +273,16 @@ class FormVehicleController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseApproved( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseApproved( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk WhatsApp message - WhatsappHelper::approveExpense($phoneNumbers, $expense_number); + $url = route('forms.vehicle.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been approved.'); @@ -358,15 +330,16 @@ class FormVehicleController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new FinalApprove( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new FinalApprove( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // send whatsapp message - WhatsappHelper::finalApprove($phoneNumbers, $expense_number); + $url = route('forms.vehicle.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been final approved.'); @@ -423,16 +396,17 @@ class FormVehicleController extends Controller $phoneNumbers = array_unique($phoneNumbers); // Send bulk email - Mail::to($recipients)->send(new ExpenseRejected( - $name, - $expense_number, - $tanggal, - $total - )); + // Mail::to($recipients)->send(new ExpenseRejected( + // $name, + // $expense_number, + // $tanggal, + // $total + // )); // Send bulk WhatsApp message - WhatsappHelper::rejectExpense($phoneNumbers, $expense_number); - + $url = route('forms.vehicle.view', $form->id); + WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url); + AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $form->expense_number . ')'); session()->flash('success', 'Form has been rejected.'); return redirect()->back(); diff --git a/app/Models/FormEntertaimentPresentation.php b/app/Models/FormEntertaimentPresentation.php index 0bb0820..5c98480 100644 --- a/app/Models/FormEntertaimentPresentation.php +++ b/app/Models/FormEntertaimentPresentation.php @@ -21,9 +21,7 @@ class FormEntertaimentPresentation extends Model 'name', 'alamat', 'nik_or_npwp', - 'bukti1', - 'bukti2', - 'bukti3', + 'bukti_total', 'account_number', 'status', 'approved_at', diff --git a/app/Models/FormOthers.php b/app/Models/FormOthers.php index 33e61d5..b2a7d82 100644 --- a/app/Models/FormOthers.php +++ b/app/Models/FormOthers.php @@ -18,9 +18,7 @@ class FormOthers extends Model 'keterangan', 'total', 'approved_total', - 'bukti1', - 'bukti2', - 'bukti3', + 'bukti_total', 'account_number', 'status', 'approved_at', diff --git a/app/Models/FormVehicleRunningCost.php b/app/Models/FormVehicleRunningCost.php index ca5cf1c..8a67dd4 100644 --- a/app/Models/FormVehicleRunningCost.php +++ b/app/Models/FormVehicleRunningCost.php @@ -21,9 +21,7 @@ class FormVehicleRunningCost extends Model 'tipe_bensin', 'nopol', 'keterangan', - 'bukti1', - 'bukti2', - 'bukti3', + 'bukti_total', 'account_number', 'status', 'approved_at', diff --git a/database/migrations/2025_01_06_072318_changed_bukti_to_form_vehicle_running_cost.php b/database/migrations/2025_01_06_072318_changed_bukti_to_form_vehicle_running_cost.php new file mode 100644 index 0000000..a02432f --- /dev/null +++ b/database/migrations/2025_01_06_072318_changed_bukti_to_form_vehicle_running_cost.php @@ -0,0 +1,36 @@ +dropColumn('bukti1'); + $table->dropColumn('bukti2'); + $table->dropColumn('bukti3'); + + $table->string('bukti_total')->after('approved_total')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('form_vehicle_running_cost', function (Blueprint $table) { + $table->string('bukti1')->after('approved_total')->nullable()->change(); + $table->string('bukti2')->after('bukti1')->nullable()->change(); + $table->string('bukti3')->after('bukti2')->nullable()->change(); + + $table->dropColumn('bukti_total'); + }); + } +}; diff --git a/database/migrations/2025_01_06_080502_changed_bukti_to_form_entertainment_presentation.php b/database/migrations/2025_01_06_080502_changed_bukti_to_form_entertainment_presentation.php new file mode 100644 index 0000000..714ae46 --- /dev/null +++ b/database/migrations/2025_01_06_080502_changed_bukti_to_form_entertainment_presentation.php @@ -0,0 +1,36 @@ +dropColumn('bukti1'); + $table->dropColumn('bukti2'); + $table->dropColumn('bukti3'); + + $table->string('bukti_total')->after('approved_total')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('form_entertainment_presentation', function (Blueprint $table) { + $table->string('bukti1')->after('approved_total')->nullable()->change(); + $table->string('bukti2')->after('bukti1')->nullable()->change(); + $table->string('bukti3')->after('bukti2')->nullable()->change(); + + $table->dropColumn('bukti_total'); + }); + } +}; diff --git a/database/migrations/2025_01_06_084746_changed_bukti_to_form_others.php b/database/migrations/2025_01_06_084746_changed_bukti_to_form_others.php new file mode 100644 index 0000000..07357bf --- /dev/null +++ b/database/migrations/2025_01_06_084746_changed_bukti_to_form_others.php @@ -0,0 +1,36 @@ +dropColumn('bukti1'); + $table->dropColumn('bukti2'); + $table->dropColumn('bukti3'); + + $table->string('bukti_total')->after('approved_total')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('form_others', function (Blueprint $table) { + $table->string('bukti1')->after('approved_total')->nullable()->change(); + $table->string('bukti2')->after('bukti1')->nullable()->change(); + $table->string('bukti3')->after('bukti2')->nullable()->change(); + + $table->dropColumn('bukti_total'); + }); + } +}; diff --git a/resources/views/backend/pages/forms/entertainment/create.blade.php b/resources/views/backend/pages/forms/entertainment/create.blade.php index d94d66b..861edd2 100644 --- a/resources/views/backend/pages/forms/entertainment/create.blade.php +++ b/resources/views/backend/pages/forms/entertainment/create.blade.php @@ -32,11 +32,11 @@
- +
- +
- +
- - -
-
- - + +
- - + +
- +
- - + +
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/entertainment/edit.blade.php b/resources/views/backend/pages/forms/entertainment/edit.blade.php index eb4b28d..231c4c9 100644 --- a/resources/views/backend/pages/forms/entertainment/edit.blade.php +++ b/resources/views/backend/pages/forms/entertainment/edit.blade.php @@ -33,11 +33,11 @@
- +
- +
- +
- - -
-
- - + +
- - + +
- +
- - + +
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/entertainment/index.blade.php b/resources/views/backend/pages/forms/entertainment/index.blade.php index f5fe56c..c5bbd0d 100644 --- a/resources/views/backend/pages/forms/entertainment/index.blade.php +++ b/resources/views/backend/pages/forms/entertainment/index.blade.php @@ -39,7 +39,7 @@
-

Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('total'), 0, ',', '.') }}

+

Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('approved_total'), 0, ',', '.') }}

Approved Expenses

@@ -84,15 +84,14 @@ # - Nama + User + Nama Penerima Tanggal Jenis Keterangan Total - Nama Penerima - Bukti 1 - Bukti 2 - Bukti 3 + Total Approved + Bukti Account Number Status @if (auth()->user()->can('approval.approve')) @@ -112,32 +111,15 @@ {{ $loop->iteration }} {{ $item->user->name }} + {{ $item->name }} {{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }} {{ $item->jenis }} {{ $item->keterangan }} {{ number_format($item->total, 0, ',', '.') }} - {{ $item->name }} + {{ number_format($item->approved_total, 0, ',', '.') }} - @if ($item->bukti1) - - Download - - @else - - - @endif - - - @if ($item->bukti2) - - Download - - @else - - - @endif - - - @if ($item->bukti3) - + @if ($item->bukti_total) + Download @else @@ -158,10 +140,10 @@ {{-- approve / reject button --}} @if ($item->status == 'On Progress') -
- @csrf - @method('PUT') -
@@ -213,6 +195,12 @@ @endif + @if (auth()->user()->can('forms.entertainment.view')) + + + + @endif + @if (auth()->user()->can('forms.entertainment.edit')) @@ -239,20 +227,178 @@
+
+ +
@endsection @section('scripts') + $(document).ready(function () { + // Uncheck all checkboxes on page refresh + $('.custom-control-input').prop('checked', false); + + if ($('#dataTable').length) { + $('#dataTable').DataTable({ + responsive: false, + dom: 'Bfrtip', + buttons: ['excel', 'pdf', 'print'] + }); + } + + // Handle Approve Button Click + $('.open-approve-modal').on('click', function () { + const approveUrl = $(this).data('id'); + + // Show spinner and hide content initially + $('#loadingSpinner').show(); + $('#modalContent').addClass('d-none'); + + $('#approveForm').attr('action', approveUrl); // Set the form action + $('#loadingSpinner').addClass('d-flex'); + $('#approveModal').modal('show'); // Show the modal + + // Get detail from /forms/up-country/detail/{id} + $.get(approveUrl.replace('approve', 'detail'), function (data) { + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#total_bensin_value').text(formatter.format(data.total)); + $('#total_bensin').data('value', data.total); + + // Detail data + $('#user').text(data.user.name); + $('#nik_or_npwp').text(data.nik_or_npwp); + $('#name').text(data.name); + $('#alamat').text(data.alamat); + $('#expense_number').text(data.expense_number); + $('#jenis').text(data.jenis); + $('#keterangan').text(data.keterangan); + $('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', { + year: 'numeric', + month: 'long', + day: 'numeric', + })); + + $('#bukti_total').html(data.bukti_total ? '
Download' : '-'); + + // Hide spinner and show content + $('#loadingSpinner').hide(); + $('#loadingSpinner').removeClass('d-flex'); + $('#loadingSpinner').addClass('d-none'); + $('#modalContent').removeClass('d-none'); + + // Reset the total to zero + $('#total').val(0); + }); + }); + + // Update total dynamically + $('.custom-control-input').on('change', function () { + let total = 0; + + // Calculate the total based on checked checkboxes + $('.custom-control-input:checked').each(function () { + total += parseFloat($(this).data('value') || 0); + }); + + // Update the total field with formatted value + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#total').val(formatter.format(total)); + }); + + // Uncheck all checkboxes when the modal is closed + $('#approveModal').on('hidden.bs.modal', function () { + $('.custom-control-input').prop('checked', false); // Uncheck all checkboxes + $('#total').val('0'); // Reset total to 0 + }); + }); + @endsection diff --git a/resources/views/backend/pages/forms/entertainment/view.blade.php b/resources/views/backend/pages/forms/entertainment/view.blade.php new file mode 100644 index 0000000..1c8b1eb --- /dev/null +++ b/resources/views/backend/pages/forms/entertainment/view.blade.php @@ -0,0 +1,100 @@ +@extends('layouts.app') + +@section('title') + Dashboard +@endsection + +@section('admin-content') + + +
+
+
+
+

Lihat Expense Entertainment & Presentation

+
+
+ +
+
+
+
+
+
+
+
+
+ @csrf + @method('PUT') + @include('backend.layouts.partials.messages') +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+ Lihat Bukti +
+
+ + +
+
+ +
+ Kembali +
+
+
+
+
+
+
+ + +@endsection diff --git a/resources/views/backend/pages/forms/other/create.blade.php b/resources/views/backend/pages/forms/other/create.blade.php index b1c309c..2141cab 100644 --- a/resources/views/backend/pages/forms/other/create.blade.php +++ b/resources/views/backend/pages/forms/other/create.blade.php @@ -32,7 +32,7 @@
- +
- +
- +
-
- - -
- - + +
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/other/edit.blade.php b/resources/views/backend/pages/forms/other/edit.blade.php index 098fe2b..30e3539 100644 --- a/resources/views/backend/pages/forms/other/edit.blade.php +++ b/resources/views/backend/pages/forms/other/edit.blade.php @@ -33,7 +33,7 @@
- +
- +
- +
-
- - -
- - + +
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/other/index.blade.php b/resources/views/backend/pages/forms/other/index.blade.php index a2f8599..7d7f5c9 100644 --- a/resources/views/backend/pages/forms/other/index.blade.php +++ b/resources/views/backend/pages/forms/other/index.blade.php @@ -89,9 +89,7 @@ Jenis Keterangan Total - Bukti 1 - Bukti 2 - Bukti 3 + Bukti Total Account Number Status @if (auth()->user()->can('approval.approve')) @@ -116,26 +114,8 @@ {{ $item->keterangan }} {{ number_format($item->total, 0, ',', '.') }} - @if ($item->bukti1) - - Download - - @else - - - @endif - - - @if ($item->bukti2) - - Download - - @else - - - @endif - - - @if ($item->bukti3) - + @if ($item->bukti_total) + Download @else @@ -156,10 +136,10 @@ {{-- approve / reject button --}} @if ($item->status == 'On Progress') -
- @csrf - @method('PUT') -
@@ -237,20 +217,168 @@
+
+ +
@endsection @section('scripts') -@endsection + $(document).ready(function () { + // Uncheck all checkboxes on page refresh + $('.custom-control-input').prop('checked', false); + + if ($('#dataTable').length) { + $('#dataTable').DataTable({ + responsive: false, + dom: 'Bfrtip', + buttons: ['excel', 'pdf', 'print'] + }); + } + + // Handle Approve Button Click + $('.open-approve-modal').on('click', function () { + const approveUrl = $(this).data('id'); + + // Show spinner and hide content initially + $('#loadingSpinner').show(); + $('#modalContent').addClass('d-none'); + + $('#approveForm').attr('action', approveUrl); // Set the form action + $('#loadingSpinner').addClass('d-flex'); + $('#approveModal').modal('show'); // Show the modal + + // Get detail from /forms/up-country/detail/{id} + $.get(approveUrl.replace('approve', 'detail'), function (data) { + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#kategori').text(data.kategori.name); + $('#keterangan').text(data.keterangan); + $('#total_pengeluaran_value').text(formatter.format(data.total)); + $('#total_pengeluaran').data('value', data.total); + + // Detail data + $('#user').text(data.user.name); + $('#expense_number').text(data.expense_number); + $('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + })); + + $('#bukti_total').html(data.bukti_total ? 'Download' : '-'); + + // Hide spinner and show content + $('#loadingSpinner').hide(); + $('#loadingSpinner').removeClass('d-flex'); + $('#loadingSpinner').addClass('d-none'); + $('#modalContent').removeClass('d-none'); + + // Reset the total to zero + $('#total').val(0); + }); + }); + + // Update total dynamically + $('.custom-control-input').on('change', function () { + let total = 0; + + // Calculate the total based on checked checkboxes + $('.custom-control-input:checked').each(function () { + total += parseFloat($(this).data('value') || 0); + }); + + // Update the total field with formatted value + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#total').val(formatter.format(total)); + }); + + // Uncheck all checkboxes when the modal is closed + $('#approveModal').on('hidden.bs.modal', function () { + $('.custom-control-input').prop('checked', false); // Uncheck all checkboxes + $('#total').val('0'); // Reset total to 0 + }); + }); + +@endsection \ No newline at end of file diff --git a/resources/views/backend/pages/forms/upcountry/view.blade.php b/resources/views/backend/pages/forms/upcountry/view.blade.php index e48d08f..bdc5588 100644 --- a/resources/views/backend/pages/forms/upcountry/view.blade.php +++ b/resources/views/backend/pages/forms/upcountry/view.blade.php @@ -37,7 +37,7 @@
- @foreach ($rayons as $rayon) diff --git a/resources/views/backend/pages/forms/vehicle/create.blade.php b/resources/views/backend/pages/forms/vehicle/create.blade.php index 9086f07..31e995f 100644 --- a/resources/views/backend/pages/forms/vehicle/create.blade.php +++ b/resources/views/backend/pages/forms/vehicle/create.blade.php @@ -32,52 +32,44 @@
- +
- +
- +
-
- - -
-
- - +
+ +
+
+ + +
- +
- +
- - -
-
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/vehicle/edit.blade.php b/resources/views/backend/pages/forms/vehicle/edit.blade.php index 0bd3b0d..580bceb 100644 --- a/resources/views/backend/pages/forms/vehicle/edit.blade.php +++ b/resources/views/backend/pages/forms/vehicle/edit.blade.php @@ -32,50 +32,43 @@
- +
- +
- +
- - -
-
- - + +
+
- + + +
+
+
- +
- - -
-
- - -
-
- - + +
diff --git a/resources/views/backend/pages/forms/vehicle/index.blade.php b/resources/views/backend/pages/forms/vehicle/index.blade.php index ba04e22..0c317a8 100644 --- a/resources/views/backend/pages/forms/vehicle/index.blade.php +++ b/resources/views/backend/pages/forms/vehicle/index.blade.php @@ -39,7 +39,7 @@
-

Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('total'), 0, ',', '.') }}

+

Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('approved_total'), 0, ',', '.') }}

Approved Expenses

@@ -88,12 +88,11 @@ Tanggal Liter Total + Total Approved Jarak Tipe Bensin Nomor Polisi - Bukti 1 - Bukti 2 - Bukti 3 + Bukti Account Number Status @if (auth()->user()->can('approval.approve')) @@ -116,30 +115,13 @@ {{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }} {{ $item->liter }} {{ number_format($item->total, 0, ',', '.') }} + {{ number_format($item->approved_total, 0, ',', '.') }} {{ $item->jarak }} km {{ $item->tipe_bensin }} {{ $item->nopol }} - @if ($item->bukti1) - - Download - - @else - - - @endif - - - @if ($item->bukti2) - - Download - - @else - - - @endif - - - @if ($item->bukti3) - + @if ($item->bukti_total) + Download @else @@ -160,10 +142,10 @@ {{-- approve / reject button --}} @if ($item->status == 'On Progress') -
- @csrf - @method('PUT') -
@@ -215,6 +197,12 @@ @endif + @if (auth()->user()->can('forms.vehicle.view')) + + + + @endif + @if (auth()->user()->can('forms.vehicle.edit')) @@ -241,20 +229,183 @@
+
+ +
@endsection @section('scripts') + $(document).ready(function () { + // Uncheck all checkboxes on page refresh + $('.custom-control-input').prop('checked', false); + + if ($('#dataTable').length) { + $('#dataTable').DataTable({ + responsive: false, + dom: 'Bfrtip', + buttons: ['excel', 'pdf', 'print'] + }); + } + + // Handle Approve Button Click + $('.open-approve-modal').on('click', function () { + const approveUrl = $(this).data('id'); + + // Show spinner and hide content initially + $('#loadingSpinner').show(); + $('#modalContent').addClass('d-none'); + + $('#approveForm').attr('action', approveUrl); // Set the form action + $('#loadingSpinner').addClass('d-flex'); + $('#approveModal').modal('show'); // Show the modal + + // Get detail from /forms/up-country/detail/{id} + $.get(approveUrl.replace('approve', 'detail'), function (data) { + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#total_bensin_value').text(formatter.format(data.total)); + $('#total_bensin').data('value', data.total); + $('#jarak').text(data.jarak); + $('#liter').text(data.liter); + $('#nopol').text(data.nopol); + $('#tipe_bensin').text(data.tipe_bensin); + $('#keterangan').text(data.keterangan); + + // Detail data + $('#user').text(data.user.name); + $('#expense_number').text(data.expense_number); + $('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + })); + + $('#bukti_total').html(data.bukti_total ? '
Download' : '-'); + + // Hide spinner and show content + $('#loadingSpinner').hide(); + $('#loadingSpinner').removeClass('d-flex'); + $('#loadingSpinner').addClass('d-none'); + $('#modalContent').removeClass('d-none'); + + // Reset the total to zero + $('#total').val(0); + }); + }); + + // Update total dynamically + $('.custom-control-input').on('change', function () { + let total = 0; + + // Calculate the total based on checked checkboxes + $('.custom-control-input:checked').each(function () { + total += parseFloat($(this).data('value') || 0); + }); + + // Update the total field with formatted value + const formatter = new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }); + + $('#total').val(formatter.format(total)); + }); + + // Uncheck all checkboxes when the modal is closed + $('#approveModal').on('hidden.bs.modal', function () { + $('.custom-control-input').prop('checked', false); // Uncheck all checkboxes + $('#total').val('0'); // Reset total to 0 + }); + }); + @endsection \ No newline at end of file diff --git a/resources/views/backend/pages/forms/vehicle/view.blade.php b/resources/views/backend/pages/forms/vehicle/view.blade.php new file mode 100644 index 0000000..b37e404 --- /dev/null +++ b/resources/views/backend/pages/forms/vehicle/view.blade.php @@ -0,0 +1,96 @@ +@extends('layouts.app') + +@section('title') + Dashboard +@endsection + +@section('admin-content') + +
+
+
+
+

Lihat Expense Vehicle Running Cost

+
+
+ +
+
+
+
+
+
+
+
+
+ @csrf + @include('backend.layouts.partials.messages') +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ Lihat Bukti +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ Kembali +
+
+
+
+
+
+
+ + +@endsection diff --git a/routes/web.php b/routes/web.php index 0304edd..dc4b5c1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,7 +38,7 @@ Route::group(['prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['auth:admi Route::resource('admins', AdminsController::class); Route::get('/admins/expense/{user_id}', [AdminsController::class, 'expense'])->name('admins.expense'); Route::resource('roles', RolesController::class); - Route::get('/admin', [DashboardController::class, 'index'])->name('dashboard'); + Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); // Rayon Route::get('/rayon', [RayonController::class, 'index'])->name('rayon.index'); @@ -77,7 +77,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { // Up Country Route::get('/up-country', [FormUpCountryController::class, 'index'])->name('forms.up-country'); Route::get('/up-country/detail/{id}', [FormUpCountryController::class, 'detail'])->name('forms.up-country.detail'); - Route::get('/up-country/view/{id}', [FormUpCountryController::class, 'view'])->name('forms.up-country.view'); + Route::get('/up-country/view/{id}', [FormUpCountryController::class, 'view'])->name('forms.up-country.view'); Route::get('/up-country/create', [FormUpCountryController::class, 'create'])->name('forms.up-country.create'); Route::post('/up-country/store', [FormUpCountryController::class, 'store'])->name('forms.up-country.store'); Route::get('/up-country/edit/{id}', [FormUpCountryController::class, 'edit'])->name('forms.up-country.edit'); @@ -90,6 +90,8 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { // Vehicle Running Cost Route::get('/vehicle-running-cost', [FormVehicleController::class, 'index'])->name('forms.vehicle'); + Route::get('/vehicle-running-cost/detail/{id}', [FormVehicleController::class, 'detail'])->name('forms.vehicle.detail'); + Route::get('/vehicle-running-cost/view/{id}', [FormVehicleController::class, 'view'])->name('forms.vehicle.view'); Route::get('/vehicle-running-cost/create', [FormVehicleController::class, 'create'])->name('forms.vehicle.create'); 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'); @@ -102,6 +104,8 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { // Entertainment & Presentation Route::get('/entertainment-presentation', [FormEntertainmentPresentationController::class, 'index'])->name('forms.entertainment'); + Route::get('/entertainment-presentation/detail/{id}', [FormEntertainmentPresentationController::class, 'detail'])->name('forms.entertainment.detail'); + Route::get('/entertainment-presentation/view/{id}', [FormEntertainmentPresentationController::class, 'view'])->name('forms.entertainment.view'); Route::get('/entertainment-presentation/create', [FormEntertainmentPresentationController::class, 'create'])->name('forms.entertainment.create'); Route::post('/entertainment-presentation/store', [FormEntertainmentPresentationController::class, 'store'])->name('forms.entertainment.store'); Route::get('/entertainment-presentation/edit/{id}', [FormEntertainmentPresentationController::class, 'edit'])->name('forms.entertainment.edit'); @@ -128,6 +132,8 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { // Other Route::get('/other', [FormOtherController::class, 'index'])->name('forms.other'); + Route::get('/other/detail/{id}', [FormOtherController::class, 'detail'])->name('forms.other.detail'); + Route::get('/other/view/{id}', [FormOtherController::class, 'view'])->name('forms.other.view'); Route::get('/other/create', [FormOtherController::class, 'create'])->name('forms.other.create'); Route::post('/other/store', [FormOtherController::class, 'store'])->name('forms.other.store'); Route::get('/other/edit/{id}', [FormOtherController::class, 'edit'])->name('forms.other.edit');