

<?php $__env->startSection('title', 'Yurt Dışı Turları'); ?>
<?php $__env->startSection('page_title', 'Yurt Dışı Turları'); ?>

<?php
    $breadcrumbs = [
        ['title' => 'Ana Sayfa', 'url' => route('agency.dashboard')],
        ['title' => 'Ürünler', 'url' => '#'],
        ['title' => 'Yurt Dışı Turları', 'url' => '']
    ];

    $sort = request('sort', 'created_at');
    $dir = request('dir', 'desc');

    $columns = [
        ['key' => 'image',    'label' => 'Görsel',       'align' => 'center', 'width' => '70px'],
        ['key' => 'name',     'label' => 'Tur Adı',      'sortable' => true, 'sort' => 'name'],
        ['key' => 'category', 'label' => 'Kategori'],
        ['key' => 'city',     'label' => 'Kalkış',       'sortable' => true, 'sort' => 'departure_city_id'],
        ['key' => 'duration', 'label' => 'Süre',         'align' => 'center'],
        ['key' => 'price',    'label' => 'Fiyat',        'align' => 'end'],
        ['key' => 'views',    'label' => 'Görüntülenme', 'sortable' => true, 'sort' => 'view_count', 'align' => 'center'],
        ['key' => 'status',   'label' => 'Durum',        'align' => 'center'],
        ['key' => 'created',  'label' => 'Oluşturma',    'sortable' => true, 'sort' => 'created_at', 'visible' => false],
        ['key' => '_actions', 'label' => 'İşlemler',     'fixed' => true, 'align' => 'end', 'width' => '150px'],
    ];

    $filters = [
        ['key' => 'status', 'label' => 'Durum', 'value' => request('status'), 'options' => [
            'active' => 'Aktif', 'inactive' => 'Pasif', 'published' => 'Yayında',
        ]],
        ['key' => 'category', 'label' => 'Kategori', 'value' => request('category'),
            'options' => $categories->pluck('name', 'id')->toArray()],
        ['key' => 'tour_type', 'label' => 'Tur Tipi', 'value' => request('tour_type'), 'options' => [
            'domestic' => 'İç Turizm', 'international' => 'Dış Turizm',
        ]],
    ];

