Gunawan19621
1 year ago
16 changed files with 490 additions and 151 deletions
@ -0,0 +1,85 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\m_warehouse; |
||||
use App\Models\Peti; |
||||
use App\Models\Transfer; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class TransferController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
$data = [ |
||||
'peminjaman' => Transfer::all(), |
||||
'active' => 'menu-transfer', |
||||
]; |
||||
return view('dashboard.Transfer.index', $data); |
||||
} |
||||
|
||||
/** |
||||
* Show the form for creating a new resource. |
||||
*/ |
||||
public function create() |
||||
{ |
||||
$data = [ |
||||
'peti' => Peti::get(), |
||||
// 'warehouse' => Peti::with('warehouse_id')->get(), |
||||
'warehouse' => m_warehouse::get(), |
||||
'active' => 'menu-transfer', |
||||
]; |
||||
return view('dashboard.Transfer.create', $data); |
||||
} |
||||
|
||||
/** |
||||
* Store a newly created resource in storage. |
||||
*/ |
||||
public function store($request) |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* Display the specified resource. |
||||
*/ |
||||
public function show($id) |
||||
{ |
||||
$data = [ |
||||
'active' => 'menu-transfer', |
||||
]; |
||||
return view('dashboard.Transfer.show', $data); |
||||
} |
||||
|
||||
/** |
||||
* Show the form for editing the specified resource. |
||||
*/ |
||||
public function edit($id) |
||||
{ |
||||
$data = [ |
||||
'active' => 'menu-transfer', |
||||
]; |
||||
return view('dashboard.Transfer.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'); |
||||
// } |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use App\Models\Peti; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Illuminate\Database\Eloquent\SoftDeletes; |
||||
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||
|
||||
class Transfer extends Model |
||||
{ |
||||
use HasFactory, SoftDeletes; |
||||
protected $table = 'petis'; |
||||
|
||||
protected $fillable = [ |
||||
'peti_id', |
||||
'tanggal', |
||||
'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', |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
<?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('transfers', function (Blueprint $table) { |
||||
$table->id(); |
||||
$table->bigInteger('peti_id')->unsigned()->nullable(); |
||||
$table->foreign('peti_id')->references('id')->on('petis')->onDelete('set null'); |
||||
$table->date('tanggal')->nullable(); |
||||
$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('transfers'); |
||||
} |
||||
}; |
@ -0,0 +1,97 @@
|
||||
@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">Transfer 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="tanggal" class="col-form-label">Tanggal Transfer: <span |
||||
class="text-danger">*</span></label> |
||||
<input class="form-control" name="tanggal" type="date" id="tanggal" value="{{ old('tanggal') }}" |
||||
required> |
||||
|
||||
<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="exit_warehouse" class="col-form-label">Asal Gudang: <span |
||||
class="text-danger">*</span></label> |
||||
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse" required> |
||||
<option disabled selected>Pilih Asal Gudang</option> |
||||
@foreach ($warehouse as $data) |
||||
<option value="{{ $data->id }}">{{ $data->name }}</option> |
||||
@endforeach |
||||
</select> |
||||
<label for="exit_warehouse" class="col-form-label">Tujuan Gudang: <span |
||||
class="text-danger">*</span></label> |
||||
<select class="form-control" name="exit_warehouse" type="text" id="" required> |
||||
<option disabled selected>Pilih Tujuan Gudang</option> |
||||
@foreach ($warehouse as $data) |
||||
<option value="{{ $data->id }}">{{ $data->name }}</option> |
||||
@endforeach |
||||
</select> |
||||
</div> |
||||
<div class="modal-footer d-flex justify-content-center"> |
||||
<a href="{{ route('dashboard.transfer.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 |
@ -0,0 +1,5 @@
|
||||
@extends('layouts.main') |
||||
@section('content') |
||||
@include('layouts.components.alert-prompt') |
||||
<p>Halaman edit transfer</p> |
||||
@endsection |
@ -0,0 +1,83 @@
|
||||
@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 Transfer</h5> |
||||
</div> |
||||
<div class="col-6 text-right"> |
||||
<a href="{{ route('dashboard.transfer.create') }}" class="btn btn-success btn-icon-split"> |
||||
<span class="text">Transfer 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>Kode</th> |
||||
<th>Tgl Peminjaman</th> |
||||
<th>PJ Peminjaman</th> |
||||
<th>Asal Gudang</th> |
||||
<th class="text-center">Action</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{{-- @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 |
@ -0,0 +1,5 @@
|
||||
@extends('layouts.main') |
||||
@section('content') |
||||
@include('layouts.components.alert-prompt') |
||||
<p>Halaman show transfer</p> |
||||
@endsection |
Loading…
Reference in new issue