From 24b9a828560c8e6d8ed70e8b448b6f176252729a Mon Sep 17 00:00:00 2001 From: Jagad R R Date: Wed, 18 Dec 2024 12:56:16 +0700 Subject: [PATCH] added form entertaiment and fix file upload --- .env | 2 +- app/Helpers/NextCloudHelper.php | 87 ++++++- ...ormEntertainmentPresentationController.php | 229 ++++++++++++++++++ .../Forms/FormUpCountryController.php | 82 +++++-- .../Forms/FormVehicleController.php | 82 +++++-- app/Models/FormEntertaimentPresentation.php | 5 + .../forms/entertainment/create.blade.php | 89 +++++++ .../pages/forms/entertainment/edit.blade.php | 90 +++++++ .../pages/forms/entertainment/index.blade.php | 136 +++++++++++ .../pages/forms/upcountry/index.blade.php | 35 ++- .../pages/forms/vehicle/index.blade.php | 35 ++- routes/web.php | 26 +- 12 files changed, 836 insertions(+), 62 deletions(-) create mode 100644 app/Http/Controllers/Forms/FormEntertainmentPresentationController.php create mode 100644 resources/views/backend/pages/forms/entertainment/create.blade.php create mode 100644 resources/views/backend/pages/forms/entertainment/edit.blade.php create mode 100644 resources/views/backend/pages/forms/entertainment/index.blade.php diff --git a/.env b/.env index 0750f1e..e49cef4 100644 --- a/.env +++ b/.env @@ -68,7 +68,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=false VITE_APP_NAME="${APP_NAME}" -NEXT_CLOUD_URL=https://mkt.tunggal-pharma.com/remote.php/dav/files/user_dev/ +NEXT_CLOUD_URL=https://mkt.tunggal-pharma.com NEXT_CLOUD_USERNAME=user_dev NEXT_CLOUD_PASSWORD=userdev12345 NEXT_CLOUD_PATHPREFIX="" diff --git a/app/Helpers/NextCloudHelper.php b/app/Helpers/NextCloudHelper.php index cc4391e..49b78ee 100644 --- a/app/Helpers/NextCloudHelper.php +++ b/app/Helpers/NextCloudHelper.php @@ -4,6 +4,7 @@ namespace App\Helpers; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use Illuminate\Support\Str; class NextCloudHelper { @@ -19,17 +20,78 @@ class NextCloudHelper public static function createFolder($baseUrl, $username, $password, $folderPath) { $client = new Client(); - $url = rtrim($baseUrl, '/') . "/remote.php/dav/files/{$username}/" . ltrim($folderPath, '/'); - + $folders = explode('/', ltrim($folderPath, '/')); // Split the folder path into an array + $currentPath = ''; // Initialize an empty string to build the path progressively + + foreach ($folders as $folder) { + $currentPath .= '/' . $folder; // Add the current folder to the path + + // Build the URL to create the folder + $url = rtrim($baseUrl, '/') . "/mktia/remote.php/dav/files/{$username}" . $currentPath; + + try { + // Attempt to create the current folder + $response = $client->request('MKCOL', $url, [ + 'auth' => [$username, $password], + 'verify' => false // Disable SSL verification (only for testing purposes) + ]); + + // If folder creation is successful, proceed to the next folder + if ($response->getStatusCode() === 201) { + echo "Folder '$currentPath' created successfully.\n"; + } + } catch (RequestException $e) { + // Handle errors, such as folder already existing + if ($e->getCode() === 409) { + echo "Folder '$currentPath' already exists.\n"; + } else { + // For other errors + echo "Failed to create folder '$currentPath': " . $e->getMessage() . "\n"; + } + } + } + + return [ + 'success' => true, + 'status' => 200, + 'message' => 'All folders processed.' + ]; + } + + public static function uploadFile($folderPath, $fileObject, $fileName) + { + $baseUrl = env('NEXT_CLOUD_URL'); + $username = env('NEXT_CLOUD_USERNAME'); + $password= env('NEXT_CLOUD_PASSWORD'); + + // Ensure the folder exists (or create it) + $folderResponse = self::createFolder($baseUrl, $username, $password, $folderPath); + + // Check if folder creation was successful or if it already exists + if (!$folderResponse['success']) { + return [ + 'success' => false, + 'status' => $folderResponse['status'], + 'message' => 'Failed to create folder: ' . $folderResponse['message'] + ]; + } + + $client = new Client(); + $url = rtrim($baseUrl, '/') . "/mktia/remote.php/dav/files/{$username}/" . ltrim($folderPath, '/') . '/' . $fileName; + try { - $response = $client->request('MKCOL', $url, [ - 'auth' => [$username, $password] + // If fileObject is a stream, we can use it directly + // If it's raw content, ensure it's being properly passed + $response = $client->request('PUT', $url, [ + 'auth' => [$username, $password], + 'body' => $fileObject, // File content or stream + 'verify' => false // Disable SSL verification (only for testing purposes) ]); return [ 'success' => true, 'status' => $response->getStatusCode(), - 'message' => 'Folder created successfully.' + 'message' => 'File uploaded successfully.' ]; } catch (RequestException $e) { return [ @@ -39,8 +101,19 @@ class NextCloudHelper ]; } } - - + + + public static function getFileUrl($filePath) + { + $baseUrl = env('NEXT_CLOUD_URL'); + $username = env('NEXT_CLOUD_USERNAME'); + + // Build the user-specific WebDAV file URL + $relativePath = "/mktia/remote.php/dav/files/{$username}/" . ltrim($filePath, '/'); + + // Return the full accessible URL + return rtrim($baseUrl, '/') . '/' . $relativePath; + } /** * Create a user in Nextcloud. diff --git a/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php new file mode 100644 index 0000000..3960240 --- /dev/null +++ b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php @@ -0,0 +1,229 @@ +checkAuthorization(auth()->user(), ['forms.entertainment.view']); + + $forms = FormEntertaimentPresentation::where('user_id', auth()->user()->id)->get(); + return view('backend.pages.forms.entertainment.index', [ + 'forms' => $forms + ]); + } + + public function create() + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.create']); + + return view('backend.pages.forms.entertainment.create'); + } + + public function store(Request $request) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.create']); + + $request->validate([ + 'tanggal' => 'required', + 'jenis' => 'required|in:entertainment,presentation,sponsorship', + 'keterangan' => 'required', + 'total' => 'required|integer', + 'name' => 'required', + 'alamat' => 'required', + 'nik_or_npwp' => 'required', + 'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'bukti2' => 'nullable|file|mimes:xlsx,xls,csv', + 'bukti3' => 'nullable|file|mimes:pdf', + ]); + + $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; + $region = Region::where('id', $cabang->region_id)->first(); + $kategori = Kategori::where('name', 'Entertainment & Presentation')->first(); + + $filePaths = []; + $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment'; + + if ($request->hasFile('bukti1')) { + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->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; + $formatted_sequence_number = str_pad($sequence_number, 4, '0', STR_PAD_LEFT); + $expense_number = $region->code . '-' . $cabang->code . '-ETY-' . date('ym') . $formatted_sequence_number; + + // Save the form data + FormEntertaimentPresentation::create([ + 'expense_number' => $expense_number, + 'user_id' => auth()->user()->id, + 'tanggal' => $request->tanggal, + 'jenis' => $request->jenis, + 'keterangan' => $request->keterangan, + 'total' => $request->total, + '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, + 'account_number' => $kategori->account_number, + 'status' => 'On Progress', + ]); + + session()->flash('success', 'Form has been created.'); + return redirect()->route('forms.entertainment'); + } + + public function edit($id) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.edit']); + + $form = FormEntertaimentPresentation::findOrfail($id); + return view('backend.pages.forms.entertainment.edit', [ + 'form' => $form + ]); + } + + public function update(Request $request, $id) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.edit']); + + $request->validate([ + 'tanggal' => 'required', + 'jenis' => 'required|in:entertainment,presentation,sponsorship', + 'keterangan' => 'required', + 'total' => 'required|integer', + 'name' => 'required', + 'alamat' => 'required', + 'nik_or_npwp' => 'required', + 'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'bukti2' => 'nullable|file|mimes:xlsx,xls,csv', + 'bukti3' => 'nullable|file|mimes:pdf', + ]); + + $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; + $region = Region::where('id', $cabang->region_id)->first(); + $kategori = Kategori::where('name', 'Entertainment & Presentation')->first(); + + $filePaths = []; + $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment/'; + + if ($request->hasFile('bukti1')) { + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->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 = FormEntertaimentPresentation::findOrfail($id); + $form->update([ + 'tanggal' => $request->tanggal, + 'jenis' => $request->jenis, + 'keterangan' => $request->keterangan, + 'total' => $request->total, + '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, + 'account_number' => $kategori->account_number, + 'status' => 'On Progress', + ]); + + session()->flash('success', 'Form has been updated.'); + return redirect()->route('forms.entertainment'); + } + + public function destroy($id) + { + $this->checkAuthorization(auth()->user(), ['forms.entertainment.delete']); + + $form = FormEntertaimentPresentation::findOrfail($id); + $form->delete(); + + session()->flash('success', 'Form has been deleted.'); + return redirect()->route('forms.entertainment'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Forms/FormUpCountryController.php b/app/Http/Controllers/Forms/FormUpCountryController.php index 8dc04e0..9eea225 100644 --- a/app/Http/Controllers/Forms/FormUpCountryController.php +++ b/app/Http/Controllers/Forms/FormUpCountryController.php @@ -12,6 +12,8 @@ use App\Models\Region; use App\Models\Cabang; use App\Models\UserHasCabang; use App\Models\Kategori; +use App\Helpers\NextCloudHelper; +use Illuminate\Support\Str; class FormUpCountryController extends Controller { @@ -60,20 +62,42 @@ class FormUpCountryController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/upcountry/'; - // check if folder not exists - // if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) { - // Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/')); - // } + if ($request->hasFile('bukti1')) { + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->getContent(), + $filename + ); - // Store files to Nextcloud and collect their paths - if ($request->hasFile('bukti1')) { - $filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName()); } if ($request->hasFile('bukti2')) { - $filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName()); + $bukti2 = $request->file('bukti2'); + $filename = Str::uuid() . '.' . $bukti2->extension(); + + $filePaths['bukti2'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti2->getContent(), + $filename + ); } if ($request->hasFile('bukti3')) { - $filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName()); + $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 @@ -142,20 +166,42 @@ class FormUpCountryController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/upcountry/'; - // check if folder not exists - // if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) { - // Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/')); - // } - - // Store files to Nextcloud and collect their paths if ($request->hasFile('bukti1')) { - $filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName()); + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->getContent(), + $filename + ); + } if ($request->hasFile('bukti2')) { - $filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName()); + $bukti2 = $request->file('bukti2'); + $filename = Str::uuid() . '.' . $bukti2->extension(); + + $filePaths['bukti2'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti2->getContent(), + $filename + ); } if ($request->hasFile('bukti3')) { - $filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName()); + $bukti3 = $request->file('bukti3'); + $filename = Str::uuid() . '.' . $bukti3->extension(); + + $filePaths['bukti3'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti3->getContent(), + $filename + ); } // Save the form data diff --git a/app/Http/Controllers/Forms/FormVehicleController.php b/app/Http/Controllers/Forms/FormVehicleController.php index 95812bf..3835042 100644 --- a/app/Http/Controllers/Forms/FormVehicleController.php +++ b/app/Http/Controllers/Forms/FormVehicleController.php @@ -12,6 +12,8 @@ use App\Models\Region; use App\Models\Cabang; use App\Models\UserHasCabang; use App\Models\Kategori; +use App\Helpers\NextCloudHelper; +use Illuminate\Support\Str; class FormVehicleController extends Controller { @@ -56,20 +58,42 @@ class FormVehicleController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle/'; - // check if folder not exists - // if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) { - // Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/')); - // } + if ($request->hasFile('bukti1')) { + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->getContent(), + $filename + ); - // Store files to Nextcloud and collect their paths - if ($request->hasFile('bukti1')) { - $filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName()); } if ($request->hasFile('bukti2')) { - $filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName()); + $bukti2 = $request->file('bukti2'); + $filename = Str::uuid() . '.' . $bukti2->extension(); + + $filePaths['bukti2'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti2->getContent(), + $filename + ); } if ($request->hasFile('bukti3')) { - $filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName()); + $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 @@ -133,20 +157,42 @@ class FormVehicleController extends Controller $filePaths = []; $folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle/'; - // check if folder not exists - // if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) { - // Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/')); - // } - - // Store files to Nextcloud and collect their paths if ($request->hasFile('bukti1')) { - $filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName()); + $bukti1 = $request->file('bukti1'); + $filename = Str::uuid() . '.' . $bukti1->extension(); + + $filePaths['bukti1'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti1->getContent(), + $filename + ); + } if ($request->hasFile('bukti2')) { - $filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName()); + $bukti2 = $request->file('bukti2'); + $filename = Str::uuid() . '.' . $bukti2->extension(); + + $filePaths['bukti2'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti2->getContent(), + $filename + ); } if ($request->hasFile('bukti3')) { - $filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName()); + $bukti3 = $request->file('bukti3'); + $filename = Str::uuid() . '.' . $bukti3->extension(); + + $filePaths['bukti3'] = $folderPath . '/' . $filename; + + NextCloudHelper::uploadFile( + $folderPath, + $bukti3->getContent(), + $filename + ); } // Save the form data diff --git a/app/Models/FormEntertaimentPresentation.php b/app/Models/FormEntertaimentPresentation.php index 02293ea..6aab6aa 100644 --- a/app/Models/FormEntertaimentPresentation.php +++ b/app/Models/FormEntertaimentPresentation.php @@ -26,4 +26,9 @@ class FormEntertaimentPresentation extends Model 'account_number', 'status', ]; + + public function user() + { + return $this->belongsTo('App\Models\Admin'); + } } diff --git a/resources/views/backend/pages/forms/entertainment/create.blade.php b/resources/views/backend/pages/forms/entertainment/create.blade.php new file mode 100644 index 0000000..72d11a1 --- /dev/null +++ b/resources/views/backend/pages/forms/entertainment/create.blade.php @@ -0,0 +1,89 @@ +@extends('layouts.app') + +@section('title') + Dashboard +@endsection + +@section('admin-content') +
+
+
+
+

