<?php $__env->startSection('content'); ?>
    <div class="container-fluid">
        <div class="page-titles">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="javascript:void(0)">Reports</a></li>
                <li class="breadcrumb-item active"><a href="javascript:void(0)">Consolidated Report</a></li>
            </ol>
        </div>
        <div class="row">
            <div class="col-12">
                <div class="card card-primary">
                    <div class="card-body"> 
                        <div class="default-tab">
                            <div class="tab-content">
                                <div class="form-row ">
                                    <div class="form-group col-3">
                                        <?php
                                            $date_from_crt = date("d-M-Y", strtotime($date_from));
                                        ?>
                                        <b>Invoice Date From : </b><?php echo e($date_from_crt); ?>

                                    </div>
                                    <div class="form-group col-3">
                                        <?php
                                            $date_to_crt = date("d-M-Y", strtotime($date_to));
                                        ?>
                                        <b>Invoice Date To : </b><?php echo e($date_to_crt); ?>

                                    </div>
                                    <?php
                                        $date_val = " From ".$date_from_crt." To ".$date_to_crt;
                                    ?>
                                </div>                
                                <div class="tab" id="listdata" style="padding-top: 30px;">       
                                    <div class="table-responsive"> 
                                        <table class="display" style="width:100%" id="consolidated_report">
                                            <thead class="thead-info">
                                                <tr>
                                                    <th>Sl No</th>
                                                    <th>Facility Name</th>
                                                    <th># of Tickets</th>
                                                    <th># of Adults</th>
                                                    <th># of Child</th>
                                                    <th>Online Amount</th>
                                                    <th>Offline (Cash)</th>
                                                    <th>Offline (Card)</th>
                                                    <th>Offline (UPI)</th>
                                                    <th>Refund Amount (Offline)</th>
                                                    <th>Refund Amount (Online)</th>
                                                    <th>Net Amount</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $n = 0;
                                                ?>
                                                <?php $__currentLoopData = $facility_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility_id): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($ticket_count[$facility_id]!=0): ?>
                                                        <?php
                                                            $n++;
                                                        ?>
                                                        <tr>
                                                            <td><?php echo e($n); ?></td>
                                                            <td>
                                                                <?php if(isset($facility_name[$facility_id])): ?>
                                                                    <?php echo e($facility_name[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td>
                                                                <?php if(isset($ticket_count[$facility_id])): ?>
                                                                    <?php echo e($ticket_count[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td>
                                                                <?php if(isset($adult_count[$facility_id])): ?>
                                                                    <?php echo e($adult_count[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td>
                                                                <?php if(isset($child_count[$facility_id])): ?>
                                                                    <?php echo e($child_count[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($online_ticket_amount[$facility_id])): ?>
                                                                    <?php echo e($online_ticket_amount[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($cash_ticket_amount[$facility_id])): ?>
                                                                <?php echo e($cash_ticket_amount[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($card_ticket_amount[$facility_id])): ?>
                                                                <?php echo e($card_ticket_amount[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($upi_ticket_amount[$facility_id])): ?>
                                                                <?php echo e($upi_ticket_amount[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($refund_amount_offline[$facility_id])): ?>
                                                                <?php echo e($refund_amount_offline[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($refund_amount_online[$facility_id])): ?>
                                                                <?php echo e($refund_amount_online[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>
                                                            <td style="text-align: center;">
                                                                <?php if(isset($totalamount[$facility_id])): ?>
                                                                <?php echo e($totalamount[$facility_id]); ?>

                                                                <?php endif; ?>
                                                            </td>                                                                    
                                                        </tr>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                            <tfoot class="tfoot-info">
                                                <tr>
                                                    <th>Total</th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </div> 
                                </div>
                            </div>     
                        </div>                                       
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            var table = $('#consolidated_report').DataTable({
                    pageLength : 200,
                    columnDefs: 
                    [
                        {
                            className: "text-center", targets: [5,6,7,8,9,10,11]
                        },
                        {
                            className: "text-center", targets: [5,6,7,8,9,10,11]
                        },
                    ],
                    dom: 'lfBrtip',
                    buttons: [
                        { extend: 'excelHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>', footer: true, filename: 'Consolidated Report' },
                        { extend: 'pdfHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>', footer: true, filename: 'Consolidated Report' }
                    ],
                    footerCallback: function (row, data, start, end, display) {
                        var api = this.api();
             
                        // Remove the formatting to get integer data for summation
                        var intVal = function (i) {
                            return typeof i === 'string' ? i.replace(/[\$,]/g, '') * 1 : typeof i === 'number' ? i : 0;
                        };
             
                        // Total online over all pages
                        total = api
                            .column(5)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal = api
                            .column(5, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(5).footer()).html(total);

                        //////////////// Total offline cash over all pages
                        total_6 = api
                            .column(6)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_6 = api
                            .column(6, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(6).footer()).html(total_6);

                        //////////////// Total offline card over all pages
                        total_7 = api
                            .column(7)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_7 = api
                            .column(7, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(7).footer()).html(total_7);

                        //////////////// Total offline upi over all pages
                        total_8 = api
                            .column(8)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_8 = api
                            .column(8, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(8).footer()).html(total_8);

                        //////////////// Total refund offline over all pages
                        total_9 = api
                            .column(9)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_9 = api
                            .column(10, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(9).footer()).html(total_9);

                        //////////////// Total Refund Online over all pages
                        total_10 = api
                            .column(10)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_10 = api
                            .column(10, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(10).footer()).html(total_10);

                        //////////////// net amount over all pages
                        total_11 = api
                            .column(11)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_11 = api
                            .column(11, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(11).footer()).html(total_11);
                    },
                    createdRow: function ( row, data, index ) {
                       $(row).addClass('selected')
                    } 
                });
                  
                table.on('click', 'tbody tr', function() {
                var $row = table.row(this).nodes().to$();
                var hasClass = $row.hasClass('selected');
                if (hasClass) {
                    $row.removeClass('selected')
                } else {
                    $row.addClass('selected')
                }
                })
                
                table.rows().every(function() {
                this.nodes().to$().removeClass('selected')
                });
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.default', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmprod/resources/views/Reports/consolidated_report_list.blade.php ENDPATH**/ ?>