Browse Source

update peminjaman peti

master
Gunawan19621 1 year ago
parent
commit
405d2f90f7
  1. 12
      app/Http/Controllers/PeminjamanController.php
  2. 90
      app/Http/Controllers/PetiController.php
  3. 25
      app/Models/asset_status.php
  4. 10
      database/migrations/2023_10_29_122033_create_asset_statuses_table.php
  5. BIN
      public/assets/img/Picture ISTW.jpg
  6. 71
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/label_pdf.blade.php
  7. 13
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php
  8. 45
      resources/views/dashboard/Peminjaman/create.blade.php
  9. 27
      resources/views/dashboard/Peminjaman/index.blade.php
  10. 19
      routes/web.php

12
app/Http/Controllers/PeminjamanController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Peti;
use App\Models\m_asset; use App\Models\m_asset;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use App\Models\asset_status; use App\Models\asset_status;
@ -33,6 +34,7 @@ class PeminjamanController extends Controller
public function create() public function create()
{ {
$data = [ $data = [
'peti' => Peti::all(),
'asset' => m_asset::all(), 'asset' => m_asset::all(),
'peminjaman' => asset_status::get(), 'peminjaman' => asset_status::get(),
'warehouse' => m_warehouse::get(), 'warehouse' => m_warehouse::get(),
@ -47,10 +49,11 @@ class PeminjamanController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
// dd('oke'); // dd('oke');
// dd($request->all());
$request->validate([ $request->validate([
'asset_id' => 'required', 'peti_id' => 'required',
'exit_at' => 'required', 'exit_at' => 'required',
'exit_pic' => 'required', 'est_pengembalian' => 'required',
'exit_warehouse' => 'required', 'exit_warehouse' => 'required',
]); ]);
// dd($request); // dd($request);
@ -58,8 +61,9 @@ class PeminjamanController extends Controller
$currentUser = Auth::user(); $currentUser = Auth::user();
$validatedData = $request->except('_token'); $validatedData = $request->except('_token');
$validatedData['created_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai created_by $validatedData['exit_pic'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai created_by
$validatedData['updated_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai updated_by $validatedData['created_by'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai created_by
$validatedData['updated_by'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai updated_by
// dd($validatedData); // dd($validatedData);
asset_status::create($validatedData); asset_status::create($validatedData);
return redirect()->route('dashboard.peminjaman.index')->with('success', 'Data peminjaman berhasil ditambah.'); return redirect()->route('dashboard.peminjaman.index')->with('success', 'Data peminjaman berhasil ditambah.');

90
app/Http/Controllers/PetiController.php

@ -2,13 +2,16 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Customer; use Dompdf\Dompdf;
use App\Models\m_warehouse; use Dompdf\Options;
use App\Models\Peti; use App\Models\Peti;
use App\Models\Customer;
use App\Models\Type_peti; use App\Models\Type_peti;
use Mockery\Matcher\Type;
use App\Models\m_warehouse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Mockery\Matcher\Type; use SimpleSoftwareIO\QrCode\Facades\QrCode;
class PetiController extends Controller class PetiController extends Controller
{ {
@ -102,7 +105,35 @@ class PetiController extends Controller
'warehouse' => m_warehouse::all(), 'warehouse' => m_warehouse::all(),
'active' => 'menu-peti', 'active' => 'menu-peti',
]; ];
return view('dashboard.Master_Data.Manajemen_Peti.Peti.show', $data);
$petiqr = Peti::find($id);
$qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate(
'Nama Customer : ' .
$petiqr->customer->name .
"\n" .
'Code Customer : ' .
$petiqr->customer->code_customer .
"\n" .
'Type Peti : ' .
$petiqr->tipe_peti->type .
"\n" .
'Warehouse : ' .
$petiqr->warehouse->name .
"\n" .
'Ukuran Peti : ' .
$petiqr->tipe_peti->size_peti .
"\n" .
'Lot Number : ' .
$petiqr->customer->lot_no .
"\n" .
'Paking Number : ' .
$petiqr->packing_no .
"\n" .
'Status Peti : ' .
$petiqr->status_disposal
));
return view('dashboard.Master_Data.Manajemen_Peti.Peti.show', compact('qrcode'), $data);
} }
/** /**
@ -179,4 +210,55 @@ class PetiController extends Controller
return redirect()->back()->with('error', 'Data peti gagal dihapus'); return redirect()->back()->with('error', 'Data peti gagal dihapus');
} }
} }
public function cetakPdf($id)
{
$peti = Peti::find($id);
// Generate QR Code
$qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate(
'Nama Customer : ' .
$peti->customer->name .
"\n" .
'Code Customer : ' .
$peti->customer->code_customer .
"\n" .
'Type Peti : ' .
$peti->tipe_peti->type .
"\n" .
'Warehouse : ' .
$peti->warehouse->name .
"\n" .
'Ukuran Peti : ' .
$peti->tipe_peti->size_peti .
"\n" .
'Lot Number : ' .
$peti->customer->lot_no .
"\n" .
'Paking Number : ' .
$peti->packing_no .
"\n" .
'Status Peti : ' .
$peti->status_disposal
));
// Inisialisasi Dompdf
$options = new Options();
$options->set('isHtml5ParserEnabled', true);
$options->set('isPhpEnabled', true);
$dompdf = new Dompdf($options);
// Load HTML dari view
$html = view('dashboard.Master_Data.Manajemen_Peti.Peti.label_pdf', compact('peti', 'qrcode'))->render();
// Load HTML ke Dompdf
$dompdf->loadHtml($html);
// Render PDF (portrait A4)
$dompdf->setPaper('A4', 'horizontal');
$dompdf->render();
// Menggunakan stream untuk menghasilkan dan mengunduh PDF
return $dompdf->stream('Label_Peti.pdf');
}
} }

25
app/Models/asset_status.php

@ -11,13 +11,15 @@ class asset_status extends Model
protected $table = 'asset_statuses'; protected $table = 'asset_statuses';
protected $fillable = [ protected $fillable = [
'asset_id', 'peti_id', //sudah
'exit_at', 'exit_at', //sudah
'exit_pic', 'est_pengembalian', //sudah
'exit_warehouse', 'exit_pic', //sudah
'exit_warehouse', //sudah
'enter_at', 'enter_at',
'enter_pic', 'enter_pic',
'enter_warehouse', 'enter_warehouse',
'kondisi_peti',
'created_by', 'created_by',
'updated_by', 'updated_by',
]; ];
@ -31,4 +33,19 @@ class asset_status extends Model
{ {
return $this->belongsTo(m_warehouse::class, 'exit_warehouse'); return $this->belongsTo(m_warehouse::class, 'exit_warehouse');
} }
public function peti()
{
return $this->belongsTo(Peti::class, 'peti_id');
}
public function tipe_peti()
{
return $this->belongsTo(Type_peti::class, 'type');
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id');
}
} }

10
database/migrations/2023_10_23_122033_create_asset_statuses_table.php → database/migrations/2023_10_29_122033_create_asset_statuses_table.php

@ -13,14 +13,16 @@ return new class extends Migration
{ {
Schema::create('asset_statuses', function (Blueprint $table) { Schema::create('asset_statuses', function (Blueprint $table) {
$table->id(); $table->id();
$table->bigInteger('asset_id')->unsigned()->nullable(); $table->bigInteger('peti_id')->unsigned()->nullable();
$table->foreign('asset_id')->references('id')->on('m_assets')->onDelete('set null'); $table->foreign('peti_id')->references('id')->on('petis')->onDelete('set null');
$table->datetime('exit_at')->nullable(); $table->date('exit_at')->nullable();
$table->date('est_pengembalian')->nullable();
$table->string('exit_pic', 200)->nullable(); $table->string('exit_pic', 200)->nullable();
$table->bigInteger('exit_warehouse')->unsigned()->nullable(); $table->bigInteger('exit_warehouse')->unsigned()->nullable();
$table->datetime('enter_at')->nullable(); $table->date('enter_at')->nullable();
$table->string('enter_pic', 200)->nullable(); $table->string('enter_pic', 200)->nullable();
$table->bigInteger('enter_warehouse')->unsigned()->nullable(); $table->bigInteger('enter_warehouse')->unsigned()->nullable();
$table->string('kondisi_peti')->nullable();
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->string('created_by', 200)->nullable(); $table->string('created_by', 200)->nullable();

BIN
public/assets/img/Picture ISTW.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

71
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/label_pdf.blade.php

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<title>Data PDF</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
}
th,
td {
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Data Peti</h1>
<table style="width:100%" class="table table-bordered">
<tr>
<td rowspan="2">
<img src="data:image/jpeg;base64,<?= base64_encode(file_get_contents('assets/img/Picture ISTW.jpg')) ?>"
alt="Logo ISTW" width="100" height="100">
</td>
<td>PETI NUMBER</td>
<td>BARCODE</td>
</tr>
<tr>
<td>
{{ $peti->fix_lot }}
</td>
<td rowspan="4">
<img src="data:image/svg+xml;base64,{{ $qrcode }}" alt="QR Code" />
</td>
</tr>
<tr>
<td>PT. {{ $peti->created_by }}</td>
<td>CUSTOMER</td>
</tr>
<tr>
<td>QTY PETI</td>
<td rowspan="2">PT. {{ $peti->customer->name }}</td>
</tr>
<tr>
<td>1</td>
</tr>
</table>
</body>
</html>

13
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php

@ -32,9 +32,11 @@
<input class="form-control" value="{{ \Carbon\Carbon::parse($peti->date_pembuatan)->format('d/m/Y') }}" <input class="form-control" value="{{ \Carbon\Carbon::parse($peti->date_pembuatan)->format('d/m/Y') }}"
readonly> readonly>
<label for="fix_lot" class="col-form-label">QR Code:</label> <div class="col-md-3">
<div> <label for="fix_lot" class="col-form-label d-flex justify-content-center align-items-center">QR
{!! QrCode::size(75)->generate( Code:</label>
<div class="d-flex justify-content-center align-items-center mb-2">
{!! QrCode::size(150)->generate(
'Nama Customer : ' . 'Nama Customer : ' .
$peti->customer->name . $peti->customer->name .
"\n" . "\n" .
@ -60,6 +62,11 @@
$peti->status_disposal, $peti->status_disposal,
) !!} ) !!}
</div> </div>
<div class="d-flex justify-content-center mt-2 mb-3">
<a href="{{ route('dashboard.peticetakpdf.cetakpdf', $peti->id) }}" class="btn btn-info">Cetak
Label</a>
</div>
</div>
<div class="modal-footer d-flex justify-content-center"> <div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.peti.index') }}" class="btn btn-secondary">Kembali</a> <a href="{{ route('dashboard.peti.index') }}" class="btn btn-secondary">Kembali</a>
</div> </div>

45
resources/views/dashboard/Peminjaman/create.blade.php

@ -13,21 +13,29 @@
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data"> <form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data">
@csrf @csrf
<div class="form-group"> <div class="form-group">
<label for="asset_id" class="col-form-label">Nama Asset:</label> {{-- <label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="asset_id" type="text" id="asset_id"> <select class="form-control" name="peti_id" type="text" id="peti_id">
<option disabled selected>Pilih Nama Asset</option> <option disabled selected>Pilih Detail Peti</option>
@foreach ($asset as $data) @foreach ($peti as $data_peti)
<option value="{{ $data->id }}">{{ $data->name }}</option> <option value="{{ $data_peti->id }}">{{ $data_peti->fix_lot }}</option>
@endforeach
</select> --}}
<label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="peti_id" type="text" id="peti_id">
<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_peti->fix_lot }}
</option>
@endforeach @endforeach
</select> </select>
<label for="exit_at" class="col-form-label">Tanggal:</label> <label for="exit_at" class="col-form-label">Tanggal Peminjaman:</label>
<input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}" <input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}"
placeholder="Masukan Tanggal Keluar" required> placeholder="Masukan Tanggal Peminjaman" required>
<label for="exit_pic" class="col-form-label">PJ Keluar:</label> <label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
<input class="form-control" name="exit_pic" type="text" id="exit_pic" value="{{ old('exit_pic') }}" <input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
placeholder="Masukan Nama PJ Keluar" pattern="[^0-9]+" value="{{ old('est_pengembalian') }}" placeholder="Masukan Estimasi Tanggal Peminjaman" required>
oninput="this.value=this.value.replace(/[0-9]/g,'');" required>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label> <label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse"> <select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse">
@ -44,4 +52,19 @@
</form> </form>
</div> </div>
</div> </div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const petiSelect = document.getElementById('peti_id');
const exitWarehouseSelect = document.getElementById('exit_warehouse');
// Saat pilihan Detail Peti berubah
petiSelect.addEventListener('change', function() {
const selectedOption = petiSelect.options[petiSelect.selectedIndex];
const warehouseId = selectedOption.getAttribute('data-warehouse-id');
// Atur nilai pilihan Asal Gudang sesuai dengan data peti yang dipilih
exitWarehouseSelect.value = warehouseId;
});
});
</script>
@endsection @endsection

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

@ -21,27 +21,30 @@
<thead> <thead>
<tr> <tr>
<th class="text-center">No</th> <th class="text-center">No</th>
<th>Nama Asset</th> <th>Kode Peti</th>
<th>Nama Customer</th>
<th>Tgl Peminjaman</th> <th>Tgl Peminjaman</th>
<th>PJ Keluar</th> <th>PJ Keluar</th>
<th>Asal Gudang</th> <th>Asal Gudang</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tfoot>
<tr>
<th class="text-center">No</th>
<th>Nama Asset</th>
<th>Tgl Peminjaman</th>
<th>PJ Keluar</th>
<th>Asal Gudang</th>
<th class="text-center">Action</th>
</tr>
</tfoot>
<tbody> <tbody>
@php @php
$no_peminjaman = 1; $no_peminjaman = 1;
@endphp @endphp
@forelse ($peminjaman as $data_peminjaman)
<tr>
<td>{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->exit_at }}</td>
</tr>
@empty
<p>Data Kosong</p>
@endforelse
{{--
@foreach ($peminjaman as $data) @foreach ($peminjaman as $data)
<tr> <tr>
<td class="text-center">{{ $no_peminjaman++ }}</td> <td class="text-center">{{ $no_peminjaman++ }}</td>
@ -65,7 +68,7 @@
</form> </form>
</td> </td>
</tr> </tr>
@endforeach @endforeach --}}
</tbody> </tbody>
</table> </table>
</div> </div>

19
routes/web.php

@ -60,15 +60,15 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
}); });
//Halaman Asset //Halaman Asset
Route::controller(M_assetController::class)->group(function () { // Route::controller(M_assetController::class)->group(function () {
Route::get('asset', 'index')->name('asset.index'); // Route::get('asset', 'index')->name('asset.index');
Route::post('asset/store', 'store')->name('asset.store'); // Route::post('asset/store', 'store')->name('asset.store');
Route::get('asset/{id}', 'show')->name('asset.show'); // Route::get('asset/{id}', 'show')->name('asset.show');
Route::put('asset/{id}', 'update')->name('asset.update'); // Route::put('asset/{id}', 'update')->name('asset.update');
Route::delete('asset/delete/{id}', 'destroy')->name('asset.destroy'); // Route::delete('asset/delete/{id}', 'destroy')->name('asset.destroy');
Route::get('/assetcetak_pdf', [M_assetController::class, 'cetakpdf'])->name('assetcetakpdf.cetakpdf'); // Route::get('/assetcetak_pdf', [M_assetController::class, 'cetakpdf'])->name('assetcetakpdf.cetakpdf');
Route::get('/assetexport', [M_assetController::class, 'export'])->name('assetexport.export'); // Route::get('/assetexport', [M_assetController::class, 'export'])->name('assetexport.export');
}); // });
//Halaman User //Halaman User
Route::controller(M_userController::class)->group(function () { Route::controller(M_userController::class)->group(function () {
@ -133,6 +133,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::get('peti/{id}/edit', 'edit')->name('peti.edit'); Route::get('peti/{id}/edit', 'edit')->name('peti.edit');
Route::put('peti/{id}', 'update')->name('peti.update'); Route::put('peti/{id}', 'update')->name('peti.update');
Route::delete('peti/delete/{id}', 'destroy')->name('peti.destroy'); Route::delete('peti/delete/{id}', 'destroy')->name('peti.destroy');
Route::get('peticetak_pdf/{id}', 'cetakpdf')->name('peticetakpdf.cetakpdf');
}); });
}); });

Loading…
Cancel
Save