@extends('admin.layout.master') @section('open-pemasaran', 'open') @section('menu-pemasaran', 'bg-gradient-to-r from-[#53BF6A] to-[#275931] text-white') @section('menu-pemasaran-laporan-penjualan', 'bg-gradient-to-r from-[#53BF6A] to-[#275931] text-white') @section('addCss') @endsection @section('content')
Pemasaran › Laporan Penjualan › Sunting Laporan
@if ($errors->any())
Ada data yang masih bermasalah:
@endif @php $isPaidOff = $sale->status === 'Lunas' || (int) $sale->debt_amount <= 0; $isPo = $sale->stock_type === 'po'; @endphp
@csrf @method('PUT') {{-- BLOK HEADER (READ ONLY) --}}
{{-- TABEL DAFTAR BARANG --}}
@if ($isPo) @endif @foreach ($sale->items as $item) @if ($isPo) @endif @endforeach
No Nama Produk Qty OrderedSudah Dipenuhi Sisa POSubtotal
{{ $loop->iteration }} {{ $item->productStock?->productVariant?->name ?? '-' }} {{ $item->quantity }}{{ $item->fulfilled_quantity }} {{ max(0, $item->quantity - $item->fulfilled_quantity) }} Rp {{ number_format((int) $item->subtotal, 0, ',', '.') }}
{{-- FULFILL PO (MUNCUL JIKA TIPE PO) --}} @if ($isPo)

Fulfill Pre-Order (Ambil dari Stok Ready)

Isi qty yang ingin diambil dari stok ready sekarang. Stok baru akan berkurang sesuai input.

@error('fulfillment_date')

{{ $message }}

@enderror
@foreach ($sale->items as $item) @php $remaining = max(0, $item->quantity - $item->fulfilled_quantity); @endphp
{{ $item->productStock?->productVariant?->name ?? '-' }}
SKU: {{ $item->productStock?->productVariant?->sku ?? '-' }}
{{ $item->quantity }}
{{ $item->fulfilled_quantity }}
@error('fulfill.' . $item->id)

{{ $message }}

@enderror
@endforeach
@endif {{-- TOTAL + PEMBAYARAN --}}
@if (!$isPaidOff)
@error('payment_date')

{{ $message }}

@enderror
@endif
{{-- BUKTI PEMBAYARAN CICILAN --}} @if (!$isPaidOff)
@error('invoice')

{{ $message }}

@enderror
@endif {{-- FOOTER ACTION --}}
Batal
{{-- BUKTI SERAH TERIMA (HANYA MUNCUL JIKA LUNAS) --}} @if ($isPaidOff) @php $bstMedia = method_exists($sale, 'getFirstMedia') ? $sale->getFirstMedia('delivery_proof') : null; $bstUrl = $bstMedia?->getUrl(); $bstMime = $bstMedia?->mime_type ?? ''; $isImage = str_starts_with($bstMime, 'image/'); $isPdf = str_contains($bstMime, 'pdf'); @endphp

Dokumen tanda terima serah barang yang sudah ditandatangani.

@if ($bstMedia) BST Sudah Diunggah @else Belum Ada BST @endif
@if ($bstMedia) {{-- DETAIL & LINK BST YANG SUDAH DIUNGGAH --}}
@if ($isPdf) @else @endif

{{ $bstMedia->file_name }}

{{ $bstMedia->human_readable_size }} · Diunggah pada {{ $bstMedia->created_at?->format('d/m/Y H:i') }}

@endif
@csrf
@error('delivery_proof')

{{ $message }}

@enderror
@endif @endsection @section('addJs') @endsection