<?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 Invoice Report</a></li>
            </ol>
        </div>
        <div class="row">
            <div class="col-12">
                <div class="card card-primary">
                    <div class="card-body"> 
                        <div class="form-row">
                            <div class="form-group col-12">
                                <?php
                                    $date_from_crt = date("d-M-Y", strtotime($date_from));
                                    $date_to_crt = date("d-M-Y", strtotime($date_to));
                                    $date_val = " From ".$date_from_crt." To ".$date_to_crt;
                                ?>
                                <u><b>COUNTER INVOICE REPORT FROM (<?php echo e($date_from_crt); ?> to <?php echo e($date_to_crt); ?>)</b></u>
                                    <br>
                                    Center : 
                                    <?php if($org_name): ?>
                                        <?php echo e($org_name); ?>

                                    <?php endif; ?>
                            </div>
                        </div>         
                        <div class="tab" id="listdata" style="padding-top: 30px;">          
                            <div class="table-responsive"> 
                                <table class="display" style="width:100%" id="card_report">
                                    <thead class="thead-info">
                                        <tr>
                                            <th>Sl No</th>
                                            <th>Invoice Number</th>
                                            <th>Invoice Date</th>
                                            <th>Show Date</th>
                                            <th>Name</th>
                                            <th>Phone #</th>
                                            <th>Payment Method</th>
                                            <th>Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                            $n = 0;
                                        ?>
                                        <?php $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $invoice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php
                                                $n++;
                                                $invoice_id = $invoice->invoice_id;
                                                $invoicemd5=md5($invoice_id);
                                                $invoice_date = $invoice->invoice_date;
                                                $invoice_month = date('m',strtotime($invoice_date));
                                                $invoice_year = date('Y',strtotime($invoice_date));
                                                $invoice_no = $invoice->invoice_no;
                                                $org_code = $invoice->organisation->short_code;
                                                if($invoice_month<4)
                                                    $invoice_year--;

                                                $nextyear = $invoice_year+1;

                                                $invoice_number = $org_code.'/'.$invoice_no.'/'.$invoice_year.'-'.$nextyear;
                                            ?>
                                            <tr>
                                                <td><?php echo e($n); ?></td>
                                                <td>
                                                    <?php echo e($invoice_number); ?>

                                                </td>
                                                <td>
                                                    <?php echo e(date("d-M-Y", strtotime($invoice->invoice_date))); ?>

                                                </td>
                                                <td>
                                                    <?php echo e(date("d-M-Y", strtotime($invoice->show_date))); ?>

                                                </td>
                                                <td>
                                                    <?php if(isset($invoice->visitor_name)): ?>
                                                        <?php echo e($invoice->visitor_name); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td>
                                                    <?php if(isset($invoice->visitor_phone_number)): ?>
                                                        <?php echo e($invoice->visitor_phone_number); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td>
                                                    <?php if(isset($invoice->payment_method)): ?>
                                                        <?php echo e($invoice->paymentmethod->method); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td>
                                                    <?php echo e($invoice->amount); ?>

                                                </td>
                                            </tr>
                                        <?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>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            var table = $('#card_report').DataTable({
                    pageLength : 50,
                    columnDefs: 
                    [
                        {
                            className: "text-center", targets: [7]
                        },
                    ],
                    dom: 'lfBrtip',
                    buttons: [
                        { extend: 'excelHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>', footer: true, filename: 'Counter Invoice Report' },
                        { extend: 'pdfHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>', footer: true, filename: 'Counter Invoice 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 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
                        $(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/ksstmprod/resources/views/Reports/counter_transaction_report_list.blade.php ENDPATH**/ ?>