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

    <link href="/assets/global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="/assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="/assets/global/plugins/bootstrap-editable/bootstrap-editable/css/bootstrap-editable.css"
          rel="stylesheet" type="text/css"/>
    <link href="/assets/global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/global/plugins/bootstrap-editable/inputs-ext/address/address.css" rel="stylesheet"
          type="text/css"/>


    <style>

        .pac-container {
            z-index: 10052 !important;
        }

        #map {
            width: auto !important;
            height: 500px !important;
        }

        #map_edit {
            width: auto !important;
            height: 500px !important;
        }

        tfoot {
            display: table-header-group;
        }

        tfoot input {
            font-weight: normal !important;
        }

        tfoot select {
            font-weight: normal !important;
        }

        .dataTables_filter {
            display: none;
        }

        #orders-table_length {
            display: none;
        }

        .ws-nr {
            width: 100% !important;
        }
    </style>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <?php if(session()->has('error')): ?>
        <div class="alert alert-danger"><?php echo e(session()->get('error')); ?></div>
    <?php endif; ?>
    <?php if(session()->has('success')): ?>
        <div class="alert alert-success"><?php echo e(session()->get('success')); ?></div>
    <?php endif; ?>
    <?php if(count($errors) > 0): ?>
        <div class="alert alert-danger">
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>
    <h1 class="page-title">
        Danh sách nhân viên
    </h1>


    <div class="row">

        <div class="col-md-12">
            <div class="text-center">
                
                
                
                
                

                
                
                
                
                

                


                <a class="btn green-meadow pull-right" href="#add-staff" id="btn-add-staff" data-toggle="modal"
                   style="float: right">
                    Thêm nhân viên</a>

            </div>
        </div>
    </div>
    <div class="row">
        
        
        
        <div class="col-md-12">
            <table class="table table-striped table-bordered table-hover" id="orders-table">
                <thead>
                <tr style="background-color: #5376B9; color: white">
                    <th>STT</th>
                    <th>Ảnh</th>
                    <th>Tên</th>
                    <th>SĐT</th>
                    <th>Email</th>
                    <th style="width: 15%">Hành động</th>
                </tr>
                </thead>
                <tfoot>
                <tr>
                    <th></th>
                    <th></th>
                    <th><input type="text" class="form-control"></th>
                    <th><input type="text" class="form-control"></th>
                    <th><input type="text" class="form-control"></th>
                    <th></th>
                    
                </tr>
                </tfoot>
            </table>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12" id="detail">
        </div>
    </div>


    <div class="modal fade in" tabindex="-1" role="dialog" id="add-staff">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">×</span>
                    </button>
                    <h4 class="modal-title">Thêm nhân viên</h4>
                </div>
                <div class="modal-body add-staff-content" id="add-staff-content">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal" id="dismiss-modal">Hủy
                    </button>
                    <button type="button" class="btn green" id="btn-save-staff">Lưu</button>

                </div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>


    <div class="modal fade bs-modal-lg" id="edit-staff" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Cập nhật nhân viên</h4>
                </div>
                <div class="modal-body" id="edit-staff-content">


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal" id="dismiss-modal">Hủy
                    </button>
                    <button type="button" class="btn green" id="btn-save-edit-staff">Lưu</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade bs-modal-lg" id="edit-staff-permission" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Cập nhật quyền nhân viên</h4>
                </div>
                <div class="modal-body" id="edit-staff-permission-content">


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal" id="dismiss-modal">Hủy
                    </button>
                    <button type="button" class="btn green" id="btn-save-edit-permission-staff">Lưu</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

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

<?php $__env->startPush('scripts'); ?>
    <script src="/assets/global/plugins/dropzone/dropzone.min.js" type="text/javascript"></script>
    <script src="/assets/pages/scripts/form-dropzone.min.js" type="text/javascript"></script>
    <script src="/assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/assets/global/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script>
    <script type="text/javascript"
            src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCydLs7dhJPuozABFQjJO-uk1PITW18oo8&libraries=places&region=vi&language=vi&sensor=false"></script>
    <script type="text/javascript" src="/js/gmap.js"></script>
    <script src="/js/jquery.validate.min.js"></script>

    <script>
        $.validator.addMethod("greaterThan",
            function (value, element, param) {
                var $otherElement = $(param);
                return parseInt(value, 10) >= parseInt($otherElement.val(), 10);
            }
        );
    </script>


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


