ibnu 1 year ago
parent
commit
202ad4e911
  1. 2
      app/Http/Controllers/CustomerController.php
  2. 108
      app/Http/Controllers/DisposalController.php
  3. 42
      app/Http/Controllers/HomeController.php
  4. 2
      app/Http/Controllers/KondisiPetiController.php
  5. 2
      app/Http/Controllers/M_userController.php
  6. 13
      app/Http/Controllers/PeminjamanController.php
  7. 6
      app/Http/Controllers/PengembalianController.php
  8. 2
      app/Http/Controllers/PetiController.php
  9. 1
      app/Http/Controllers/PetternLotPetiController.php
  10. 2
      app/Http/Controllers/RoleController.php
  11. 6
      app/Http/Controllers/TransferController.php
  12. 2
      app/Http/Controllers/TypePetiController.php
  13. 2
      app/Http/Controllers/WarehouseController.php
  14. 41
      app/Http/Requests/Disposal/ValidasiCreateDisposal.php
  15. 41
      app/Http/Requests/Disposal/ValidasiUpdateDisposal.php
  16. 1
      app/Http/Requests/ValidasiUpdatePengembalian.php
  17. 47
      app/Models/Disposal.php
  18. 1
      app/Models/Transfer.php
  19. 2
      app/Models/asset_status.php
  20. 1
      database/migrations/2023_11_06_085238_create_petis_table.php
  21. 3
      database/migrations/2023_11_06_122033_create_asset_statuses_table.php
  22. 11
      database/migrations/2023_11_08_132316_create_transfers_table.php
  23. 37
      database/migrations/2023_11_17_075418_create_disposals_table.php
  24. 58
      resources/views/dashboard/Disposal/create.blade.php
  25. 125
      resources/views/dashboard/Disposal/edit.blade.php
  26. 47
      resources/views/dashboard/Disposal/index.blade.php
  27. 30
      resources/views/dashboard/Peminjaman/index.blade.php
  28. 2
      resources/views/dashboard/Pengembalian/edit.blade.php
  29. 5
      resources/views/dashboard/Pengembalian/index.blade.php
  30. 10
      resources/views/dashboard/Transfer/create.blade.php
  31. 94
      resources/views/dashboard/index.blade.php
  32. 8
      resources/views/layouts/sidebar.blade.php
  33. 2
      routes/web.php

2
app/Http/Controllers/CustomerController.php

