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

@@ -5,6 +5,13 @@
Detail
</a>
<!-- Print Button -->
<a href="{{ route('mutations.print', $row->id) }}"
class="btn btn-sm btn-success mr-2"
target="_blank">
Print
</a>
@if($row->status->value === 'sent')
<!-- Receive Button (untuk dealer tujuan) -->
@if(auth()->user()->dealer_id == $row->to_dealer_id)

View File

@@ -0,0 +1,546 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Mutasi - {{ $mutation->mutation_number }}</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-sent {
background-color: #bee3f8;
color: #2c5282;
}
.status-received {
background-color: #fef5e7;
color: #744210;
}
.status-approved {
background-color: #c6f6d5;
color: #22543d;
}
.status-rejected {
background-color: #fed7d7;
color: #742a2a;
}
.status-cancelled {
background-color: #e2e8f0;
color: #4a5568;
}
/* 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;
}
/* Quantity highlighting */
.quantity-full {
color: #22543d;
font-weight: bold;
}
.quantity-partial {
color: #744210;
font-weight: bold;
}
.quantity-none {
color: #742a2a;
font-weight: bold;
}
/* 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;
}
/* Notes Section */
.notes-section {
background-color: #f7fafc;
border-left: 4px solid #2c5282;
padding: 15px;
margin: 20px 0;
}
.notes-title {
font-weight: bold;
color: #2c5282;
margin-bottom: 8px;
}
.notes-content {
color: #4a5568;
line-height: 1.5;
}
/* 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">Dokumen Mutasi Stock</div>
</div>
<!-- Info Section -->
<div class="info-section">
<div class="info-box">
<div class="info-title">Informasi Mutasi</div>
<div class="info-item">
<span class="info-label">No. Mutasi:</span>
<span class="info-value">{{ $mutation->mutation_number }}</span>
</div>
<div class="info-item">
<span class="info-label">Tanggal Dibuat:</span>
<span class="info-value">{{ \Carbon\Carbon::parse($mutation->created_at)->format('d F Y H:i') }}</span>
</div>
<div class="info-item">
<span class="info-label">Status:</span>
<span class="info-value">
@php
$status = $mutation->status instanceof \App\Enums\MutationStatus ? $mutation->status : \App\Enums\MutationStatus::from($mutation->status);
@endphp
<span class="status-badge status-{{ strtolower($status->name) }}">{{ $status->label() }}</span>
</span>
</div>
<div class="info-item">
<span class="info-label">Dibuat oleh:</span>
<span class="info-value">{{ $mutation->requestedBy->name ?? '-' }}</span>
</div>
</div>
<div class="info-box">
<div class="info-title">Informasi Dealer</div>
<div class="info-item">
<span class="info-label">Dari Dealer:</span>
<span class="info-value">{{ $mutation->fromDealer->name ?? '-' }}</span>
</div>
<div class="info-item">
<span class="info-label">Ke Dealer:</span>
<span class="info-value">{{ $mutation->toDealer->name ?? '-' }}</span>
</div>
@if($mutation->receivedBy)
<div class="info-item">
<span class="info-label">Diterima oleh:</span>
<span class="info-value">{{ $mutation->receivedBy->name ?? '-' }}</span>
</div>
@endif
@if($mutation->received_at)
<div class="info-item">
<span class="info-label">Tanggal Terima:</span>
<span class="info-value">{{ \Carbon\Carbon::parse($mutation->received_at)->format('d F Y H:i') }}</span>
</div>
@endif
</div>
</div>
@if($mutation->shipping_notes)
<div class="notes-section">
<div class="notes-title">Catatan Pengiriman</div>
<div class="notes-content">{{ $mutation->shipping_notes }}</div>
</div>
@endif
@if($mutation->reception_notes)
<div class="notes-section">
<div class="notes-title">Catatan Penerimaan</div>
<div class="notes-content">{{ $mutation->reception_notes }}</div>
</div>
@endif
@if($mutation->approval_notes)
<div class="notes-section">
<div class="notes-title">Catatan Persetujuan</div>
<div class="notes-content">{{ $mutation->approval_notes }}</div>
</div>
@endif
@if($mutation->rejection_reason)
<div class="notes-section" style="border-left-color: #742a2a; background-color: #fed7d7;">
<div class="notes-title" style="color: #742a2a;">Alasan Penolakan</div>
<div class="notes-content" style="color: #742a2a;">{{ $mutation->rejection_reason }}</div>
</div>
@endif
<!-- Table Section -->
<div class="table-container">
<div class="table-title">Detail Produk Mutasi</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">Qty Diminta</th>
@if($mutation->status->value !== 'sent')
<th style="width: 10%;" class="text-center">Qty Diterima</th>
<th style="width: 10%;">Catatan</th>
@endif
</tr>
</thead>
<tbody>
@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
<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->quantity_requested, 2) }}</td>
@if($mutation->status->value !== 'sent')
<td class="text-center
@if($detail->quantity_approved == $detail->quantity_requested) quantity-full
@elseif($detail->quantity_approved > 0) quantity-partial
@else quantity-none
@endif">
{{ $detail->quantity_approved ? number_format($detail->quantity_approved, 2) : '0.00' }}
@if($detail->quantity_approved && $detail->quantity_approved < $detail->quantity_requested)
<br><small class="text-muted">(Kurang {{ number_format($detail->quantity_requested - $detail->quantity_approved, 2) }})</small>
@endif
</td>
<td style="font-size: 10px;">{{ $detail->notes ?: '-' }}</td>
@endif
</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($totalRequested, 2) }}</td>
@if($mutation->status->value !== 'sent')
<td class="text-center">{{ number_format($totalApproved, 2) }}</td>
<td>-</td>
@endif
</tr>
</tfoot>
</table>
</div>
<!-- Summary Section -->
<div class="summary-section">
<div class="summary-title">Ringkasan Mutasi</div>
<div class="summary-stats">
<div class="stat-item">
<div class="stat-number">{{ count($mutation->mutationDetails) }}</div>
<div class="stat-label">Total Item</div>
</div>
@if($mutation->status->value !== 'sent')
<div class="stat-item">
<div class="stat-number" style="color: #22543d;">{{ $fullItems }}</div>
<div class="stat-label">Lengkap</div>
</div>
<div class="stat-item">
<div class="stat-number" style="color: #744210;">{{ $partialItems }}</div>
<div class="stat-label">Sebagian</div>
</div>
<div class="stat-item">
<div class="stat-number" style="color: #742a2a;">{{ $rejectedItems }}</div>
<div class="stat-label">Ditolak</div>
</div>
@endif
<div class="stat-item">
<div class="stat-number">{{ number_format($totalRequested, 2) }}</div>
<div class="stat-label">Total Diminta</div>
</div>
@if($mutation->status->value !== 'sent')
<div class="stat-item">
<div class="stat-number">{{ number_format($totalApproved, 2) }}</div>
<div class="stat-label">Total Diterima</div>
</div>
@endif
</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>