<?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)">Transaction 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;
                                ?>
                                <?php if(isset($organisations)): ?>
                                    <?php
                                        $org_name = $organisations->organisation_name." (".$organisations->city.")";
                                    ?>
                                <?php endif; ?>  
                                <u><b>TRANSACTION REPORT FROM (<?php echo e($date_from_crt); ?> to <?php echo e($date_to_crt); ?>)</b>
                                    <?php if(isset($organisations)): ?>
                                        at <?php echo e($organisations->organisation_name); ?>(<?php echo e($organisations->city); ?>)
                                    <?php endif; ?>
                                </u>
                            </div>
                        </div>         
                        <div class="tab" id="listdata" style="padding-top: 30px;">          
                            <div class="table-responsive"> 
                                <table class="table table-sm table-responsive-lg mb-0" style="font-size:90%;" id="refund_list">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Public User</th>
                                            <th>Transaction Name</th>
                                            <th>Organisation Name</th>
                                            <th>Amount</th>
                                            <th>Status</th>
                                            <th>Transaction Ref. #</th>
                                            <th>Order ID</th>
                                            <th>Created At</th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                            $status_name ="";
                                            $n=0;
                                        ?>
                                        <?php $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>   
                                            <?php
                                                $n++;  
                                                
                                                $status = $transaction->status;
                                                if($status==0)
                                                {
                                                    $status_name = "Not Paid";
                                                }
                                                if($status==1)
                                                {
                                                    $status_name = "Paid";
                                                }
                                                if($status==2)
                                                {
                                                    $status_name = "Failed";
                                                }
                                                if($status==3)
                                                {
                                                    $status_name = "Return";
                                                }
                                            ?>                                                
                                            <tr>
                                                <td><?php echo e($n); ?></td>
                                                <td>
                                                    <?php if($transaction->public_user_id): ?>
                                                        <?php if(isset($transaction->publicuser->name)): ?>
                                                            <?php echo e($transaction->publicuser->name); ?>

                                                        <?php endif; ?>
                                                    <?php endif; ?>
                                                </td>
                                                <td><?php echo e($transaction->transaction_name); ?></td>
                                                <td>
                                                    <?php if($transaction->organisation_id): ?>
                                                        <?php echo e($transaction->organisation->organisation_name); ?> &nbsp;&nbsp;
                                                        <?php echo e($transaction->organisation->city); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td style="text-align: right;">&nbsp;<?php echo e($transaction->amount); ?></td>
                                                <td><?php echo e($status_name); ?></td>
                                                <td><?php echo e($transaction->transaction_refno); ?></td>
                                                <td><?php echo e($transaction->order_id); ?></td>
                                                <td><?php echo date("d-M-Y", strtotime($transaction->created_at)); ?></td>
                                                <td>
                                                    <a href="<?php echo e(URL::to('/transaction_view')); ?>/<?php echo e($transaction->id); ?>" class="btn btn-xs btn-info">View</a>
                                                </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 align="right">&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>   
                        </div>                                    
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            var table = $('#refund_list').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; ?>', footer: true, filename: 'Transaction Report' },
                        { extend: 'pdfHtml5',title: '<?php echo $org_name; ?>' + '\n' + '<?php echo $date_val; ?>', footer: true, filename: 'Transaction 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(4)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
             
                        // Total over this page
                        pageTotal = api
                            .column(4, { 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(4).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/transaction_list.blade.php ENDPATH**/ ?>