From 13a390e0dcd67d7d088a306f8d8a58eb06530cce Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Thu, 5 Oct 2023 10:33:42 +0700 Subject: [PATCH] update revisi tampilan --- app/Http/Controllers/M_assetController.php | 7 +- app/Http/Controllers/M_userController.php | 25 ----- app/Http/Controllers/PeminjamanController.php | 7 +- .../Controllers/PengembalianController.php | 34 +++++- app/Http/Controllers/WarehouseController.php | 21 ++++ app/Models/asset_status.php | 5 + ...09_20_163615_create_m_warehouses_table.php | 4 +- ..._20_163641_create_asset_statuses_table.php | 8 +- resources/views/MasterData/asset.blade.php | 8 -- .../views/MasterData/warehouse.blade.php | 46 +++++++- .../views/dashboard/peminjaman.blade.php | 54 +++++++-- .../views/dashboard/pengembalian.blade.php | 82 ++------------ .../dashboard/update_pengembalian.blade.php | 31 ++++-- resources/views/login.blade.php | 103 ------------------ 14 files changed, 190 insertions(+), 245 deletions(-) delete mode 100644 resources/views/login.blade.php diff --git a/app/Http/Controllers/M_assetController.php b/app/Http/Controllers/M_assetController.php index 469029f..9e2e019 100644 --- a/app/Http/Controllers/M_assetController.php +++ b/app/Http/Controllers/M_assetController.php @@ -177,11 +177,14 @@ class M_assetController extends Controller $dompdf->render(); // Tampilkan PDF di browser - return $dompdf->stream('Laporan Barang'); + return $dompdf->stream('Laporan Assets'); } + /** + * Cetak Exel. + */ public function export() { - return Excel::download(new AssetExport, 'Assets.xlsx'); + return Excel::download(new AssetExport, 'Laporan Assets.xlsx'); } } diff --git a/app/Http/Controllers/M_userController.php b/app/Http/Controllers/M_userController.php index 42ac86f..473c7f7 100644 --- a/app/Http/Controllers/M_userController.php +++ b/app/Http/Controllers/M_userController.php @@ -33,30 +33,6 @@ class M_userController extends Controller /** * Store a newly created resource in storage. */ - // public function store(Request $request) - // { - // $request->validate([ - // 'username' => 'required', - // 'fullname' => 'required', - // 'email' => 'required|email', - // 'divisi' => 'required', - // 'role_id' => 'required', - // 'warehouse_id' => 'required', - // 'password' => 'required', - // ]); - - // try { - // $currentUser = Auth::user(); - // $validatedData = $request->except('_token'); - // $validatedData['created_by'] = $currentUser->name; // Menggunakan nama pengguna sebagai created_by - // $validatedData['updated_by'] = $currentUser->name; // Menggunakan nama pengguna sebagai updated_by - // $validatedData['password'] = bcrypt($request->input('password')); // Enkripsi password - // user::create($validatedData); - // return redirect()->back()->with('success', 'Data User Berhasil Ditambah.'); - // } catch (\Throwable $th) { - // return redirect()->back()->with('error', 'Data User Gagal Ditambah.'); - // } - // } public function store(Request $request) { $request->validate([ @@ -126,7 +102,6 @@ class M_userController extends Controller $userData['updated_by'] = Auth::user()->fullname; $user->update($userData); - return redirect()->route('user.index')->with('success', 'Data User berhasil diperbaharui'); } catch (\Throwable $th) { return redirect()->back()->with('error', 'Data User gagal diperbaharui'); diff --git a/app/Http/Controllers/PeminjamanController.php b/app/Http/Controllers/PeminjamanController.php index dbc364e..136584c 100644 --- a/app/Http/Controllers/PeminjamanController.php +++ b/app/Http/Controllers/PeminjamanController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\asset_status; use App\Models\m_asset; +use App\Models\m_warehouse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -16,7 +17,8 @@ class PeminjamanController extends Controller { $asset = m_asset::all(); $peminjaman = asset_status::get(); - return view('dashboard.peminjaman', compact('asset', 'peminjaman')); + $warehouse = m_warehouse::get(); + return view('dashboard.peminjaman', compact('asset', 'peminjaman', 'warehouse')); } /** @@ -86,8 +88,7 @@ class PeminjamanController extends Controller // dd($request); try { $peminjaman = asset_status::findOrFail($id); - // dd($peminjaman); - // dd($request->all()); + $peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by $peminjaman->update($request->all()); return redirect()->back()->with('success', 'Data peminjaman berhasil diperbaharui'); } catch (\Throwable $th) { diff --git a/app/Http/Controllers/PengembalianController.php b/app/Http/Controllers/PengembalianController.php index 68e1c5e..75e1038 100644 --- a/app/Http/Controllers/PengembalianController.php +++ b/app/Http/Controllers/PengembalianController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\asset_status; use App\Models\m_asset; +use App\Models\m_warehouse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -37,8 +38,9 @@ class PengembalianController extends Controller */ public function show($id) { + $warehouse = m_warehouse::get(); $peminjaman = asset_status::findOrFail($id); - return view('dashboard.update_pengembalian', compact('peminjaman')); + return view('dashboard.update_pengembalian', compact('peminjaman', 'warehouse')); } /** @@ -55,20 +57,18 @@ class PengembalianController extends Controller public function update(Request $request, $id) { // dd('oke'); + // dd($request->all()); $request->validate([ 'asset_id' => 'required', 'exit_at' => 'required', 'exit_pic' => 'required', - 'exit_warehouse' => 'required', 'enter_at' => 'required', 'enter_pic' => 'required', 'enter_warehouse' => 'required', ]); - // dd($request); try { $peminjaman = asset_status::findOrFail($id); - // dd($peminjaman); - // dd($request->all()); + $peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by $peminjaman->update($request->all()); return redirect()->route('pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui'); } catch (\Throwable $th) { @@ -76,6 +76,30 @@ class PengembalianController extends Controller return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui'); } } + // public function update(Request $request, $id) + // { + // // dd('oke'); + // $request->validate([ + // 'asset_id' => 'required', + // 'exit_at' => 'required', + // 'exit_pic' => 'required', + // 'exit_warehouse' => 'required', + // 'enter_at' => 'required', + // 'enter_pic' => 'required', + // 'enter_warehouse' => 'required', + // ]); + // // dd($request); + // try { + // $peminjaman = asset_status::findOrFail($id); + // // dd($peminjaman); + // // dd($request->all()); + // $peminjaman->update($request->all()); + // return redirect()->route('pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui'); + // } catch (\Throwable $th) { + // // dd($th->getMessage()); + // return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui'); + // } + // } /** * Remove the specified resource from storage. diff --git a/app/Http/Controllers/WarehouseController.php b/app/Http/Controllers/WarehouseController.php index 60d45b5..3a7b51d 100644 --- a/app/Http/Controllers/WarehouseController.php +++ b/app/Http/Controllers/WarehouseController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\m_warehouse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class WarehouseController extends Controller { @@ -36,7 +37,10 @@ class WarehouseController extends Controller 'address' => 'required', ]); try { + $currentUser = Auth::user(); $validatedData = $request->except('_token'); + $validatedData['created_by'] = $currentUser->fullname; // Menggunakan nama pengguna sebagai created_by + $validatedData['updated_by'] = $currentUser->fullname; // Menggunakan nama pengguna sebagai updated_by m_warehouse::create($validatedData); return redirect()->back()->with('success', 'Data gudang berhasil ditambah.'); } catch (\Throwable $th) { @@ -67,6 +71,23 @@ class WarehouseController extends Controller public function update(Request $request, $id) { // dd('oke'); + $request->validate([ + 'name' => 'required', + 'description' => 'required', + 'address' => 'required', + ]); + // dd($request); + try { + $warehouse = m_warehouse::findOrFail($id); + $warehouse->update($request->all()); + + // Menambahkan nama pengguna yang melakukan pembaruan + $userData['updated_by'] = Auth::user()->fullname; + + return redirect()->back()->with('success', 'Data Gudang Berhasil Diperbaharui'); + } catch (\Throwable $th) { + return redirect()->back()->with('error', 'Data Gudang Gagal Diperbaharui'); + } } /** diff --git a/app/Models/asset_status.php b/app/Models/asset_status.php index ae8a4e0..98868f1 100644 --- a/app/Models/asset_status.php +++ b/app/Models/asset_status.php @@ -14,4 +14,9 @@ class asset_status extends Model { return $this->belongsTo(m_asset::class, 'asset_id'); } + + public function warehouse() + { + return $this->belongsTo(m_warehouse::class, 'exit_warehouse'); + } } diff --git a/database/migrations/2023_09_20_163615_create_m_warehouses_table.php b/database/migrations/2023_09_20_163615_create_m_warehouses_table.php index d73426b..f539621 100644 --- a/database/migrations/2023_09_20_163615_create_m_warehouses_table.php +++ b/database/migrations/2023_09_20_163615_create_m_warehouses_table.php @@ -19,8 +19,8 @@ return new class extends Migration $table->text('address')->nullable(); $table->timestamps(); $table->softDeletes(); - $table->string('created_by', 200)->nullable()->default('System'); - $table->string('updated_by', 200)->nullable()->default('System'); + $table->string('created_by', 200)->nullable(); + $table->string('updated_by', 200)->nullable(); }); DB::table('m_warehouses')->insert([ diff --git a/database/migrations/2023_09_20_163641_create_asset_statuses_table.php b/database/migrations/2023_09_20_163641_create_asset_statuses_table.php index aaf3e5d..d3a2634 100644 --- a/database/migrations/2023_09_20_163641_create_asset_statuses_table.php +++ b/database/migrations/2023_09_20_163641_create_asset_statuses_table.php @@ -17,10 +17,14 @@ return new class extends Migration $table->foreign('asset_id')->references('id')->on('m_assets')->onDelete('cascade'); $table->datetime('exit_at'); $table->string('exit_pic', 200); - $table->string('exit_warehouse', 200); + // $table->string('exit_warehouse', 200); + $table->bigInteger('exit_warehouse')->unsigned()->nullable(); + $table->foreign('exit_warehouse')->references('id')->on('m_warehouses')->onDelete('cascade'); $table->datetime('enter_at')->nullable(); $table->string('enter_pic', 200)->nullable(); - $table->string('enter_warehouse', 200)->nullable(); + // $table->string('enter_warehouse', 200)->nullable(); + $table->bigInteger('enter_warehouse')->unsigned()->nullable(); + $table->foreign('enter_warehouse')->references('id')->on('m_warehouses')->onDelete('cascade'); $table->timestamps(); $table->softDeletes(); $table->string('created_by', 200); diff --git a/resources/views/MasterData/asset.blade.php b/resources/views/MasterData/asset.blade.php index 37938ee..1549e5e 100644 --- a/resources/views/MasterData/asset.blade.php +++ b/resources/views/MasterData/asset.blade.php @@ -2,14 +2,6 @@ @section('title', 'Setting Platform') @section('content')
-
diff --git a/resources/views/MasterData/warehouse.blade.php b/resources/views/MasterData/warehouse.blade.php index 5ad2752..4bdec07 100644 --- a/resources/views/MasterData/warehouse.blade.php +++ b/resources/views/MasterData/warehouse.blade.php @@ -2,7 +2,6 @@ @section('title', 'Update Data User') @section('content')
- {{--

Halaman management warehouse

--}}
@@ -14,13 +13,13 @@ data-target="#tambahDataModal"> + Tambah data - Cetak PDF - Cetak Exel + Cetak Exel --}}
@@ -76,7 +75,7 @@
- +
+ + + @foreach ($warehouses as $data) + + @endforeach @endsection diff --git a/resources/views/dashboard/peminjaman.blade.php b/resources/views/dashboard/peminjaman.blade.php index d70f38e..3b73237 100644 --- a/resources/views/dashboard/peminjaman.blade.php +++ b/resources/views/dashboard/peminjaman.blade.php @@ -5,16 +5,34 @@
-
Data Peminjaman
+
+
+
Data Peminjaman
+
+ +
- + - + @@ -22,9 +40,9 @@ - + - + @@ -36,11 +54,11 @@ @endphp @foreach ($peminjaman as $data) - + - + - - + + - - + + @@ -28,11 +28,11 @@ - - + + - - + + @@ -48,7 +48,7 @@ - +
NoNo Nama AssetTgl KeluarTgl Peminjaman PJ Keluar Asal Gudang Action
NoNo Nama AssetTgl KeluarTgl Peminjaman PJ Keluar Asal Gudang Action
{{ $no_peminjaman++ }}{{ $no_peminjaman++ }} {{ $data->asset->name }} {{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }} {{ $data->exit_pic }}{{ $data->exit_warehouse }}{{ $data->warehouse->name }} @@ -93,9 +111,15 @@ oninput="this.value=this.value.replace(/[0-9]/g,'');" required> - + + @foreach ($warehouse as $data) + + @endforeach + + {{-- + required> --}}
No Nama AssetTgl KeluarPJ KeluarTgl PeinjamanPJ Peinjaman Asal GudangTgl MasukPJ MasukTgl PengembalianPJ Pengembalian Tujuan Gudang Status Action
No Nama AssetTgl KeluarPJ KeluarTgl PeinjamanPJ Peinjaman Asal GudangTgl MasukPJ MasukTgl PengembalianPJ Pengembalian Tujuan Gudang Status Action{{ $data->asset->name }} {{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }} {{ $data->exit_pic }}{{ $data->exit_warehouse }}{{ $data->warehouse->name }} @if ($data->enter_at) {{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }} @@ -65,7 +65,7 @@ @if ($data->enter_warehouse) - {{ $data->enter_warehouse }} + {{ $data->warehouse->name }} @else

-

@endif @@ -91,64 +91,4 @@ - - - {{-- @foreach ($peminjaman as $data) - - @endforeach --}} @endsection diff --git a/resources/views/dashboard/update_pengembalian.blade.php b/resources/views/dashboard/update_pengembalian.blade.php index 1116074..5b6e385 100644 --- a/resources/views/dashboard/update_pengembalian.blade.php +++ b/resources/views/dashboard/update_pengembalian.blade.php @@ -27,13 +27,22 @@ value="{{ $peminjaman->exit_pic }}" placeholder="Masukan Nama PJ Keluar" readonly required> - + {{-- --}} + + + {{-- --}} - {{-- --}} @@ -44,9 +53,15 @@ pattern="[^0-9]+" oninput="this.value=this.value.replace(/[0-9]/g,'');" required> - +