Tambahkan Expense Entertainment & Presentation

+
+
+ +
+
+
+
+
+
+
+
+
+ @csrf + @include('backend.layouts.partials.messages') +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+@endsection diff --git a/resources/views/backend/pages/forms/entertainment/edit.blade.php b/resources/views/backend/pages/forms/entertainment/edit.blade.php new file mode 100644 index 0000000..768892d --- /dev/null +++ b/resources/views/backend/pages/forms/entertainment/edit.blade.php @@ -0,0 +1,90 @@ +@extends('layouts.app') + +@section('title') + Dashboard +@endsection + +@section('admin-content') +
+
+
+
+

Edit Expense Entertainment & Presentation

+
+
+ +
+
+
+
+
+
+
+
+
+ @csrf + @method('PUT') + @include('backend.layouts.partials.messages') +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+@endsection diff --git a/resources/views/backend/pages/forms/entertainment/index.blade.php b/resources/views/backend/pages/forms/entertainment/index.blade.php new file mode 100644 index 0000000..5c548a3 --- /dev/null +++ b/resources/views/backend/pages/forms/entertainment/index.blade.php @@ -0,0 +1,136 @@ +@extends('layouts.app') + +@section('title') + Dashboard +@endsection + +@section('admin-content') +
+
+
+
+

