<?php $__env->startSection('title', 'Rent Collection Report'); ?>

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

<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-gray-800">Rent Collection Report</h1>
</div>
<div class="card shadow mb-4">
    <!-- Display Errors (if any) -->
    <?php if($errors->any()): ?>
        <div class="alert alert-danger">
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>
    <!-- Report Filters -->
    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary">Report Filters</h6>
    </div>
    <div class="card-body">
        <form action="<?php echo e(route('RentCollectionReport.data')); ?>" method="post">
            <?php echo csrf_field(); ?>

            <div class="form-group row">

                        <div class="col-md-4 mb-3">
                <label class="font-weight-bold text-secondary">Currency</label>
                <select class="form-control form-control-user" id="curr" name="curr" required>
                    <option value="" disabled <?php echo e(old('curr', request()->input('curr')) ? '' : 'selected'); ?>>Select Currency</option>
                    <?php $__currentLoopData = $currencys; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($currency->ID); ?>"
                            <?php echo e((int)old('curr', request()->input('curr')) === $currency->ID ? 'selected' : ''); ?>>
                            <?php echo e($currency->Name); ?>

                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

                <div class="col-md-4 mb-3">
                    <label class="font-weight-bold text-secondary">Date From</label>
                    <input type="date" class="form-control" name="from_date"
                           value="<?php echo e(request()->input('from_date', now()->format('Y-m-d'))); ?>" required>
                </div>

                <div class="col-md-4 mb-3">
                    <label class="font-weight-bold text-secondary">Date To</label>
                    <input type="date" class="form-control" name="to_date"
                           value="<?php echo e(request()->input('to_date', now()->format('Y-m-d'))); ?>" required>
                </div>
            </div>

            <div style="display: flex;">
                <button type="submit" id="viewButton" class="btn btn-primary btn-user btn-block" style="width: 100px; height: 40px; margin-right: 10px; margin-top: 6px;">View</button>
                <a href="<?php echo e(route('RentCollectionReport')); ?>" class="btn btn-secondary btn-user btn-block" style="width: 100px;">Refresh</a>
            </div>
        </form>
    </div>

   <!-- Rent Collection Table Results -->
<?php if(request()->isMethod('post')): ?>
    <?php if($summaryData->isNotEmpty()): ?>
        <div class="card-body">
            <h5 class="mb-3">
                Rent Collection Report from <strong><?php echo e($fromDate); ?></strong> to <strong><?php echo e($toDate); ?></strong> (Currency: <strong><?php echo e($currnames); ?></strong>)
            </h5>
            <div id="summaryTable" class="table-responsive" style="max-height: 500px; overflow-y: auto;">
                <table class="table table-bordered table-hover table-sm mb-0">
                    <thead class="thead-light sticky-top">
                        <tr>
                            <th>Reference</th>
                            <th>Date</th>
                            <th>Tenant Code</th>
                            <th>Name</th>
                            <th>Floor</th>
                            <th>Rooms</th>
                            <th>Space (sqm)</th>
                            <th>Amount Paid (<?php echo e($currnames); ?>)</th>
                            <th>Discount</th>
                            <th>Total (<?php echo e($currnames); ?>)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $summaryData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td>
                                    <span style="color: red;"><?php echo e($data->refference); ?></span><strong>/</strong>
                                    <span style="color: blue;"><?php echo e($data->batch); ?></span>
                                </td>
                                <td><?php echo e(\Carbon\Carbon::parse($data->entrydate)->format('d/m/Y')); ?></td>
                                <td><?php echo e($data->tenantcode); ?></td>
                                <td><?php echo e($data->tenant_name); ?></td>
                                <td><?php echo e($data->floor); ?></td>
                                <td><?php echo e($data->rooms); ?></td>
                                <td><?php echo e($data->space); ?></td>
                                <td><?php echo e($data->dr); ?></td>
                                <td><?php echo e($data->discount); ?></td>
                                <td><?php echo e($currnames); ?><?php echo e(number_format($data->dr, 2)); ?></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    <tfoot class="bg-light">
                        <tr>
                            <td colspan="9" class="font-weight-bold text-right">Grand Total</td>
                            <td class="font-weight-bold"><?php echo e($currnames); ?><?php echo e(number_format($grandTotal, 2)); ?></td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    <?php else: ?>
        <div class="text-center text-muted mt-5">
            <i class="fas fa-file-invoice-dollar" style="font-size: 3rem; color: #E6111FFF;"></i>
            <strong><p class="mt-2">No rent collection data found for the selected currency and date range.</p></strong>
        </div>
    <?php endif; ?>
<?php endif; ?>

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

<?php echo $__env->make('layouts.nav', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\pinetops\re.pro\resources\views/Rentcollection.blade.php ENDPATH**/ ?>