

<?php $__env->startSection('title', 'Lease Reports'); ?>

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

    <div class="container-fluid">

        

        <div class="card shadow-sm mb-4">

            <div class="card-header  text-white">

                <div class="d-flex justify-content-between align-items-center">

                    <h4 class="mb-0">

                        <i class="bi bi-bar-chart-fill"></i>

                        Lease Report Dashboard

                    </h4>

                    <a href="<?php echo e(route('reports.leases')); ?>" class="btn btn-light">

                        <i class="bi bi-arrow-left"></i>

                        Change Filters

                    </a>

                </div>

            </div>

            <div class="card-body">

                <div class="row">

                    <div class="col-md-3">

                        <div class="card border-primary">

                            <div class="card-body text-center">

                                <h6>Total Leases</h6>

                                <h4 class="text-primary">

                                    <?php echo e(number_format($totalLeases)); ?>


                                </h4>

                            </div>

                        </div>

                    </div>

                    <div class="col-md-3">

                        <div class="card border-success">

                            <div class="card-body text-center">

                                <h6>Grand Total</h6>

                                <h4 class="text-success">

                                    TZS <?php echo e(number_format($grandTotal)); ?>


                                </h4>

                            </div>

                        </div>

                    </div>

                    <div class="col-md-3">

                        <div class="card border-info">

                            <div class="card-body text-center">

                                <h6>Average Amount</h6>

                                <h4 class="text-info">

                                    TZS
                                    <?php echo e($totalLeases > 0 ? number_format($grandTotal / $totalLeases) : 0); ?>


                                </h4>

                            </div>

                        </div>

                    </div>

                    <div class="col-md-3">

                        <div class="card border-warning">

                            <div class="card-body text-center">

                                <h6>Cargo Types</h6>

                                <h4 class="text-warning">

                                    <?php echo e($cargoSummary->count()); ?>


                                </h4>

                            </div>

                        </div>

                    </div>

                </div>

            </div>

        </div>

        

        <div class="card shadow-sm mb-4">

            <div class="card-header">

                <h5>

                    Summary By Cargo Type

                </h5>

            </div>

            <div class="card-body">

                <table class="table table-bordered">

                    <thead>

                        <tr>

                            <th>Cargo Type</th>

                            <th class="text-center">

                                Qty

                            </th>

                            <th class="text-end">

                                Amount (TZS)

                            </th>

                        </tr>

                    </thead>

                    <tbody>

                        <?php $__currentLoopData = $cargoSummary; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cargo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>

                                <td>

                                    <?php echo e($cargo->cargo_type); ?>


                                </td>

                                <td class="text-center">

                                    <?php echo e(number_format($cargo->qty)); ?>


                                </td>

                                <td class="text-end">

                                    <?php echo e(number_format($cargo->amount)); ?>


                                </td>

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

                    </tbody>

                    <tfoot>

                        <tr class="table-primary">

                            <th>

                                Grand Total

                            </th>

                            <th class="text-center">

                                <?php echo e(number_format($totalLeases)); ?>


                            </th>

                            <th class="text-end">

                                <?php echo e(number_format($grandTotal)); ?>


                            </th>

                        </tr>

                    </tfoot>

                </table>

            </div>

        </div>

        
        <div class="card">

            <div class="card-header">

                <h4 class="mb-0">

                    Summary By Status

                </h4>

            </div>

            <div class="card-body">

                <div class="table-responsive">

                    <table class="table table-bordered table-striped table-hover">

                        <thead class="table-light">

                            <tr>

                                <th width="80%">
                                    Lease Status
                                </th>

                                <th class="text-end">
                                    Qty
                                </th>

                            </tr>

                        </thead>

                        <tbody>

                            <?php
                                $totalStatus = 0;
                            ?>

                            <?php $__currentLoopData = $statusSummary; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status => $qty): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $totalStatus += $qty;
                                ?>

                                <tr>

                                    <td>

                                        <?php echo e(ucwords(str_replace('_', ' ', $status))); ?>


                                    </td>

                                    <td class="text-end">

                                        <?php echo e(number_format($qty)); ?>


                                    </td>

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

                        </tbody>

                        <tfoot class="table-secondary">

                            <tr>

                                <th>

                                    Grand Total

                                </th>

                                <th class="text-end">

                                    <?php echo e(number_format($totalStatus)); ?>


                                </th>

                            </tr>

                        </tfoot>

                    </table>

                </div>

            </div>

        </div>

        

        <div class="card shadow-sm">

            <div class="card-header">

                <h5>

                    Lease Details

                </h5>

            </div>

            <div class="card-body">

                <div class="table-responsive">

                    <table class="table table-striped" id="leaseReportTable">

                        <thead>

                            <tr>

                                <th>#</th>

                                <th>Date</th>

                                <th>Lease No</th>

                                <th>Customer</th>

                                <th>Cargo</th>

                                <th>Destination</th>

                                <th>Amount</th>

                                <th>Status</th>

                                <th>Sales Officer</th>

                            </tr>

                        </thead>

                        <tbody>

                            <?php $__currentLoopData = $leases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lease): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>

                                    <td>

                                        <?php echo e($loop->iteration); ?>


                                    </td>

                                    <td>

                                        <?php echo e(optional($lease->leased_at)->format('d/m/Y H:i')); ?>


                                    </td>

                                    <td>

                                        <?php echo e($lease->lease_no); ?>


                                    </td>

                                    <td>

                                        <?php echo e($lease->customer_name); ?>


                                    </td>

                                    <td>

                                        <?php echo e($lease->cargo_type); ?>


                                    </td>

                                    <td>

                                        <?php echo e($lease->destination?->name); ?>


                                    </td>

                                    <td>

                                        <?php echo e(number_format($lease->amount)); ?>


                                    </td>

                                    <td>

                                        <?php echo e(strtoupper($lease->status)); ?>


                                    </td>

                                    <td>

                                        <?php echo e($lease->salesUser?->name); ?>


                                    </td>

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

                        </tbody>

                    </table>

                </div>

            </div>

        </div>

    </div>

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

<?php $__env->startPush('scripts'); ?>
    <script>
        $(function() {

            $('#leaseReportTable').DataTable({

                pageLength: 25,

                order: [
                    [1, 'desc']
                ],

                scrollX: true,

                dom: 'Bfrtip',

                buttons: [

                    'copy',

                    'excel',

                    'csv',

                    'print'

                ]

            });

        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\Projects\lms-ects\resources\views/reports/leases/view.blade.php ENDPATH**/ ?>