
<?php
    $fieldUrl = route('agency.operations.passengers.field', [$typeKey, $id]);
?>

<div class="pmf-table-scroll">
    <table class="pmf-table" id="pmfTable-<?php echo e($uid); ?>">
        <thead>
            <tr>
                <th class="pmf-th-check">
                    <label class="pmf-check" title="Tümünü seç">
                        <input type="checkbox" onchange="mfToggleAll('<?php echo e($uid); ?>', this.checked)">
                        <span></span>
                    </label>
                </th>
                <th class="pmf-th-no">#</th>
                <th>Yolcu</th>
                <th>Kimlik / Pasaport</th>
                <th>Rezervasyon</th>
                <th class="pmf-th-ops">Oda</th>
                <th class="pmf-th-ops">Koltuk</th>
                <?php if($isFlight): ?>
                    <th class="pmf-th-ops">Bilet No</th>
                    <th class="pmf-th-ops pmf-th-sm">PNR</th>
                <?php endif; ?>
                <th class="pmf-th-doc">Belge</th>
                <th class="pmf-th-act"></th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $rows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php
                    $rowKey = $r['_sale_id'] . ':' . $r['_passenger_id'];
                    $named = $r['_named'];
                    $doc = $r['_doc_id'] ?? null;
                    $docCount = $r['_doc_count'] ?? 0;
                ?>
                <tr class="<?php echo e($named ? '' : 'is-unnamed'); ?>" data-mf-row="<?php echo e($rowKey); ?>">
                    <td class="pmf-td-check">
                        <?php if($named): ?>
                            <label class="pmf-check">
                                <input type="checkbox" class="pmf-rowcheck" value="<?php echo e($rowKey); ?>">
                                <span></span>
                            </label>
                        <?php endif; ?>
                    </td>
                    <td class="pmf-no"><?php echo e($r['no']); ?></td>

                    
                    <td>
                        <div class="pmf-pax <?php echo e($named && $r['_customer_id'] ? 'is-link' : ''); ?>"
                             <?php if($named && $r['_customer_id']): ?>
                                 onclick="mfOpenPassengerCard(<?php echo e($r['_customer_id']); ?>, <?php echo e($r['_passenger_id']); ?>)"
                                 title="Müşteri kartında düzenle"
                             <?php endif; ?>>
                            <span class="pmf-av <?php echo e($named ? '' : 'ghost'); ?>">
                                <?php echo e($named ? mb_strtoupper(mb_substr($r['passenger_name'], 0, 1)) : '?'); ?>

                            </span>
                            <div class="pmf-pax-txt">
                                <span class="pmf-name"><?php echo e($r['passenger_name']); ?></span>
                                <span class="pmf-meta">
                                    <?php if($r['pax_type']): ?><span class="pmf-chip"><?php echo e($r['pax_type']); ?></span><?php endif; ?>
                                    <?php if($r['gender']): ?><span><?php echo e($r['gender']); ?></span><?php endif; ?>
                                    <?php if($r['birth_date']): ?><span><?php echo e($r['birth_date']); ?></span><?php endif; ?>
                                    <?php if(!$named): ?><span class="pmf-chip warn">Ad girilmemiş</span><?php endif; ?>
                                </span>
                            </div>
                        </div>
                    </td>

                    
                    <td>
                        <div class="pmf-idcell">
                            <?php if($r['national_id']): ?><span><i class="fas fa-id-card"></i><?php echo e($r['national_id']); ?></span><?php endif; ?>
                            <?php if($r['passport_number']): ?>
                                <span><i class="fas fa-passport"></i><?php echo e($r['passport_number']); ?>

                                    <?php if($r['passport_expiry']): ?><small>· <?php echo e($r['passport_expiry']); ?></small><?php endif; ?>
                                </span>
                            <?php endif; ?>
                            <?php if(!$r['national_id'] && !$r['passport_number']): ?><span class="pmf-dash">—</span><?php endif; ?>
                        </div>
                    </td>

                    
                    <td>
                        <div class="pmf-rescell">
                            <button type="button" class="pmf-link" onclick="event.stopPropagation(); openSaleDrawer(<?php echo e($r['_sale_id']); ?>)" title="Satış kartını aç">
                                #<?php echo e($r['sale_code']); ?>

                            </button>
                            <?php if($r['customer_name'] && $r['_customer_id']): ?>
                                <button type="button" class="pmf-link pmf-cust" onclick="event.stopPropagation(); openCustomerDrawer(<?php echo e($r['_customer_id']); ?>)" title="Müşteri kartını aç">
                                    <?php echo e($r['customer_name']); ?>

                                </button>
                            <?php else: ?>
                                <span class="pmf-meta"><?php echo e($r['customer_name']); ?></span>
                            <?php endif; ?>
                            <span class="pmf-meta">
                                <span class="pmf-chip <?php echo e($r['remaining_amount'] > 0 ? 'warn' : 'ok'); ?>"><?php echo e($r['payment_status']); ?></span>
                            </span>
                        </div>
                    </td>

                    
                    <td><?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'room_number', 'value' => $r['room_number'], 'row' => $r, 'named' => $named, 'url' => $fieldUrl, 'ph' => 'Oda'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                    <td><?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'seat_number', 'value' => $r['seat_number'], 'row' => $r, 'named' => $named, 'url' => $fieldUrl, 'ph' => 'Koltuk'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                    <?php if($isFlight): ?>
                        <td><?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'ticket_number', 'value' => $r['ticket_number'], 'row' => $r, 'named' => $named, 'url' => $fieldUrl, 'ph' => 'Bilet no'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                        <td><?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'ticket_pnr', 'value' => $r['ticket_pnr'], 'row' => $r, 'named' => $named, 'url' => $fieldUrl, 'ph' => 'PNR'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                    <?php endif; ?>

                    
                    <td>
                        <div class="pmf-doccell">
                            <?php if($doc): ?>
                                <span class="pmf-docbadge" title="Bu yolcu için belge üretildi">
                                    <i class="fas fa-file-signature"></i><?php echo e($r['_doc_status']); ?>

                                    <?php if($docCount > 1): ?><b>×<?php echo e($docCount); ?></b><?php endif; ?>
                                </span>
                            <?php elseif($named): ?>
                                <span class="pmf-docbadge none" title="Bu yolcu için belge üretilmedi">
                                    <i class="fas fa-file"></i>Belge yok
                                </span>
                            <?php endif; ?>
                        </div>
                    </td>

                    
                    <td class="pmf-td-act">
                        <?php if(!$named): ?>
                            
                            <button type="button" class="pmf-addpax" title="Bu kişi için yolcu kaydı aç"
                                    onclick="mfAddPassenger(<?php echo e($r['_sale_id']); ?>, '<?php echo e($uid); ?>')">
                                <i class="fas fa-user-plus"></i> Bilgi gir
                            </button>
                        <?php endif; ?>
                        <?php if($named): ?>
                            <div class="pmf-rowbtns">
                                <button type="button" class="pmf-iconbtn" title="Detay / tüm alanlar" onclick="mfToggleDetail(this)"><i class="fas fa-chevron-down"></i></button>
                                <?php if($doc): ?>
                                    <a class="pmf-iconbtn ok" title="Belgeyi indir" href="<?php echo e(route('agency.passenger-documents.pdf', $doc)); ?>" target="_blank"><i class="fas fa-file-pdf"></i></a>
                                    <button type="button" class="pmf-iconbtn" title="Belgeyi düzenle" onclick="mfEditDoc(<?php echo e($doc); ?>,'<?php echo e($uid); ?>')"><i class="fas fa-pen"></i></button>
                                <?php endif; ?>
                                <button type="button" class="pmf-iconbtn" title="Bu yolcu için belge üret" onclick="mfOpenDocModal('<?php echo e($uid); ?>','<?php echo e($rowKey); ?>')"><i class="fas fa-file-circle-plus"></i></button>
                            </div>
                        <?php endif; ?>
                    </td>
                </tr>

                
                <?php if($r['_named']): ?>
                    <tr class="pmf-detail" hidden data-mf-detail="<?php echo e($rowKey); ?>">
                        <td colspan="<?php echo e($isFlight ? 11 : 9); ?>">
                            
                            <div class="pmf-dsec"><i class="fas fa-id-card"></i> Kimlik Bilgileri
                                <small>Kişi kaydına işlenir — müşteri kartında da görünür</small>
                            </div>
                            <div class="pmf-detail-grid">
                                <div class="pmf-dfld edit"><label>Ad</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'first_name', 'value' => $r['_first_name'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Ad'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld edit"><label>Soyad</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'last_name', 'value' => $r['_last_name'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Soyad'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld edit"><label>T.C. Kimlik No</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'national_id', 'value' => $r['national_id'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => '11 hane'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld edit"><label>Doğum Tarihi <?php if($r['age'] !== null): ?><b class="pmf-agechip"><?php echo e($r['age']); ?> yaş</b><?php endif; ?></label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'birth_date', 'value' => $r['birth_date'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Doğum tarihi', 'type' => 'date'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld edit"><label>Cinsiyet</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'gender', 'value' => $r['_gender'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Seçilmedi', 'type' => 'select', 'options' => ['male' => 'Erkek', 'female' => 'Kadın', 'other' => 'Diğer']], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld"><label>Pasaport No</label><span><?php echo e($r['passport_number'] ?: '—'); ?></span></div>
                            </div>

                            <div class="pmf-dsec"><i class="fas fa-circle-info"></i> Diğer Bilgiler</div>
                            <div class="pmf-detail-grid">
                                <div class="pmf-dfld"><label>Telefon</label><span><?php echo e($r['phone'] ?: '—'); ?></span></div>
                                <div class="pmf-dfld"><label>E-posta</label><span><?php echo e($r['email'] ?: '—'); ?></span></div>
                                <div class="pmf-dfld"><label>Vize Durumu</label><span><?php echo e($r['visa_status'] ?: '—'); ?></span></div>
                                <div class="pmf-dfld"><label>Vize Bitiş</label><span><?php echo e($r['visa_expiry'] ?: '—'); ?></span></div>
                                <div class="pmf-dfld"><label>Biniş Noktası</label><span><?php echo e($r['pickup_location'] ?: '—'); ?></span></div>
                                <div class="pmf-dfld"><label>Satış Temsilcisi</label><span><?php echo e($r['agent_name'] ?: '—'); ?></span></div>

                                <?php if($isFlight): ?>
                                    <div class="pmf-dfld edit"><label>Uçuş No</label>
                                        <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'flight_no', 'value' => $r['flight_no'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Uçuş no'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </div>
                                    <div class="pmf-dfld edit"><label>Bagaj</label>
                                        <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'baggage_info', 'value' => $r['baggage_info'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Örn: 20 kg'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </div>
                                <?php endif; ?>

                                <div class="pmf-dfld edit wide"><label>Özel İstek</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'special_request', 'value' => $r['special_request'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Özel istek'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="pmf-dfld edit wide"><label>Operasyon Notu</label>
                                    <?php echo $__env->make('agency.operations.partials.manifest-cell', ['field' => 'notes', 'value' => $r['notes'], 'row' => $r, 'named' => true, 'url' => $fieldUrl, 'ph' => 'Not'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="<?php echo e($isFlight ? 11 : 9); ?>" class="pmf-empty">
                        <i class="fas fa-user-slash"></i>
                        Bu kalkışa bağlı yolcu kaydı yok.
                    </td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>

<div class="pmf-foot">
    <span class="pmf-selinfo" id="pmfSel-<?php echo e($uid); ?>" hidden><b>0</b> yolcu seçili</span>
    <span class="pmf-hint"><i class="fas fa-bolt"></i> Hücreye tıklayıp yazın — değişiklik anında kaydedilir.</span>
</div>
<?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/operations/partials/manifest-table.blade.php ENDPATH**/ ?>