{{-- UÇUŞ BİLGİLERİ — uçak bileti satış kanalının bilgi girişi. Rezervasyon sisteminden alınan bilgiler (PNR, uçuş, opsiyon…) buraya satır satır girilir; her satır yazıldığı anda kaydedilir (PATCH agency.sales.flight.update-field). Satış kartının genel otomatik kaydına karışmaz: değerler sales.flight_details + sales.airline_supplier_id'de tutulur. Beklenen: $sale (uçak bileti kanalında) --}} @php $fd = (array) ($sale->flight_details ?? []); $fv = fn (string $k) => $fd[$k] ?? null; $fDmy = fn ($d) => $d ? \Carbon\Carbon::parse($d)->format('d.m.Y') : ''; $airlines = \App\Models\Product\FlightProduct::airlineSuppliers((int) $sale->agency_id); $airlineOpts = collect([['value' => '', 'label' => '—']]) ->concat($airlines->map(fn ($a) => ['value' => (string) $a->id, 'label' => $a->full_name]))->values()->all(); $tripOpts = [['value' => '', 'label' => '—'], ['value' => 'one_way', 'label' => 'Tek yön'], ['value' => 'round_trip', 'label' => 'Gidiş - dönüş'], ['value' => 'multi', 'label' => 'Çoklu uçuş']]; $cabinOpts = [['value' => '', 'label' => '—'], ['value' => 'economy', 'label' => 'Ekonomi'], ['value' => 'premium', 'label' => 'Premium Ekonomi'], ['value' => 'business', 'label' => 'Business'], ['value' => 'first', 'label' => 'First']]; $optLabel = fn (array $opts, $v) => collect($opts)->firstWhere('value', (string) $v)['label'] ?? ''; $fRow = function (string $label, string $field, $value, ?string $text = null, array $o = []) { return [ 'label' => $label, 'field' => $field, 'type' => $o['type'] ?? 'text', 'value' => $value === null ? '' : (string) $value, 'text' => $text === null ? ($value === null ? '' : (string) $value) : $text, 'options' => $o['options'] ?? null, 'mono' => $o['mono'] ?? false, 'ph' => $o['ph'] ?? null, ]; }; $optionDeadline = $fv('option_deadline'); $optionIso = $optionDeadline ? \Carbon\Carbon::parse($optionDeadline)->format('Y-m-d\TH:i') : ''; $optionText = $optionDeadline ? \Carbon\Carbon::parse($optionDeadline)->format('d.m.Y H:i') : ''; // Opsiyon yalnızca bilet henüz kesilmemişken (teklif aşaması) anlamlıdır; // tamamlanan satış "Biletlendi" sayılır, operasyon adımına bakılmaz. $optionLate = $optionDeadline && \Carbon\Carbon::parse($optionDeadline)->isPast() && in_array($sale->status, ['potential', 'offer_sent', 'revised', 'pending'], true); @endphp @include('components.quick-view.ledger-card', ['card' => [ 'title' => 'Uçuş Bilgileri', 'icon' => 'fa-plane-departure', 'url' => route('agency.sales.flight.update-field', $sale), 'foldable' => true, 'note' => $airlines->isEmpty() ? 'Havayolu seçebilmek için Tedarikçiler modülünde hizmet kategorisi “Havayolu” olan tedarikçi ekleyin.' : 'Rezervasyon sistemindeki bilgileri girin; her satır anında kaydedilir.', 'sections' => [ [ 'title' => 'Rezervasyon', 'icon' => 'fa-bookmark', 'rows' => [ $fRow('Havayolu', 'airline_supplier_id', $sale->airline_supplier_id, $optLabel($airlineOpts, $sale->airline_supplier_id), ['type' => 'select', 'options' => $airlineOpts]), $fRow('PNR', 'pnr', $fv('pnr'), null, ['mono' => true, 'ph' => 'Ör. X7K2PQ']), $fRow('Yolculuk Tipi', 'trip_type', $fv('trip_type'), $optLabel($tripOpts, $fv('trip_type')), ['type' => 'select', 'options' => $tripOpts]), $fRow('Kabin', 'cabin', $fv('cabin'), $optLabel($cabinOpts, $fv('cabin')), ['type' => 'select', 'options' => $cabinOpts]), $fRow('Rezervasyon Kaynağı', 'booking_source', $fv('booking_source'), null, ['ph' => 'Ör. Amadeus, havayolu portalı']), ], ], [ 'title' => 'Gidiş', 'icon' => 'fa-plane-departure', 'rows' => [ $fRow('Kalkış', 'out_from', $fv('out_from'), null, ['mono' => true, 'ph' => 'Ör. IST']), $fRow('Varış', 'out_to', $fv('out_to'), null, ['mono' => true, 'ph' => 'Ör. ESB']), $fRow('Tarih', 'out_date', $fv('out_date'), $fDmy($fv('out_date')), ['type' => 'date', 'mono' => true]), $fRow('Saat', 'out_time', $fv('out_time'), null, ['type' => 'time', 'mono' => true]), $fRow('Uçuş No', 'out_flight_no', $fv('out_flight_no'), null, ['mono' => true, 'ph' => 'Ör. TK2124']), ], ], [ 'title' => 'Dönüş', 'icon' => 'fa-plane-arrival', 'rows' => [ $fRow('Tarih', 'ret_date', $fv('ret_date'), $fDmy($fv('ret_date')), ['type' => 'date', 'mono' => true, 'ph' => 'Tek yönse boş']), $fRow('Saat', 'ret_time', $fv('ret_time'), null, ['type' => 'time', 'mono' => true]), $fRow('Uçuş No', 'ret_flight_no', $fv('ret_flight_no'), null, ['mono' => true]), ], ], [ 'title' => 'Biletleme', 'icon' => 'fa-ticket', 'rows' => [ $fRow('Opsiyon Son Tarihi', 'option_deadline', $optionIso, $optionText . ($optionLate ? ' · süresi geçti' : ''), ['type' => 'datetime-local', 'mono' => true]), $fRow('Biletleme Tarihi', 'ticketed_at', $fv('ticketed_at'), $fDmy($fv('ticketed_at')), ['type' => 'date', 'mono' => true]), $fRow('Bagaj Hakkı', 'baggage', $fv('baggage'), null, ['ph' => 'Ör. 20 kg + 8 kg kabin']), $fRow('Not', 'note', $fv('note'), null, ['type' => 'textarea', 'ph' => 'Rezervasyonla ilgili notlar']), ], ], ], ]])