
<?php $__env->startSection('breadcrumb-first', $breadcrumb->first); ?>
<?php $__env->startSection('breadcrumb-second', $breadcrumb->second); ?>
<?php $__env->startSection('button'); ?>
<a href="javascript:;" onclick="modal('send', 'Saldo', '<?php echo e(url('admin/deposit/send')); ?>')" class="btn btn-custom btn-sm">
	<i class="fa fa-plus fa-fw"></i> Kirim Saldo
</a>
<a href="javascript:;" class="btn btn-custom btn-sm waves-effect waves-light" data-toggle="modal" data-target="#modal-filter">
	<i class="mdi mdi-filter me-1"></i> Filter Deposit
</a>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="row">
	<div class="col-lg-12">
        <?php echo $__env->make('admin.deposit.deposit.filter', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <div class="row">
            <div class="col-lg-3">
                <div class="card stats-widget card m-b-30">
                    <div class="card-body">
                        <div class="float-left">
                            <span class="label label-warning mb-3">Total</span>
                            <h5 class="mt-2">
                                <div id="report_total">
                                    Rp <?php echo e(number_format($total['total'],0,',','.')); ?> (<?php echo e(number_format($total['count'],0,',','.')); ?>)
                                </div>
                            </h5>
                        </div>
                        <div class="float-right">
                            <div class="avatar-xs">
                                <span class="avatar-title rounded-circle bg-custom">
                                    <i class="mdi mdi-cart-outline"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="card stats-widget card m-b-30">
                    <div class="card-body">
                        <div class="float-left">
                            <span class="label label-warning mb-3">Tertunda</span>
                            <h5 class="mt-2">
                                <div id="report_pending">
                                    Rp <?php echo e(number_format($pending['total'],0,',','.')); ?> (<?php echo e(number_format($pending['count'],0,',','.')); ?>)
                                </div>
                            </h5>
                        </div>
                        <div class="float-right">
                            <div class="avatar-xs">
                                <span class="avatar-title rounded-circle bg-custom">
                                    <i class="mdi mdi-cart-outline"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="card stats-widget card m-b-30">
                    <div class="card-body">
                        <div class="float-left">
                            <span class="label label-warning mb-3">Gagal</span>
                            <h5 class="mt-2">
                                <div id="report_canceled">
                                    Rp <?php echo e(number_format($canceled['total'],0,',','.')); ?> (<?php echo e(number_format($canceled['count'],0,',','.')); ?>)
                                </div>
                            </h5>
                        </div>
                        <div class="float-right">
                            <div class="avatar-xs">
                                <span class="avatar-title rounded-circle bg-custom">
                                    <i class="mdi mdi-cart-outline"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="card stats-widget card m-b-30">
                    <div class="card-body">
                        <div class="float-left">
                            <span class="label label-warning mb-3">Berhasil</span>
                            <h5 class="mt-2">
                                <div id="report_success">
                                    Rp <?php echo e(number_format($success['total'],0,',','.')); ?> (<?php echo e(number_format($success['count'],0,',','.')); ?>)
                                </div>
                            </h5>
                        </div>
                        <div class="float-right">
                            <div class="avatar-xs">
                                <span class="avatar-title rounded-circle bg-custom">
                                    <i class="mdi mdi-cart-outline"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="card card-custom">
            <div class="card-body">
                <div class="table-responsive">
                    <?php echo $dataTable->table(['class' => 'table table-borderless table-hover mb-0'], false); ?>

                </div>
			</div>
		</div>
	</div>
</div>
<?php echo $dataTable->scripts(); ?>

<script>
    $(document).ready(function () {
        document.getElementById("data-table").children[0].className = "thead-light";
        $('#filter_form').on('submit', function(element) {
            element.preventDefault();
            getReport()
            $("#modal-filter").modal('hide');
            $('#preloader').fadeIn('slow');
            $.when(window.LaravelDataTables["data-table"].page.len($('#filter_row').val()).draw()).done(function() {
                $('#preloader').fadeOut('slow');
            });
        });
        $('#filter_form').on('reset', function(element) {
            $('[data-toggle="select2"], select, input, textarea').val(null).trigger('change');
            $('#filter_row').val('10').trigger('change');
            getReport()
            $("#modal-filter").modal('hide');
            $('#preloader').fadeIn('slow');
            $.when(window.LaravelDataTables["data-table"].page.len('10').draw()).done(function() {
                $('#preloader').fadeOut('slow');
            });
        });
        $('#export-button').on('click', function() {
            window.location.href = '<?php echo e(url('admin/deposit/export-data')); ?>?' + $('#filter_form').serialize();
        });
        function getReport() {
            $.ajax({
                type: "GET",
                url: "<?php echo e(url('admin/deposit/report/list')); ?>",
                data: {
                    start_date       : $('#filter_start_date').val(),
                    end_date         : $('#filter_end_date').val(),
                    user             : $('#filter_user').val(),
                    method           : $('#filter_method').val(),
                    status           : $('#filter_status').val(),
                    search           : $('#search').val(),
                },
                dataType: "json",
                success: function(response) {
                    $('#report_total').html(response.total);
                    $('#report_pending').html(response.pending);
                    $('#report_canceled').html(response.canceled);
                    $('#report_success').html(response.success);
                }, error: function() {
                    swal.fire("Gagal!", "Terjadi kesalahan.", "error");
                }
            });
        }
    });
    function confirmDeposit(elt, id, title, url) {
        swal.fire({
            title: "Konfirmasi Deposit",
            html: "ID Deposit <b style=\"font-weight: bold;\">"+id+"</b>?",
            icon: "warning",
            showCancelButton: !0,
            confirmButtonText: "Ya, Konfirmasi!",
            cancelButtonText: "Tutup",
            confirmButtonClass: "btn btn-success mt-2",
            cancelButtonClass: "btn btn-secondary ml-2 mt-2",
            buttonsStyling: !1,
        }).then(result => {
            if (result.value) {
                $.ajax({
                    url: url,
                    type: 'GET',
                    beforeSend: function() {
                        $('#preloader').fadeIn("slow");
                    },
                    error: function() {
                        $('#preloader').fadeOut("slow");
                        showAlert('danger', 'Terjadi kesalahan.', 3000);
                    },
                    success: function(response) {
                        $('#preloader').fadeOut("slow");
                        if (response.result == false) {
                            showAlert(
                                response.hasOwnProperty('alert') ? response.alert : 'danger', 
                                response.message, 
                                response.hasOwnProperty('timeout') ? response.timeout : 5000
                            );
                        } else {
                            window.LaravelDataTables["data-table"].draw('page');
                            showAlert('success', response.message, 30000, 'col-lg-12');
                        }
                    }
                });
            
            }
        });
    }
    function cancelDeposit(elt, id, title, url) {
        swal.fire({
            title: "Batalkan Deposit",
            html: "ID Deposit <b style=\"font-weight: bold;\">"+id+"</b>?",
            icon: "warning",
            showCancelButton: !0,
            confirmButtonText: "Ya, Batalkan!",
            cancelButtonText: "Tutup",
            confirmButtonClass: "btn btn-success mt-2",
            cancelButtonClass: "btn btn-secondary ml-2 mt-2",
            buttonsStyling: !1,
        }).then(result => {
            if (result.value) {
                $.ajax({
                    url: url,
                    type: 'GET',
                    beforeSend: function() {
                        $('#preloader').fadeIn("slow");
                    },
                    error: function() {
                        $('#preloader').fadeOut("slow");
                        showAlert('danger', 'Terjadi kesalahan.', 3000);
                    },
                    success: function(response) {
                        $('#preloader').fadeOut("slow");
                        if (response.result == false) {
                            showAlert(
                                response.hasOwnProperty('alert') ? response.alert : 'danger', 
                                response.message, 
                                response.hasOwnProperty('timeout') ? response.timeout : 5000
                            );
                        } else {
                            window.LaravelDataTables["data-table"].draw('page');
                            showAlert('success', 'Deposit berhasil dibatalkan.', 30000, 'col-lg-12');
                        }
                    }
                });
            
            }
        });
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/glor5228/public_html/resources/views/admin/deposit/deposit/list.blade.php ENDPATH**/ ?>