<?php $__env->startSection('title', 'আয় ব্যবস্থাপনা'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- ব্রেডক্রাম্ব -->
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">ড্যাশবোর্ড</a></li>
            <li class="breadcrumb-item active" aria-current="page">আয় ব্যবস্থাপনা</li>
        </ol>
    </nav>
    
    <div class="card shadow">
        <div class="card-header py-3 d-flex justify-content-between align-items-center">
            <h6 class="m-0 font-weight-bold">আয় ব্যবস্থাপনা</h6>
            <div>
                <a href="<?php echo e(route('incomes.create')); ?>" class="btn btn-primary">
                    <i class="fas fa-plus me-1"></i>নতুন আয়
                </a>
                <a href="<?php echo e(route('incomes.report')); ?>" class="btn btn-success ms-1">
                    <i class="fas fa-chart-bar me-1"></i>রিপোর্ট
                </a>
            </div>
        </div>
        <div class="card-body">
            <!-- ফিল্টার ফর্ম -->
            <form method="GET" action="<?php echo e(route('incomes.index')); ?>" class="row g-3 mb-4">
                <div class="col-md-3">
                    <select name="category" class="form-select">
                        <option value="">সব ধরণ</option>
                        <option value="membership_fee" <?php echo e(request('category') == 'membership_fee' ? 'selected' : ''); ?>>সদস্য ফি</option>
                        <option value="monthly_saving" <?php echo e(request('category') == 'monthly_saving' ? 'selected' : ''); ?>>মাসিক সঞ্চয়</option>
                        <option value="loan_interest" <?php echo e(request('category') == 'loan_interest' ? 'selected' : ''); ?>>ঋণের সুদ</option>
                        <option value="donation" <?php echo e(request('category') == 'donation' ? 'selected' : ''); ?>>অনুদান</option>
                        <option value="event" <?php echo e(request('category') == 'event' ? 'selected' : ''); ?>>অনুষ্ঠান</option>
                        <option value="other" <?php echo e(request('category') == 'other' ? 'selected' : ''); ?>>অন্যান্য</option>
                    </select>
                </div>
                
                <div class="col-md-2">
                    <input type="date" name="from_date" class="form-control" 
                           value="<?php echo e(request('from_date')); ?>" placeholder="শুরু তারিখ">
                </div>
                
                <div class="col-md-2">
                    <input type="date" name="to_date" class="form-control" 
                           value="<?php echo e(request('to_date')); ?>" placeholder="শেষ তারিখ">
                </div>
                
                <div class="col-md-3">
                    <input type="text" name="search" class="form-control" 
                           value="<?php echo e(request('search')); ?>" placeholder="খুঁজুন...">
                </div>
                
                <div class="col-md-2">
                    <button type="submit" class="btn btn-primary w-100">
                        <i class="fas fa-search me-1"></i>খুঁজুন
                    </button>
                </div>
            </form>
            
            <!-- সারাংশ -->
            <div class="row mb-4">
                <div class="col-md-4">
                    <div class="card border-primary">
                        <div class="card-body text-center">
                            <h5 class="card-title text-primary"><?php echo e(number_format($totalIncome, 2)); ?> টাকা</h5>
                            <p class="card-text">মোট আয়</p>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="card border-success">
                        <div class="card-body text-center">
                            <h5 class="card-title text-success"><?php echo e(number_format($currentMonthIncome, 2)); ?> টাকা</h5>
                            <p class="card-text">এই মাসের আয়</p>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="card border-info">
                        <div class="card-body text-center">
                            <h5 class="card-title text-info"><?php echo e($incomes->total()); ?></h5>
                            <p class="card-text">মোট রেকর্ড</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- আয়ের তালিকা -->
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead class="table-dark">
                        <tr>
                            <th>#</th>
                            <th>আয় নং</th>
                            <th>তারিখ</th>
                            <th>ধরণ</th>
                            <th>উৎস</th>
                            <th>পরিমাণ</th>
                            <th>পদ্ধতি</th>
                            <th>কার্যক্রম</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $incomes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $income): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($loop->iteration + ($incomes->currentPage() - 1) * $incomes->perPage()); ?></td>
                            <td><?php echo e($income->income_number); ?></td>
                            <td><?php echo e($income->income_date->format('d/m/Y')); ?></td>
                            <td>
                                <span class="badge bg-<?php echo e($income->category == 'membership_fee' ? 'primary' : ($income->category == 'monthly_saving' ? 'success' : ($income->category == 'loan_interest' ? 'warning' : 'info'))); ?>">
                                    <?php echo e($income->category_in_bangla); ?>

                                </span>
                            </td>
                            <td><?php echo e($income->source); ?></td>
                            <td class="text-success"><?php echo e(number_format($income->amount, 2)); ?> টাকা</td>
                            <td><?php echo e($income->payment_method_in_bangla); ?></td>
                            <td>
                                <div class="btn-group btn-group-sm" role="group">
                                    <a href="<?php echo e(route('incomes.show', $income->id)); ?>" class="btn btn-info" title="দেখুন">
                                        <i class="fas fa-eye"></i>
                                    </a>
                                    <a href="<?php echo e(route('incomes.edit', $income->id)); ?>" class="btn btn-warning" title="সম্পাদনা">
                                        <i class="fas fa-edit"></i>
                                    </a>
                                    <button type="button" class="btn btn-danger delete-btn" 
                                            data-id="<?php echo e($income->id); ?>" 
                                            data-source="<?php echo e($income->source); ?>" 
                                            title="ডিলিট">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center py-4">
                                <i class="fas fa-money-bill-wave fa-3x text-muted mb-3"></i>
                                <h5 class="text-muted">কোন আয় রেকর্ড পাওয়া যায়নি</h5>
                                <a href="<?php echo e(route('incomes.create')); ?>" class="btn btn-primary mt-2">
                                    <i class="fas fa-plus me-1"></i>নতুন আয় যোগ করুন
                                </a>
                            </td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            
            <!-- পেজিনেশন -->
            <?php if($incomes->hasPages()): ?>
            <div class="d-flex justify-content-center mt-3">
                <?php echo e($incomes->withQueryString()->links()); ?>

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

<!-- ডিলিট মডাল -->
<div class="modal fade" id="deleteModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">আয় রেকর্ড ডিলিট করুন</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <p>আপনি কি নিশ্চিত যে আপনি "<strong id="deleteIncomeSource"></strong>" আয় রেকর্ড ডিলিট করতে চান?</p>
                <p class="text-danger"><small>এই কাজটি বাতিল করা যাবে না।</small></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">বাতিল</button>
                <form id="deleteForm" method="POST" style="display: inline;">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('DELETE'); ?>
                    <button type="submit" class="btn btn-danger">ডিলিট করুন</button>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // ডিলিট বাটন হ্যান্ডলিং
        document.querySelectorAll('.delete-btn').forEach(button => {
            button.addEventListener('click', function() {
                const incomeId = this.getAttribute('data-id');
                const incomeSource = this.getAttribute('data-source');
                
                document.getElementById('deleteIncomeSource').textContent = incomeSource;
                document.getElementById('deleteForm').action = `/incomes/${incomeId}`;
                
                const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal'));
                deleteModal.show();
            });
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/naowarin/somoti.naowarinternational.my.id/resources/views/incomes/index.blade.php ENDPATH**/ ?>