From f606d46ba576627a2e1b74f0f911ca7309678959 Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Thu, 2 Nov 2023 22:21:49 +0700 Subject: [PATCH] update QR --- app/Exports/PetternLotPetiExport.php | 60 +++++++++++++++ app/Http/Controllers/HomeController.php | 52 ++++++++++--- app/Http/Controllers/PetiController.php | 71 ++---------------- .../Controllers/PetternLotPetiController.php | 25 +++++++ .../Manajemen_Peti/Peti/show.blade.php | 35 +-------- .../Manajemen_Peti/Type_peti/create.blade.php | 2 +- .../Manajemen_Peti/Type_peti/edit.blade.php | 2 +- .../Report/PATTERN LOT PETI/index.blade.php | 73 +++++++++++++++++++ resources/views/dashboard/index.blade.php | 73 +++++++++++++------ resources/views/layouts/sidebar.blade.php | 12 ++- routes/web.php | 61 +++++++++------- 11 files changed, 303 insertions(+), 163 deletions(-) create mode 100644 app/Exports/PetternLotPetiExport.php create mode 100644 app/Http/Controllers/PetternLotPetiController.php create mode 100644 resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php diff --git a/app/Exports/PetternLotPetiExport.php b/app/Exports/PetternLotPetiExport.php new file mode 100644 index 0000000..c42a468 --- /dev/null +++ b/app/Exports/PetternLotPetiExport.php @@ -0,0 +1,60 @@ +get(); + + // Inisialisasi nomor awal + $nomor = 1; + + // Modifikasi data dan tambahkan nomor + $data = $petis->map(function ($peti) use (&$nomor) { + return [ + 'No' => $nomor++, + 'User' => 'ISTW', + 'Customer' => $peti->customer->name, + 'Warehouse' => $peti->warehouse->name, + 'CODE CUSTOMER' => $peti->customer->code_customer, + 'TYPE PETI' => $peti->tipe_peti->type, + 'UKURAN PETI' => $peti->tipe_peti->size_peti, + 'LOT NO' => $peti->customer->lot_no, + 'PACKING NO' => $peti->packing_no, + 'FIX LOT' => $peti->fix_lot, + ]; + }); + + return $data; + } + + public function headings(): array + { + return [ + 'No', + 'User', + 'Customer', + 'WH', + 'CODE CUSTOMER', + 'TYPE PETI', + 'UKURAN PETI', + 'LOT NO', + 'PACKING NO', + 'FIX LOT', + ]; + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index bc607e0..f6a32ad 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -12,7 +12,7 @@ class HomeController extends Controller { $data = [ 'reminder' => \App\Models\asset_status::whereNull('enter_at')->count(), - 'jumlahAsset' => \App\Models\m_asset::count(), + 'jumlahPeti' => \App\Models\Peti::count(), 'jumlahPeminjaman' => \App\Models\asset_status::count(), 'jumlahPengembalian' => \App\Models\asset_status::whereNotNull('enter_at')->count(), 'active' => 'menu-admin', @@ -32,28 +32,58 @@ class HomeController extends Controller return view('pages.user.index', $data); } - public function generateChartData() { - $months = []; + $years = []; $exitData = []; $enterData = []; - $monthNames = [ 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember' ]; - for ($i = 1; $i <= 12; $i++) { - $months[] = date("F", mktime(0, 0, 0, $i, 1)); + // Ambil data tahun dari kolom exit_at + $exitYears = \App\Models\asset_status::selectRaw('YEAR(exit_at) as year') + ->distinct() + ->orderBy('year', 'asc') + ->get() + ->pluck('year') + ->toArray(); + + // Ambil data tahun dari kolom enter_at + $enterYears = \App\Models\asset_status::selectRaw('YEAR(enter_at) as year') + ->distinct() + ->orderBy('year', 'asc') + ->get() + ->pluck('year') + ->toArray(); + + // Gabungkan dan sortir tahun-tahun dari kedua kolom + $years = array_merge($exitYears, $enterYears); + $years = array_unique($years); + sort($years); + + foreach ($years as $year) { + $yearExitData = []; + $yearEnterData = []; + + // Ambil data untuk setiap bulan dalam tahun tersebut + foreach ($monthNames as $monthName) { + $exitCount = \App\Models\asset_status::whereYear('exit_at', $year) + ->whereMonth('exit_at', array_search($monthName, $monthNames) + 1) + ->count(); + $enterCount = \App\Models\asset_status::whereYear('enter_at', $year) + ->whereMonth('enter_at', array_search($monthName, $monthNames) + 1) + ->count(); - $exitCount = \App\Models\asset_status::whereMonth('exit_at', $i)->count(); - $enterCount = \App\Models\asset_status::whereMonth('enter_at', $i)->count(); + $yearExitData[] = $exitCount; + $yearEnterData[] = $enterCount; + } - $exitData[] = $exitCount; - $enterData[] = $enterCount; + $exitData[] = $yearExitData; + $enterData[] = $yearEnterData; } - return compact('months', 'exitData', 'enterData', 'monthNames'); + return compact('years', 'exitData', 'enterData', 'monthNames'); } } diff --git a/app/Http/Controllers/PetiController.php b/app/Http/Controllers/PetiController.php index 7613142..36e5a91 100644 --- a/app/Http/Controllers/PetiController.php +++ b/app/Http/Controllers/PetiController.php @@ -95,40 +95,12 @@ class PetiController extends Controller 'active' => 'menu-peti', ]; - $petiqr = Peti::find($id); + // $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" . - 'ID Peti : ' . - $petiqr->tipe_peti->id . - "\n" . - 'Type Peti : ' . - $petiqr->tipe_peti->type . - "\n" . - 'ID Warehouse : ' . - $petiqr->warehouse->id . - "\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); + // $qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate( + // $petiqr->fix_lot . ";" . $petiqr->id . ";" . $petiqr->warehouse->id + // )); + return view('dashboard.Master_Data.Manajemen_Peti.Peti.show', $data); } /** @@ -204,38 +176,7 @@ class PetiController extends Controller // 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" . - 'ID Peti : ' . - $peti->tipe_peti->id . - "\n" . - 'Type Peti : ' . - $peti->tipe_peti->type . - "\n" . - 'ID Warehouse : ' . - $peti->warehouse->id . - "\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" . - 'Fix Lot : ' . - $peti->fix_lot . - - 'Status Peti : ' . - $peti->status_disposal + $peti->fix_lot . ';' . $peti->id . ';' . $peti->warehouse->id )); // Inisialisasi Dompdf diff --git a/app/Http/Controllers/PetternLotPetiController.php b/app/Http/Controllers/PetternLotPetiController.php new file mode 100644 index 0000000..f273592 --- /dev/null +++ b/app/Http/Controllers/PetternLotPetiController.php @@ -0,0 +1,25 @@ + Peti::get(), + 'active' => 'menu-Pettern_Lot_Peti' + ]; + return view('dashboard.Master_Data.Report.PATTERN LOT PETI.index', $data); + } + + public function export() + { + return Excel::download(new PetternLotPetiExport, 'PATTERN LOT PETI.xlsx'); + } +} diff --git a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php index c52ff98..6a41420 100644 --- a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php +++ b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php @@ -36,40 +36,7 @@
- {!! QrCode::size(150)->generate( - 'Nama Customer : ' . - $peti->customer->name . - "\n" . - 'Code Customer : ' . - $peti->customer->code_customer . - "\n" . - 'ID Peti : ' . - $peti->tipe_peti->id . - "\n" . - 'Type Peti : ' . - $peti->tipe_peti->type . - "\n" . - 'ID Warehouse : ' . - $peti->warehouse->id . - "\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" . - 'Fix Lot : ' . - $peti->fix_lot . - "\n" . - 'Status Peti : ' . - $peti->status_disposal, - ) !!} + {!! QrCode::size(150)->generate($peti->fix_lot . ';' . $peti->id . ';' . $peti->warehouse->id) !!}
Ukuran Peti: * + title="Format yang diperbolehkan: 5 x 5 x 5" required> diff --git a/resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php b/resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php index 857d8a4..b2582cd 100644 --- a/resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php +++ b/resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php @@ -23,7 +23,7 @@ + title="Format yang diperbolehkan: 5 x 5 x 5" required> diff --git a/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php b/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php new file mode 100644 index 0000000..6d6e14f --- /dev/null +++ b/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php @@ -0,0 +1,73 @@ +@extends('layouts.main') +@section('content') + @include('layouts.components.alert-prompt') + + +
+ +
+
+ + + + + + + + + + + + + + + + + @php + $noreport = 1; + @endphp + @forelse ($peti as $data_peti) + + + + + + + + + + + + + @empty +

