<?php $__env->startSection('title', 'Günübirlik Turlar'); ?>
<?php $__env->startSection('page_title', 'Günübirlik Turlar'); ?>

<?php
    $breadcrumbs = [
        ['title' => 'Ana Sayfa', 'url' => route('agency.dashboard')],
        ['title' => 'Ürünler', 'url' => '#'],
        ['title' => 'Günübirlik 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ış',       'sort' => 'departure_city_id'],
        ['key' => 'time',     'label' => 'Saat',         'align' => 'center'],
        ['key' => 'price',    'label' => 'Fiyat',        'sortable' => true, 'sort' => 'adult_price', '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' => '120px'],
    ];

    $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-gunubirlik','title' => 'Günübirlik Turlar','subtitle' => 'Günübirlik turlarınızı yönetin','icon' => 'fa-sun','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.gunubirlik-turlar.quick-create')).'\')','createLabel' => 'Yeni Günübirlik Tur','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-gunubirlik','title' => 'Günübirlik Turlar','subtitle' => 'Günübirlik turlarınızı yönetin','icon' => 'fa-sun','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.gunubirlik-turlar.quick-create')).'\')','create-label' => 'Yeni Günübirlik Tur','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.gunubirlik-turlar.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="daytour-row" data-quickview-url="<?php echo e(route('agency.products.gunubirlik-turlar.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?->image_url): ?>
                        <img class="dt-thumb" src="<?php echo e($tour->coverImage->thumbnail_url ?: $tour->coverImage->image_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="time" class="text-center">
                    <?php if($tour->start_time): ?>
                        <span class="dt-badge dt-badge-slate"><?php echo e(substr($tour->start_time, 0, 5)); ?> - <?php echo e(substr($tour->end_time, 0, 5)); ?></span>
                    <?php else: ?>
                        <span class="dt-cell-sub">—</span>
                    <?php endif; ?>
                </td>
                <td data-col="price" class="text-end">
                    <span class="dt-cell-main"><?php echo e(number_format($tour->adult_price, 0)); ?></span>
                    <span class="dt-cell-sub"><?php echo e($tour->currency); ?></span>
                </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.gunubirlik-turlar.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.gunubirlik-turlar.general', $tour)); ?>" class="dt-iconbtn" title="Düzenle"><i class="fas fa-pen"></i></a>
                        <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-sun"></i>
                        <h4>Henüz günübirlik tur bulunmuyor</h4>
                        <p>İlk günübirlik 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 toggleStatus(tourId) {
        fetch(`/agency/products/gunubirlik-turlar/${tourId}/toggle-status`, {
            method: 'POST',
            headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, 'Content-Type': 'application/json' }
        }).then(r => r.json()).then(d => { if (d.success) location.reload(); });
    }
    function deleteTour(tourId) {
        if (!confirm('Bu turu silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.')) return;
        fetch(`/agency/products/gunubirlik-turlar/${tourId}`, {
            method: 'DELETE',
            headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, 'Content-Type': 'application/json' }
        }).then(r => r.json()).then(d => { if (d.success) location.reload(); });
    }
    function bulkAction(action) {
        const selected = Array.from(document.querySelectorAll('.dt-root .dt-rowcheck:checked')).map(c => c.value);
        if (selected.length === 0) return;
        const csrf = document.querySelector('meta[name="csrf-token"]').content;

        let confirmText = '', endpoint = '';
        if (action === 'delete') { confirmText = `${selected.length} turu silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.`; endpoint = '/agency/products/gunubirlik-turlar/bulk-delete'; }
        else { confirmText = `${selected.length} turun durumunu güncellemek istediğinizden emin misiniz?`; endpoint = '/agency/products/gunubirlik-turlar/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/gunubirlik-turlar/index.blade.php ENDPATH**/ ?>