<?php
    use Carbon\Carbon;
?>


<?php $__env->startSection('title', 'Expense'); ?>

<?php $__env->startPush('css'); ?>
    <!-- data tables -->
    <link href="<?php echo e(asset('admin/assets/plugins/datatables/plugins/bootstrap/dataTables.bootstrap4.min.css')); ?> " rel="stylesheet" type="text/css"/>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
    <div class="page-bar">
        <div class="page-title-breadcrumb">

        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
                <div class="btn-group">
                    <a href="<?php echo e(route('admin.expense.create')); ?>" id="addRow1" class="btn btn-primary" style="font-size:14px; padding: 6px 12px;">
                        Add New Expense <i style="color:white;" class="fa fa-plus"></i>
                    </a>

                </div>

            <div class="card card-topline-red">
                <div class="card-head" style="text-align: center;">
                    <header>EXPENSE</header> <span class="btn btn-primary ml-1"> <?php echo e($expenses->count()); ?> </span>

                </div>
                <div class="card-body ">
                    <div class="row p-b-20">
                        <div class="col-md-6 col-sm-6 col-6">

                        </div>
                        <div class="col-md-6 col-sm-6 col-6">

                        </div>
                    </div>
                    <header class="panel-heading panel-heading-gray custom-tab ">
                        <ul class="nav nav-tabs">
                            <li class="nav-item">
                                <a href="#active" data-toggle="tab" class="active">Approved</a>
                            </li>
                            <li class="nav-item">
                                <a href="#pending" data-toggle="tab">Pending</a>
                            </li>

                        </ul>
                    </header>

                    <div class="tab-content">
                        
                        <div class="tab-pane active" id="active">
                            <div class="col-12">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="table-scrollable">
                                            <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
                                                <thead>
                                                <tr>

                                                    <th> Serial </th>
                                                    <th> Expense Head </th>
                                                    <th> Amount </th>
                                                    <th> Description </th>
                                                    <th> Recipient Name </th>
                                                    <th> Given Name </th>
                                                    <th> Created </th>
                                                    <th> Actions </th>
                                                </tr>
                                                </thead>
                                                <tbody>

                                                <?php $__currentLoopData = $expenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$expense): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <tr class="odd gradeX">
                                                        <td> <?php echo e($key+1); ?> </td>
                                                        <td>

                                                            <?php echo e($expense->expensehead->name); ?>


                                                        </td>
                                                        <td><?php echo e($expense->amount); ?></td>
                                                        <td><?php echo e($expense->description); ?></td>
                                                        <td><?php echo e($expense->recipient_name); ?></td>
                                                        <td>

                                                            <?php echo e($expense->user->name); ?>


                                                        </td>
                                                        <td><?php echo e($expense->created_at->toDayDateTimeString()); ?></td>
                                                        <td>
                                                            <?php if(auth()->check() && auth()->user()->hasRole('superadmin')): ?>
                                                            <a  class="waves-effect btn btn-primary" href="<?php echo e(route('admin.expense.edit', $expense->id)); ?>"><i class="material-icons">edit</i></a>

                                                            <button type="submit" class="waves-effect btn deepPink-bgcolor"
                                                                    onclick="deleteExpense(<?php echo e($expense->id); ?>)">
                                                                <i class="material-icons">delete</i>
                                                            </button>

                                                            <form id="delete-form-<?php echo e($expense->id); ?>" action="<?php echo e(route('admin.expense.destroy', $expense->id)); ?>" method="post" style="display:none;">
                                                                <?php echo csrf_field(); ?>
                                                                <?php echo method_field("DELETE"); ?>
                                                            </form>
                                                            <?php endif; ?>
                                                        </td>
                                                    </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        
                        <div class="tab-pane" id="pending">
                            <div class="row">
                                <div class="col-md-12 col-sm-12">
                                    <div class="card">

                                        <div class="card-body">
                                            <div class="table-scrollable">
                                                <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="pending_expense">
                                                    <thead>
                                                    <tr>
                                                        <th> Serial </th>
                                                        <th> Expense Head </th>
                                                        <th> Amount </th>
                                                        <th> Description </th>
                                                        <th> Recipient Name </th>
                                                        <th> Given Name </th>
                                                        <th> Created </th>
                                                        <th> Actions </th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <?php $__currentLoopData = $pending; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <tr class="odd gradeX">
                                                            <td> <?php echo e($key+1); ?> </td>
                                                            <td>

                                                                <?php echo e($value->expensehead->name); ?>


                                                            </td>
                                                            <td><?php echo e($value->amount); ?></td>
                                                            <td><?php echo e($value->description); ?></td>
                                                            <td><?php echo e($value->recipient_name); ?></td>
                                                            <td>

                                                                <?php echo e($value->user->name); ?>


                                                            </td>
                                                            <td><?php echo e($value->created_at->toDayDateTimeString()); ?></td>
                                                            <td>

                                                                <a  class="waves-effect btn btn-primary" href="<?php echo e(route('admin.expense.edit', $value->id)); ?>"><i class="material-icons">edit</i></a>
                                                                <?php if(auth()->check() && auth()->user()->hasRole('superadmin')): ?>
                                                                <button type="submit" class="waves-effect btn deepPink-bgcolor"
                                                                        onclick="deleteExpense(<?php echo e($value->id); ?>)">
                                                                    <i class="material-icons">delete</i>
                                                                </button>

                                                                <form id="delete-form-<?php echo e($value->id); ?>" action="<?php echo e(route('admin.expense.destroy', $value->id)); ?>" method="post" style="display:none;">
                                                                    <?php echo csrf_field(); ?>
                                                                    <?php echo method_field("DELETE"); ?>
                                                                </form>
                                                                <?php endif; ?>
                                                            </td>
                                                        </tr>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

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

<?php $__env->startPush('js'); ?>
    <!-- data tables -->
    <script src="<?php echo e(asset('admin/assets/plugins/datatables/jquery.dataTables.min.js')); ?>"></script>
    <script src="<?php echo e(asset('admin/assets/plugins/datatables/plugins/bootstrap/dataTables.bootstrap4.min.js')); ?>" ></script>
    <script src="<?php echo e(asset('admin/assets/js/pages/table/table_data.js')); ?>" ></script>
    <!-- sweet aleart -->
    <script src="<?php echo e(asset('admin/assets/js/sweetalert.min.js')); ?>"></script>

    <script type="text/javascript">

    function deleteExpense(id) {

        const swalWithBootstrapButtons = Swal.mixin({
            customClass: {
                confirmButton: 'btn btn-success',
                cancelButton: 'btn btn-danger'
            },
            buttonsStyling: false,
            })

            swalWithBootstrapButtons.fire({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            type: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Yes, delete it!',
            cancelButtonText: 'No, cancel!',
            reverseButtons: true
            }).then((result) => {
            if (result.value) {
                event.preventDefault();
                document.getElementById("delete-form-"+id).submit();
            } else if (
                // Read more about handling dismissals
                result.dismiss === Swal.DismissReason.cancel
            ) {
                swalWithBootstrapButtons.fire(
                'Cancelled',
                'Your Branch name is safe :)',
                'error'
                )
            }
        })

    }

    </script>
<?php $__env->stopPush(); ?>



<?php echo $__env->make('template.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/forazitradersbd/public_html/resources/views/admin/expense/index.blade.php ENDPATH**/ ?>