
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>Leave List</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.list')); ?></li>
                    </ol>
                </nav>
            </div>
            <div class="toast" data-autohide="false">
               
                <div class="toast-body">
                <button type="button" class="ml-2 mb-1 close" data-dismiss="toast">&times;</button>
                    Some text inside the toast body
                </div>
            </div>
            <!-- end::page header -->
            <div class="card">

                <div class="card-header">
                  
                    <div class="row mt-3">
                        <div class="col-md-5">
                            <form action="<?php echo e(asset('hrms/employee-leave-management')); ?>" method="get">
                                
                                <div class="company-field-box">
                                        <div>
                                            <div class="input-group">
                                                <div class="input-group-prepend">
                                                    <button type="button" class="btn border input-group-text filter-company-btn px-4">
                                                        <i class="ti ti-filter fa-lg"></id></i>
                                                    </button>
                                                </div>
                                                    
                                                    <input type="search" value="<?php echo e(isset($_GET['search']) ? $_GET['search'] : null); ?>" name="search" placeholder="Name" class="form-control border-right-0 seach-input">
                                                    <button class="btn border border-left-0" type="submit" style="margin-left:-5px;">
                                                        <i class="ti ti-search fa-lg"></i>
                                                    </button>
                                                    <a class="btn btn-white border" href="<?php echo e(asset('hrms/employee-leave-management')); ?>"><i class="ti ti-reload fa-lg"></i></a>
                                                    
                                            </div>
                                            <div class="filter-form-box d-none">
                                                <div class="diamond"></div>
                                                <form method="get" action="<?php echo e(asset('hrms/employee-leave-management')); ?>">
                                                    <div class="form-group">
                                                        <label>Name</label>
                                                        <input value="<?php echo e(isset($_GET['name']) ? $_GET['name'] : null); ?>" type="text" name="name" class="form-control" >
                                                    </div>
                                                  
                                                    <div class="row">
                                                        <div class="form-group col-6">
                                                            <label>Start Date</label>
                                                            <input type="date" name="start_date" value="<?php echo e(isset($_GET['start_date']) ? $_GET['start_date'] : null); ?>"  class="form-control" id="start_date">
                                                        </div>
                                                        
                                                        <div class="form-group col-6">
                                                            <label>End Date</label>
                                                            <input type="date" name="end_date" value="<?php echo e(isset($_GET['end_date']) ? $_GET['end_date'] : null); ?>" class="form-control" id="end_date">
                                                        </div>
                                                        
                                                    </div>
                                                    <div class="row">
                                                        <div class="form-group col-12 d-flex justify-content-end">
                                                            <button type="submit" class="btn btn-success mr-5 px-4 apply-button">Apply </button>
                                                        
                                                            <a href="<?php echo e(asset('hrms/employee-leave-management')); ?>" class="btn btn-primary px-3 text-white">Clear</a>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-md-4"></div>
                        <div class="col-md-3 d-flex justify-content-end">
                            <div>
                                <a data-toggle="tooltip" data-original-title="Add Leave"
                                    href="<?php echo e(asset('hrms/add-employee-leave')); ?>" class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="ti ti-plus fa-lg"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card-body">

                    <?php if(isset($leaves)): ?>

                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>
                                            <input type="checkbox" id="checkAll" />
                                        </th>
                                        <th class="wrap">S.NO</th>
                                        <th>SUBJECT</th>
                                        <th>LEAVE TYPE</th>          
                                        <th>NAME</th>                                       
                                        <th>DESIGNATION</th>  
                                        <th>START DATE</th>
                                        <th>END DATE</th>
                                        <th>STATUS</th>                     
                                        <th>ACTION</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(!empty($leaves)): ?>
                                        <?php $__currentLoopData = $leaves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                       
                                           <tr>
                                                <td>
                                                    <input type="checkbox" id="checkAll" />
                                                </td>
                                                <td><?php echo e(++$key); ?></td>
                                                <td>
                                                    <?php echo e($value->subject); ?>

                                                </td>
                                                
                                                <td><?php echo e($value->leave_head_name); ?></td>
                                                <td class="text-capitalize"><?php echo e($value->employee_name); ?></td>
                                                <td class="text-capitalize"><?php echo e($value->designation); ?></td>                               
                                                <td class="text-capitalize"><?php echo e($value->start_date); ?></td>
                                                <td class="text-capitalize"><?php echo e($value->end_date); ?></td>
                                                <td >
                                                    <select class="form-control leave_status_change" leave_id="<?php echo e($value->id); ?>">
                                                        <option value="pending" <?php echo e($value->status == "pending" ? 'selected' : ''); ?>>PENDING</option>
                                                        <option value="approved" <?php echo e($value->status == "approved" ? 'selected' : ''); ?>>APPROVED</option>
                                                        <option value="reject" <?php echo e($value->status == "reject" ? 'selected' : ''); ?>>REJECT</option>
                                                    </select>
                                                    
                                                </td>
                                                <td>
                                                    
                                                    <div class="btn-group">
                                                        <a class="btn btn-sm btn-outline-info" href="<?php echo e(asset('hrms/edit-employee-leave/'.$value->id)); ?>"><i class="ti ti-pencil"></i></a>
                                                        
                                                        <button class="btn btn-sm btn-outline-danger reg-delete-btn" reg_id="<?php echo e($value->id); ?>" data-toggle="tooltip"
                                                            data-original-title="Delete Leave" ><i
                                                                class="ti ti-trash fa-lg"></i>
                                                        </button>
                                                        
                                                    </div>
                                                </td>
                                           </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                        <h1>No Record Found!!</h1>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                            <div class="pagination-block d-flex justify-content-center">
                                <div class="">
                                    <?php if(isset($_GET['query'])): ?>
                                        <?php echo e($leaves->appends(['query' => $_GET['query'], 'per_page' => $_GET['per_page'], 'datefilter' => $_GET['datefilter']])->links('includes.paginationlinks')); ?>

                                    <?php else: ?>
                                        <?php echo e($leaves->links('includes.paginationlinks')); ?>

                                    <?php endif; ?>
                                    <label>Total Record Found- <?php echo count($leaves); ?></label>
                                </div>
                            
                            </div>


                        </div>


                        
                    <?php endif; ?>
                </div>
            </div>
        </div>

        
        <!-- Button to Open the Modal -->


    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::dataTable -->
    <script src="<?php echo e(asset('public/admin/js/examples/datatable.js')); ?>"></script>
    <!-- end::dataTable -->
    <script>
        $(document).ready(function() {
            $(".filter-company-btn").click(function(){
            
                if($(".filter-form-box").hasClass("d-none"))
                {
                    $(".filter-form-box").removeClass("d-none");
                }
                else
                {
                    $(".filter-form-box").addClass("d-none");
                }
            });

            $(".reset_password_btn").click(function(){
                var user_id = $(this).attr("user_id");
                $("#user_unique_id").val(user_id);
            });

            $("#checkAll").click(function() {
                $('input:checkbox').not(this).prop('checked', this.checked);
            });
            /*
            $('#deleteAll').click(function() {
                if (confirm("Are you sure you want to delete Users? ")) {
                    var val = [];
                    $('.deleteall:checked').each(function(i) {
                        val[i] = $(this).val();
                    });

                    if (val.length > 0) {
                        $.ajax({
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            url: "<?php echo e(asset('delete-multiple-users')); ?>",
                            data: {
                                "ids": val
                            }
                        }).done(function(data) {
                            if (data) {
                                location.reload();
                            } else {
                                alert("Something went wrong!, Try again");
                            }
                        });
                    }
                }
                //alert(<?php echo e(asset('admin/delete-multiple-users')); ?>);
            });*/
            
            $(".reg-delete-btn").click(function(){
                var id = $(this).attr("reg_id");
               
                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "delete",
                            data: {
                                "id": id
                            },
                            url: "<?php echo e(asset('hrms/delete-employee-leave')); ?>",
                            dataType: "html",
                            success: function(result) 
                            {
                                swal("success!", "Successfully deleted!", "success");
                                window.location.reload();
                            },
                            error: function(error,xhr,status)
                            {
                                swal("failed!", "failed to delete!", "error");
                               window.location.reload();
                            }
                        });
                       
                    }
                });
                
            });
            $("#delete-multiple").click(function() {
                var URL = "<?php echo e(asset('notice/multidelete')); ?>";
                var parent_ids = [];
                $('.parentids:checkbox:checked').each(function() {
                    parent_ids.push($(this).val());
                });
                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "post",
                            data: {
                                "student_ids": parent_ids
                            },
                            url: URL,
                            dataType: "html",
                            success: function(result) {}
                        });
                        swal("success!", "Successfully deleted!", "success");
                        window.location.reload();
                    }
                });
            });

            $(".purpose-btn").click(function(){
                
                $("#purposeModal").modal();
            });

            //leave status change
            $(".leave_status_change").on("change",function(){
                var status = $(this).val();
                var leave_id = $(this).attr("leave_id");

                $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "post",
                            data: {
                                "leave_id": leave_id,
                                "status": status
                            },
                            url: "<?php echo e(asset('hrms/leave_status_change')); ?>",
                            dataType: "html",
                            success: function(result) 
                            {
                                
                                toastr.success('Successfully changed !');
                                
                            },
                            error: function(error,xhr,status)
                            {
                                toastr.danger('Failed !');
                               //window.location.reload();
                            }
                        });
                       
                
            });
            
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\blurb_erp\resources\views/hrms/payroll/leave_management/list.blade.php ENDPATH**/ ?>