Browse Source

update id_incre

master
Gunawan19621 1 year ago
parent
commit
89d915f377
  1. 84
      app/Http/Controllers/DisposalController.php
  2. 4
      app/Http/Controllers/PetiController.php
  3. 37
      app/Http/Requests/ValidasiCreatePeti.php
  4. 1
      app/Models/Peti.php
  5. 1
      database/migrations/2023_11_06_085238_create_petis_table.php
  6. 75
      resources/views/dashboard/Disposal/create.blade.php
  7. 5
      resources/views/dashboard/Disposal/edit.blade.php
  8. 104
      resources/views/dashboard/Disposal/index.blade.php
  9. 5
      resources/views/dashboard/Disposal/show.blade.php
  10. 27
      resources/views/dashboard/Transfer/index.blade.php
  11. 2
      resources/views/layouts/sidebar.blade.php
  12. 12
      routes/web.php

84
app/Http/Controllers/DisposalController.php

@ -0,0 +1,84 @@
<?php
namespace App\Http\Controllers;
use App\Models\Peti;
use App\Models\m_warehouse;
use Illuminate\Http\Request;
class DisposalController extends Controller
{
public function index()
{
$data = [
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data = [
'peti' => Peti::get(),
'warehouse' => m_warehouse::get(),
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store($request)
{
//
}
/**
* Display the specified resource.
*/
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)
{
$data = [
'active' => 'menu-disposal',
];
return view('dashboard.Disposal.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update($request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
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');
// }
}
}

4
app/Http/Controllers/PetiController.php

@ -76,6 +76,10 @@ class PetiController extends Controller
$validatedData['created_by'] = $currenttype->fullname; // Menggunakan nama pengguna sebagai created_by $validatedData['created_by'] = $currenttype->fullname; // Menggunakan nama pengguna sebagai created_by
$validatedData['updated_by'] = $currenttype->fullname; // Menggunakan nama pengguna sebagai updated_by $validatedData['updated_by'] = $currenttype->fullname; // Menggunakan nama pengguna sebagai updated_by
// Ambil nomor urutan otomatis untuk id_incre
$nextIdIncre = Peti::max('id_incre') + 1;
$validatedData['id_incre'] = $nextIdIncre;
// Buat entri peti baru // Buat entri peti baru
Peti::create($validatedData); Peti::create($validatedData);
} }

37
app/Http/Requests/ValidasiCreatePeti.php

@ -22,6 +22,7 @@ class ValidasiCreatePeti extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'id_incre' => 'integer',
'tipe_peti_id' => 'required|exists:type_petis,id', 'tipe_peti_id' => 'required|exists:type_petis,id',
'warna' => 'required|string|max:50', 'warna' => 'required|string|max:50',
'customer_id' => 'required|exists:customers,id', 'customer_id' => 'required|exists:customers,id',
@ -37,23 +38,25 @@ class ValidasiCreatePeti extends FormRequest
public function messages() public function messages()
{ {
return [ return [
'tipe_peti_id.required' => 'Tipe Peti harus diisi', 'id_incre.integer' => 'ID Incre harus berupa angka!',
'tipe_peti_id.exists' => 'Tipe Peti tidak ditemukan', 'tipe_peti_id.required' => 'Tipe Peti tidak boleh kosong!',
'warna.required' => 'Warna harus diisi', 'tipe_peti_id.exists' => 'Tipe Peti tidak ditemukan!',
'warna.string' => 'Warna harus berupa string', 'warna.required' => 'Warna tidak boleh kosong!',
'warna.max' => 'Warna maksimal 50 karakter', 'warna.string' => 'Warna harus berupa string!',
'customer_id.required' => 'Customer harus diisi', 'warna.max' => 'Warna maksimal 50 karakter!',
'customer_id.exists' => 'Customer tidak ditemukan', 'customer_id.required' => 'Customer tidak boleh kosong!',
'warehouse_id.required' => 'Warehouse harus diisi', 'customer_id.exists' => 'Customer tidak ditemukan!',
'warehouse_id.exists' => 'Warehouse tidak ditemukan', 'warehouse_id.required' => 'Warehouse tidak boleh kosong!',
'jumlah.required' => 'Jumlah harus diisi', 'warehouse_id.exists' => 'Warehouse tidak ditemukan!',
'jumlah.numeric' => 'Jumlah harus berupa angka', 'jumlah.required' => 'Jumlah tidak boleh kosong!',
'jumlah.min' => 'Jumlah minimal 1', 'jumlah.numeric' => 'Jumlah harus berupa angka!',
'date_pembuatan.required' => 'Tanggal Pembuatan harus diisi', 'jumlah.min' => 'Jumlah minimal 1!',
'date_pembuatan.date' => 'Tanggal Pembuatan harus berupa tanggal', 'date_pembuatan.required' => 'Tanggal Pembuatan tidak boleh kosong!',
'packing_no.integer' => 'Packing No harus berupa angka', 'date_pembuatan.date' => 'Tanggal Pembuatan harus berupa tanggal!',
'fix_lot.string' => 'Fix Lot harus berupa string', 'kondisipeti_id.required' => 'Kondisi Peti tidak boleh kosong!',
'fix_lot.max' => 'Fix Lot maksimal 100 karakter', 'packing_no.integer' => 'Packing No harus berupa angka!',
'fix_lot.string' => 'Fix Lot harus berupa string!',
'fix_lot.max' => 'Fix Lot maksimal 100 karakter!',
]; ];
} }
} }

