

<?php $__env->startSection('content'); ?>

    <?php Fun::lang() ?>


    <div class="page">

        <div class=container-fluid>

            <div class="top-content">

                <div class="row">

                    <div class="col-sm-12 col-xs-12">

                        <div>

                            <b style="font-size: 30px"><?php echo e(__('administrator.payment_report')); ?></b>

                        </div>

                    </div>

                </div>

            </div>

            <br>&nbsp;

            <br>

            <div class="top-content">

                <div class="row">

                    <div class="col-sm-12 col-xs-12">

                        <?php echo Form::open(array('route' => 'datatable_account_receivable','method'=>'POST')); ?>


                        <div class="col-sm-3">

                            <div class="form-group col-sm-3">

                                <label for="name"><?php echo e(__('administrator.suppliers')); ?></label>

                            </div>

                            <div class="form-group col-sm-9">

                                <?php echo Form::select('supplier_id', $suppliers, null, ['placeholder'=>__('administrator.please_select'),'class' => 'form-control select2','id'=>'supplier_id']); ?>


                            </div>

                        </div>

                        <div class="col-sm-3">

                            <div class="form-group col-sm-3">

                                <label for="name"><?php echo e(__('administrator.status')); ?></label>

                            </div>

                            <div class="form-group col-sm-9">

                                <?php echo Form::select('status', [''=>__('administrator.please_select'),'Due'=>__('administrator.owed'),'Paid'=>__('administrator.paid')], null, ['class' => 'form-control select2','id'=>'']); ?>


                            </div>

                        </div>

                        <div class="col-sm-4">

                            <div class="form-group col-sm-3">

                                <label for="name"><?php echo e(__('administrator.purchase_date')); ?></label>

                            </div>

                            <div class="form-group  col-sm-9">

                                <?php echo Form::text('p_date', null, ['class' => 'form-control date_picker input-sm purchase_date']); ?>


                            </div>

                        </div>

                        <div class="col-sm-2">

                            <div class="pull-right">

                                <a class="button_primary cursor" onclick="searching()"><span
                                            class="fa fa-search"></span> <?php echo e(__('administrator.searching')); ?></a>

                            </div>

                        </div>

                        <?php echo Form::close(); ?>


                    </div>

                </div>

            </div>

            <div class="wrapper-table">

                <table id="datatable_account_receivable" width="100%" class="table table-striped table-hover  ">

                    <thead>

                    <tr>

                        <th>#</th>

                        <th><?php echo e(__('administrator.invoice_number')); ?></th>

                        <th><?php echo e(__('administrator.suppliers')); ?></th>

                        <th><?php echo e(__('administrator.phone')); ?></th>

                        <th><?php echo e(__('administrator.purchase_date')); ?></th>

                        <th><?php echo e(__('administrator.payment_date')); ?></th>

                        <th><?php echo e(__('administrator.amount')); ?></th>

                        <th><?php echo e(__('administrator.refund')); ?></th>

                        <th><?php echo e(__('administrator.status')); ?></th>

                    </tr>

                    </thead>

                    <tbody class="tbody">


                    </tbody>

                </table>

            </div>

        </div>

        <?php $__env->stopSection(); ?>

        <?php $__env->startSection('script'); ?>

            <script type="text/javascript">

                function searching() {


                    var supplier_id = $("select[name=supplier_id]").val();

                    var status = $("select[name=status]").val();

                    var date1 = $(".purchase_date").val();

                    var table = '';

                    var i = 0;

                    $('.tbody').empty();

                    $('.tfoot').empty();


                    $.ajax({

                        method: 'post',

                        dataType: 'json',

                        url: "<?php echo e(route('datatable.payment-report')); ?>",

                        async: false,

                        data: {

                            _token: '<?php echo e(csrf_token()); ?>',

                            supplier_id: supplier_id,

                            status: status,

                            search_date: date1,

                        },

                        success: function (response) {

                            $.each(response, function (index, val) {


                                if (val.payment_status.toLowerCase() == 'paid') {

                                    status = '<span class="label label-success">Paid</span>';

                                } else {

                                    status = '<span class="label label-danger">Due</span>';

                                }

                                var date = val.purchase_date.split('-');

                                var pdate = val.payment_date.split('-');

                                table += `

                                        <tr>

                                            <td>${index + 1}</td>

                                            <td>${val.payment_invoice}</td>

                                            <td>${val.supplier_name}</td>

                                            <td>${val.supplier_phone}</td>

                                            <td>${date[2] + '-' + date[1] + '-' + date[0]}</td>

                                            <td>${pdate[2] + '-' + pdate[1] + '-' + pdate[0]}</td>

                                            <td>$${val.payment_amount.toFixed(2)}</td>

                                            <td>$${val.payment_refunds.toFixed(2)}</td>

                                            <td>${status}</td>

                                        </tr>`;


                            });

                            table = table != '' ? table : '<tr><td colspan="10" class="text-center">No Data</td></tr>';

                            $('.tbody').append(table);


                        },


                    });

                }

                $(document).ready(function () {

                    $('.main-spinner').show();

                    $('#datatable_account_receivable').DataTable({

                        "lengthMenu": [

                            [20, 25, 50, 100, 500],

                            [20, 25, 50, 100, 500]

                        ],

                        ordering: false,

                        serverSide: true,

                        ajax: "<?php echo e(route('datatable.payment-report')); ?>",

                        columns: [

                            {

                                "data": "DT_RowIndex",

                                "searchable": false

                            },

                            {

                                data: 'payment_invoice',

                            },

                            {

                                data: 'supplier_name'

                            },

                            {

                                data: 'supplier_phone'

                            },

                            {

                                data: 'purchase_date',

                                "searchable": false

                            },

                            {

                                data: 'payment_date',

                                "searchable": false

                            },

                            {

                                data: 'payment_amount',

                                'name': 'nso007_payment.payment_amount'

                            },

                            {

                                data: 'amount',

                                'name': 'nso007_payment.payment_refunds'

                            },

                            {

                                data: 'payment_status',

                                'name': 'nso007_payment.payment_status'

                            },


                        ],

                    });


                    $.fn.dataTable.ext.errMode = 'throw';

                });


                $('[data-toggle=confirmation]').confirmation({

                    rootSelector: '[data-toggle=confirmation]',

                    onConfirm: function (event, element) {

                        element.closest('form').submit();

                    }

                });

            </script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make(branchMenu(), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/administrator/payment-report/index.blade.php ENDPATH**/ ?>