<?php $__env->startSection('content'); ?>
<?php
$today = now()->toDateString();
$hasTodayBalance = \App\Models\OpeningBalance::where('user_id', auth()->id())
    ->where('date', $today)
    ->exists();

if ($hasTodayBalance && !$openingBalance) {
    // Balance exists but not passed - redirect to sales
    header('Location: ' . route('pos.sales'));
    exit;
}
?>
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
                    <h5 class="mb-0"><i class="bi bi-cash-stack me-2"></i>Opening Balance</h5>
                    <?php if(auth()->user()->hasPermission('opening-balance.view') || auth()->user()->isSuperAdmin() || auth()->user()->isAdmin()): ?>
                    <a href="<?php echo e(route('opening-balance.report')); ?>" class="btn btn-sm btn-light">
                        <i class="bi bi-file-earmark-text"></i> Report
                    </a>
                    <?php endif; ?>
                </div>
                <div class="card-body">
                    <?php if($openingBalance): ?>
                    <div class="alert alert-info">
                        <h4>Today's Opening Balance: Kes <?php echo e(number_format($openingBalance->amount, 2)); ?></h4>
                        <p class="mb-0">You can update your opening balance below if needed.</p>
                    </div>
                    <?php else: ?>
                    <div class="alert alert-warning">
                        <p class="mb-0">Please enter your opening balance before starting sales.</p>
                    </div>
                    <?php endif; ?>

                    <form method="POST" action="<?php echo e(route('opening-balance.store')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="mb-3">
                            <label class="form-label">Opening Balance Amount (Kes)</label>
                            <input type="number" name="opening_balance" class="form-control form-control-lg" 
                                   step="0.01" min="0" 
                                   value="<?php echo e($openingBalance->amount ?? ''); ?>" 
                                   placeholder="Enter amount" required>
                        </div>
                        <div class="d-grid">
                            <button type="submit" class="btn btn-success btn-lg">
                                <i class="bi bi-check-circle me-2"></i> Save & Start Sales
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.main', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\AI PROJECT POS\PosAI3\resources\views/opening-balance/index.blade.php ENDPATH**/ ?>