<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <?php if (isset($component)) { $__componentOriginal80ffb5bf12f57d81844c4bbf89dbe34a = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal80ffb5bf12f57d81844c4bbf89dbe34a = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.module-hero','data' => ['title' => 'Organogram','description' => 'Visualize organizational hierarchy','icon' => 'fa-project-diagram']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('module-hero'); ?>
<?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(['title' => 'Organogram','description' => 'Visualize organizational hierarchy','icon' => 'fa-project-diagram']); ?>

         <?php $__env->slot('tabs', null, []); ?> 
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view organizations')): ?><a href="<?php echo e(route('organization.details.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.details.*') ? 'active-tab' : ''); ?>"><i class="fas fa-building"></i> Organizations</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view leadership positions')): ?><a href="<?php echo e(route('organization.leadership-positions.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.leadership-positions.*') ? 'active-tab' : ''); ?>"><i class="fas fa-sitemap"></i> Leadership Positions</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view leadership history')): ?><a href="<?php echo e(route('organization.leadership-history.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.leadership-history.*') ? 'active-tab' : ''); ?>"><i class="fas fa-history"></i> Leadership History</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view staff history')): ?><a href="<?php echo e(route('organization.staff-history.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.staff-history.*') ? 'active-tab' : ''); ?>"><i class="fas fa-user-tie"></i> Staff History</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view election cycles')): ?><a href="<?php echo e(route('organization.election-cycles.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.election-cycles.*') ? 'active-tab' : ''); ?>"><i class="fas fa-calendar-alt"></i> Election Cycles</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view voting procedures')): ?><a href="<?php echo e(route('organization.voting-procedures.index')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.voting-procedures.*') ? 'active-tab' : ''); ?>"><i class="fas fa-vote-yea"></i> Voting Procedures</a><?php endif; ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view organogram')): ?><a href="<?php echo e(route('organization.organogram.show')); ?>" class="module-hero-tab <?php echo e(request()->routeIs('organization.organogram.*') ? 'active-tab' : ''); ?>"><i class="fas fa-project-diagram"></i> Organogram</a><?php endif; ?>
         <?php $__env->endSlot(); ?>

        <?php if($selectedOrganization): ?>
         <?php $__env->slot('actions', null, []); ?> 
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('export organogram')): ?>
            <a href="<?php echo e(route('organization.organogram.export', ['format' => 'pdf', 'organization_id' => $selectedOrganization->id])); ?>"
               class="inline-flex items-center gap-2 px-4 py-2 bg-white text-[#1a4731] text-sm font-semibold rounded-lg hover:bg-gray-100 transition">
                <i class="fas fa-file-pdf"></i> Export PDF
            </a>
            <a href="<?php echo e(route('organization.organogram.export', ['format' => 'svg', 'organization_id' => $selectedOrganization->id])); ?>"
               class="inline-flex items-center gap-2 px-4 py-2 bg-white/20 text-white text-sm font-semibold rounded-lg hover:bg-white/30 transition">
                <i class="fas fa-image"></i> Export SVG
            </a>
            <a href="<?php echo e(route('organization.organogram.export', ['format' => 'json', 'organization_id' => $selectedOrganization->id])); ?>"
               class="inline-flex items-center gap-2 px-4 py-2 bg-white/20 text-white text-sm font-semibold rounded-lg hover:bg-white/30 transition">
                <i class="fas fa-code"></i> Export JSON
            </a>
            <?php endif; ?>
         <?php $__env->endSlot(); ?>
        <?php endif; ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal80ffb5bf12f57d81844c4bbf89dbe34a)): ?>
