

<?php $__env->startSection('title', 'Cash Flow - ' . $fy['label']); ?>

<?php $__env->startSection('styles'); ?>
<style>
    .report-header {
        background: linear-gradient(135deg, #36b9cc 0%, #258391 100%);
        color: #fff;
        padding: 20px;
        border-radius: 10px;
        text-align: center;
        margin-bottom: 20px;
    }
    .stat-card { border-radius: 10px; padding: 15px; text-align: center; color: #fff; }
    .bg-inflow { background: linear-gradient(135deg, #1cc88a 0%, #13855c 100%); }
    .bg-outflow { background: linear-gradient(135deg, #e74a3b 0%, #be2617 100%); }
    .bg-net { background: linear-gradient(135deg, #4e73df 0%, #224abe 100%); }
    .section-header { font-weight: bold; background-color: #f8f9fc; }
    .net-row-positive { background-color: #d4edda; font-weight: bold; }
    .net-row-negative { background-color: #f8d7da; font-weight: bold; }
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<!-- Page Heading -->
<div class="bg-white p-2 d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h5 mb-0 text-gray-800">UEPL | Cash Flow Statement</h1>
    <div class="d-flex gap-2">
        <form method="GET" class="d-inline-flex align-items-center">
            <select name="year" class="form-control form-control-sm mr-2" onchange="this.form.submit()">
                <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($year['value']); ?>" <?php echo e($fy['year'] == $year['value'] ? 'selected' : ''); ?>>
                        <?php echo e($year['label']); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </form>
        <button onclick="window.print()" class="btn btn-secondary btn-sm">
            <i class="fas fa-print mr-1"></i> Print
        </button>
    </div>
</div>

<!-- Report Header -->
<div class="report-header">
    <h4 class="mb-1">UMBREY ENGINEERING PVT LTD</h4>
    <h5 class="mb-1">Cash Flow Statement</h5>
    <div>For the period <?php echo e($fy['start']->format('d M Y')); ?> to <?php echo e($fy['end']->format('d M Y')); ?></div>
</div>

<!-- Summary Cards -->
<div class="row mb-4">
    <div class="col-md-4 mb-3">
        <div class="stat-card bg-inflow">
            <div class="h4 mb-0">₹<?php echo e(number_format(array_sum(array_column($data['operating']['inflows'], 'amount')), 0)); ?></div>
            <div class="small">Cash Inflows</div>
        </div>
    </div>
    <div class="col-md-4 mb-3">
        <div class="stat-card bg-outflow">
            <div class="h4 mb-0">₹<?php echo e(number_format(array_sum(array_column($data['operating']['outflows'], 'amount')), 0)); ?></div>
            <div class="small">Cash Outflows</div>
        </div>
    </div>
    <div class="col-md-4 mb-3">
        <div class="stat-card bg-net">
            <div class="h4 mb-0">₹<?php echo e(number_format($data['net_cash_flow'], 0)); ?></div>
            <div class="small">Net Cash Flow</div>
        </div>
    </div>
</div>

<div class="row">
    <!-- Cash Flow Statement -->
    <div class="col-lg-7 mb-4">
        <div class="card shadow">
            <div class="card-header py-3" style="background: linear-gradient(135deg, #36b9cc 0%, #258391 100%);">
                <h6 class="m-0 font-weight-bold text-white">
                    <i class="fas fa-exchange-alt mr-2"></i> Cash Flow Details
                </h6>
            </div>
            <div class="card-body p-0">
                <table class="table table-sm mb-0">
                    <tbody>
                        <!-- Operating Activities -->
                        <tr class="section-header">
                            <td colspan="2"><i class="fas fa-cogs mr-2"></i>OPERATING ACTIVITIES</td>
                        </tr>
                        <tr>
                            <td class="pl-4 font-italic">Cash Inflows:</td>
                            <td></td>
                        </tr>
                        <?php $__currentLoopData = $data['operating']['inflows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="pl-5"><?php echo e($item['name']); ?></td>
                                <td class="text-right text-success">₹<?php echo e(number_format($item['amount'], 2)); ?></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td class="pl-4 font-italic">Cash Outflows:</td>
                            <td></td>
                        </tr>
                        <?php $__currentLoopData = $data['operating']['outflows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="pl-5"><?php echo e($item['name']); ?></td>
                                <td class="text-right text-danger">(₹<?php echo e(number_format($item['amount'], 2)); ?>)</td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <tr class="<?php echo e($data['operating']['net'] >= 0 ? 'net-row-positive' : 'net-row-negative'); ?>">
                            <td>Net Cash from Operating Activities</td>
                            <td class="text-right">₹<?php echo e(number_format($data['operating']['net'], 2)); ?></td>
                        </tr>
                        
                        <!-- Investing Activities -->
                        <tr class="section-header">
                            <td colspan="2"><i class="fas fa-chart-line mr-2"></i>INVESTING ACTIVITIES</td>
                        </tr>
                        <tr>
                            <td class="pl-4 text-muted">No investing activities recorded</td>
                            <td class="text-right">₹0.00</td>
                        </tr>
                        
                        <!-- Financing Activities -->
                        <tr class="section-header">
                            <td colspan="2"><i class="fas fa-university mr-2"></i>FINANCING ACTIVITIES</td>
                        </tr>
                        <tr>
                            <td class="pl-4 text-muted">No financing activities recorded</td>
                            <td class="text-right">₹0.00</td>
                        </tr>
                        
                        <!-- Net Cash Flow -->
                        <tr class="<?php echo e($data['net_cash_flow'] >= 0 ? 'net-row-positive' : 'net-row-negative'); ?>" style="font-size: 1.1rem;">
                            <td><i class="fas fa-coins mr-2"></i>Net Change in Cash</td>
                            <td class="text-right">₹<?php echo e(number_format($data['net_cash_flow'], 2)); ?></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    
    <!-- Monthly Cash Flow Chart -->
    <div class="col-lg-5 mb-4">
        <div class="card shadow mb-4">
            <div class="card-header py-3" style="background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);">
                <h6 class="m-0 font-weight-bold text-white">
                    <i class="fas fa-chart-area mr-2"></i> Monthly Cash Flow
                </h6>
            </div>
            <div class="card-body">
                <canvas id="cashFlowChart" height="200"></canvas>
            </div>
        </div>
        
        <!-- Recent Inflows -->
        <div class="card shadow">
            <div class="card-header py-3" style="background: linear-gradient(135deg, #1cc88a 0%, #13855c 100%);">
                <h6 class="m-0 font-weight-bold text-white">
                    <i class="fas fa-arrow-down mr-2"></i> Recent Payments Received
                </h6>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-sm mb-0">
                        <thead class="thead-light">
                            <tr>
                                <th>Date</th>
                                <th>Party</th>
                                <th class="text-right">Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $data['recent_inflows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e(\Carbon\Carbon::parse($payment->payment_date)->format('d M')); ?></td>
                                    <td><?php echo e(Str::limit($payment->party->company_name ?? 'N/A', 20)); ?></td>
                                    <td class="text-right text-success">₹<?php echo e(number_format($payment->payment_amount, 0)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="3" class="text-center text-muted">No recent payments</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
    const monthlyData = <?php echo json_encode($data['monthly'], 15, 512) ?>;
    
    new Chart(document.getElementById('cashFlowChart'), {
        type: 'line',
        data: {
            labels: monthlyData.map(m => m.month),
            datasets: [
                {
                    label: 'Inflow',
                    data: monthlyData.map(m => m.inflow),
                    borderColor: 'rgba(28, 200, 138, 1)',
                    backgroundColor: 'rgba(28, 200, 138, 0.1)',
                    fill: true,
                    tension: 0.4
                },
                {
                    label: 'Outflow',
                    data: monthlyData.map(m => m.outflow),
                    borderColor: 'rgba(231, 74, 59, 1)',
                    backgroundColor: 'rgba(231, 74, 59, 0.1)',
                    fill: true,
                    tension: 0.4
                }
            ]
        },
        options: {
            responsive: true,
            scales: {
                y: { beginAtZero: true }
            },
            plugins: {
                legend: { position: 'bottom' }
            }
        }
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.dashboard.superadminapp', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Admin\Desktop\ip.co.in\resources\views/superadmin/accounts/reports/cash-flow.blade.php ENDPATH**/ ?>