create print opname and mutations

This commit is contained in:
2025-06-19 18:02:20 +07:00
parent e478dc81bb
commit 82f9d7f466
6 changed files with 1029 additions and 1 deletions

View File

@@ -0,0 +1,438 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Opname - {{ $opname->id }}</title>
<style>
@media print {
@page {
margin: 0.5in;
size: A4;
}
body {
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
.no-print {
display: none !important;
}
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
font-size: 12px;
line-height: 1.4;
color: #333;
background: white;
}
.container {
width: 100%;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
/* Header Section */
.header {
border-bottom: 3px solid #2c5282;
padding-bottom: 20px;
margin-bottom: 30px;
}
.company-info {
text-align: center;
margin-bottom: 15px;
}
.company-name {
font-size: 24px;
font-weight: bold;
color: #2c5282;
margin-bottom: 5px;
}
.company-tagline {
font-size: 14px;
color: #666;
margin-bottom: 10px;
}
.document-title {
text-align: center;
font-size: 18px;
font-weight: bold;
color: #2c5282;
text-transform: uppercase;
letter-spacing: 1px;
}
/* Info Section */
.info-section {
display: flex;
justify-content: space-between;
margin-bottom: 30px;
flex-wrap: wrap;
}
.info-box {
flex: 1;
min-width: 250px;
margin-right: 20px;
}
.info-box:last-child {
margin-right: 0;
}
.info-title {
font-weight: bold;
color: #2c5282;
margin-bottom: 10px;
font-size: 14px;
border-bottom: 1px solid #e2e8f0;
padding-bottom: 5px;
}
.info-item {
display: flex;
justify-content: space-between;
padding: 4px 0;
border-bottom: 1px dotted #e2e8f0;
}
.info-label {
font-weight: 600;
color: #4a5568;
width: 40%;
}
.info-value {
color: #2d3748;
width: 55%;
text-align: right;
}
/* Status Badge */
.status-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 12px;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
}
.status-approved {
background-color: #c6f6d5;
color: #22543d;
}
/* Table Styles */
.table-container {
margin-bottom: 30px;
}
.table-title {
font-size: 16px;
font-weight: bold;
color: #2c5282;
margin-bottom: 15px;
text-transform: uppercase;
}
.data-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #e2e8f0;
margin-bottom: 20px;
}
.data-table th {
background-color: #2c5282;
color: white;
padding: 12px 8px;
text-align: left;
font-weight: bold;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.data-table td {
padding: 10px 8px;
border-bottom: 1px solid #e2e8f0;
vertical-align: top;
}
.data-table tbody tr:nth-child(even) {
background-color: #f7fafc;
}
/* Numeric columns */
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
/* Difference highlighting */
.difference-positive {
color: #22543d;
font-weight: bold;
}
.difference-negative {
color: #742a2a;
font-weight: bold;
}
.difference-zero {
color: #4a5568;
}
/* Summary Section */
.summary-section {
background-color: #f7fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 20px;
margin-top: 30px;
}
.summary-title {
font-size: 16px;
font-weight: bold;
color: #2c5282;
margin-bottom: 15px;
}
.summary-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
}
.stat-item {
text-align: center;
padding: 10px;
background: white;
border-radius: 6px;
border: 1px solid #e2e8f0;
}
.stat-number {
font-size: 18px;
font-weight: bold;
color: #2c5282;
}
.stat-label {
font-size: 11px;
color: #666;
text-transform: uppercase;
margin-top: 5px;
}
/* Footer */
.footer {
margin-top: 50px;
padding-top: 20px;
border-top: 1px solid #e2e8f0;
}
.print-info {
text-align: center;
color: #666;
font-size: 11px;
}
/* Print button */
.print-button {
position: fixed;
top: 20px;
right: 20px;
background-color: #2c5282;
color: white;
border: none;
padding: 12px 24px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 1000;
}
.print-button:hover {
background-color: #2a4365;
}
</style>
</head>
<body>
<button class="print-button no-print" onclick="window.print()">Print</button>
<div class="container">
<!-- Header -->
<div class="header">
<div class="company-info">
<div class="company-name">PT. CINTA KASIH BERSAMA</div>
<div class="company-tagline">Warehouse Management System</div>
</div>
<div class="document-title">Laporan Stock Opname</div>
</div>
<!-- Info Section -->
<div class="info-section">
<div class="info-box">
<div class="info-title">Informasi Opname</div>
<div class="info-item">
<span class="info-label">Tanggal Opname:</span>
<span class="info-value">{{ \Carbon\Carbon::parse($opname->opname_date)->format('d F Y') }}</span>
</div>
<div class="info-item">
<span class="info-label">Status:</span>
<span class="info-value">
@php
$status = $opname->status instanceof \App\Enums\OpnameStatus ? $opname->status : \App\Enums\OpnameStatus::from($opname->status);
@endphp
<span class="status-badge status-approved">{{ $status->label() }}</span>
</span>
</div>
<div class="info-item">
<span class="info-label">Dibuat:</span>
<span class="info-value">{{ \Carbon\Carbon::parse($opname->created_at)->format('d F Y H:i') }}</span>
</div>
</div>
<div class="info-box">
<div class="info-title">Informasi Dealer & User</div>
<div class="info-item">
<span class="info-label">Dealer:</span>
<span class="info-value">{{ $opname->dealer->name ?? '-' }}</span>
</div>
<div class="info-item">
<span class="info-label">User:</span>
<span class="info-value">{{ $opname->user->name ?? '-' }}</span>
</div>
</div>
</div>
<!-- Table Section -->
<div class="table-container">
<div class="table-title">Detail Stock Opname</div>
<table class="data-table">
<thead>
<tr>
<th style="width: 5%;">No.</th>
<th style="width: 15%;">Kode Produk</th>
<th style="width: 35%;">Nama Produk</th>
<th style="width: 15%;">Kategori</th>
<th style="width: 10%;" class="text-center">Stok Sistem</th>
<th style="width: 10%;" class="text-center">Stok Fisik</th>
<th style="width: 10%;" class="text-center">Selisih</th>
</tr>
</thead>
<tbody>
@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
<tr>
<td class="text-center">{{ $index + 1 }}</td>
<td>{{ $detail->product->code ?? '-' }}</td>
<td>{{ $detail->product->name ?? '-' }}</td>
<td>{{ $detail->product->category->name ?? '-' }}</td>
<td class="text-center">{{ number_format($detail->system_stock, 2) }}</td>
<td class="text-center">{{ number_format($detail->physical_stock, 2) }}</td>
<td class="text-center
@if($difference > 0) difference-positive
@elseif($difference < 0) difference-negative
@else difference-zero
@endif">
{{ $difference > 0 ? '+' : '' }}{{ number_format($difference, 2) }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr style="background-color: #2c5282; color: white; font-weight: bold;">
<td colspan="4" class="text-center">TOTAL</td>
<td class="text-center">{{ number_format($totalSystemStock, 2) }}</td>
<td class="text-center">{{ number_format($totalPhysicalStock, 2) }}</td>
<td class="text-center">{{ $totalDifference > 0 ? '+' : '' }}{{ number_format($totalDifference, 2) }}</td>
</tr>
</tfoot>
</table>
</div>
<!-- Summary Section -->
<div class="summary-section">
<div class="summary-title">Ringkasan Stock Opname</div>
<div class="summary-stats">
<div class="stat-item">
<div class="stat-number">{{ count($opname->details) }}</div>
<div class="stat-label">Total Produk</div>
</div>
<div class="stat-item">
<div class="stat-number" style="color: #22543d;">{{ $positiveCount }}</div>
<div class="stat-label">Surplus</div>
</div>
<div class="stat-item">
<div class="stat-number" style="color: #742a2a;">{{ $negativeCount }}</div>
<div class="stat-label">Minus</div>
</div>
<div class="stat-item">
<div class="stat-number" style="color: #4a5568;">{{ $zeroCount }}</div>
<div class="stat-label">Sesuai</div>
</div>
</div>
</div>
<!-- Footer -->
<div class="footer">
<div class="print-info">
Dicetak pada: {{ now()->format('d F Y H:i:s') }} |
Sistem Manajemen Gudang PT. Cinta Kasih Bersama
</div>
</div>
</div>
<script>
// Print on Ctrl+P
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.key === 'p') {
e.preventDefault();
window.print();
}
});
</script>
</body>
</html>