Gunawan19621
1 year ago
14 changed files with 513 additions and 55 deletions
@ -0,0 +1,83 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\asset_status; |
||||
use App\Models\Peti; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class StokOpNameController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
|
||||
|
||||
// Total Peti Berdasarkan Tanggal Sekarang |
||||
$todayStokOpnames = Peti::with('customer', 'tipe_peti') |
||||
->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); |
||||
// } |
||||
} |
@ -0,0 +1,96 @@
|
||||
@extends('layouts.main') |
||||
@section('content') |
||||
<style> |
||||
.table th { |
||||
white-space: nowrap; |
||||
} |
||||
|
||||
.table td { |
||||
white-space: nowrap; |
||||
} |
||||
</style> |
||||
<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">Detail Histori Peti</h5> |
||||
</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>No</th> |
||||
<th>Kode Peti</th> |
||||
<th>Customer</th> |
||||
<th>Tgl Peinjaman</th> |
||||
<th>Estimasi Pengembalian</th> |
||||
<th>PJ Peminjaman</th> |
||||
<th>Asal WH Peminjaman</th> |
||||
<th>Tgl Pengembalian</th> |
||||
<th>PJ Pengembalian</th> |
||||
<th>Tujuan WH Pengembalian</th> |
||||
<th>Kondisi Peti</th> |
||||
<th>Status</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
@php |
||||
$no_peminjaman = 1; |
||||
@endphp |
||||
@forelse ($assetStatus as $data_assetStatus) |
||||
<tr> |
||||
<td class="text-center">{{ $no_peminjaman++ }}</td> |
||||
<td>{{ $data_assetStatus->peti->fix_lot }}</td> |
||||
<td>{{ $data_assetStatus->peti->customer->name }}</td> |
||||
<td>{{ \Carbon\Carbon::parse($data_assetStatus->exit_at)->format('d/m/Y') }}</td> |
||||
<td>{{ \Carbon\Carbon::parse($data_assetStatus->est_pengembalian)->format('d/m/Y') }}</td> |
||||
<td>{{ $data_assetStatus->exit_pic }}</td> |
||||
<td>{{ $data_assetStatus->warehouse->name }}</td> |
||||
<td> |
||||
@if ($data_assetStatus->enter_at) |
||||
{{ \Carbon\Carbon::parse($data_assetStatus->enter_at)->format('d-m-Y') }} |
||||
@else |
||||
<p class="text-center font-weight-bold">-</p> |
||||
@endif |
||||
</td> |
||||
<td> |
||||
@if ($data_assetStatus->enter_pic) |
||||
{{ $data_assetStatus->enter_pic }} |
||||
@else |
||||
<p class="text-center font-weight-bold">-</p> |
||||
@endif |
||||
</td> |
||||
<td> |
||||
@if ($data_assetStatus->enter_warehouse) |
||||
{{ $data_assetStatus->warehouse->name }} |
||||
@else |
||||
<p class="text-center font-weight-bold">-</p> |
||||
@endif |
||||
</td> |
||||
<td> |
||||
@if ($data_assetStatus->kondisi_peti) |
||||
{{ $data_assetStatus->kondisi_peti->nama_kondisi }} |
||||
@else |
||||
<p class="text-center font-weight-bold">-</p> |
||||
@endif |
||||
</td> |
||||
<td> |
||||
@if ($data_assetStatus->enter_warehouse === null) |
||||
Not Return |
||||
@else |
||||
Return |
||||
@endif |
||||
</td> |
||||
</tr> |
||||
@empty |
||||
<p>Data Kosong</p> |
||||
@endforelse |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@endsection |
@ -0,0 +1,157 @@
|
||||
@extends('layouts.main') |
||||
@section('content') |
||||
<style> |
||||
.table th { |
||||
white-space: nowrap; |
||||
} |
||||
|
||||
.table td { |
||||
white-space: nowrap; |
||||
} |
||||
</style> |
||||
{{-- <p>Halaman Stop Op Name</p> --}} |
||||
<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">Report Stok Opname</h5> |
||||
</div> |
||||
<div class="col-6 text-right"> |
||||
<a href="#" class="btn btn-success btn-icon-split ml-auto" target="_blank"> |
||||
<span class="text">Cetak PDF</span> |
||||
</a> |
||||
<a href="{{ route('dashboard.Pettern_Lot_Peti.export') }}" class="btn btn-info btn-icon-split ml-auto" |
||||
target="_blank"> |
||||
<span class="text">Cetak Exel</span> |
||||
</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 rowspan="2" style="vertical-align: middle; text-align: center;">No</th> |
||||
<th rowspan="2"style="vertical-align: middle; text-align: center;">Customer</th> |
||||
<th rowspan="2"style="vertical-align: middle; text-align: center;">Kode</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Ukuran Peti</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Bagginning</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Add</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Total</th> |
||||
<th colspan="4" style="text-align: center; vertical-align: middle;">Stock</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Stok Opname</th> |
||||
<th rowspan="2" style="vertical-align: middle; text-align: center;">Total</th> |
||||
</tr> |
||||
<tr> |
||||
<th>DI ISTW</th> |
||||
<th>Gudang A</th> |
||||
<th>Gudang B</th> |
||||
<th>Gudang C</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
@php |
||||
$noreport = 1; |
||||
@endphp |
||||
@forelse ($stokOpnames as $data_StokOpname) |
||||
<tr> |
||||
<td>{{ $noreport++ }}</td> |
||||
<td>{{ $data_StokOpname->customer->name }}</td> |
||||
<td>{{ $data_StokOpname->customer->code_customer }} - |
||||
{{ $data_StokOpname->tipe_peti->type }}</td> |
||||
<td>{{ $data_StokOpname->tipe_peti->size_peti }}</td> |
||||
<td> |
||||
@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 |
||||
</td> |
||||
<td> |
||||
@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 |
||||
</td> |
||||
<td> |
||||
@if ($data_StokOpname->total_petis > 0) |
||||
{{ $data_StokOpname->total_petis }} |
||||
@else |
||||
- |
||||
@endif |
||||
</td> |
||||
<td> |
||||
- |
||||
</td> |
||||
<td>Gudang A</td> |
||||
<td>Gudang B</td> |
||||
<td> |
||||
@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 --}} |
||||
|
||||
</td> |
||||
<td> - </td> |
||||
<td> |
||||
@if ($data_StokOpname->total_petis > 0) |
||||
{{ $data_StokOpname->total_petis }} |
||||
@else |
||||
- |
||||
@endif |
||||
</td> |
||||
</tr> |
||||
@empty |
||||
<p>Data Kosong</p> |
||||
@endforelse |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@endsection |
Loading…
Reference in new issue