Forms Entertainment & Presentation

+
+
+ +
+
+
+
+
+
+
+
+

List Data Forms Entertainment & Presentation

+

+ @if (auth()->user()->can('forms.entertainment.create')) + + Add New Expense Entertainment & Presentation + + @endif +

+
+
+ @include('backend.layouts.partials.messages') + + + + + + + + + + + + + + + + + + + + + @php + use App\Helpers\NextCloudHelper; + @endphp + @foreach ($forms as $item) + + + + + + + + + + + + + + + + + @endforeach + +
#NamaTanggalJenisKeteranganTotalNama PenerimaNPWP / NIKBukti 1Bukti 2Bukti 3Account NumberStatusAksi
{{ $loop->iteration }}{{ $item->user->name }}{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}{{ $item->jenis }}{{ $item->keterangan }}{{ number_format($item->total, 0, ',', '.') }}{{ $item->name }}{{ $item->nik_or_npwp }} + @if ($item->bukti1) + + Download + + @else + - + @endif + + @if ($item->bukti2) + + Download + + @else + - + @endif + + @if ($item->bukti3) + + Download + + @else + - + @endif + {{ $item->account_number }} + @if ($item->status == 'On Progress') + {{ $item->status }} + @elseif ($item->status == 'Completed') + {{ $item->status }} + @else + {{ $item->status }} + @endif + + @if (auth()->user()->can('forms.entertainment.edit')) + + + + @endif + + @if (auth()->user()->can('forms.entertainment.delete')) +
+ @csrf + @method('DELETE') + +
+ @endif +
+
+
+
+
+
+@endsection diff --git a/resources/views/backend/pages/forms/upcountry/index.blade.php b/resources/views/backend/pages/forms/upcountry/index.blade.php index 2f8a739..7864948 100644 --- a/resources/views/backend/pages/forms/upcountry/index.blade.php +++ b/resources/views/backend/pages/forms/upcountry/index.blade.php @@ -57,19 +57,46 @@ + @php + use App\Helpers\NextCloudHelper; + @endphp @foreach ($forms as $item) {{ $loop->iteration }} {{ $item->user->name }} {{ $item->rayon->code }} - {{ $item->tanggal }} + {{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }} {{ $item->tujuan }} {{ $item->jarak }} km {{ number_format($item->allowance, 0, ',', '.') }} {{ number_format($item->total, 0, ',', '.') }} - {{ $item->bukti1 }} - {{ $item->bukti2 }} - {{ $item->bukti3 }} + + @if ($item->bukti1) + + Download + + @else + - + @endif + + + @if ($item->bukti2) + + Download + + @else + - + @endif + + + @if ($item->bukti3) + + Download + + @else + - + @endif + {{ $item->account_number }} @if ($item->status == 'On Progress') diff --git a/resources/views/backend/pages/forms/vehicle/index.blade.php b/resources/views/backend/pages/forms/vehicle/index.blade.php index 1fd3170..498f96e 100644 --- a/resources/views/backend/pages/forms/vehicle/index.blade.php +++ b/resources/views/backend/pages/forms/vehicle/index.blade.php @@ -57,19 +57,46 @@ + @php + use App\Helpers\NextCloudHelper; + @endphp @foreach ($forms as $item) {{ $loop->iteration }} {{ $item->user->name }} {{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }} {{ $item->liter }} - {{ $item->harga }} + {{ number_format($item->harga, 0, ',', '.') }} {{ $item->jarak }} {{ $item->tipe_bensin }} {{ $item->nopol }} - {{ $item->bukti1 }} - {{ $item->bukti2 }} - {{ $item->bukti3 }} + + @if ($item->bukti1) + + Download + + @else + - + @endif + + + @if ($item->bukti2) + + Download + + @else + - + @endif + + + @if ($item->bukti3) + + Download + + @else + - + @endif + {{ $item->account_number }} @if ($item->status == 'On Progress') diff --git a/routes/web.php b/routes/web.php index 8f5f568..cf0aab8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,7 +13,9 @@ use App\Http\Controllers\Master\RayonController; use App\Http\Controllers\Master\CostCentreController; use App\Http\Controllers\Master\CategoryController; use App\Http\Controllers\Forms\FormVehicleController; +use App\Http\Controllers\Forms\FormEntertainmentPresentationController; use Illuminate\Support\Facades\Storage; +use App\Helpers\NextCloudHelper; Auth::routes(); @@ -80,6 +82,14 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { 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/destroy/{id}', [FormVehicleController::class, 'destroy'])->name('forms.vehicle.destroy'); + + // Entertainment & Presentation + Route::get('/entertainment-presentation', [FormEntertainmentPresentationController::class, 'index'])->name('forms.entertainment'); + 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'); + Route::put('/entertainment-presentation/update/{id}', [FormEntertainmentPresentationController::class, 'update'])->name('forms.entertainment.update'); + Route::delete('/entertainment-presentation/destroy/{id}', [FormEntertainmentPresentationController::class, 'destroy'])->name('forms.entertainment.destroy'); }); //Menu Role @@ -88,14 +98,10 @@ Route::middleware(['auth:admin', 'menu'])->group(function () { }); Route::get('/test-nextcloud', function () { - $disk = Storage::disk('nextcloud'); - $folderPath = 'test-directory'; - - // Check if directory exists - if (!$disk->exists($folderPath)) { - $disk->makeDirectory($folderPath); - return "Directory created: $folderPath"; - } - - return "Directory already exists: $folderPath"; + $baseUrl = env('NEXT_CLOUD_URL'); + $adminUsername = env('NEXT_CLOUD_USERNAME'); + $adminPassword = env('NEXT_CLOUD_PASSWORD'); + + $response = NextCloudHelper::createFolder($baseUrl, $adminUsername, $adminPassword, 'test-folder'); + dd($response); });