diff --git a/app/Http/Controllers/WarehouseManagement/MutationsController.php b/app/Http/Controllers/WarehouseManagement/MutationsController.php index 97222a8..45fff5c 100755 --- a/app/Http/Controllers/WarehouseManagement/MutationsController.php +++ b/app/Http/Controllers/WarehouseManagement/MutationsController.php @@ -527,4 +527,25 @@ class MutationsController extends Controller ], 500); } } + + public function print($id) + { + try { + $mutation = Mutation::with([ + 'fromDealer', + 'toDealer', + 'requestedBy.role', + 'approvedBy.role', + 'receivedBy.role', + 'rejectedBy.role', + 'cancelledBy.role', + 'mutationDetails.product.category' + ])->findOrFail($id); + + return view('warehouse_management.mutations.print', compact('mutation')); + } catch (\Exception $e) { + Log::error('Error printing mutation: ' . $e->getMessage()); + return back()->with('error', 'Gagal membuka halaman print mutasi.'); + } + } } \ No newline at end of file diff --git a/app/Http/Controllers/WarehouseManagement/OpnamesController.php b/app/Http/Controllers/WarehouseManagement/OpnamesController.php index 333f2fb..7fb5b08 100755 --- a/app/Http/Controllers/WarehouseManagement/OpnamesController.php +++ b/app/Http/Controllers/WarehouseManagement/OpnamesController.php @@ -77,7 +77,8 @@ class OpnamesController extends Controller ->addColumn('action', function ($row) use ($menu) { $btn = '
'; - $btn .= 'Detail'; + $btn .= 'Detail'; + $btn .= 'Print'; $btn .= '
'; @@ -477,5 +478,18 @@ class OpnamesController extends Controller } } + public function print($id) + { + try { + $opname = Opname::with(['details.product.category', 'user', 'dealer']) + ->findOrFail($id); + + return view('warehouse_management.opnames.print', compact('opname')); + } catch (\Exception $e) { + Log::error('Error printing opname: ' . $e->getMessage()); + return back()->with('error', 'Gagal membuka halaman print opname.'); + } + } + } diff --git a/resources/views/warehouse_management/mutations/_action.blade.php b/resources/views/warehouse_management/mutations/_action.blade.php index b176571..080c5cc 100755 --- a/resources/views/warehouse_management/mutations/_action.blade.php +++ b/resources/views/warehouse_management/mutations/_action.blade.php @@ -5,6 +5,13 @@ Detail + + + Print + + @if($row->status->value === 'sent') @if(auth()->user()->dealer_id == $row->to_dealer_id) diff --git a/resources/views/warehouse_management/mutations/print.blade.php b/resources/views/warehouse_management/mutations/print.blade.php new file mode 100644 index 0000000..9d9c9c1 --- /dev/null +++ b/resources/views/warehouse_management/mutations/print.blade.php @@ -0,0 +1,546 @@ + + + + + + Print Mutasi - {{ $mutation->mutation_number }} + + + + + +
+ +
+
+
PT. CINTA KASIH BERSAMA
+
Warehouse Management System
+
+
Dokumen Mutasi Stock
+
+ + +
+
+
Informasi Mutasi
+
+ No. Mutasi: + {{ $mutation->mutation_number }} +
+
+ Tanggal Dibuat: + {{ \Carbon\Carbon::parse($mutation->created_at)->format('d F Y H:i') }} +
+
+ Status: + + @php + $status = $mutation->status instanceof \App\Enums\MutationStatus ? $mutation->status : \App\Enums\MutationStatus::from($mutation->status); + @endphp + {{ $status->label() }} + +
+
+ Dibuat oleh: + {{ $mutation->requestedBy->name ?? '-' }} +
+
+ +
+
Informasi Dealer
+
+ Dari Dealer: + {{ $mutation->fromDealer->name ?? '-' }} +
+
+ Ke Dealer: + {{ $mutation->toDealer->name ?? '-' }} +
+ @if($mutation->receivedBy) +
+ Diterima oleh: + {{ $mutation->receivedBy->name ?? '-' }} +
+ @endif + @if($mutation->received_at) +
+ Tanggal Terima: + {{ \Carbon\Carbon::parse($mutation->received_at)->format('d F Y H:i') }} +
+ @endif +
+
+ + @if($mutation->shipping_notes) +
+
Catatan Pengiriman
+
{{ $mutation->shipping_notes }}
+
+ @endif + + @if($mutation->reception_notes) +
+
Catatan Penerimaan
+
{{ $mutation->reception_notes }}
+
+ @endif + + @if($mutation->approval_notes) +
+
Catatan Persetujuan
+
{{ $mutation->approval_notes }}
+
+ @endif + + @if($mutation->rejection_reason) +
+
Alasan Penolakan
+
{{ $mutation->rejection_reason }}
+
+ @endif + + +
+
Detail Produk Mutasi
+ + + + + + + + + @if($mutation->status->value !== 'sent') + + + @endif + + + + @php + $totalRequested = 0; + $totalApproved = 0; + $fullItems = 0; + $partialItems = 0; + $rejectedItems = 0; + @endphp + + @foreach($mutation->mutationDetails as $index => $detail) + @php + $totalRequested += $detail->quantity_requested; + $totalApproved += $detail->quantity_approved ?? 0; + + if ($detail->quantity_approved) { + if ($detail->quantity_approved == $detail->quantity_requested) { + $fullItems++; + } elseif ($detail->quantity_approved > 0) { + $partialItems++; + } else { + $rejectedItems++; + } + } + @endphp + + + + + + + @if($mutation->status->value !== 'sent') + + + @endif + + @endforeach + + + + + + @if($mutation->status->value !== 'sent') + + + @endif + + +
No.Kode ProdukNama ProdukKategoriQty DimintaQty DiterimaCatatan
{{ $index + 1 }}{{ $detail->product->code ?? '-' }}{{ $detail->product->name ?? '-' }}{{ $detail->product->category->name ?? '-' }}{{ number_format($detail->quantity_requested, 2) }} + {{ $detail->quantity_approved ? number_format($detail->quantity_approved, 2) : '0.00' }} + @if($detail->quantity_approved && $detail->quantity_approved < $detail->quantity_requested) +
(Kurang {{ number_format($detail->quantity_requested - $detail->quantity_approved, 2) }}) + @endif +
{{ $detail->notes ?: '-' }}
TOTAL{{ number_format($totalRequested, 2) }}{{ number_format($totalApproved, 2) }}-
+
+ + +
+
Ringkasan Mutasi
+
+
+
{{ count($mutation->mutationDetails) }}
+
Total Item
+
+ @if($mutation->status->value !== 'sent') +
+
{{ $fullItems }}
+
Lengkap
+
+
+
{{ $partialItems }}
+
Sebagian
+
+
+
{{ $rejectedItems }}
+
Ditolak
+
+ @endif +
+
{{ number_format($totalRequested, 2) }}
+
Total Diminta
+
+ @if($mutation->status->value !== 'sent') +
+
{{ number_format($totalApproved, 2) }}
+
Total Diterima
+
+ @endif +
+
+ + + +
+ + + + \ No newline at end of file diff --git a/resources/views/warehouse_management/opnames/print.blade.php b/resources/views/warehouse_management/opnames/print.blade.php new file mode 100644 index 0000000..91dcabf --- /dev/null +++ b/resources/views/warehouse_management/opnames/print.blade.php @@ -0,0 +1,438 @@ + + + + + + Print Opname - {{ $opname->id }} + + + + + +
+ +
+
+
PT. CINTA KASIH BERSAMA
+
Warehouse Management System
+
+
Laporan Stock Opname
+
+ + +
+
+
Informasi Opname
+
+ Tanggal Opname: + {{ \Carbon\Carbon::parse($opname->opname_date)->format('d F Y') }} +
+
+ Status: + + @php + $status = $opname->status instanceof \App\Enums\OpnameStatus ? $opname->status : \App\Enums\OpnameStatus::from($opname->status); + @endphp + {{ $status->label() }} + +
+
+ Dibuat: + {{ \Carbon\Carbon::parse($opname->created_at)->format('d F Y H:i') }} +
+
+ +
+
Informasi Dealer & User
+
+ Dealer: + {{ $opname->dealer->name ?? '-' }} +
+
+ User: + {{ $opname->user->name ?? '-' }} +
+
+
+ + +
+
Detail Stock Opname
+ + + + + + + + + + + + + + @php + $totalSystemStock = 0; + $totalPhysicalStock = 0; + $totalDifference = 0; + $positiveCount = 0; + $negativeCount = 0; + $zeroCount = 0; + @endphp + + @foreach($opname->details as $index => $detail) + @php + $difference = $detail->difference; + $totalSystemStock += $detail->system_stock; + $totalPhysicalStock += $detail->physical_stock; + $totalDifference += $difference; + + if ($difference > 0) $positiveCount++; + elseif ($difference < 0) $negativeCount++; + else $zeroCount++; + @endphp + + + + + + + + + + @endforeach + + + + + + + + + +
No.Kode ProdukNama ProdukKategoriStok SistemStok FisikSelisih
{{ $index + 1 }}{{ $detail->product->code ?? '-' }}{{ $detail->product->name ?? '-' }}{{ $detail->product->category->name ?? '-' }}{{ number_format($detail->system_stock, 2) }}{{ number_format($detail->physical_stock, 2) }} + {{ $difference > 0 ? '+' : '' }}{{ number_format($difference, 2) }} +
TOTAL{{ number_format($totalSystemStock, 2) }}{{ number_format($totalPhysicalStock, 2) }}{{ $totalDifference > 0 ? '+' : '' }}{{ number_format($totalDifference, 2) }}
+
+ + +
+
Ringkasan Stock Opname
+
+
+
{{ count($opname->details) }}
+
Total Produk
+
+
+
{{ $positiveCount }}
+
Surplus
+
+
+
{{ $negativeCount }}
+
Minus
+
+
+
{{ $zeroCount }}
+
Sesuai
+
+
+
+ + + +
+ + + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 812eaea..c10cdf4 100755 --- a/routes/web.php +++ b/routes/web.php @@ -240,6 +240,7 @@ Route::group(['middleware' => 'auth'], function() { Route::get('create','create')->name('opnames.create'); Route::post('/','store')->name('opnames.store'); Route::get('{opnames}','show')->name('opnames.show'); + Route::get('{opnames}/print','print')->name('opnames.print'); Route::post('get-stock-data', 'getStockData')->name('opnames.get-stock-data'); }); @@ -253,6 +254,7 @@ Route::group(['middleware' => 'auth'], function() { Route::get('{mutation}', 'show')->name('show'); Route::get('{mutation}/edit', 'edit')->name('edit'); Route::get('{mutation}/details', 'getDetails')->name('details'); + Route::get('{mutation}/print', 'print')->name('print'); Route::post('{mutation}/receive', 'receive')->name('receive'); Route::post('{mutation}/approve', 'approve')->name('approve'); Route::post('{mutation}/reject', 'reject')->name('reject');