1
app/Models/Peti.php

@ -16,6 +16,7 @@ class Peti extends Model
protected $table = 'petis'; protected $table = 'petis';
protected $fillable = [ protected $fillable = [
'id_incre',
'tipe_peti_id', 'tipe_peti_id',
'warna', 'warna',
'customer_id', 'customer_id',

1
database/migrations/2023_11_06_085238_create_petis_table.php

@ -13,6 +13,7 @@ return new class extends Migration
{ {
Schema::create('petis', function (Blueprint $table) { Schema::create('petis', function (Blueprint $table) {
$table->uuid('id')->primary(); $table->uuid('id')->primary();
$table->bigInteger('id_incre')->default(1)->unsigned();
$table->foreignUuid('tipe_peti_id')->nullable()->constrained('type_petis')->onDelete('set null'); $table->foreignUuid('tipe_peti_id')->nullable()->constrained('type_petis')->onDelete('set null');
$table->string('warna', 50); $table->string('warna', 50);
$table->string('fix_lot', 100); $table->string('fix_lot', 100);

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

@ -0,0 +1,75 @@
@extends('layouts.main')
@section('content')
@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">Disposal Peti</h5>
</div>
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.transfer.store') }}" method="POST" enctype="multipart/form-data"
id="transferForm">
@csrf
<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->fix_lot }}
</option>
@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.">
</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('transferForm').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 exitWarehouseSelect = document.getElementById('exit_warehouse');
// Mendapatkan elemen input Customer
const nameInput = document.getElementById('name');
// 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
exitWarehouseSelect.value = warehouseId;
// Mengisi input Customer dengan nama pelanggan
nameInput.value = customerName;
});
</script>
@endsection

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

@ -0,0 +1,5 @@
@extends('layouts.main')
@section('content')
@include('layouts.components.alert-prompt')
<p>Halaman Edit Disposal</p>
@endsection

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

@ -0,0 +1,104 @@
@extends('layouts.main')
@section('content')
<style>
.table th {
white-space: nowrap;
}
.table td {
white-space: nowrap;
}
</style>
@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">Data Disposal</h5>
</div>
<div class="col-6 text-right">
<a href="{{ route('dashboard.disposal.create') }}" class="btn btn-success btn-icon-split">
<span class="text">Disposal Peti</span>
</a>
</a>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<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>Tgl Transfer</th>
<th>Asal Gudang</th>
<th>Tujuan Gudang</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>kode dari Peti</td>
<td>Gunawan</td>
<td>13-11-2023</td>
<td>Gudang A</td>
<td>Gudang B</td>
<td class="text-center">
<a href="#" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="#" 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>
{{-- @php
$no_peminjaman = 1;
@endphp
@forelse ($peminjaman as $data_peminjaman)
@if ($data_peminjaman->enter_warehouse == null)
<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>
@endif
@empty
<p>Data Kosong</p>
@endforelse --}}
</tbody>
</table>
</div>
</div>
</div>
@endsection

5
resources/views/dashboard/Disposal/show.blade.php

@ -0,0 +1,5 @@
@extends('layouts.main')
@section('content')
@include('layouts.components.alert-prompt')
<p>Halaman Show Disposal</p>
@endsection

27
resources/views/dashboard/Transfer/index.blade.php

@ -32,14 +32,35 @@
<th class="text-center">No</th> <th class="text-center">No</th>
<th>Kode Peti</th> <th>Kode Peti</th>
<th>Nama Customer</th> <th>Nama Customer</th>
<th>Kode</th> <th>Tgl Transfer</th>
<th>Tgl Peminjaman</th>
<th>PJ Peminjaman</th>
<th>Asal Gudang</th> <th>Asal Gudang</th>
<th>Tujuan Gudang</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td>1</td>
<td>kode dari Peti</td>
<td>Gunawan</td>
<td>13-11-2023</td>
<td>Gudang A</td>
<td>Gudang B</td>
<td class="text-center">
<a href="#" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="#" 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>
{{-- @php {{-- @php
$no_peminjaman = 1; $no_peminjaman = 1;
@endphp @endphp

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

@ -43,7 +43,7 @@
</a> </a>
</li> </li>
<li class="nav-item {{ $active == 'menu-disposal' ? 'active' : '' }}"> <li class="nav-item {{ $active == 'menu-disposal' ? 'active' : '' }}">
<a class="nav-link" href="#"> <a class="nav-link" href="{{ route('dashboard.disposal.index') }}">
<i class="fas fa-fw fa-trash"></i> <i class="fas fa-fw fa-trash"></i>
<span>Disposal</span> <span>Disposal</span>
</a> </a>

12
routes/web.php

@ -7,6 +7,7 @@ use App\Http\Controllers\M_userController;
use App\Http\Controllers\M_assetController; use App\Http\Controllers\M_assetController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\CustomerController; use App\Http\Controllers\CustomerController;
use App\Http\Controllers\DisposalController;
use App\Http\Controllers\TransferController; use App\Http\Controllers\TransferController;
use App\Http\Controllers\TypePetiController; use App\Http\Controllers\TypePetiController;
use App\Http\Controllers\WarehouseController; use App\Http\Controllers\WarehouseController;
@ -79,6 +80,16 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::delete('transfer/delete/{id}', 'destroy')->name('transfer.destroy'); Route::delete('transfer/delete/{id}', 'destroy')->name('transfer.destroy');
}); });
//Halaman Disposal
Route::controller(DisposalController::class)->group(function () {
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}/edit', 'edit')->name('disposal.edit');
Route::put('disposal/{id}', 'update')->name('disposal.update');
Route::delete('disposal/delete/{id}', 'destroy')->name('disposal.destroy');
});
//Halaman User //Halaman User
Route::controller(M_userController::class)->group(function () { Route::controller(M_userController::class)->group(function () {
@ -112,6 +123,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::post('customers/import', 'importCustomer')->name('customer.import'); Route::post('customers/import', 'importCustomer')->name('customer.import');
}); });
//Halaman Kondisi Peti
Route::controller(KondisiPetiController::class)->group(function () { Route::controller(KondisiPetiController::class)->group(function () {
Route::get('kondisipeti', 'index')->name('kondisipeti.index'); Route::get('kondisipeti', 'index')->name('kondisipeti.index');
// Route::get('kondisipeti/create', 'create')->name('kondisipeti.create'); // Route::get('kondisipeti/create', 'create')->name('kondisipeti.create');

Loading…
Cancel
Save