?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <?php if (isset($component)) { $__componentOriginalc8463834ba515134d5c98b88e1a9dc03 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalc8463834ba515134d5c98b88e1a9dc03 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.data-table','data' => ['module' => 'products-yurtdisi','title' => 'Yurt Dışı Turları','subtitle' => 'Kültür turlarınızı yönetin','icon' => 'fa-globe','columns' => $columns,'filters' => $filters,'bulk' => true,'search' => request('search', ''),'searchPlaceholder' => 'Tur adı veya kod ara...','sort' => $sort,'dir' => $dir,'createOnclick' => 'openDraftQuickView(\''.e(route('agency.products.yurtdisi-turlari.quick-create')).'\')','createLabel' => 'Yeni Yurt Dışı Turu','paginator' => $tours,'perPageOptions' => [12, 24, 48, 96]]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('data-table'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['module' => 'products-yurtdisi','title' => 'Yurt Dışı Turları','subtitle' => 'Kültür turlarınızı yönetin','icon' => 'fa-globe','columns' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($columns),'filters' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($filters),'bulk' => true,'search' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(request('search', '')),'search-placeholder' => 'Tur adı veya kod ara...','sort' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($sort),'dir' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($dir),'create-onclick' => 'openDraftQuickView(\''.e(route('agency.products.yurtdisi-turlari.quick-create')).'\')','create-label' => 'Yeni Yurt Dışı Turu','paginator' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($tours),'per-page-options' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute([12, 24, 48, 96])]); ?>
         <?php $__env->slot('headerActions', null, []); ?> 
            <a href="<?php echo e(route('agency.products.yurtdisi-turlari.drafts')); ?>" class="dt-btn dt-btn-ghost">
                <i class="fas fa-file-pen"></i> Taslaklar
                <?php if($draftCount): ?><span class="dt-pill"><?php echo e($draftCount); ?></span><?php endif; ?>
            </a>
         <?php $__env->endSlot(); ?>

         <?php $__env->slot('bulkActions', null, []); ?> 
            <button type="button" class="dt-mini-btn" onclick="bulkAction('active')"><i class="fas fa-check"></i> Aktif Et</button>
            <button type="button" class="dt-mini-btn" onclick="bulkAction('inactive')"><i class="fas fa-pause"></i> Pasif Et</button>
            <button type="button" class="dt-mini-btn" onclick="bulkAction('delete')"><i class="fas fa-trash"></i> Sil</button>
         <?php $__env->endSlot(); ?>

        <?php $__empty_1 = true; $__currentLoopData = $tours; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tour): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr class="kultur-row" data-quickview-url="<?php echo e(route('agency.products.yurtdisi-turlari.quick-view', $tour)); ?>" style="cursor:pointer">
                <td data-col="_select"><label class="dt-check"><input type="checkbox" class="dt-rowcheck" value="<?php echo e($tour->id); ?>"><span></span></label></td>
                <td data-col="image" class="text-center">
                    <?php if($tour->coverImage?->galleryImage): ?>
                        <img class="dt-thumb" src="<?php echo e($tour->coverImage->galleryImage->thumbnail_url); ?>" alt="">
                    <?php else: ?>
                        <span class="dt-thumb-ph"><i class="fas fa-image"></i></span>
                    <?php endif; ?>
                </td>
                <td data-col="name">
                    <div class="dt-cell-main"><?php echo e($tour->name); ?></div>
                    <div class="dt-cell-sub">
                        <i class="fas fa-hashtag" style="font-size:.62rem"></i> <?php echo e($tour->code ?? '—'); ?>

                        <?php if($tour->is_featured): ?> <span class="dt-badge dt-badge-amber ms-1"><i class="fas fa-star"></i></span><?php endif; ?>
                    </div>
                </td>
                <td data-col="category">
                    <?php if($tour->categories->isNotEmpty()): ?>
                        <span class="dt-badge dt-badge-indigo"><?php echo e($tour->categories->first()->name); ?></span>
                        <?php if($tour->categories->count() > 1): ?><span class="dt-cell-sub">+<?php echo e($tour->categories->count() - 1); ?></span><?php endif; ?>
                    <?php else: ?>
                        <span class="dt-cell-sub">—</span>
                    <?php endif; ?>
                </td>
                <td data-col="city">
                    <i class="fas fa-location-dot text-danger" style="font-size:.72rem"></i>
                    <?php echo e($tour->departureCity->city ?? 'Belirtilmemiş'); ?>

                </td>
                <td data-col="duration" class="text-center">
                    <span class="dt-badge dt-badge-slate"><?php echo e($tour->days); ?>G / <?php echo e($tour->nights); ?>Gece</span>
                </td>
                <td data-col="price" class="text-end">
                    <?php $startingPrice = $tour->getLowestPrice(); ?>
                    <?php if($startingPrice > 0): ?>
                        <span class="dt-cell-main"><?php echo e(number_format($startingPrice, 0)); ?></span>
                        <span class="dt-cell-sub"><?php echo e($tour->currency); ?></span>
                    <?php else: ?>
                        <span class="dt-cell-sub">—</span>
                    <?php endif; ?>
                </td>
                <td data-col="views" class="text-center"><i class="fas fa-eye text-muted" style="font-size:.72rem"></i> <?php echo e($tour->view_count); ?></td>
                <td data-col="status" class="text-center">
                    <?php if($tour->is_active && $tour->is_public): ?>
                        <span class="dt-badge dt-badge-green"><i class="fas fa-circle" style="font-size:.5rem"></i> Yayında</span>
                    <?php elseif($tour->is_active && !$tour->is_public): ?>
                        <span class="dt-badge dt-badge-amber"><i class="fas fa-circle" style="font-size:.5rem"></i> Gizli</span>
                    <?php else: ?>
                        <span class="dt-badge dt-badge-red"><i class="fas fa-circle" style="font-size:.5rem"></i> Pasif</span>
                    <?php endif; ?>
                </td>
                <td data-col="created"><span class="dt-cell-sub"><?php echo e($tour->created_at?->format('d.m.Y')); ?></span></td>
                <td data-col="_actions" class="text-end">
                    <div class="dt-rowact">
                        <a href="<?php echo e(route('agency.products.yurtdisi-turlari.show', $tour)); ?>" class="dt-iconbtn" title="Görüntüle"><i class="fas fa-eye"></i></a>
                        <a href="<?php echo e(route('agency.products.yurtdisi-turlari.general', $tour)); ?>" class="dt-iconbtn" title="Düzenle"><i class="fas fa-pen"></i></a>
                        <button type="button" class="dt-iconbtn" onclick="duplicateTour(<?php echo e($tour->id); ?>)" title="Kopyala"><i class="fas fa-copy"></i></button>
                        <button type="button" class="dt-iconbtn <?php echo e($tour->is_active ? 'warn' : 'success'); ?>" onclick="toggleStatus(<?php echo e($tour->id); ?>)" title="Durum Değiştir">
                            <i class="fas <?php echo e($tour->is_active ? 'fa-pause' : 'fa-play'); ?>"></i>
                        </button>
                        <button type="button" class="dt-iconbtn danger" onclick="deleteTour(<?php echo e($tour->id); ?>)" title="Sil"><i class="fas fa-trash"></i></button>
                    </div>
                </td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr>
                <td colspan="100">
                    <div class="dt-empty">
                        <i class="fas fa-globe"></i>
                        <h4>Henüz yurt dışı turu bulunmuyor</h4>
                        <p>İlk yurt dışı turunuzu oluşturarak başlayın.</p>
                    </div>
                </td>
            </tr>
        <?php endif; ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalc8463834ba515134d5c98b88e1a9dc03)): ?>