Data Kosong

+ @endforelse + +
NoUserCustomerWHCODE CUSTOMERTYPE PETIUKURAN PETILOT NOPACKING NOFIX LOT
{{ $noreport++ }}ISTW{{ $data_peti->customer->name }}{{ $data_peti->warehouse->name }}{{ $data_peti->customer->code_customer }}{{ $data_peti->tipe_peti->type }}{{ $data_peti->tipe_peti->size_peti }}{{ $data_peti->customer->lot_no }}{{ $data_peti->packing_no }}{{ $data_peti->fix_lot }}
+
+
+
+@endsection diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index 3e0dfac..56fd15b 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -17,7 +17,7 @@ Pengadaan
- {{ $jumlahAsset }} + {{ $jumlahPeti }}
@@ -95,33 +95,25 @@
Grafik Peminjaman VS Pengembalian
-
@php $chartData = app('App\Http\Controllers\HomeController')->generateChartData(); @endphp
+ + +
- -
@@ -164,25 +156,41 @@
- @push('script') @endpush diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index c928a79..006e77d 100644 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -97,12 +97,20 @@ diff --git a/routes/web.php b/routes/web.php index 6d93896..54b23ce 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,6 +11,7 @@ use App\Http\Controllers\TypePetiController; use App\Http\Controllers\WarehouseController; use App\Http\Controllers\PeminjamanController; use App\Http\Controllers\PengembalianController; +use App\Http\Controllers\PetternLotPetiController; /* |-------------------------------------------------------------------------- @@ -44,33 +45,6 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home.admin'); Route::get('/homeuser', [App\Http\Controllers\HomeController::class, 'indexUser'])->name('home.user'); - //Halaman Warehouse - Route::controller(WarehouseController::class)->group(function () { - Route::get('warehouse', 'index')->name('warehouse.index'); - Route::post('warehouse/store', 'store')->name('warehouse.store'); - Route::put('warehouse/{id}', 'update')->name('warehouse.update'); - Route::delete('warehouse/delete/{id}', 'destroy')->name('warehouse.destroy'); - }); - - //Halaman Role - Route::controller(RoleController::class)->group(function () { - Route::get('role', 'index')->name('role.index'); - Route::post('role/store', 'store')->name('role.store'); - Route::put('role/{id}', 'update')->name('role.update'); - Route::delete('role/delete/{id}', 'destroy')->name('role.destroy'); - }); - - //Halaman User - Route::controller(M_userController::class)->group(function () { - Route::get('user', 'index')->name('user.index'); - Route::get('user/create', 'create')->name('user.create'); - Route::post('user/store', 'store')->name('user.store'); - Route::get('user/{id}', 'show')->name('user.show'); - Route::get('user/{id}/edit', 'edit')->name('user.edit'); - Route::put('user/{id}', 'update')->name('user.update'); - Route::delete('user/delete/{id}', 'destroy')->name('user.destroy'); - }); - //Halaman Peminjaman Route::controller(PeminjamanController::class)->group(function () { Route::get('peminjaman', 'index')->name('peminjaman.index'); @@ -92,6 +66,25 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func Route::delete('pengembalian/delete/{id}', 'destroy')->name('pengembalian.destroy'); }); + //Halaman User + Route::controller(M_userController::class)->group(function () { + Route::get('user', 'index')->name('user.index'); + Route::get('user/create', 'create')->name('user.create'); + Route::post('user/store', 'store')->name('user.store'); + Route::get('user/{id}', 'show')->name('user.show'); + Route::get('user/{id}/edit', 'edit')->name('user.edit'); + Route::put('user/{id}', 'update')->name('user.update'); + Route::delete('user/delete/{id}', 'destroy')->name('user.destroy'); + }); + + //Halaman Role + Route::controller(RoleController::class)->group(function () { + Route::get('role', 'index')->name('role.index'); + Route::post('role/store', 'store')->name('role.store'); + Route::put('role/{id}', 'update')->name('role.update'); + Route::delete('role/delete/{id}', 'destroy')->name('role.destroy'); + }); + //Halaman Customer Route::controller(CustomerController::class)->group(function () { Route::get('customer', 'index')->name('customer.index'); @@ -125,6 +118,20 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func Route::delete('peti/delete/{id}', 'destroy')->name('peti.destroy'); Route::get('peticetak_pdf/{id}', 'cetakpdf')->name('peticetakpdf.cetakpdf'); }); + + //Halaman Warehouse + Route::controller(WarehouseController::class)->group(function () { + Route::get('warehouse', 'index')->name('warehouse.index'); + Route::post('warehouse/store', 'store')->name('warehouse.store'); + Route::put('warehouse/{id}', 'update')->name('warehouse.update'); + Route::delete('warehouse/delete/{id}', 'destroy')->name('warehouse.destroy'); + }); + + //halaman Report + Route::controller(PetternLotPetiController::class)->group(function () { + Route::get('Pettern_Lot_Peti', 'index')->name('Pettern_Lot_Peti.index'); + Route::get('Pettern_Lot_Peti/export', 'export')->name('Pettern_Lot_Peti.export'); + }); });