<?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)">Counter 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-4">
                                        <?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-4">
                                        <?php
                                            $date_to_crt = date("d-M-Y", strtotime($date_to));
                                        ?>
                                        <b>Invoice Date To : </b><?php echo e($date_to_crt); ?>

                                    </div>
                                </div>  
                                <div class="form-row ">
                                    <div class="form-group col-4">
                                        <b>Center : </b><?php echo e($org_name); ?>

                                        <?php
                                            $date_val = " From ".$date_from_crt." To ".$date_to_crt;
                                        ?>
                                    </div>
                                    <div class="form-group col-4">
                                        <b>Counter User : </b><?php echo e($user_name); ?>

                                    </div>
                                </div> 
                                <div class="form-row">
                                    <div class="form-group">
                                        <?php if($user_name=="All Counter Users"): ?>
                                            <?php
                                                echo "<b>Invoice Number</b> From $invoice_number_from to $invoice_number_to";
                                                $inv_num = "Invoice Number From $invoice_number_from to $invoice_number_to";
                                            ?>
                                        <?php endif; ?>
                                    </div>
                                </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>Offline (Cash)</th>
                                                    <th>Offline (Card)</th>
                                                    <th>Offline (UPI)</th>
                                                    <th>Refund Amount</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($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[$facility_id])): ?>
                                                                <?php echo e($refund_amount[$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>&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]
                        },
                        {
                            className: "text-center", targets: [5,6,7,8,9]
                        },
                    ],
                    dom: 'lfBrtip',
                    buttons: [
                        { extend: 'excelHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $user_name; ?>' + '\n' + '<?php echo $inv_num; ?>' , footer: true, filename: 'Counter Consolidated Report'},
                        { extend: 'pdfHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $user_name; ?>' + '\n' + '<?php echo $inv_num; ?>', footer: true, filename: 'Counter Consolidated Report'
                            , 
                            customize: function (doc) {
                                //Create a date string that we use in the footer. Format is dd-mm-yyyy
                                var now = new Date();
                                var jsDate = now.getDate()+'-'+(now.getMonth()+1)+'-'+now.getFullYear()+' '+now.getHours()+':'+now.getMinutes()+' '+now.getSeconds();

                                doc['footer']=(function(page, pages) {
                                    return {
                                        columns: [
                                            {
                                                alignment: 'left',
                                                text: ['Created On: ', { text: jsDate.toString() }]
                                            },
                                            {
                                                alignment: 'right',
                                                text: ['page ', { text: page.toString() },  ' of ', { text: pages.toString() }]
                                            }
                                        ],
                                        margin: 20
                                    }
                                });
                            }
                        }
                    ],
                    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 offline cash over all pages
                        total_5 = api
                            .column(5)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal_5 = api
                            .column(5, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(5).footer()).html(total_5);

                        //////////////// Total offline card 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 upi 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 refund 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 netamount 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(9, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        $(api.column(9).footer()).html(total_9);

                    },
                    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/ksstmorg/resources/views/Reports/counter_consolidated_report_list.blade.php ENDPATH**/ ?>