<?php $__env->startPush('scripts'); ?>
    
    

    
    
    
    


    
    
    
    
    

    <script>
        $('.date-picker').datepicker({
            format: 'dd/mm/yyyy',
            autoclose: true

        })


        //    $(document).on('change', '.add-image-hostel', function(e) {
        //        alert('123');
        //       $('.fileinput-exists').css({
        //           'width' : '48%'
        //       });
        //
        //      $('.btn-file').css({
        //          'width' : '100%'
        //      });
        //
        //
        //    });

        var table;

        $(document).on('change', '#province1', function (e) {
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'province',
                },
                dataType: 'html',
                success: function (response) {
                    $('#district1').html(response);
                    $('#ward1').html('');

                }
            });
        });

        $(document).on('change', '#district1', function (e) {
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'district'
                },
                dataType: 'html',
                success: function (response) {
                    $('#ward1').html(response);

                }
            });
        });


        $(document).on('change', '#province2', function (e) {
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'province',
                },
                dataType: 'html',
                success: function (response) {
                    $('#district2').html(response);
                    $('#ward2').html('');

                }
            });
        });

        $(document).on('change', '#district2', function (e) {
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'district'
                },
                dataType: 'html',
                success: function (response) {
                    $('#ward2').html(response);

                }
            });
        });


        $('#hostels').on('change', function () {
            getPostByAttr();
        });

        $(document).on('click', '#btn-save-staff', function (e) {
            e.preventDefault();
            var formStatus = $("#form-add-staff").validate(
                {
                    errorElement: "span",
                    errorClass: "help-block help-block-error",

                    highlight: function (e) {
                        $(e).closest(".form-group").addClass("has-error")
                    },
                    unhighlight: function (e) {
                        $(e).closest(".form-group").removeClass("has-error")
                    },
                    success: function (e) {
                        e.closest(".form-group").removeClass("has-error")
                    },
                    ignore: ".ignore",
                    rules: {
                        phone: {
                            required: true,
                            remote: {
                                url: "<?php echo e(url('admin/check-unique-phone')); ?>",
                                type: "post",
                                data: {
                                    phone: function () {
                                        return $("#phone").val();
                                    }
                                }
                            }
                        },
                        email: {
                            email: true,
                            remote: {
                                url: "<?php echo e(url('admin/check-unique-email')); ?>",
                                type: "post",
                                data: {
                                    email: function () {
                                        return $("#email").val();
                                    }
                                }
                            }
                        },
                        name: {
                            required: true
                        },
                        password: {
                            required: true
                        },
                        confirm_password: {
                            required: true,
                            equalTo: "#password"
                        },
                    },
                    messages: {
                        name: "Vui lòng không bỏ trống Tên",
                        phone: {
                            required: "Vui lòng không bỏ trống số điện thoại",
                            remote: jQuery.validator.format("{0} đã được sử dụng")
                        },
                        email: {

                            remote: jQuery.validator.format("{0} đã được sử dụng")
                        },
                        type: "Vui lòng không bỏ trống loại tài khoản",
                        password: "Vui lòng không bỏ trống mật khẩu",
                        //    confirm_password: "Vui lòng không bỏ trống loại tài khoản",
                        confirm_password: {
                            required: "Vui lòng nhập lại mật khẩu",
                            equalTo: "Vui lòng nhập lại chính xác mật khẩu"
                        },
                        // image: 'Vui lòng không bỏ trống hình ảnh'
                    }
                }
            ).form();

            if (formStatus) {

                var data = $('#form-add-staff').serialize();
                $.ajax({
                    url: '<?php echo e(url('/admin2/staff/create-staff')); ?>',
                    type: 'post',
                    data: data,
                    dataType: 'json',
                    beforeSend: function () {
                        $('#add-staff-content').addClass('ht-on-loading');
                    },
                    success: function (response) {
                        $('#add-staff-content').removeClass('ht-on-loading');
                        if (response.status == 1) {
                            swal('Thành công', 'Nhân viên đã được lưu lại', 'success');
                            $('#add-staff').modal('hide');
                        } else if (response.status == 0) {
                            swal('Thông báo', response.message, 'warning');
                        } else if (response.status == 2) {
                            swal('Thông báo', response.message, 'info');
                        }

                        $.ajax({
                            url: '<?php echo e(url('admin/account/get-remain-staff')); ?>',
                            type: 'get',
                            success: function (response) {
                                if (response.status == 1) {
                                    $('#report').text(response.message);
                                }
                            }
                        });

                        table.ajax.reload();
                    }
                });
            }
        });

        $(document).on('click', '#btn-save-edit-staff', function (e) {
            e.preventDefault();
            var formStatus = $("#form-edit-staff").validate(
                {
                    errorElement: "span",
                    errorClass: "help-block help-block-error",

                    highlight: function (e) {
                        $(e).closest(".form-group").addClass("has-error")
                    },
                    unhighlight: function (e) {
                        $(e).closest(".form-group").removeClass("has-error")
                    },
                    success: function (e) {
                        e.closest(".form-group").removeClass("has-error")
                    },
                    ignore: ".ignore",
                    rules: {
                        name: {
                            required: true
                        },
                        phone: {
                            required: true,
                            remote: {
                                url: "<?php echo e(url('admin/check-unique-phone')); ?>",
                                type: "post",
                                data: {
                                    phone: function () {
                                        return $("#phone-e").val();
                                    },
                                    type: 'edit',
                                    user_id: $('#user_id').val()
                                }
                            }
                        },
                        email: {
                            email: true,
                            remote: {
                                url: "<?php echo e(url('admin/check-unique-email')); ?>",
                                type: "post",
                                data: {
                                    email: function () {
                                        return $("#email-e").val();
                                    },
                                    type: 'edit',
                                    user_id: $('#user_id').val()
                                }
                            }
                        }
                    },
                    messages: {
                        name: "Vui lòng không bỏ trống tên",
                        phone: {
                            required: "Vui lòng không bỏ trống số điện thoại",
                            remote: jQuery.validator.format("{0} đã được sử dụng")
                        },
                        email: {
                            remote: jQuery.validator.format("{0} đã được sử dụng")
                        },
                        // image: 'Vui lòng không bỏ trống hình ảnh'
                    }
                }
            ).form();

            if (formStatus) {

                var data = new $('#form-edit-staff').serialize();
                $.ajax({
                    url: '<?php echo e(url('/admin2/staff/update')); ?>',
                    type: 'post',
                    data: data,
                    dataType: 'json',
                    beforeSend: function () {
                        $('#edit-staff-content').addClass('ht-on-loading');
                    },
                    success: function (response) {
                        $('#edit-staff-content').removeClass('ht-on-loading');
                        if (response.status == 1) {
                            swal('Thành công', 'Thông tin đã được lưu lại', 'success');
                            $('#edit-staff').modal('hide');
                        } else {
                            swal('Thông báo', response.message, 'warning');
                        }
                        table.ajax.reload();
                    }
                });
            }
        });

        $(document).on('click', '#btn-save-edit-permission-staff', function (e) {
            e.preventDefault();
            var data = $("#form-staff-permission").serialize();
            $.ajax({
                url: '<?php echo e(url('/admin2/staff/update-permission')); ?>',
                type: 'post',
                data: data,
                dataType: 'json',
                beforeSend: function () {
                    $('#edit-staff-permission-content').addClass('ht-on-loading');
                },
                success: function (response) {
                    $('#edit-staff-permission-content').removeClass('ht-on-loading');
                    if (response.status == 1) {
                        swal('Thành công', 'Thông tin đã được lưu lại', 'success');
                        $('#edit-staff-permission').modal('hide');
                    } else if (response.status == 2) {
                        swal('Thông báo', response.message, 'info');
                    } else {
                        swal('Thông báo', response.message, 'warning');
                    }
                }
            });

        });

        $(document).on('click', '.btn-delete-staff', function (e) {
            e.preventDefault();
            var id = $(this).attr('data-id');

            bootbox.confirm({
                message: "Bạn có chắc chắn muốn xóa",
                buttons: {
                    confirm: {
                        label: 'Có',
                        className: 'btn-success'
                    },
                    cancel: {
                        label: 'Không',
                        className: 'btn-danger'
                    }
                },


                callback: function (result) {
                    if (result == true) {

                        $.ajax({
                            url: '<?php echo e(url('admin2/staff/delete-staff')); ?>',
                            type: 'post',
                            data: {
                                id: id,
                            },
                            dataType: 'json',
                            success: function (response) {
                                if (response.status == 1) {
                                    swal('Thành công', '', 'success');
                                } else if (response.status == 2) {
                                    swal('Thông báo', response.message, 'info');
                                } else {
                                    swal('Thông báo', response.message, 'warning');
                                }
                                table.ajax.reload();
                            }
                        });

                    }
                }
            });
        });

        $(document).on('click', '.btn-edit-staff', function (e) {
            e.preventDefault();

            var id = $(this).attr('data-id');
            $.ajax({
                url: '<?php echo e(url('admin2/staff/edit-staff')); ?>' + '/' + id,
                type: 'get',
                dataType: 'json',
                beforeSend: function () {
                    $('#edit-staff-content').addClass('ht-on-loading');
                },
                success: function (response) {
                    $('#edit-staff-content').removeClass('ht-on-loading').html(response.data);
                    $('.date-picker').datepicker({
                        format: 'dd/mm/yyyy',
                        autoclose: true

                    });
                    $('.select2').select2();
                }
            });
        });

        $(document).on('click', '#btn-add-staff', function (e) {
            e.preventDefault();

            $.ajax({
                url: '<?php echo e(url('admin2/staff/create-staff')); ?>',
                type: 'get',
                dataType: 'json',
                beforeSend: function () {
                    $('#add-staff-content').addClass('ht-on-loading');
                },
                success: function (response) {
                    $('#add-staff-content').removeClass('ht-on-loading').html(response.data);
                    $('.date-picker').datepicker({
                        format: 'dd/mm/yyyy',
                        autoclose: true

                    });
                    $('.select2').select2();
                }
            });
        });

        $(document).on('click', '.btn-edit-permission', function (e) {
            e.preventDefault();

            var id = $(this).attr('data-id');
            $.ajax({
                url: '<?php echo e(url('admin2/staff/edit-staff-permission')); ?>' + '/' + id,
                type: 'get',
                dataType: 'json',
                beforeSend: function () {
                    $('#edit-staff-permission-content').addClass('ht-on-loading');
                },
                success: function (response) {
                    $('#edit-staff-permission-content').removeClass('ht-on-loading').html(response.data);
                    $('.date-picker').datepicker({
                        format: 'dd/mm/yyyy',
                        autoclose: true

                    });
                    $('.select2').select2();
                }
            });
        });

        function getPostByAttr() {
            var hostel = $('#hostels').val();
            table = $('#orders-table').DataTable({
                "bDestroy": true,
                processing: true,
                serverSide: true,
                "aaSorting": [],
                searching: true,
                ajax: {
                    url: '<?php echo url('admin2/staff/staff.data'); ?>',
                    data: {
                        hostel_id: hostel
                    }
                },
                columns: [
//               {data: 'DT_Row_Index', name: 'DT_Row_Index'},
                    {data: 'DT_Row_Index', name: 'DT_Row_Index', orderable: false, searchable: false},
                    {data: 'name', name: 'name'},
                    {data: 'phone', name: 'phone'},
                    {data: 'email', name: 'email'},
                    {data: 'gender', name: 'gender'},
                    {data: 'birthday', name: 'birthday'},
                    {data: 'address', name: 'address'},
                    {data: 'province_name', name: 'province_name'},
                    {data: 'district_name', name: 'district_name'},
                    {data: 'ward_name', name: 'ward_name'},
                    {data: 'action', name: 'action'},
                ]
            });
        }

        $(function () {

//        $('#orders-table tfoot th').each( function (index) {
//            if(index != 0 && index != 9) {
//                $(this).html('<input type="text" class="form-control" />');
//            }
//        } );
            table = $('#orders-table').DataTable({
                "bDestroy": true,
                processing: true,
                searching: true,
                "aaSorting": [],
                serverSide: true,
                ajax: {
                    url: '<?php echo url('admin2/staff/staff.data'); ?>',
                },
                columns: [

                    {data: 'DT_Row_Index', name: 'DT_Row_Index', orderable: false, searchable: false},
                    {data: 'image', name: 'image'},
                    {data: 'name', name: 'name'},
                    {data: 'phone', name: 'phone'},
                    {data: 'email', name: 'email'},
                    {data: 'action', name: 'action'},
                    // {data: 'action', name: 'action', 'orderable' : false, searchable: false},
                ],
            });


            table.columns().every(function (index) {
                if (index !== 0 && index !== 10) {
                    var that = this;
                    $('input', this.footer()).on('keyup change', function () {
                        if (that.search() !== this.value) {
                            that
                                .search(this.value)
                                .draw();
                        }
                    });

                    $('select', this.footer()).on('change', function () {
                        if (that.search() !== this.value) {
                            that
                                .search(this.value)
                                .draw();
                        }
                    });
                }
            });

        });

        $(document).on('change', '#province_id', function (e) {
            var id = $(this).val();
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'province',
                },
                dataType: 'html',
                success: function (response) {
                    $('#district_id').html(response);
                    $('#ward_id').html('');
                    getCoor(id, 'province');


                }
            });
        });

        $(document).on('change', '#district_id', function (e) {
            var id = $(this).val();
            $.ajax({
                url: '<?php echo e(url('get-sub-location')); ?>',
                type: 'get',
                data: {
                    'id': $(this).val(),
                    'type': 'district'
                },
                dataType: 'html',
                success: function (response) {
                    $('#ward_id').html(response);
                    getCoor(id, 'district');
                }
            });
        });

        $(document).on('click', '.btn-paid', function (e) {
            var that = this;
            var money_info_id = $(this).attr('data-money-info');
            $.ajax({
                url: '<?php echo e(url('admin2/room/paid-form')); ?>',
                type: 'get',
                data: {
                    money_info_id: money_info_id
                },
                dataType: 'json',
                success: function (response) {
                    $('#form-paid-' + money_info_id).html(response.data);
                    $('.datepicker').datepicker({
                        format: 'dd/mm/yyyy',
                        autoclose: true
                    });

//                $(that).parent().parent().find('.col-md-12').first().next().html(response.data);
                }
            })
        });

        $(document).on('click', '.btn-save-payment', function (e) {
            e.preventDefault();

            var data = $(this).closest('form').serialize();

            $.ajax({
                url: '<?php echo e(url('admin2/room/spend')); ?>',
                type: 'post',
                data: data,
                dataType: 'json',
                beforeSend: function () {
                    $('#payment-items').addClass('ht-on-loading');
                },
                success: function (response) {
                    $('#payment-items').removeClass('ht-on-loading');
                    if (response.status == 1) {
                        swal('Thành công', 'Thanh toán thành công', 'success');
                        $('#detail-money-info').modal('hide');
                        table.ajax.reload();
                    } else {
                        swal('Thông báo', response.message, 'warning');
                    }
                }
            });

        });

        $(document).on('click', '.btn-cancel-paid', function (e) {
            e.preventDefault();

            $(this).parent().parent().parent().parent().remove();

        });

        $(document).on('click', '.btn-edit-payment', function (e) {
            e.preventDefault();
            var transaction_id = $(this).attr('data-payment');
            var that = this;

            $.ajax({
                url: '<?php echo e(url('admin2/room/get-edit-payment')); ?>',
                type: 'get',
                data: {
                    transaction_id: transaction_id
                },
                dataType: 'json',
                success: function (response) {
                    $(that).closest('td').prev().html(response.html);
                    $(that).closest('td').html(response.button);
                }
            });


        });


        $(document).on('click', '.btn-save-edit-payment', function (e) {
            e.preventDefault();
            var transaction_id = $(this).attr('data-transaction');
            var amount = $(this).closest('td').prev().find('input').val();
            var that = this;

            $.ajax({
                url: '<?php echo e(url('admin2/room/edit-payment')); ?>',
                type: 'post',
                data: {
                    transaction_id: transaction_id,
                    amount: amount
                },
                dataType: 'json',
                success: function (response) {
                    if (response.status == 1) {
                        swal('Thành công', '', 'success');
                    } else {
                        swal('Thông báo', response.message, 'warning');
                    }
                    $(that).closest('td').prev().html(response.html);
                    $(that).closest('td').html(response.button);
                }
            });
        });

        $(document).on('click', '.btn-cancel-edit-payment', function (e) {
            e.preventDefault();
            var transaction_id = $(this).attr('data-transaction');
            var that = this;

            $.ajax({
                url: '<?php echo e(url('admin2/room/cancel-edit-payment')); ?>',
                type: 'get',
                data: {
                    transaction_id: transaction_id,
                },
                dataType: 'json',
                success: function (response) {
                    $(that).closest('td').prev().html(response.html);
                    $(that).closest('td').html(response.button);
                }
            });
        });

        //    $(document).on('change', '#ward_id', function (e) {
        //        var id = $(this).val();
        //        getCoor(id, 'ward');
        //    });

        $(document).on('change', '.check-all', function (e) {
            if (!$(this).is(':checked')) {
                $(this).parent().parent().find('input').prop('checked', false);
            } else {
                $(this).parent().parent().find('input').prop('checked', true);
            }
        });

        $(document).on('change', '.check-hostel', function (e) {
            var number_hostel = $('.check-hostel').length - 1;
            var item_val = $(this).val();
            if (item_val == -1) {
                if ($(this).is(':checked')) {
                    $('.check-hostel').prop('checked', true);
                }
            } else {
                if (!$(this).is(':checked')) {
                    var cnt_checked = $('.check-hostel:checked').length - 1;
                    if (number_hostel != cnt_checked) {
                        $('#all').prop('checked', false);
                    }

                } else {
                    var cnt_checked = $('.check-hostel:checked').length;
                    if (number_hostel == cnt_checked) {
                        $('#all').prop('checked', true);
                    }
                }
            }
        });

    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin2', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>