<?php $__env->startSection('content'); ?>
    <script>
        var title_string_display = "";
    </script>
    <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)">Facility 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 if(isset($org_arr->organisation_name)): ?>
                                            <b>Organisation  : </b><?php echo e($org_arr->organisation_name); ?>

                                        <?php else: ?>
                                            <b>Organisation  : </b> : All
                                        <?php endif; ?>
                                    </div>
                                    <div class="form-group col-3">
                                        <?php if(isset($facilities->facility_name)): ?>
                                            <b>Facility  : </b><?php echo e($facilities->facility_name); ?>

                                        <?php else: ?>
                                            <b>Facility  : </b> : All
                                        <?php endif; ?>
                                    </div>
                                    <div class="form-group col-3">
                                        <?php
                                            $date_from_crt = date("d-M-Y", strtotime($date_from));
                                        ?>
                                        <b>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>Date To : </b><?php echo e($date_to_crt); ?>

                                    </div>
                                </div>  
                                <?php if(isset($org_arr->organisation_name)): ?>     
                                    <?php
                                        $org_name = $org_arr->organisation_name."(".$org_arr->city.")";
                                    ?>
                                <?php else: ?>
                                    <?php
                                        $org_name = "All";
                                    ?>
                                <?php endif; ?> 

                                <?php if(isset($facilities->facility_name)): ?>
                                    <?php
                                        $fac_name = "Facility : ".$facilities->facility_name;
                                    ?>
                                <?php else: ?>
                                    <?php
                                        $fac_name = "All Facilities";
                                    ?>
                                <?php endif; ?>
                                <?php
                                    $date_val = " From ".$date_from_crt." To ".$date_to_crt;
                                    $title_string = $org_name."\n".$date_val."\n on ".$fac_name;
                                ?>
                                
                                <div class="tab" id="listdata" style="padding-top: 30px;">       
                                    <div class="table-responsive"> 
                                        <table class="display" style="width:100%" id="facility_report">
                                            <thead class="thead-info">
                                                <tr>
                                                    <th>Sl No</th>
                                                    <th>Date</th>
                                                    <th>Facility Name</th>
                                                    <th># of Tickets</th>
                                                    <th>Ticket Serial #</th>
                                                    <th># of Adults</th>
                                                    <th># of Children</th>
                                                    <th>Amount</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $n = 0;
                                                ?>
                                                <?php $__currentLoopData = $ticket_date_arr; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket_dates): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if(isset($facility_list[$ticket_dates])): ?>
                                                        <?php $__currentLoopData = $facility_list[$ticket_dates]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility_id): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <?php if(isset($ticket_array[$ticket_dates][$facility_id]['totalamount'])): ?>
                                                                <?php
                                                                    $n++;
                                                                ?>
                                                                <tr>
                                                                    <td><?php echo e($n); ?></td>
                                                                    <td><?php echo e(date("d-M-Y", strtotime($ticket_dates))); ?></td>
                                                                    <td>
                                                                        <?php if(isset($ticket_array[$ticket_dates][$facility_id]['facility_name'])): ?>
                                                                            <?php echo e($ticket_array[$ticket_dates][$facility_id]['facility_name']); ?>

                                                                        <?php endif; ?>
                                                                    </td>
                                                                    <td>
                                                                        <?php if(isset($ticket_array[$ticket_dates][$facility_id]['nooftickets'])): ?>
                                                                            <?php echo e($ticket_array[$ticket_dates][$facility_id]['nooftickets']); ?>

                                                                        <?php endif; ?>
                                                                    </td>
                                                                    <td>
                                                                        <?php if(isset($ticket_array[$ticket_dates][$facility_id]['ticketnumber'])): ?>
                                                                            <?php echo e($ticket_array[$ticket_dates][$facility_id]['ticketnumber']); ?>

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

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

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

                                                                        <?php endif; ?>
                                                                    </td>
                                                                </tr>
                                                            <?php endif; ?>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                                    <?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>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th align="right">&nbsp;</th>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </div> 
                                </div>
                            </div>     
                        </div>                                       
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            var table = $('#facility_report').DataTable({
                    pageLength : 100,
                    columnDefs: 
                    [
                        {
                            className: "text-center", targets: [3, 4]
                        },
                        {
                            className: "text-center", targets: [5]
                        },
                    ],
                    dom: 'lfBrtip',
                    buttons: [
                        { extend: 'excelHtml5', title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $fac_name; ?>', footer: true,  filename: 'facility report' },
                        { extend: 'pdfHtml5', footer: true, title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>' + '\n' + '<?php echo $fac_name; ?>', filename: 'facility 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(7)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal = api
                            .column(7, { 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(7).footer()).html(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/ksstmorg/resources/views/Reports/facility_report_list.blade.php ENDPATH**/ ?>