{{-- Flash message (sukses/error) --}}
@if (session('error')) @endif @if (session('message')) @endif
{{-- Tabs Mode --}}
@if($viewMode == 'input') {{-- Header Input --}}
@if($step == 1) {{-- STEP 1: PILIH BARANG --}} {{-- Search --}}
{{-- List Barang --}}
@forelse($hps as $hp) @php $modalBelumDiisi = $hp->modalBelumDiisi(); @endphp

{{ $hp->merk_model }}

IMEI: {{ $hp->imei }}
@if($hp->warna) {{ $hp->warna }} @endif @if($hp->keterangan_minus) Minus: {{ $hp->keterangan_minus }} @endif @if($modalBelumDiisi) Menunggu modal admin @endif
@if(auth()->user()?->isAdmin()) Modal: Rp {{ number_format($hp->total_modal ?? 0, 0, ',', '.') }} @if($modalBelumDiisi) Modal belum diisi@endif @endif
@if($modalBelumDiisi) @else id, $selectedHps) ? 'checked' : '' }} /> @endif
@empty
Tidak ada barang READY yang ditemukan.
@endforelse
{{-- Bottom Bar --}} @if(count($selectedHps) > 0)
{{ count($selectedHps) }} Barang dipilih
@endif @elseif($step == 2) {{-- STEP 2: CHECKOUT & SPLIT HARGA --}}
{{-- Info Pembeli --}}

Info Transaksi

@error('wa_pembeli') {{ $message }} @enderror
Rp
@error('total_transaksi') {{ $message }} @enderror {{-- Realtime Profit Info (khusus admin) --}} @php $totalModal = (float) $hps->sum('total_modal'); $estimasiProfit = (float)$total_transaksi - $totalModal; @endphp @if(auth()->user()?->isAdmin())
Total Modal
Rp {{ number_format($totalModal, 0, ',', '.') }}
Estimasi Profit
{{ $estimasiProfit >= 0 ? '+' : '' }} Rp {{ number_format($estimasiProfit, 0, ',', '.') }}
@endif
{{-- Rincian Per Item --}}

Rincian Harga Per Unit

Masukkan harga jual untuk masing-masing unit agar keuntungan tercatat akurat per barang.

@foreach($hps as $hp)
{{ $hp->merk_model }}
{{ $hp->imei }}
@if($hp->warna) {{ $hp->warna }} @endif @if($hp->keterangan_minus) Minus: {{ $hp->keterangan_minus }} @endif
@if(auth()->user()?->isAdmin())
Modal: {{ number_format($hp->total_modal ?? 0, 0, ',', '.') }}
@endif
Rp
{{-- Kalkulasi Laba Realtime (khusus admin) --}} @if(auth()->user()?->isAdmin() && isset($harga_jual_items[$hp->id]) && is_numeric($harga_jual_items[$hp->id]))
@php $laba = $harga_jual_items[$hp->id] - ($hp->total_modal ?? 0); @endphp Laba: Rp {{ number_format($laba, 0, ',', '.') }}
@endif
@endforeach
{{-- Summary Check --}} @php $sumItems = 0; foreach($harga_jual_items as $val) { $sumItems += (float) $val; } @endphp
Total Rincian: Rp {{ number_format($sumItems, 0, ',', '.') }}
@if($sumItems != $total_transaksi)
Selisih: Rp {{ number_format($total_transaksi - $sumItems, 0, ',', '.') }}
@endif
{{-- Bottom Action --}}
@endif
@elseif($viewMode == 'history')
{{-- Search History --}}
{{-- List History --}} @forelse($history as $trx)
{{ $trx->nama_pembeli ?: 'Tanpa Nama' }}
{{ $trx->created_at->format('d M Y H:i') }}
@if($trx->user)
{{ $trx->user->name }}{{ $trx->user->isAdmin() ? ' (Admin)' : '' }}
@endif @if($trx->wa_pembeli) {{ $trx->wa_pembeli }} @endif
Rp {{ number_format($trx->total_transaksi, 0, ',', '.') }}
Total
@foreach($trx->details as $dtl)
{{ $dtl->hp->merk_model ?? 'Item Terhapus' }}
IMEI: {{ $dtl->hp->imei ?? '-' }}
Rp {{ number_format($dtl->harga_jual_unit, 0, ',', '.') }}
@if($dtl->hp && auth()->user()?->isAdmin()) @endif
@endforeach
@empty
Belum ada riwayat penjualan
@endforelse
@endif