<?php $__env->startSection('title', 'Sub Accounts — Index'); ?>

<?php $__env->startSection('content'); ?>
<?php echo $__env->make('partials.qi-styles', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="qi-wrap">
    <nav class="qi-bc">
        <a href="<?php echo e(route('home')); ?>">Home</a>
        <span>›</span>
        <a href="<?php echo e(route('main-accounts.index')); ?>">Chart of Accounts</a>
        <span>›</span>
        <a href="<?php echo e(route('main-accounts.index')); ?>">Main Accounts</a>
        <span>›</span>
        <span><?php echo e($mainAccount->account_name); ?></span>
        <span>›</span>
        <span class="qi-bc-current">Sub Accounts</span>
    </nav>

    <div class="qi-hero">
        <div>
            <h1><?php echo e($mainAccount->account_name); ?> — Sub Accounts</h1>
            <p>Unified sub-account view for <?php echo e($mainAccount->code ?? $mainAccount->account_code); ?>.</p>
        </div>
        <div class="qi-badge">
            <div class="qi-badge-val"><?php echo e($subAccounts->total()); ?></div>
            <div class="qi-badge-lab">Records</div>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="qi-alert qi-alert-success"><?php echo e(session('success')); ?></div>
    <?php endif; ?>

    <form method="GET" action="<?php echo e(route('chart-of-accounts.main-accounts.sub-accounts.index', $mainAccount)); ?>">
        <div class="qi-toolbar">
            <a href="<?php echo e(route('main-accounts.index')); ?>" class="qi-btn">← Back</a>
            <div class="qi-search">
                <input name="search" type="search" value="<?php echo e(request('search')); ?>" placeholder="Search...">
            </div>
            <div class="qi-toolbar-right">
                <a href="<?php echo e(route('subacc.add', ['id' => $mainAccount->id])); ?>" class="qi-btn qi-btn-primary">+ Add Sub Account</a>
            </div>
        </div>

        <div class="qi-filters">
            <div>
                <label class="qi-filter-label" for="sub_table">Sub Table</label>
                <select class="qi-filter-control" name="sub_table" id="sub_table">
                    <option value="">All</option>
                    <?php $__currentLoopData = $subTables; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $table): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($table); ?>" <?php if(request('sub_table') === $table): echo 'selected'; endif; ?>><?php echo e($table); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="qi-filter-actions">
                <button type="submit" class="qi-btn qi-btn-primary">Apply</button>
                <a href="<?php echo e(route('chart-of-accounts.main-accounts.sub-accounts.index', $mainAccount)); ?>" class="qi-btn">Reset</a>
            </div>
        </div>
    </form>

    <div class="qi-table" style="--qi-cols: repeat(4, minmax(120px, 1fr));">
        <div class="qi-thead">
            <div>Account Code</div>
            <div>Sub Name</div>
            <div>Sub Table</div>
            <div>Actions</div>
        </div>
        <?php $__empty_1 = true; $__currentLoopData = $subAccounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="qi-trow">
                <div class="qi-cell" data-label="Account Code"><?php echo e($row->account_code); ?></div>
                <div class="qi-cell" data-label="Sub Name"><?php echo e($row->sub_name); ?></div>
                <div class="qi-cell" data-label="Sub Table"><span class="qi-status qi-status-draft"><?php echo e($row->sub_table ?? 'sub_accounts'); ?></span></div>
                <div class="qi-actions">
                    <span class="qi-act-view">View</span>
                    <a href="<?php echo e(route('subacc.add', ['id' => $mainAccount->id, 'sub_table' => $row->sub_table, 'sub_id' => $row->id])); ?>" class="qi-act-edit">Edit</a>
                    <form action="<?php echo e(route('chart-of-accounts.main-accounts.sub-accounts.destroy', [$row->sub_table, $row->id])); ?>" method="POST" onsubmit="return confirm('Delete this record?')">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <button type="submit" class="qi-act-delete">Delete</button>
                    </form>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="qi-empty">No records found.</div>
        <?php endif; ?>
    </div>

    <div class="qi-pagination"><?php echo e($subAccounts->withQueryString()->links()); ?></div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\admin\Desktop\melsoft\resources\views/chart-of-accounts/sub-accounts/index.blade.php ENDPATH**/ ?>