<?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)">Online Collection 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>
                                    <div class="form-group col-6">
                                    <?php if(isset($organisations)): ?>
                                        <b>Organisation :</b> <?php echo e($organisations->organisation_name); ?>(<?php echo e($organisations->city); ?>)
                                    <?php endif; ?>
                                    <?php
                                        $date_val = " From ".$date_from_crt." To ".$date_to_crt;
                                    ?>
                                    </div>
                                </div>                
                                <div class="tab" id="listdata" style="padding-top: 30px;">       
                                    <div class="table-responsive"> 
                                        <table class="display" style="width:100%; font-size: 80%;" id="detailed_report">
                                            <thead class="thead-info">
                                                <tr>
                                                    <th>#</th>
                                                    <th>Invoice #</th>
                                                    <th>Invoice Date</th>
                                                    <th>Show Date</th>
                                                    <th>Ticket #</th>
                                                    <th>Facility</th>
                                                    <th>Adults</th>
                                                    <th>Child</th>
                                                    <th>Amount</th>
                                                    <th>User</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $n = 0;
                                                ?>
                                                <?php if(isset($ticket_arr)): ?>
                                                    <?php $__currentLoopData = $ticket_arr; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket_id): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <?php if(isset($invoice_array[$ticket_id]['invoice_number'])): ?>
                                                            <?php
                                                                $n++;
                                                            ?>
                                                            <tr>
                                                                <td><?php echo e($n); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['invoice_number']); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['invoice_date']); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['show_date']); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['ticket_no']); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['facility_name']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($invoice_array[$ticket_id]['noofadult']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($invoice_array[$ticket_id]['noofchild']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($invoice_array[$ticket_id]['amount']); ?></td>
                                                                <td><?php echo e($invoice_array[$ticket_id]['counter_user']); ?></td>
                                                            </tr>
                                                        <?php endif; ?>
                                                        <?php if(isset($ticket_cancelledlist[$ticket_id]['invoice_number'])): ?>
                                                            <?php
                                                                $n++;
                                                            ?>
                                                            <tr>
                                                                <td><?php echo e($n); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['invoice_number']); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['invoice_date']); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['show_date']); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['ticket_no']); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['facility_name']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($ticket_cancelledlist[$ticket_id]['noofadult']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($ticket_cancelledlist[$ticket_id]['noofchild']); ?></td>
                                                                <td style="text-align: center;"><?php echo e($ticket_cancelledlist[$ticket_id]['amount']); ?></td>
                                                                <td><?php echo e($ticket_cancelledlist[$ticket_id]['counter_user']); ?></td>
                                                            </tr>
                                                        <?php endif; ?>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
                                                <?php endif; ?>              
                                            </tbody>
                                            <tfoot class="tfoot-info">
                                                <tr>
                                                    <th>&nbsp;</th>
                                                    <th>Total</th>
                                                    <th>&nbsp;</th>
                                                    <th>Filters</th>
                                                    <th>
                                                        <?php
                                                            $date_from_crt = date("d-M-Y", strtotime($date_from));
                                                        ?>
                                                        <b>Date From : </b><?php echo e($date_from_crt); ?>

                                                    </th>
                                                    <th>
                                                        <?php
                                                            $date_to_crt = date("d-M-Y", strtotime($date_to));
                                                        ?>
                                                        <b>Date To : </b><?php echo e($date_to_crt); ?>

                                                    </th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th>
                                                        <?php if(isset($organisations)): ?>
                                                            Organisation :
                                                        <?php endif; ?>
                                                    </th>
                                                    <th>
                                                        <?php if(isset($organisations)): ?>
                                                           <?php echo e($organisations->organisation_name); ?><br>(<?php echo e($organisations->city); ?>)
                                                        <?php endif; ?>
                                                    </th>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </div> 
                                </div>
                            </div>     
                        </div>                                       
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            var table = $('#detailed_report').DataTable({
                    pageLength : 100,
                    columnDefs: 
                    [
                        {
                            className: "text-center", targets: [3, 4, 5]
                        },
                        {
                            className: "text-center", targets: [6]
                        },
                    ],
                    dom: 'lfBrtip',
                    buttons: [
                        { extend: 'excelHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $fac_name; ?>', footer: true, filename: 'Online Collection Report' },
                        { extend: 'pdfHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $fac_name; ?>',orientation : 'landscape', footer: true, filename: 'Online Collection 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 over all pages
                        total = api
                            .column(8)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal = api
                            .column(8, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Update footer
                        //alert(total);
                        //$(api.column(7).footer()).html('' + pageTotal + ' ( ' + total + ' total)');
                        $(api.column(1).footer()).html("Total : "+total);
                    },
                    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/online_ticket_list.blade.php ENDPATH**/ ?>