<?php $attributes = $__attributesOriginal80ffb5bf12f57d81844c4bbf89dbe34a; ?>
<?php unset($__attributesOriginal80ffb5bf12f57d81844c4bbf89dbe34a); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal80ffb5bf12f57d81844c4bbf89dbe34a)): ?>
<?php $component = $__componentOriginal80ffb5bf12f57d81844c4bbf89dbe34a; ?>
<?php unset($__componentOriginal80ffb5bf12f57d81844c4bbf89dbe34a); ?>
<?php endif; ?>

    
    <?php if(session('success')): ?>
    <div class="px-6 pt-4">
        <div class="p-4 bg-green-100 border border-green-400 text-green-700 rounded-lg flex items-center gap-2">
            <i class="fas fa-check-circle"></i><?php echo e(session('success')); ?>

        </div>
    </div>
    <?php endif; ?>
    <?php if(session('error')): ?>
    <div class="px-6 pt-4">
        <div class="p-4 bg-red-100 border border-red-400 text-red-700 rounded-lg flex items-center gap-2">
            <i class="fas fa-exclamation-circle"></i><?php echo e(session('error')); ?>

        </div>
    </div>
    <?php endif; ?>

    <div class="p-6">
        
        <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5 mb-6">
            <form method="GET">
                <div class="flex flex-wrap items-end gap-4">
                    <div class="flex-1 min-w-[220px]">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Select Organization</label>
                        <select name="organization_id"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg bg-white text-gray-800 focus:ring-2 focus:ring-green-500 focus:border-transparent"
                            onchange="this.form.submit()">
                            <option value="">-- Select an Organization --</option>
                            <?php $__currentLoopData = $organizations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $org): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($org->id); ?>" <?php echo e(request('organization_id') == $org->id ? 'selected' : ''); ?>>
                                    <?php echo e($org->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
            </form>
        </div>

        <?php if($selectedOrganization): ?>
            
            <?php if(!empty($statistics)): ?>
            <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-xs text-gray-500 mb-0.5">Total Positions</p>
                            <p class="text-2xl font-bold text-gray-800"><?php echo e($statistics['total_positions']); ?></p>
                        </div>
                        <i class="fas fa-sitemap text-3xl text-blue-400 opacity-60"></i>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-xs text-gray-500 mb-0.5">Filled Positions</p>
                            <p class="text-2xl font-bold text-green-600"><?php echo e($statistics['filled_positions']); ?></p>
                        </div>
                        <i class="fas fa-user-check text-3xl text-green-400 opacity-60"></i>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-xs text-gray-500 mb-0.5">Vacant Positions</p>
                            <p class="text-2xl font-bold text-orange-600"><?php echo e($statistics['empty_positions']); ?></p>
                        </div>
                        <i class="fas fa-user-slash text-3xl text-orange-400 opacity-60"></i>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-xs text-gray-500 mb-0.5">Fill Rate</p>
                            <p class="text-2xl font-bold text-purple-600"><?php echo e($statistics['fill_rate']); ?>%</p>
                        </div>
                        <i class="fas fa-chart-pie text-3xl text-purple-400 opacity-60"></i>
                    </div>
                </div>
            </div>
            <?php endif; ?>

            
            <div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
                <div class="p-4 border-b border-gray-200">
                    <h2 class="text-base font-semibold text-gray-800">
                        <i class="fas fa-project-diagram mr-2 text-green-600"></i><?php echo e($selectedOrganization->name); ?> — Organizational Hierarchy
                    </h2>
                </div>
                <div class="p-6">
                    <?php if(!empty($hierarchy)): ?>
                    <div class="overflow-x-auto">
                        <div class="min-w-[800px]">
                            <?php $__currentLoopData = $hierarchy; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $node): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php echo $__env->make('organization.organogram.partials.node', ['node' => $node, 'level' => 0], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    </div>
                    <?php else: ?>
                    <div class="text-center py-12">
                        <i class="fas fa-project-diagram text-6xl text-gray-300 mb-4"></i>
                        <h3 class="text-xl font-semibold text-gray-700 mb-2">No Leadership Structure Found</h3>
                        <p class="text-gray-500 mb-4">Create leadership positions to visualize the organogram.</p>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create leadership positions')): ?>
                        <a href="<?php echo e(route('organization.leadership-positions.create')); ?>" class="theme-btn-primary px-6 py-2 rounded-lg">
                            <i class="fas fa-plus mr-2"></i>Create Leadership Positions
                        </a>
                        <?php endif; ?>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        <?php else: ?>
            <div class="text-center py-16">
                <i class="fas fa-project-diagram text-6xl text-gray-300 mb-4"></i>
                <h3 class="text-xl font-semibold text-gray-700 mb-2">Select an Organization</h3>
                <p class="text-gray-500">Choose an organization from the dropdown above to view its organogram.</p>
            </div>
        <?php endif; ?>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH /home/www/sshia.org/sshia/resources/views/organization/organogram/show.blade.php ENDPATH**/ ?>