From 88733e66e763f41604271b32a84f2569aad08ee4 Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Wed, 6 Dec 2023 08:19:52 +0700 Subject: [PATCH] tambah fitur hapus bulk peti --- app/Http/Controllers/PetiController.php | 38 ++-- .../Manajemen_Peti/Peti/index.blade.php | 164 ++++++------------ routes/web.php | 1 + 3 files changed, 71 insertions(+), 132 deletions(-) diff --git a/app/Http/Controllers/PetiController.php b/app/Http/Controllers/PetiController.php index d69a6ca..dc9fbef 100644 --- a/app/Http/Controllers/PetiController.php +++ b/app/Http/Controllers/PetiController.php @@ -322,31 +322,6 @@ class PetiController extends Controller ); } - // public function importPeti(Request $request) - // { - // $import = new PetiImport; - // Excel::import($import, request()->file('file')); - - // // Cek apakah ada data yang berhasil diimpor - // if ($import->getRowCount() > 0) { - // return redirect()->route('dashboard.peti.index')->with('success', 'Data Peti berhasil diimport'); - // } else { - // $errors = $import->getErrors(); - - // if ($errors) { - // foreach ($errors as $error) { - // foreach ($error->all() as $message) { - // // Tampilkan pesan kesalahan untuk setiap baris - // // Simpan pesan flash dengan kategori 'error' - // session()->flash('error', $message); - // } - // } - // } - - // // Redirect back with import data and error message - // return redirect()->back()->with('import', $import)->with('error', 'Data Import Peti gagal di import.'); - // } - // } public function importPeti(Request $request) { $import = new PetiImport; @@ -373,4 +348,17 @@ class PetiController extends Controller } } } + + public function deleteSelected(Request $request) + { + $petiIds = $request->input('peti_ids'); + + if (!empty($petiIds)) { + Peti::destroy($petiIds); + + return response()->json(['message' => 'Data peti terpilih berhasil dihapus.']); + } else { + return response()->json(['error' => 'Tidak ada data peti terpilih untuk dihapus.'], 400); + } + } } diff --git a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php index 9491c42..be785a8 100644 --- a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php +++ b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php @@ -20,21 +20,26 @@
Data Peti
- - Tambah Peti - -
-
- @csrf - - -
+ +
+ +
- - Import Peti -
@@ -173,99 +178,6 @@ - - - {{--
-
-
-
-
Data Peti
-
-
- - Tambah Peti - -
-
- @csrf - - -
-
- - Import Customer - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - @php - $i = 1; - @endphp - @forelse ($peti as $data_peti) - - - - - - - - - - - - - - - - - @empty - @endforelse - -
NoFix LotUserCustomerWHKode CustomerTipe PetiUkuran PetiLot NoKondisi PetiPacking NoStatusAction
{{ $i++ }}{{ $data_peti->fix_lot }}{{ $data_peti->created_by }}{{ $data_peti->customer->name }}{{ $data_peti->warehouse->name }}{{ $data_peti->customer->code_customer }}{{ $data_peti->tipe_peti->type }}{{ $data_peti->tipe_peti->size_peti }}{{ $data_peti->customer->lot_no }}{{ $data_peti->kondisipeti->nama_kondisi }}{{ $data_peti->packing_no }}{{ $data_peti->status }} - - - - - - -
- @csrf - @method('DELETE') - -
-
-
-
-
--}} @elseif (auth()->user()->role_id == 2) @include('pages.user.Master_Data.Manajemen_Peti.Peti.index') @endif @@ -308,6 +220,7 @@ + diff --git a/routes/web.php b/routes/web.php index 25ab97e..c6ca23f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -184,6 +184,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func Route::get('peticetak_pdf/{id}', 'cetakPdf')->name('peticetakpdf.cetakpdf'); Route::get('all-cetak/peti', 'AllPdf')->name('all-pdf.cetakpdf'); Route::post('peti/import', 'importPeti')->name('peti.import'); + Route::post('peti/delete-selected', 'deleteSelected')->name('peti.delete-selected'); });