From 477986e797b0a126ff162b38c561756a7718d016 Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Sat, 25 Nov 2023 20:49:24 +0700 Subject: [PATCH] update report StockOpname --- .../Controllers/PetternLotPetiController.php | 11 ++ app/Http/Controllers/StokOpNameController.php | 83 +++++++++ app/Models/Peti.php | 1 - .../History/Peminjaman/index.blade.php | 24 ++- .../History/Pengembalian/index.blade.php | 10 +- .../PATTERN LOT PETI/detail_peti.blade.php | 96 +++++++++++ .../Report/PATTERN LOT PETI/index.blade.php | 6 +- .../Report/Stok_opname/index.blade.php | 157 ++++++++++++++++++ .../dashboard/Peminjaman/index.blade.php | 2 +- .../dashboard/Pengembalian/index.blade.php | 16 +- .../views/dashboard/Transfer/create.blade.php | 18 +- resources/views/dashboard/index.blade.php | 125 ++++++++++++-- resources/views/layouts/sidebar.blade.php | 8 +- routes/web.php | 11 +- 14 files changed, 513 insertions(+), 55 deletions(-) create mode 100644 app/Http/Controllers/StokOpNameController.php create mode 100644 resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/detail_peti.blade.php create mode 100644 resources/views/dashboard/Master_Data/Report/Stok_opname/index.blade.php diff --git a/app/Http/Controllers/PetternLotPetiController.php b/app/Http/Controllers/PetternLotPetiController.php index 852dc76..1cbe293 100644 --- a/app/Http/Controllers/PetternLotPetiController.php +++ b/app/Http/Controllers/PetternLotPetiController.php @@ -6,6 +6,7 @@ use App\Models\Peti; use Illuminate\Http\Request; use Maatwebsite\Excel\Facades\Excel; use App\Exports\PetternLotPetiExport; +use App\Models\asset_status; class PetternLotPetiController extends Controller { @@ -19,6 +20,16 @@ class PetternLotPetiController extends Controller return view('dashboard.Master_Data.Report.PATTERN LOT PETI.index', $data); } + public function show($id) + { + $data = [ + 'peti' => Peti::find($id), + 'assetStatus' => asset_status::where('peti_id', $id)->get(), + 'active' => 'menu-Pettern_Lot_Peti' + ]; + return view('dashboard.Master_Data.Report.PATTERN LOT PETI.detail_peti', $data); + } + public function export() { return Excel::download(new PetternLotPetiExport, 'PATTERN LOT PETI.xlsx'); diff --git a/app/Http/Controllers/StokOpNameController.php b/app/Http/Controllers/StokOpNameController.php new file mode 100644 index 0000000..cb057b8 --- /dev/null +++ b/app/Http/Controllers/StokOpNameController.php @@ -0,0 +1,83 @@ +select('customer_id', 'tipe_peti_id', DB::raw('COUNT(*) as total_petis')) + ->whereDate('created_at', today()) + ->groupBy('customer_id', 'tipe_peti_id') + ->get(); + + // Total Peti Berdasarkan Tanggal Sebelum Tanggal Sekarang + $yesterdayStokOpnames = Peti::with('customer', 'tipe_peti') + ->select('customer_id', 'tipe_peti_id', DB::raw('COUNT(*) as total_petis')) + ->whereDate('created_at', today()->subDays(1)) + ->groupBy('customer_id', 'tipe_peti_id') + ->get(); + + // Total Peti Berdasarkan Tabel asset_status + // $totalPetiAssetStatus = asset_status::select('peti_id', DB::raw('COUNT(*) as total_petis')) + // ->groupBy('peti_id') + // ->get(); + $petiIds = asset_status::whereHas('peti', function ($query) { + $query->groupBy('customer_id', 'tipe_peti_id'); + }) + ->pluck('peti_id'); + + // Total Peti + $stokOpnames = Peti::with('customer', 'tipe_peti') + ->select('customer_id', 'tipe_peti_id', DB::raw('COUNT(*) as total_petis')) + ->groupBy('customer_id', 'tipe_peti_id') + ->get(); + + $petis = Peti::get(); + + $data = [ + 'stokOpnames' => $stokOpnames, + 'todayStokOpnames' => $todayStokOpnames, // tambahin ini di array data 'todayStokOpnames' => $todayStokOpnames, + 'yesterdayStokOpnames' => $yesterdayStokOpnames, // tambahin ini di array data 'yesterdayStokOpnames' => $yesterdayStokOpnames, + 'totalPetiAssetStatus' => $petiIds, // Sesuaikan dengan model dan kolom yang sesuai + 'assetStatus' => asset_status::get(), + 'petis' => $petis, + 'active' => 'menu-Stok_Opname' + ]; + return view('dashboard.Master_Data.Report.Stok_opname.index', $data); + } + // public function index() + // { + + + + // // // Total Peti Berdasarkan Gudang + // // $gudangStokOpnames = Peti::with('customer', 'tipe_peti') + // // ->select('customer_id', 'tipe_peti_id', DB::raw('COUNT(*) as total_petis')) + // // ->groupBy('customer_id', 'tipe_peti_id') + // // ->get(); + + // $stokOpnames = Peti::with('customer', 'tipe_peti') + // ->select('customer_id', 'tipe_peti_id', DB::raw('COUNT(*) as total_petis')) + // ->groupBy('customer_id', 'tipe_peti_id') + // ->get(); + // $data = [ + // 'stokOpnames ' => $stokOpnames, + // // 'todayStokOpnames' => $todayStokOpnames, + // // 'yesterdayStokOpnames' => $yesterdayStokOpnames, + // // 'gudangStokOpnames' => $gudangStokOpnames, + // 'active' => 'menu-Stok_Opname' + // ]; + + // return view('dashboard.Master_Data.Report.Stok_opname.index', $data); + // } +} diff --git a/app/Models/Peti.php b/app/Models/Peti.php index efedd7a..ef38889 100644 --- a/app/Models/Peti.php +++ b/app/Models/Peti.php @@ -16,7 +16,6 @@ class Peti extends Model protected $table = 'petis'; protected $fillable = [ - 'id_incre', 'tipe_peti_id', 'warna', 'customer_id', diff --git a/resources/views/dashboard/History/Peminjaman/index.blade.php b/resources/views/dashboard/History/Peminjaman/index.blade.php index 11b6dec..db78a15 100644 --- a/resources/views/dashboard/History/Peminjaman/index.blade.php +++ b/resources/views/dashboard/History/Peminjaman/index.blade.php @@ -29,7 +29,7 @@ Kode Tgl Peminjaman PJ Peminjaman - Asal Gudang + WH Peminjam @@ -37,18 +37,16 @@ $no_peminjaman = 1; @endphp @forelse ($peminjaman as $data_peminjaman) - @if ($data_peminjaman->enter_warehouse == null) - - {{ $no_peminjaman++ }} - {{ $data_peminjaman->peti->fix_lot }} - {{ $data_peminjaman->peti->customer->name }} - {{ $data_peminjaman->peti->customer->code_customer }} - - {{ $data_peminjaman->peti->tipe_peti->type }} - {{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }} - {{ $data_peminjaman->exit_pic }} - {{ $data_peminjaman->warehouse->name }} - - @endif + + {{ $no_peminjaman++ }} + {{ $data_peminjaman->peti->fix_lot }} + {{ $data_peminjaman->peti->customer->name }} + {{ $data_peminjaman->peti->customer->code_customer }} - + {{ $data_peminjaman->peti->tipe_peti->type }} + {{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }} + {{ $data_peminjaman->exit_pic }} + {{ $data_peminjaman->warehouse->name }} + @empty

Data Kosong

@endforelse diff --git a/resources/views/dashboard/History/Pengembalian/index.blade.php b/resources/views/dashboard/History/Pengembalian/index.blade.php index ce4f7ec..0f37e5c 100644 --- a/resources/views/dashboard/History/Pengembalian/index.blade.php +++ b/resources/views/dashboard/History/Pengembalian/index.blade.php @@ -50,7 +50,13 @@ {{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }} {{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d/m/Y') }} {{ $data->exit_pic }} - {{ $data->warehouse->name }} + + @if ($data->exit_warehouse) + {{ $data->warehouse->name }} + @else +

-

+ @endif + @if ($data->enter_at) {{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }} @@ -67,7 +73,7 @@ @if ($data->enter_warehouse) - {{ $data->warehouse->name }} + {{ $data->warehouseEnter->name }} @else

-

@endif diff --git a/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/detail_peti.blade.php b/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/detail_peti.blade.php new file mode 100644 index 0000000..042750d --- /dev/null +++ b/resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/detail_peti.blade.php @@ -0,0 +1,96 @@ +@extends('layouts.main') +@section('content') + +
+
+
+
+
Detail Histori Peti
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + @php + $no_peminjaman = 1; + @endphp + @forelse ($assetStatus as $data_assetStatus) + + + + + + + + + + + + + + + @empty +

Data Kosong

+ @endforelse + +
NoKode PetiCustomerTgl PeinjamanEstimasi PengembalianPJ PeminjamanAsal WH PeminjamanTgl PengembalianPJ PengembalianTujuan WH PengembalianKondisi PetiStatus
{{ $no_peminjaman++ }}{{ $data_assetStatus->peti->fix_lot }}{{ $data_assetStatus->peti->customer->name }}{{ \Carbon\Carbon::parse($data_assetStatus->exit_at)->format('d/m/Y') }}{{ \Carbon\Carbon::parse($data_assetStatus->est_pengembalian)->format('d/m/Y') }}{{ $data_assetStatus->exit_pic }}{{ $data_assetStatus->warehouse->name }} + @if ($data_assetStatus->enter_at) + {{ \Carbon\Carbon::parse($data_assetStatus->enter_at)->format('d-m-Y') }} + @else +

-

+ @endif +
+ @if ($data_assetStatus->enter_pic) + {{ $data_assetStatus->enter_pic }} + @else +

-

+ @endif +
+ @if ($data_assetStatus->enter_warehouse) + {{ $data_assetStatus->warehouse->name }} + @else +

-

+ @endif +
+ @if ($data_assetStatus->kondisi_peti) + {{ $data_assetStatus->kondisi_peti->nama_kondisi }} + @else +

-

+ @endif +
+ @if ($data_assetStatus->enter_warehouse === null) + Not Return + @else + Return + @endif +
+
+
+
+@endsection 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 index 6d6e14f..32d7efa 100644 --- 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 @@ -1,6 +1,5 @@ @extends('layouts.main') @section('content') - @include('layouts.components.alert-prompt') + {{--

Halaman Stop Op Name

--}} +
+
+
+
+
Report Stok Opname
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + @php + $noreport = 1; + @endphp + @forelse ($stokOpnames as $data_StokOpname) + + + + + + + + + + + + + + + + @empty +

Data Kosong

+ @endforelse + +
NoCustomerKodeUkuran PetiBagginningAddTotalStockStok OpnameTotal
DI ISTWGudang AGudang BGudang C
{{ $noreport++ }}{{ $data_StokOpname->customer->name }}{{ $data_StokOpname->customer->code_customer }} - + {{ $data_StokOpname->tipe_peti->type }}{{ $data_StokOpname->tipe_peti->size_peti }} + @php + // Temukan data dari tanggal sebelum sekarang (kemarin) berdasarkan id + $yesterdayStokOpname = $yesterdayStokOpnames + ->where('customer_id', $data_StokOpname->customer_id) + ->where('tipe_peti_id', $data_StokOpname->tipe_peti_id) + ->first(); + @endphp + {{-- Jumlah total peti pada tanggal sebelum sekarang (kemarin) --}} + @if ($yesterdayStokOpname && $yesterdayStokOpname->total_petis > 0) + {{ $yesterdayStokOpname->total_petis }} + @else + - + @endif + + @php + $todayStokOpname = $todayStokOpnames + ->where('customer_id', $data_StokOpname->customer_id) + ->where('tipe_peti_id', $data_StokOpname->tipe_peti_id) + ->first(); + @endphp + @if ($todayStokOpname && $todayStokOpname->total_petis > 0) + {{ $todayStokOpname->total_petis }} + @else + - + @endif + + @if ($data_StokOpname->total_petis > 0) + {{ $data_StokOpname->total_petis }} + @else + - + @endif + + - + Gudang AGudang B + @php + $totalNullableCount = 0; + @endphp + + @foreach ($petis as $peti) + @php + $totalNullableCount += $assetStatus + ->where('peti_id', $peti->id) + ->where('enter_warehouse', '=', 0) + // ->where('customer_id', $peti->customer_id) + ->count(); + @endphp + @endforeach + + {{ $totalNullableCount }} + + + + + {{-- @foreach ($petis as $item) + @php + $totalAsset = \App\Models\asset_status::get(); + $totalAssetStatus = $totalAsset + ->where('customer_id', $item->customer_id) + ->where('peti_id', $item->id) + ->count(); + @endphp + @if ($totalAssetStatus > 0) + {{ $totalAssetStatus }} + @else + 0 + @endif + @endforeach --}} + + - + @if ($data_StokOpname->total_petis > 0) + {{ $data_StokOpname->total_petis }} + @else + - + @endif +
+
+
+
+@endsection diff --git a/resources/views/dashboard/Peminjaman/index.blade.php b/resources/views/dashboard/Peminjaman/index.blade.php index c890cc0..e81d23a 100644 --- a/resources/views/dashboard/Peminjaman/index.blade.php +++ b/resources/views/dashboard/Peminjaman/index.blade.php @@ -36,7 +36,7 @@ Kode Tgl Peminjaman PJ Peminjaman - Asal Gudang + WH Peminjam Action diff --git a/resources/views/dashboard/Pengembalian/index.blade.php b/resources/views/dashboard/Pengembalian/index.blade.php index 2b67180..22090fc 100644 --- a/resources/views/dashboard/Pengembalian/index.blade.php +++ b/resources/views/dashboard/Pengembalian/index.blade.php @@ -30,10 +30,10 @@ Tgl Peinjaman Estimasi Pengembalian PJ Peminjaman - Asal WH Peminjaman + WH Peminjam Tgl Pengembalian PJ Pengembalian - Tujuan WH Pengembalian + WH Pengembalian Kondisi Peti Status Action @@ -52,7 +52,13 @@ {{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }} {{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d/m/Y') }} {{ $data->exit_pic }} - {{ $data->warehouse->name }} + + @if ($data->exit_warehouse) + {{ $data->warehouse->name }} + @else +

-

+ @endif + @if ($data->enter_at) {{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }} @@ -69,14 +75,14 @@ @if ($data->enter_warehouse) - {{ $data->warehouse->name }} + {{ $data->warehouseEnter->name }} @else

-

@endif @if ($data->kondisi_peti) - {{ $data->kondisi_peti_id }} + {{ $data->kondisi_peti->nama_kondisi }} @else

-

@endif diff --git a/resources/views/dashboard/Transfer/create.blade.php b/resources/views/dashboard/Transfer/create.blade.php index 78fb6cf..1a2cd0b 100644 --- a/resources/views/dashboard/Transfer/create.blade.php +++ b/resources/views/dashboard/Transfer/create.blade.php @@ -33,7 +33,7 @@ + + + @foreach ($chartDataPie['years'] as $year) + @if (count($chartDataPie['enterData']) > 0 && $chartDataPie['enterData'][$loop->index]) + + @endif + @endforeach + + + + + + --}} @push('script') @@ -143,27 +168,30 @@ // Function to update the pie chart based on selected year function updatePieChart(selectedYear) { // Call the controller function to get data for the selected year - var chartData = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; - var yearIndex = chartData.years.indexOf(selectedYear); + var chartDataPie = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; + var yearIndex = chartDataPie.years.indexOf(selectedYear); // Update the pie chart data - myPieChart.data.datasets[0].data = chartData.enterData[yearIndex]; + myPieChart.data.datasets[0].data = chartDataPie.enterData[yearIndex]; myPieChart.update(); + + // Save selected year to local storage + localStorage.setItem('selectedYearPie', selectedYear); } // Initial chart data - var initialChartData = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; + var initialChartDataPie = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; // Get the canvas element for the pie chart - var ctx = document.getElementById("myPieChartsiopas").getContext('2d'); + var ctxPie = document.getElementById("myPieChartsiopas").getContext('2d'); // Create the initial pie chart instance - var myPieChart = new Chart(ctx, { + var myPieChart = new Chart(ctxPie, { type: 'pie', data: { - labels: initialChartData.monthNames, + labels: initialChartDataPie.monthNames, datasets: [{ - data: initialChartData.enterData[0], + data: initialChartDataPie.enterData[0], backgroundColor: ["#4e73df", "#1cc88a", "#36b9cc", "#ff6384", "#ff9f40", "#9966ff", "#cc65fe", "#ffcc29", "#a4e56d", "#ff3d00", "#9c9c9c", "#0d47a1" @@ -193,16 +221,83 @@ }, }); - // Custom legend using legendCallback - document.getElementById('chart-legend').innerHTML = myPieChart.generateLegend(); - // Event listener for year filter change - document.getElementById('yearFilter').addEventListener('change', function() { + document.getElementById('yearFilterPie').addEventListener('change', function() { var selectedYear = this.value; updatePieChart(selectedYear); }); + + // On page load, try to retrieve the selected year from local storage + document.addEventListener('DOMContentLoaded', function() { + var selectedYear = localStorage.getItem('selectedYearPie'); + if (selectedYear) { + // If a year is found, set the dropdown value and update the chart + document.getElementById('yearFilterPie').value = selectedYear; + updatePieChart(selectedYear); + } + }); + {{-- + --}}