

<?php $__env->startSection('title', 'Profit & Loss Statement'); ?>

<?php $__env->startSection('content'); ?>
<div class="card mb-4">
    <div class="card-header">
        <h4 class="card-title mb-0">Profit & Loss Statement</h4>
    </div>
    <div class="card-body">
        <form method="GET" action="<?php echo e(route('accounting.reports.profit-loss')); ?>">
            <div class="row g-3 align-items-end">
                <div class="col-md-3">
                    <label class="form-label">Start Date</label>
                    <input type="date" name="start_date" class="form-control" value="<?php echo e($startDate); ?>">
                </div>
                <div class="col-md-3">
                    <label class="form-label">End Date</label>
                    <input type="date" name="end_date" class="form-control" value="<?php echo e($endDate); ?>">
                </div>
                <div class="col-md-2 d-flex gap-2">
                    <button type="submit" class="btn btn-primary w-100">
                        <i class="fas fa-filter me-2"></i>Filter
                    </button>
                    <a href="<?php echo e(route('accounting.reports.profit-loss')); ?>" class="btn btn-secondary w-100">
                        <i class="fas fa-times me-2"></i>Clear
                    </a>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="row justify-content-center">
    <div class="col-lg-10">
        <div class="card">
            <div class="card-header bg-light text-center py-3">
                <h5 class="mb-0">Habib Cables</h5>
                <h6 class="text-muted mb-0">Profit & Loss Statement</h6>
                <small class="text-muted">For the period <?php echo e($startDate ? \Carbon\Carbon::parse($startDate)->format('M d, Y') : 'Beginning'); ?> to <?php echo e($endDate ? \Carbon\Carbon::parse($endDate)->format('M d, Y') : 'Present'); ?></small>
            </div>
            
            <div class="card-body">
                <h4 class="text-primary border-bottom pb-2 mb-3">Revenues</h4>
                <div class="table-responsive mb-4">
                    <table class="table table-borderless table-sm mb-0">
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $revenues; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rev): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($rev->name); ?></td>
                                    <td class="text-end text-success"><?php echo e(number_format($rev->amount, 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="2" class="text-muted fst-italic ps-3">No revenue recorded in this period.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                        <tfoot>
                            <tr class="fw-bold fs-5 border-top">
                                <td>Total Revenue:</td>
                                <td class="text-end text-success">Rs. <?php echo e(number_format($totalRevenue, 2)); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>

                <div class="table-responsive mb-4">
                    <table class="table table-borderless table-sm mb-0">
                        <tbody>
                            <tr>
                                <td class="text-danger ps-0">Less: Cost of Goods Sold (COGS)</td>
                                <td class="text-end text-danger">-<?php echo e(number_format($cogsAmount, 2)); ?></td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr class="fw-bold fs-4 border-top border-bottom">
                                <td>Gross Profit:</td>
                                <td class="text-end <?php if($grossProfit >= 0): ?> text-success <?php else: ?> text-danger <?php endif; ?>">Rs. <?php echo e(number_format($grossProfit, 2)); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>

                <h4 class="text-danger border-bottom pb-2 mb-3 mt-4">Expenses & Costs</h4>
                <div class="table-responsive mb-4">
                    <table class="table table-borderless table-sm mb-0">
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $expenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $exp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($exp->name); ?></td>
                                    <td class="text-end text-danger"><?php echo e(number_format($exp->amount, 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="2" class="text-muted fst-italic ps-3">No expenses recorded in this period.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                        <tfoot>
                            <tr class="fw-bold fs-5 border-top">
                                <td>Total Expenses:</td>
                                <td class="text-end text-danger">Rs. <?php echo e(number_format($totalExpense, 2)); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>

            <div class="card-footer <?php if($netProfit >= 0): ?> bg-success-subtle <?php else: ?> bg-danger-subtle <?php endif; ?> pt-4 pb-4">
                <div class="d-flex justify-content-between align-items-center">
                    <h3 class="mb-0 <?php if($netProfit >= 0): ?> text-success <?php else: ?> text-danger <?php endif; ?>">Net Profit/Loss</h3>
                    <h2 class="mb-0 fw-bold <?php if($netProfit >= 0): ?> text-success <?php else: ?> text-danger <?php endif; ?>">
                        Rs. <?php echo e(number_format($netProfit, 2)); ?>

                    </h2>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\accounting\reports\profit_loss.blade.php ENDPATH**/ ?>