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. 61
      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;
use App\Models\Peti;
use App\Models\m_asset;
use App\Models\m_warehouse;
use App\Models\asset_status;
@ -33,6 +34,7 @@ class PeminjamanController extends Controller
public function create()
{
$data = [
'peti' => Peti::all(),
'asset' => m_asset::all(),
'peminjaman' => asset_status::get(),
'warehouse' => m_warehouse::get(),
@ -47,10 +49,11 @@ class PeminjamanController extends Controller
public function store(Request $request)
{
// dd('oke');
// dd($request->all());
$request->validate([
'asset_id' => 'required',
'peti_id' => 'required',
'exit_at' => 'required',
'exit_pic' => 'required',
'est_pengembalian' => 'required',
'exit_warehouse' => 'required',
]);
// dd($request);
@ -58,8 +61,9 @@ class PeminjamanController extends Controller
$currentUser = Auth::user();
$validatedData = $request->except('_token');
$validatedData['created_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai created_by
$validatedData['updated_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai updated_by
$validatedData['exit_pic'] = $currentUser->fullname; // Menambahkan ID pengguna sebagai created_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);
asset_status::create($validatedData);
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;
use App\Models\Customer;
use App\Models\m_warehouse;
use Dompdf\Dompdf;
use Dompdf\Options;
use App\Models\Peti;
use App\Models\Customer;
use App\Models\Type_peti;
use Mockery\Matcher\Type;
use App\Models\m_warehouse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Mockery\Matcher\Type;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class PetiController extends Controller
{
@ -102,7 +105,35 @@ class PetiController extends Controller
'warehouse' => m_warehouse::all(),
'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');
}
}
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 $fillable = [
'asset_id',
'exit_at',
'exit_pic',
'exit_warehouse',
'peti_id', //sudah
'exit_at', //sudah
'est_pengembalian', //sudah
'exit_pic', //sudah
'exit_warehouse', //sudah
'enter_at',
'enter_pic',
'enter_warehouse',
'kondisi_peti',
'created_by',
'updated_by',
];
@ -31,4 +33,19 @@ class asset_status extends Model
{
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) {
$table->id();
$table->bigInteger('asset_id')->unsigned()->nullable();
$table->foreign('asset_id')->references('id')->on('m_assets')->onDelete('set null');
$table->datetime('exit_at')->nullable();
$table->bigInteger('peti_id')->unsigned()->nullable();
$table->foreign('peti_id')->references('id')->on('petis')->onDelete('set null');
$table->date('exit_at')->nullable();
$table->date('est_pengembalian')->nullable();
$table->string('exit_pic', 200)->nullable();
$table->bigInteger('exit_warehouse')->unsigned()->nullable();
$table->datetime('enter_at')->nullable();
$table->date('enter_at')->nullable();
$table->string('enter_pic', 200)->nullable();
$table->bigInteger('enter_warehouse')->unsigned()->nullable();
$table->string('kondisi_peti')->nullable();
$table->timestamps();
$table->softDeletes();
$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>

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

@ -32,33 +32,40 @@
<input class="form-control" value="{{ \Carbon\Carbon::parse($peti->date_pembuatan)->format('d/m/Y') }}"
readonly>
<label for="fix_lot" class="col-form-label">QR Code:</label>
<div>
{!! QrCode::size(75)->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,
) !!}
<div class="col-md-3">
<label for="fix_lot" class="col-form-label d-flex justify-content-center align-items-center">QR
Code:</label>
<div class="d-flex justify-content-center align-items-center mb-2">
{!! QrCode::size(150)->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,
) !!}
</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">
<a href="{{ route('dashboard.peti.index') }}" class="btn btn-secondary">Kembali</a>

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

@ -13,21 +13,29 @@
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label for="asset_id" class="col-form-label">Nama Asset:</label>
<select class="form-control" name="asset_id" type="text" id="asset_id">
<option disabled selected>Pilih Nama Asset</option>
@foreach ($asset as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
{{-- <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_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
</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') }}"
placeholder="Masukan Tanggal Keluar" required>
placeholder="Masukan Tanggal Peminjaman" required>
<label for="exit_pic" class="col-form-label">PJ Keluar:</label>
<input class="form-control" name="exit_pic" type="text" id="exit_pic" value="{{ old('exit_pic') }}"
placeholder="Masukan Nama PJ Keluar" pattern="[^0-9]+"
oninput="this.value=this.value.replace(/[0-9]/g,'');" required>
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
value="{{ old('est_pengembalian') }}" placeholder="Masukan Estimasi Tanggal Peminjaman" required>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse">
@ -44,4 +52,19 @@
</form>
</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

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

@ -21,27 +21,30 @@
<thead>
<tr>
<th class="text-center">No</th>
<th>Nama Asset</th>
<th>Kode Peti</th>
<th>Nama Customer</th>
<th>Tgl Peminjaman</th>
<th>PJ Keluar</th>
<th>Asal Gudang</th>
<th class="text-center">Action</th>
</tr>
</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>
@php
$no_peminjaman = 1;
@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)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
@ -65,7 +68,7 @@
</form>
</td>
</tr>
@endforeach
@endforeach --}}
</tbody>
</table>
</div>

19
routes/web.php

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

Loading…
Cancel
Save