@extends('layouts.admin') @section('title', 'Daftar Penawaran Produk') @section('content') @php $breadcrumbs = [ ['label' => 'Dashboard', 'url' => route('admin.dashboard')], ['label' => 'Penawaran', 'url' => route('admin.product-inquiries.index')], ]; @endphp @if (session('error'))
{{ session('error') }}
@endif

Daftar Penawaran

@if (!empty(request('search'))) @endif
Refresh
@if (request('search') || request('status') || request('state'))
@endif
@if (request('search') || request('status') || request('state'))
Filter Aktif: @if (request('search')) Pencarian: "{{ request('search') }}" @endif @if (request('status')) Status: {{ request('status') == 'unread' ? 'Belum Dibaca' : 'Sudah Dibaca' }} @endif @if (request('state')) @php $stateLabels = [ 'pending' => 'Menunggu', 'supervisor_review' => 'Review Supervisor', 'teknisi_review' => 'Review Teknisi', 'sent_to_admin' => 'Dikirim ke Admin', 'approved' => 'Disetujui', 'customer_accepted' => 'Diterima Customer', 'customer_counter' => 'Tawar Menawar', 'converted_to_order' => 'Jadi Pesanan', 'rejected' => 'Ditolak', ]; $stateLabel = $stateLabels[request('state')] ?? ucwords(str_replace('_', ' ', request('state'))); @endphp Tahap: {{ $stateLabel }} @endif
@endif
@forelse ($inquiries as $inquiry) @csrf @method('DELETE') @empty @endforelse
No Nama Email Produk Pesan Status Tahap Tanggal Aksi
{{ $loop->iteration + $inquiries->firstItem() - 1 }}
{{ $inquiry->name }} @if (!$inquiry->is_read) @endif
{{ $inquiry->email }} {{ Str::limit($inquiry->product->product_title ?? 'Produk tidak ditemukan', 30) }} @php $raw = $inquiry->message ?? ''; $lines = preg_split("/(\r\n|\n|\r)/", $raw); $type = null; $addons = []; $hasAddonsLine = false; if (!empty($lines)) { $first = $lines[0] ?? ''; $second = $lines[1] ?? ''; if (substr($first, 0, 14) === '[REQUEST_TYPE]') { $type = trim(substr($first, 14)); } if (substr($second, 0, 8) === '[ADDONS]') { $hasAddonsLine = true; $matches = []; if (preg_match('/^\[ADDONS\]\s*(\[[\s\S]*\])$/', $second, $matches)) { $decoded = json_decode($matches[1], true); if (is_array($decoded)) { $addons = $decoded; } } } } $startIdx = 0; if ($type) { $startIdx++; } if ($hasAddonsLine) { $startIdx++; } if (!empty($lines) && isset($lines[$startIdx]) && trim($lines[$startIdx]) === '') { $startIdx++; } $plain = implode("\n", array_slice($lines, $startIdx)); $badgeText = $type === 'custom_addon' ? 'Custom Add-on' : ($type === 'custom_new' ? 'Custom Baru' : ($type ? 'Katalog' : null)); $badgeCls = $type === 'custom_addon' ? 'bg-yellow-100 text-yellow-800' : ($type === 'custom_new' ? 'bg-red-100 text-red-800' : 'bg-blue-100 text-blue-800'); @endphp
@if ($badgeText) {{ $badgeText }} @endif @if (!empty($addons)) @php $preview = collect($addons) ->take(2) ->map(function ($a) { $name = is_array($a) ? $a['name'] ?? '' : ''; $value = is_array($a) ? $a['value'] ?? '' : ''; return trim(($name ?: '-') . ': ' . ($value ?: '-')); }) ->implode('; '); $moreCount = max(count($addons) - 2, 0); @endphp
Spesifikasi: {{ $preview }}@if ($moreCount > 0) (+{{ $moreCount }} lagi) @endif
@endif

{{ $plain }}

@if ($inquiry->is_read) Dibaca @else Belum Dibaca @endif @php $state = $inquiry->status ?? 'pending'; $stateLabels = [ 'pending' => 'Menunggu', 'supervisor_review' => 'Review Supervisor', 'teknisi_review' => 'Review Teknisi', 'admin_review' => 'Review Admin', 'sent_to_admin' => 'Dikirim ke Admin', 'sent_to_customer' => 'Dikirim ke Customer', 'approved' => 'Disetujui', 'customer_accepted' => 'Diterima Customer', 'customer_counter' => 'Tawar Menawar', 'converted_to_order' => 'Jadi Pesanan', 'rejected' => 'Ditolak', ]; $map = [ 'pending' => 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300', 'supervisor_review' => 'bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300', 'teknisi_review' => 'bg-indigo-100 dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-300', 'admin_review' => 'bg-cyan-100 dark:bg-cyan-900/40 text-cyan-700 dark:text-cyan-300', 'sent_to_admin' => 'bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300', 'sent_to_customer' => 'bg-teal-100 dark:bg-teal-900/40 text-teal-700 dark:text-teal-300', 'approved' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'customer_accepted' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'customer_counter' => 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300', 'converted_to_order' => 'bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300', 'rejected' => 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300', ]; $cls = $map[$state] ?? 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'; $label = $stateLabels[$state] ?? ucwords(str_replace('_', ' ', $state)); @endphp {{ $label }} {{ $inquiry->created_at->format('d M Y H:i') }}
@php $state = $inquiry->status ?? 'pending'; @endphp @if (in_array($state, ['pending', 'customer_counter'])) @endif @if (in_array($state, ['pending', 'admin_review', 'customer_counter'])) @endif @if (!is_null($inquiry->final_offer_price)) @endif @if (!$inquiry->is_read) @endif @if (($inquiry->status ?? '') === 'sent_to_admin') @php $finalPayload = [ 'id' => $inquiry->id, 'productTitle' => $inquiry->product->product_title ?? '', 'floor' => (float) ($inquiry->supervisor_floor_price ?? 0), 'target' => (float) ($inquiry->supervisor_target_price ?? 0), 'ceiling' => (float) ($inquiry->supervisor_ceiling_price ?? 0), 'validity' => $inquiry->validity_until ? \Carbon\Carbon::parse($inquiry->validity_until)->format('Y-m-d') : '', 'internalCost' => (float) ($inquiry->internal_cost ?? 0), 'marginPercent' => $inquiry->margin_percent, ]; @endphp @endif @if (!empty($inquiry->final_offer_price) && !empty($inquiry->phone)) @php $waNumber = preg_replace('/\D/', '', $inquiry->phone); $waText = 'Halo ' . $inquiry->name . ",\n\n" . 'Penawaran harga final untuk ' . ($inquiry->product->product_title ?? 'produk') . ' adalah Rp ' . number_format($inquiry->final_offer_price, 0, ',', '.') . ".\nLihat dokumen: " . route('admin.print.quotation.offer.preview', $inquiry); $waLink = 'https://wa.me/' . $waNumber . '?text=' . urlencode($waText); @endphp @endif @if ( ($inquiry->status ?? '') === 'customer_accepted' && !empty($inquiry->final_offer_price) && is_null($inquiry->order_id)) @endif @if (($inquiry->status ?? '') === 'converted_to_order' && $inquiry->order_id) @endif

Belum ada penawaran produk

Penawaran produk akan muncul di sini

@if ($inquiries->hasPages())
{{ $inquiries->onEachSide(1)->links() }}
@endif {{-- Modal Detail Pesan --}} {{-- Modal Reply --}} @endsection