@ -18,7 +18,7 @@ class CustomerController extends Controller
public function index()
{
$data = [
'customer' => Customer::all(),
'customer' => Customer::orderBy('created_at', 'desc')->get(),
'active' => 'menu-customer',
];
return view('dashboard.Master_Data.Customer.index', $data);

108
app/Http/Controllers/DisposalController.php

@ -3,14 +3,21 @@
namespace App\Http\Controllers;
use App\Models\Peti;
use App\Models\Customer;
use App\Models\Disposal;
use App\Models\m_warehouse;
use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\Disposal\ValidasiCreateDisposal;
use App\Http\Requests\Disposal\ValidasiUpdateDisposal;
class DisposalController extends Controller
{
public function index()
{
$data = [
'disposal' => Disposal::orderBy('created_at', 'desc')->get(),
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.index', $data);
@ -25,6 +32,7 @@ class DisposalController extends Controller
$data = [
'peti' => Peti::get(),
'warehouse' => m_warehouse::get(),
'customer' => Customer::get(),
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.create', $data);
@ -33,39 +41,100 @@ class DisposalController extends Controller
/**
* Store a newly created resource in storage.
*/
public function store($request)
public function store(ValidasiCreateDisposal $request)
{
//
// dd($request->all());
// dd($request);
try {
// Mendapatkan informasi pengguna yang sedang login
$currentUser = Auth::user();
// Validasi data dari request
$validatedData = $request->validated();
// Menambahkan informasi pengguna ke dalam data yang akan disimpan
$validatedData['mobile_id'] = Uuid::v4(); // Menambahkan ID Mobile
$validatedData['created_by'] = $currentUser->fullname;
$validatedData['updated_by'] = $currentUser->fullname;
// Membuat entitas Disposal
$disposal = Disposal::create($validatedData);
// Mengupdate warehouse_id pada model Peti
Peti::where('id', $disposal->peti_id)
->update([
'status' => $disposal->status_disposal,
]);
return redirect()->route('dashboard.disposal.index')->with('success', 'Data Disposal Peti berhasil ditambahkan');
} catch (\Throwable $th) {
return redirect()->back()->with('error', 'Data Disposal Peti gagal dimasukan ke disposal');
}
}
/**
* Display the specified resource.
*/
public function show($id)
{
$data = [
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.show', $data);
}
// public function show($id)
// {
// $data = [
// 'active' => 'menu-disposal',
// ];
// return view('dashboard.Disposal.show', $data);
// }
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$jenis_disposal = ['Pemusnaan', 'Perbaikan'];
$data = [
'disposal' => Disposal::findOrFail($id),
'peti' => Peti::get(),
'customer' => Customer::get(),
'warehouse' => m_warehouse::get(),
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.edit', $data);
return view('dashboard.Disposal.edit', compact('jenis_disposal'), $data);
}
/**
* Update the specified resource in storage.
*/
public function update($request, $id)
public function update(ValidasiUpdateDisposal $request, $id)
{
//
// dd("oke");
try {
// Mendapatkan informasi pengguna yang sedang login
$currentUser = Auth::user();
// Validasi data dari request
$validatedData = $request->validated();
// Menambahkan informasi pengguna ke dalam data yang akan disimpan
$validatedData['updated_by'] = $currentUser->fullname;
// Mencari transfer berdasarkan ID
$disposal = Disposal::find($id);
if (!$disposal) {
return redirect()->route('dashboard.disposal.index')->with('error', 'Data Disposal Peti tidak ditemukan');
}
// Memperbarui data transfer
$disposal->update($validatedData);
// Mengupdate warehouse_id pada model Peti
Peti::where('id', $disposal->peti_id)
->update([
'status' => $disposal->status_disposal,
]);
return redirect()->route('dashboard.disposal.index')->with('success', 'Data Disposal Peti berhasil diperbaharui');
} catch (\Throwable $th) {
return redirect()->back()->with('error', 'Data Disposal Peti gagal diperbaharui');
}
}
/**
@ -73,12 +142,13 @@ class DisposalController extends Controller
*/
public function destroy($id)
{
// try {
// $typepeti = Peti::findOrFail($id);
// $typepeti->delete();
// return redirect()->back()->with('success', 'Data peti berhasil dihapus');
// } catch (\Throwable $th) {
// return redirect()->back()->with('error', 'Data peti gagal dihapus');
// }
// dd("oke");
try {
$disposal = Disposal::findOrFail($id);
$disposal->delete();
return redirect()->back()->with('success', 'Data disposal peti berhasil dihapus');
} catch (\Throwable $th) {
return redirect()->back()->with('error', 'Data disposal peti gagal dihapus');
}
}
}

42
app/Http/Controllers/HomeController.php

@ -24,7 +24,6 @@ class HomeController extends Controller
{
$data = [
'reminder' => \App\Models\asset_status::whereNull('enter_at')->count(),
'jumlahAsset' => \App\Models\m_asset::count(),
'jumlahPeminjaman' => \App\Models\asset_status::count(),
'jumlahPengembalian' => \App\Models\asset_status::whereNotNull('enter_at')->count(),
'active' => 'menu-user',
@ -32,6 +31,8 @@ class HomeController extends Controller
return view('pages.user.index', $data);
}
//data pertahun untuk bar chart
public function generateChartData()
{
$years = [];
@ -86,4 +87,43 @@ class HomeController extends Controller
return compact('years', 'exitData', 'enterData', 'monthNames');
}
public function generateChartDataPie()
{
$years = [];
$enterData = [];
$monthNames = [
'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni',
'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'
];
// Ambil data tahun dari kolom date_pembuatan
$enterYears = \App\Models\Peti::selectRaw('YEAR(date_pembuatan) as year')
->distinct()
->orderBy('year', 'asc')
->get()
->pluck('year')
->toArray();
// Gabungkan dan sortir tahun-tahun dari kolom date_pembuatan
$years = array_unique($enterYears);
sort($years);
foreach ($years as $year) {
$yearEnterData = [];
// Ambil data untuk setiap bulan dalam tahun tersebut
foreach ($monthNames as $monthName) {
$enterCount = \App\Models\Peti::whereYear('date_pembuatan', $year)
->whereMonth('date_pembuatan', array_search($monthName, $monthNames) + 1)
->count();
$yearEnterData[] = $enterCount;
}
$enterData[] = $yearEnterData;
}
return compact('years', 'enterData', 'monthNames');
}
}

2
app/Http/Controllers/KondisiPetiController.php

@ -13,7 +13,7 @@ class KondisiPetiController extends Controller
public function index()
{
$data = [
'kondisiPeti' => Kondisi_Peti::all(),
'kondisiPeti' => Kondisi_Peti::orderBy('created_at', 'desc')->get(),
'active' => 'menu-kondisipeti'
];
return view('dashboard.Master_Data.Manajemen_Peti.Kondisi_Peti.index', $data);

2
app/Http/Controllers/M_userController.php

@ -17,9 +17,9 @@ class M_userController extends Controller
public function index()
{
$data = [
'user' => User::orderBy('created_at', 'desc')->get(),
'warehouse' => m_warehouse::get(),
'role' => m_role::get(),
'user' => User::get(),
'active' => 'menu-user',
];
return view('dashboard.Master_Data.User.index', $data);

13
app/Http/Controllers/PeminjamanController.php

@ -5,12 +5,10 @@ namespace App\Http\Controllers;
use App\Http\Requests\ValidasiCreatePeminjaman;
use App\Http\Requests\ValidasiUpdatePeminjaman;
use App\Models\Peti;
use App\Models\m_asset;
use App\Models\m_warehouse;
use App\Models\asset_status;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Symfony\Component\Uid\Uuid;
class PeminjamanController extends Controller
{
@ -22,7 +20,7 @@ class PeminjamanController extends Controller
$data = [
// 'peminjaman' => asset_status::get(),
'peminjaman' => asset_status::get(),
'peminjaman' => asset_status::orderBy('created_at', 'desc')->get(),
'warehouse' => m_warehouse::get(),
'active' => 'menu-peminjaman',
];
@ -39,7 +37,10 @@ class PeminjamanController extends Controller
'peti' => Peti::all(),
'peminjaman' => asset_status::get(),
'warehouse' => m_warehouse::get(),
'peti_block' => Peti::whereNotIn('id', asset_status::pluck('peti_id')->toArray())->get(),
'peti_block' => Peti::whereNotIn('id', asset_status::where('status', 0)->pluck('peti_id')->toArray())
->where('status', 'AKTIF') // Sesuaikan dengan nama kolom yang benar
->get(),
'existingPeti' => asset_status::pluck('peti_id')->toArray(),
'active' => 'menu-peminjaman',
];
@ -56,8 +57,10 @@ class PeminjamanController extends Controller
$validatedData = $request->except('_token');
$validatedData['exit_pic'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai created_by
$validatedData['mobile_id'] = Uuid::v4(); // Menambahkan ID Mobile
$validatedData['created_by'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai created_by
$validatedData['updated_by'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai updated_by
// dd($validatedData);
asset_status::create($validatedData);
return redirect()->route('dashboard.peminjaman.index')->with('success', 'Data peminjaman berhasil ditambah.');

6
app/Http/Controllers/PengembalianController.php

@ -14,7 +14,7 @@ class PengembalianController extends Controller
public function index()
{
$data = [
'peminjaman' => asset_status::all(),
'peminjaman' => asset_status::orderBy('created_at', 'desc')->get(),
'active' => 'menu-pengembalian',
];
return view('dashboard.Pengembalian.index', $data);
@ -76,7 +76,9 @@ class PengembalianController extends Controller
$peminjaman->enter_at = $request->input('enter_at');
$peminjaman->enter_warehouse = $request->input('enter_warehouse');
$peminjaman->kondisi_peti = $request->input('kondisi_peti');
// Mengatur status menjadi 0 secara otomatis
$peminjaman->status = 0;
// dd($peminjaman);
$peminjaman->save();
return redirect()->route('dashboard.pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');

2
app/Http/Controllers/PetiController.php

@ -24,8 +24,8 @@ class PetiController extends Controller
public function index()
{
$data = [
'peti' => Peti::orderBy('created_at', 'desc')->get(),
'kondisiPeti' => Kondisi_Peti::all(),
'peti' => Peti::all(),
'active' => 'menu-peti',
];
return view('dashboard.Master_Data.Manajemen_Peti.Peti.index', $data);

1
app/Http/Controllers/PetternLotPetiController.php

@ -12,6 +12,7 @@ class PetternLotPetiController extends Controller
public function index()
{
$data = [
// 'warehouses' => m_warehouse::orderBy('created_at', 'desc')->get(),
'peti' => Peti::get(),
'active' => 'menu-Pettern_Lot_Peti'
];

2
app/Http/Controllers/RoleController.php

@ -16,7 +16,7 @@ class RoleController extends Controller
public function index()
{
$data = [
'role' => m_role::all(),
'role' => m_role::orderBy('created_at', 'desc')->get(),
'active' => 'menu-role',
];
return view('dashboard.Master_Data.Role.index', $data);

6
app/Http/Controllers/TransferController.php

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\Peti;
use Symfony\Component\Uid\Uuid;
use App\Models\Customer;
use App\Models\Transfer;
use App\Models\m_warehouse;
@ -16,7 +17,7 @@ class TransferController extends Controller
public function index()
{
$data = [
'transfer' => Transfer::all(),
'transfer' => Transfer::orderBy('created_at', 'desc')->get(),
'active' => 'menu-transfer',
];
return view('dashboard.Transfer.index', $data);
@ -50,12 +51,13 @@ class TransferController extends Controller
$validatedData = $request->validated();
// Menambahkan informasi pengguna ke dalam data yang akan disimpan
$validatedData['mobile_id'] = Uuid::v4(); // Menambahkan ID Mobile
$validatedData['created_by'] = $currentUser->fullname;
$validatedData['updated_by'] = $currentUser->fullname;
// Membuat entitas Transfer
$transfer = Transfer::create($validatedData);
// dd($transfer);
// Mengupdate warehouse_id pada model Peti
Peti::where('id', $transfer->peti_id)
->update([

2
app/Http/Controllers/TypePetiController.php

@ -16,7 +16,7 @@ class TypePetiController extends Controller
public function index()
{
$data = [
'typepeti' => Type_peti::all(),
'typepeti' => Type_peti::orderBy('created_at', 'desc')->get(),
'active' => 'menu-typepeti',
];
return view('dashboard.Master_Data.Manajemen_Peti.Type_peti.index', $data);

2
app/Http/Controllers/WarehouseController.php

@ -16,7 +16,7 @@ class WarehouseController extends Controller
public function index()
{
$data = [
'warehouses' => m_warehouse::all(),
'warehouses' => m_warehouse::orderBy('created_at', 'desc')->get(),
'active' => 'menu-warehouse',
];
return view('dashboard.Master_Data.Warehouse.index', $data);

41
app/Http/Requests/Disposal/ValidasiCreateDisposal.php

@ -0,0 +1,41 @@
<?php
namespace App\Http\Requests\Disposal;
use Illuminate\Foundation\Http\FormRequest;
class ValidasiCreateDisposal extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'peti_id' => 'required',
'customer_id' => 'nullable',
'warehouse_id' => 'nullable',
'date_disposal' => 'nullable|date',
'description' => 'nullable|string',
'status_disposal' => 'nullable',
];
}
public function messages(): array
{
return [
'date_disposal.date' => 'Format tanggal disposal tidak valid.',
'description.string' => 'Deskripsi harus berupa teks.',
];
}
}

41
app/Http/Requests/Disposal/ValidasiUpdateDisposal.php

@ -0,0 +1,41 @@
<?php
namespace App\Http\Requests\Disposal;
use Illuminate\Foundation\Http\FormRequest;
class ValidasiUpdateDisposal extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'peti_id' => 'required',
'customer_id' => 'nullable',
'warehouse_id' => 'nullable',
'date_disposal' => 'nullable|date',
'description' => 'nullable|string',
'status_disposal' => 'nullable',
];
}
public function messages(): array
{
return [
'date_disposal.date' => 'Format tanggal disposal tidak valid.',
'description.string' => 'Deskripsi harus berupa teks.',
];
}
}

1
app/Http/Requests/ValidasiUpdatePengembalian.php

@ -29,6 +29,7 @@ class ValidasiUpdatePengembalian extends FormRequest
'enter_at' => 'required|date',
'enter_warehouse' => 'required',
'kondisi_peti' => 'required|string',
'status' => '',
];
}

47
app/Models/Disposal.php

@ -0,0 +1,47 @@
<?php
namespace App\Models;
use App\Traits\UUID;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Disposal extends Model
{
use HasFactory, SoftDeletes, UUID;
protected $table = 'disposals';
protected $fillable = [
'mobile_id',
'peti_id',
'customer_id',
'date_disposal',
'warehouse_id',
'description',
'status_disposal',
'created_by',
'updated_by',
];
public function peti()
{
return $this->belongsTo(Peti::class, 'peti_id')->select(
'id',
'tipe_peti_id',
'customer_id',
'warehouse_id',
'date_pembuatan',
'kondisipeti_id',
'fix_lot',
'updated_by',
);
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id')->select(
'name',
'code_customer',
);
}
}

1
app/Models/Transfer.php

@ -14,6 +14,7 @@ class Transfer extends Model
protected $table = 'transfers';
protected $fillable = [
'mobile_id',
'peti_id',
'source_warehouse',
'destination_warehouse',

2
app/Models/asset_status.php

@ -15,6 +15,7 @@ class asset_status extends Model
protected $table = 'asset_statuses';
protected $fillable = [
'mobile_id',
'peti_id',
'exit_at',
'est_pengembalian',
@ -24,6 +25,7 @@ class asset_status extends Model
'enter_pic',
'enter_warehouse',
'kondisi_peti',
'status',
'created_by',
'updated_by',
];

1
database/migrations/2023_11_06_085238_create_petis_table.php

@ -23,6 +23,7 @@ return new class extends Migration
$table->date('date_pembuatan', 100)->nullable();
$table->foreignUuid('warehouse_id')->nullable()->constrained('m_warehouses')->onDelete('set null');
$table->foreignUuid('kondisipeti_id')->nullable()->constrained('kondisi_petis')->onDelete('set null');
$table->string('status', 50)->default('AKTIF');
$table->timestamps();
$table->softDeletes();
$table->string('created_by', 200)->nullable();

3
database/migrations/2023_11_06_122033_create_asset_statuses_table.php

@ -13,6 +13,7 @@ return new class extends Migration
{
Schema::create('asset_statuses', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('mobile_id')->nullable();
$table->foreignUuid('peti_id')->nullable()->constrained('petis')->onDelete('set null');
$table->date('exit_at')->nullable();
$table->date('est_pengembalian')->nullable();
@ -22,6 +23,8 @@ return new class extends Migration
$table->string('enter_pic', 200)->nullable();
$table->foreignUuid('enter_warehouse')->nullable()->constrained('m_warehouses');
$table->string('kondisi_peti')->nullable();
// $table->string('status')->default('DIPINJAM');
$table->boolean('status')->default(1);
$table->timestamps();
$table->softDeletes();
$table->string('created_by', 200)->nullable();

11
database/migrations/2023_11_08_132316_create_transfers_table.php

@ -13,11 +13,12 @@ return new class extends Migration
{
Schema::create('transfers', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('peti_id')->nullable()->constrained('petis')->onDelete('set null');
$table->foreignUuid('name_customer')->nullable()->constrained('customers');
$table->foreignUuid('source_warehouse')->nullable()->constrained('m_warehouses');
$table->foreignUuid('destination_warehouse')->nullable()->constrained('m_warehouses');
$table->date('date')->nullable();
$table->uuid('mobile_id')->nullable();
$table->foreignUuid('peti_id')->constrained('petis');
$table->foreignUuid('name_customer')->constrained('customers');
$table->foreignUuid('source_warehouse')->constrained('m_warehouses');
$table->foreignUuid('destination_warehouse')->constrained('m_warehouses');
$table->date('date');
$table->timestamps();
$table->softDeletes();
$table->string('created_by', 200)->nullable();

37
database/migrations/2023_11_17_075418_create_disposals_table.php

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('disposals', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('mobile_id')->nullable();
$table->foreignUuid('peti_id')->constrained('petis');
$table->foreignUuid('customer_id')->nullable()->constrained('customers');
$table->foreignUuid('warehouse_id')->nullable()->constrained('m_warehouses');
$table->date('date_disposal');
$table->text('description')->nullable();
$table->string('status_disposal', 50);
$table->timestamps();
$table->softDeletes();
$table->string('created_by', 200)->nullable();
$table->string('updated_by', 200)->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('disposals');
}
};

58
resources/views/dashboard/Disposal/create.blade.php

@ -10,8 +10,8 @@
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.transfer.store') }}" method="POST" enctype="multipart/form-data"
id="transferForm">
<form action="{{ route('dashboard.disposal.store') }}" method="POST" enctype="multipart/form-data"
id="disposalForm">
@csrf
<div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
@ -26,9 +26,38 @@
@endforeach
</select>
<label for="name" class="col-form-label">Customer: <span class="text-danger">*</span></label>
<input class="form-control" name="name" type="text" id="name"
placeholder="Nama Customer akan otomatis terpilih ketika memilih detail peti.">
<label for="customer_id" class="col-form-label">Customer: <span class="text-danger">*</span></label>
<select class="form-control" name="customer_id" type="text" id="customer_id" required>
<option disabled selected>Nama Customer akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($customer as $data_customer)
<option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option>
@endforeach
</select>
<label for="date_disposal" class="col-form-label">Tanggal Disposal: <span
class="text-danger">*</span></label>
<input class="form-control" name="date_disposal" type="date" id="date_disposal"
value="{{ old('date_disposal') }}" required>
<label for="warehouse_id" class="col-form-label">Asal Gudang: <span class="text-danger">*</span></label>
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required>
<option disabled selected>Asal gudang akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
<label for="status_disposal" class="col-form-label">Status Peti: <span
class="text-danger">*</span></label>
<select class="form-control" name="status_disposal" id="status_disposal" required>
<option disabled selected>Pilih Jenis Status Peti</option>
<option value="AKTIF">AKTIF</option>
<option value="INAKTIF">INAKTIF</option>
</select>
<label for="description" class="col-form-label">Alasan Disposal: <span
class="text-danger">*</span></label>
<textarea class="form-control" name="description" id="description" placeholder="Masukan Alasan Disposal" required>{{ old('description') }}</textarea>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.disposal.index') }}" class="btn btn-secondary">Kembali</a>
@ -40,7 +69,7 @@
<!-- auto disable form pada saat sudah di simpan-->
<script>
document.getElementById('transferForm').addEventListener('submit', function() {
document.getElementById('disposalForm').addEventListener('submit', function() {
document.getElementById('submitButton').setAttribute('disabled', 'true');
});
</script>
@ -51,10 +80,10 @@
const petiSelect = document.getElementById('peti_id');
// Mendapatkan elemen select asal gudang
const exitWarehouseSelect = document.getElementById('exit_warehouse');
const warehouseSelect = document.getElementById('warehouse_id');
// Mendapatkan elemen input Customer
const nameInput = document.getElementById('name');
// Mendapatkan elemen select Customer
const customerSelect = document.getElementById('customer_id');
// Menambahkan event listener ke select detail peti
petiSelect.addEventListener('change', function() {
@ -66,10 +95,15 @@
const customerName = selectedOption.getAttribute('data-customer-name');
// Memilih asal gudang berdasarkan data-warehouse-id
exitWarehouseSelect.value = warehouseId;
warehouseSelect.value = warehouseId;
// Mengisi input Customer dengan nama pelanggan
nameInput.value = customerName;
// Memilih customer berdasarkan data-customer-name
for (let i = 0; i < customerSelect.options.length; i++) {
if (customerSelect.options[i].text === customerName) {
customerSelect.selectedIndex = i;
break;
}
}
});
</script>
@endsection

125
resources/views/dashboard/Disposal/edit.blade.php

@ -1,5 +1,128 @@
@extends('layouts.main')
@section('content')
@include('layouts.components.alert-prompt')
<p>Halaman Edit Disposal</p>
@include('layouts.components.alert-prompt')
<div class="card shadow mb-4">
<div class="card-header py-3">
<div class="row">
<div class="col-6">
<h5 class="m-0 font-weight-bold text-primary mt-2">Edit Disposal Peti</h5>
</div>
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.disposal.update', $disposal->id) }}" method="POST" enctype="multipart/form-data"
id="disposalForm">
@csrf
@method('PUT')
<div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
class="text-danger">*</span></label>
<select class="form-control" name="peti_id" type="text" id="peti_id" required>
<option disabled selected>Pilih Detail Peti</option>
@foreach ($peti as $data_peti)
<option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}"
data-customer-name="{{ $data_peti->customer->name }}"
{{ $data_peti->id == $disposal->peti_id ? 'selected' : '' }}>
{{ $data_peti->fix_lot }}
</option>
@endforeach
</select>
<label for="customer_id" class="col-form-label">Customer: <span class="text-danger">*</span></label>
<select class="form-control" name="customer_id" type="text" id="customer_id" required>
<option disabled selected>Pilih Customer</option>
@foreach ($customer as $data_customer)
<option value="{{ $data_customer->id }}"
{{ $data_customer->id == $disposal->customer_id ? 'selected' : '' }}>
{{ $data_customer->name }}
</option>
@endforeach
</select>
<label for="date_disposal" class="col-form-label">Tanggal Disposal: <span
class="text-danger">*</span></label>
<input class="form-control" name="date_disposal" type="date" id="date_disposal"
value="{{ $disposal->date_disposal }}">
<label for="warehouse_id" class="col-form-label">Asal Gudang: <span class="text-danger">*</span></label>
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required>
<option disabled selected>Pilih Asal gudang</option>
@foreach ($warehouse as $data_warehouse)
<option value="{{ $data_warehouse->id }}"
{{ $data_warehouse->id == $disposal->warehouse_id ? 'selected' : '' }}>
{{ $data_warehouse->name }}
</option>
@endforeach
</select>
<label for="description" class="col-form-label">Alasan Disposal: <span
class="text-danger">*</span></label>
<textarea class="form-control" name="description" id="description" placeholder="Masukan Alasan Disposal" required>{{ $disposal->description }}</textarea>
{{-- <label for="status_disposal" class="col-form-label">Status Peti: <span
class="text-danger">*</span></label>
<select class="form-control" name="status_disposal" id="status_disposal">
<option disabled selected>Pilih Jenis Status Peti</option>
<option value="AKTIF">AKTIF</option>
<option value="INAKTIF">INAKTIF</option>
</select> --}}
<label for="status_disposal" class="col-form-label">Status Peti: <span
class="text-danger">*</span></label>
<select class="form-control" name="status_disposal" id="status_disposal">
<option disabled>Pilih Jenis Status Peti</option>
<option value="AKTIF" {{ $disposal->status_disposal === 'AKTIF' ? 'selected' : '' }}>AKTIF
</option>
<option value="INAKTIF" {{ $disposal->status_disposal === 'INAKTIF' ? 'selected' : '' }}>INAKTIF
</option>
</select>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.disposal.index') }}" class="btn btn-secondary">Kembali</a>
<button type="submit" class="btn btn-primary" id="submitButton">Simpan</button>
</div>
</form>
</div>
</div>
<!-- auto disable form pada saat sudah di simpan-->
<script>
document.getElementById('disposalForm').addEventListener('submit', function() {
document.getElementById('submitButton').setAttribute('disabled', 'true');
});
</script>
<!-- otomatis asal gudang dan Customer berdasarkan detail peti -->
<script>
// Mendapatkan elemen select detail peti
const petiSelect = document.getElementById('peti_id');
// Mendapatkan elemen select asal gudang
const warehouseSelect = document.getElementById('warehouse_id');
// Mendapatkan elemen select Customer
const customerSelect = document.getElementById('customer_id');
// Menambahkan event listener ke select detail peti
petiSelect.addEventListener('change', function() {
// Mendapatkan data-warehouse-id dari option yang dipilih
const selectedOption = this.options[this.selectedIndex];
const warehouseId = selectedOption.getAttribute('data-warehouse-id');
// Mendapatkan data-customer-name dari option yang dipilih
const customerName = selectedOption.getAttribute('data-customer-name');
// Memilih asal gudang berdasarkan data-warehouse-id
warehouseSelect.value = warehouseId;
// Memilih customer berdasarkan data-customer-name
for (let i = 0; i < customerSelect.options.length; i++) {
if (customerSelect.options[i].text === customerName) {
customerSelect.selectedIndex = i;
break;
}
}
});
</script>
@endsection

47
resources/views/dashboard/Disposal/index.blade.php

@ -26,7 +26,7 @@
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0">
{{-- <table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0">
<thead>
<tr>
<th class="text-center">No</th>
@ -61,26 +61,37 @@
</form>
</td>
</tr>
{{-- @php
$no_peminjaman = 1;
</tbody>
</table> --}}
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0">
<thead>
<tr>
<th class="text-center">No</th>
<th>Kode Peti</th>
<th>Nama Customer</th>
<th>Tanggal Disposal</th>
<th>Alasan Disposal</th>
<th>Status Peti</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
@php
$nodisposal = 1;
@endphp
@forelse ($peminjaman as $data_peminjaman)
@if ($data_peminjaman->enter_warehouse == null)
@forelse ($disposal as $data_disposal)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->fix_lot }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }}</td>
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td>{{ $nodisposal++ }}</td>
<td>{{ $data_disposal->peti->fix_lot }}</td>
<td>{{ $data_disposal->customer->name }}</td>
<td>{{ \Carbon\Carbon::parse($data_disposal->date_disposal)->format('d/m/Y') }}</td>
<td>{{ $data_disposal->description }}</td>
<td>{{ $data_disposal->status_disposal }}</td>
<td class="text-center">
<a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}"
title="Edit">
<a href="{{ route('dashboard.disposal.edit', $data_disposal->id) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="{{ route('dashboard.peminjaman.destroy', $data_peminjaman->id) }}"
<form action="{{ route('dashboard.disposal.destroy', $data_disposal->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
@ -92,12 +103,12 @@
</form>
</td>
</tr>
@endif
@empty
<p>Data Kosong</p>
@endforelse --}}
@endforelse
</tbody>
</table>
</div>
</div>
</div>

30
resources/views/dashboard/Peminjaman/index.blade.php

@ -57,6 +57,10 @@
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', $data_peminjaman->id) }}"
title="Pengembalian">
<i class="fa fa-reply mr-2" style="font-size: 20px"></i>
</a>
<a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}"
title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
@ -75,32 +79,6 @@
</td>
</tr>
@endif
{{-- <tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->fix_lot }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }}</td>
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td class="text-center">
<a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}"
title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="{{ route('dashboard.peminjaman.destroy', $data_peminjaman->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
<button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
title="Delete" style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button>
</form>
</td>
</tr> --}}
@empty
<p>Data Kosong</p>
@endforelse

2
resources/views/dashboard/Pengembalian/edit.blade.php

@ -62,7 +62,7 @@
pattern="[^0-9]+" oninput="this.value=this.value.replace(/[0-9]/g,'');" required>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.pengembalian.index') }}" class="btn btn-secondary">Kembali</a>
<a href="{{ route('dashboard.peminjaman.index') }}" class="btn btn-secondary">Kembali</a>
<button type="submit" class="btn btn-primary" id="submitButton">Simpan</button>
</div>
</form>

5
resources/views/dashboard/Pengembalian/index.blade.php

@ -40,6 +40,7 @@
$no_peminjaman = 1;
@endphp
@forelse ($peminjaman as $data)
@if ($data->enter_warehouse !== null)
<tr>
<td>{{ $no_peminjaman++ }}</td>
<td>{{ $data->peti->fix_lot }}</td>
@ -84,11 +85,13 @@
@endif
</td>
<td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}" title="Edit">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}"
title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
</td>
</tr>
@endif
@empty
<p>Data Kosong</p>
@endforelse

10
resources/views/dashboard/Transfer/create.blade.php

@ -28,10 +28,11 @@
<label for="date" class="col-form-label">Tanggal Transfer: <span
class="text-danger">*</span></label>
<input class="form-control" name="date" type="date" id="date" value="{{ old('date') }}">
<input class="form-control" name="date" type="date" id="date" value="{{ old('date') }}"
required>
<label for="name_customer" class="col-form-label">Customer: <span class="text-danger">*</span></label>
<select class="form-control" name="name_customer" type="text" id="name_customer">
<select class="form-control" name="name_customer" type="text" id="name_customer" required>
<option disabled selected>Nama Customer akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($customer as $data_customer)
<option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option>
@ -40,15 +41,16 @@
<label for="source_warehouse" class="col-form-label">Asal Gudang: <span
class="text-danger">*</span></label>
<select class="form-control" name="source_warehouse" type="text" id="source_warehouse" disabled>
<select class="form-control" name="source_warehouse" type="text" id="source_warehouse" required>
<option disabled selected>Asal gudang akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
<label for="destination_warehouse" class="col-form-label">Tujuan Gudang: <span
class="text-danger">*</span></label>
<select class="form-control" name="destination_warehouse" type="text">
<select class="form-control" name="destination_warehouse" type="text" required>
<option disabled selected>Pilih Tujuan Gudang</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>

94
resources/views/dashboard/index.blade.php

@ -87,7 +87,7 @@
</div>
<!-- Area Bar Chart -->
<div class="col-xl-7 col-lg-7">
{{-- <div class="col-xl-7 col-lg-7">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6>
@ -105,12 +105,35 @@
@endforeach
</select>
<canvas id="ChartAssetStatus" style="max-height: 500px;"></canvas>
<canvas id="ChartAssetStatus" style="max-height: 600px;"></canvas>
</div>
</div>
</div> --}}
<div class="col-xl-7 col-lg-7">
<div class="card shadow mb-4" style="max-height: 600px;">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6>
</div>
@php
$chartData = app('App\Http\Controllers\HomeController')->generateChartData();
@endphp
<div class="card-body" style="height: 80%;"> <!-- Sesuaikan persentase tinggi konten yang diinginkan -->
<label for="yearFilter">Pilih Tahun:</label>
<select id="yearFilter" class="form-control">
@foreach ($chartData['years'] as $year)
@if ($chartData['exitData'][$loop->index] || $chartData['enterData'][$loop->index])
<option value="{{ $year }}">{{ $year }}</option>
@endif
@endforeach
</select>
<canvas id="ChartAssetStatus" style="width: 100px; height: 68px;"></canvas>
</div>
</div>
</div>
<!-- Area Pie Chart -->
<div class="col-xl-5 col-lg-5">
<div class="card shadow mb-4">
@ -118,46 +141,66 @@
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Grafik Pengadaan Peti</h6>
</div>
<!-- Card Body -->
<div class="card-body">
@php
$chartDataPie = app('App\Http\Controllers\HomeController')->generateChartDataPie();
@endphp
<div class="card-body">
<label for="yearFilter">Pilih Tahun:</label>
<select id="yearFilter" class="form-control">
@foreach ($chartDataPie['years'] as $year)
@if (count($chartDataPie['enterData']) > 0 && $chartDataPie['enterData'][$loop->index])
<option value="{{ $year }}">{{ $year }}</option>
@endif
@endforeach
</select>
<canvas id="myPieChartsiopas"></canvas>
</div>
</div>
</div>
</div>
</div>
@push('script')
<!-- script pie chart -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Sample data for the pie chart
var data = {
labels: ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober",
"November", "Desember"
],
datasets: [{
data: [30, 40, 30, 25, 35, 45, 20, 30, 40, 50, 30, 20],
backgroundColor: ["#4e73df", "#1cc88a", "#36b9cc", "#ff6384", "#ff9f40", "#9966ff", "#cc65fe",
"#ffcc29", "#a4e56d", "#ff3d00", "#9c9c9c", "#0d47a1"
],
}]
};
// Function to update the pie chart based on selected year
function updatePieChart(selectedYear) {
// Call the controller function to get data for the selected year
var chartData = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!};
var yearIndex = chartData.years.indexOf(selectedYear);
// Update the pie chart data
myPieChart.data.datasets[0].data = chartData.enterData[yearIndex];
myPieChart.update();
}
// Initial chart data
var initialChartData = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!};
// Get the canvas element for the pie chart
var ctx = document.getElementById("myPieChartsiopas").getContext('2d');
// Create the pie chart instance
// Create the initial pie chart instance
var myPieChart = new Chart(ctx, {
type: 'pie',
data: data,
data: {
labels: initialChartData.monthNames,
datasets: [{
data: initialChartData.enterData[0],
backgroundColor: ["#4e73df", "#1cc88a", "#36b9cc", "#ff6384", "#ff9f40", "#9966ff",
"#cc65fe",
"#ffcc29", "#a4e56d", "#ff3d00", "#9c9c9c", "#0d47a1"
],
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'right', // Set the legend position to the right
maxHeight: 200, // Set a maximum height for the legend
position: 'right',
maxHeight: 200,
},
tooltip: {
callbacks: {
@ -166,7 +209,7 @@
if (label) {
label += ' : ';
}
label += Math.round(context.parsed * 1) + '%';
label += Math.round(context.parsed * 1) + ' Peti';
return label;
}
}
@ -177,8 +220,15 @@
// Custom legend using legendCallback
document.getElementById('chart-legend').innerHTML = myPieChart.generateLegend();
// Event listener for year filter change
document.getElementById('yearFilter').addEventListener('change', function() {
var selectedYear = this.value;
updatePieChart(selectedYear);
});
</script>
<!-- script bar chart -->
<script>
document.addEventListener('DOMContentLoaded', function() {

8
resources/views/layouts/sidebar.blade.php

@ -82,7 +82,7 @@
<li class="nav-item">
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTwo"
aria-expanded="{{ $isUserActive ? 'true' : 'false' }}" aria-controls="collapseTwo">
<i class="fas fa-fw fa-user"></i>
<i class="fas fa-fw fa-users"></i>
<span>Manajemen User</span>
</a>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
@ -96,7 +96,7 @@
</li>
<li class="nav-item {{ $active == 'menu-customer' ? 'active' : '' }}">
<a class="nav-link" href="{{ route('dashboard.customer.index') }}">
<i class="fas fa-fw fa-users"></i>
<i class="fas fa-fw fa-user"></i>
<span>Customer</span>
</a>
</li>
@ -107,7 +107,7 @@
<li class="nav-item">
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapsepeti"
aria-expanded="{{ $isPetiActive ? 'true' : 'false' }}" aria-controls="collapsepeti">
<i class="fas fa-fw fa-user"></i>
<i class="fas fa-fw fa-box"></i>
<span>Manajemen Peti</span>
</a>
<div id="collapsepeti" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
@ -124,7 +124,7 @@
</li>
<li class="nav-item {{ $active == 'menu-warehouse' ? 'active' : '' }}">
<a class="nav-link" href="{{ route('dashboard.warehouse.index') }}">
<i class="fas fa-fw fa-table"></i>
<i class="fas fa-fw fa-warehouse"></i>
<span>Warehouse</span>
</a>
</li>

2
routes/web.php

@ -96,7 +96,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::get('disposal', 'index')->name('disposal.index');
Route::get('disposal/create', 'create')->name('disposal.create');
Route::post('disposal/store', 'store')->name('disposal.store');
Route::get('disposal/{id}', 'show')->name('disposal.show');
// Route::get('disposal/{id}', 'show')->name('disposal.show');
Route::get('disposal/{id}/edit', 'edit')->name('disposal.edit');
Route::put('disposal/{id}', 'update')->name('disposal.update');
Route::delete('disposal/delete/{id}', 'destroy')->name('disposal.destroy');

Loading…
Cancel
Save