<?php $attributes = $__attributesOriginalc8463834ba515134d5c98b88e1a9dc03; ?>
<?php unset($__attributesOriginalc8463834ba515134d5c98b88e1a9dc03); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc8463834ba515134d5c98b88e1a9dc03)): ?>
<?php $component = $__componentOriginalc8463834ba515134d5c98b88e1a9dc03; ?>
<?php unset($__componentOriginalc8463834ba515134d5c98b88e1a9dc03); ?>
<?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    function csrf() { return document.querySelector('meta[name="csrf-token"]').content; }

    function toggleStatus(id) {
        fetch(`/agency/products/yurtdisi-turlari/${id}/toggle-status`, { method: 'POST', headers: { 'X-CSRF-TOKEN': csrf(), 'Content-Type': 'application/json' } })
            .then(r => r.json()).then(d => { if (d.success) location.reload(); });
    }
    function deleteTour(id) {
        if (!confirm('Bu turu silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.')) return;
        fetch(`/agency/products/yurtdisi-turlari/${id}`, { method: 'DELETE', headers: { 'X-CSRF-TOKEN': csrf(), 'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest' } })
            .then(async r => {
                if (r.ok || r.status === 404) { location.reload(); return; }
                const d = await r.json().catch(() => ({}));
                alert(d.message || 'Tur silinemedi.');
            })
            .catch(() => alert('Bağlantı hatası.'));
    }
    function duplicateTour(id) {
        if (!confirm('Bu turu kopyalamak istediğinizden emin misiniz?')) return;
        fetch(`/agency/products/yurtdisi-turlari/${id}/duplicate`, { method: 'POST', headers: { 'X-CSRF-TOKEN': csrf(), 'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest' } })
            .then(async r => {
                const d = await r.json().catch(() => ({}));
                if (d.success && d.redirect) { window.location.href = d.redirect; }
                else { alert(d.message || 'Tur kopyalanamadı.'); }
            })
            .catch(() => alert('Bağlantı hatası.'));
    }
    function bulkAction(action) {
        const selected = Array.from(document.querySelectorAll('.dt-root .dt-rowcheck:checked')).map(c => c.value);
        if (selected.length === 0) return;

        let confirmText = '', endpoint = '';
        if (action === 'delete') { confirmText = `${selected.length} turu silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.`; endpoint = '/agency/products/yurtdisi-turlari/bulk-delete'; }
        else { confirmText = `${selected.length} turun durumunu güncellemek istediğinizden emin misiniz?`; endpoint = '/agency/products/yurtdisi-turlari/bulk-status'; }

        if (!confirm(confirmText)) return;
        const data = { tours: selected };
        if (action !== 'delete') data.status = action;

        fetch(endpoint, { method: 'POST', headers: { 'X-CSRF-TOKEN': csrf(), 'Content-Type': 'application/json' }, body: JSON.stringify(data) })
            .then(r => r.json()).then(d => { if (d.success) location.reload(); });
    }
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('agency.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/products/yurtdisi-turlari/index.blade.php ENDPATH**/ ?>