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

    <div class="row">
        <div class="col-md-12">
            <?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; ?>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i>Phòng <?php echo e($room->name); ?>

                    </div>
                    
                    
                    
                    
                    
                </div>
                <div class="portlet-body">
                    <div class="tabbable-custom nav-justified">
                        <ul class="nav nav-tabs nav-justified" id="myTab">
                            <li class="active">
                                <a href="#tab_1_1_1" data-toggle="tab"> Thông tin chung </a>
                            </li>
                            <li>
                                <a href="#tab_1_1_2" data-toggle="tab"> Nhân khẩu </a>
                            </li>
                            <li>
                                <a href="#tab_1_1_3" data-toggle="tab"> Lịch sử phòng </a>
                            </li>
                        </ul>
                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_1_1_1">

                                <form role="form" action="<?php echo e(url('admin/room/update', ['id' => $room->id ])); ?>"
                                      method="post" enctype="multipart/form-data">
                                    <?php echo csrf_field(); ?>


                                    <div class="portlet light">
                                        <div class="portlet-title">
                                            <div class="caption font-red-sunglo">
                                                <i class="icon-settings font-red-sunglo"></i>
                                                <span class="caption-subject bold uppercase"> Thông số phòng</span>
                                            </div>
                                        </div>
                                        <div class="portlet-body form">

                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-body">
                                                        <div class="form-group">
                                                            <label>Phòng</label>
                                                            <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                                <input type="text" class="form-control" name="name"
                                                                       placeholder="" value="<?php echo e($room->name); ?>"></div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label>Trạng thái</label>
                                                            <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                                <select class="form-control" name="status">

                                                                    <option value="">Vui lòng chọn</option>
                                                                    <option <?php if($room->status == \App\Models\Room::AVAILABLE): ?> selected
                                                                            <?php endif; ?> value="<?php echo e(\App\Models\Room::AVAILABLE); ?>">
                                                                        Còn trống
                                                                    </option>
                                                                    <option <?php if($room->status == \App\Models\Room::FULL): ?> selected
                                                                            <?php endif; ?> value="<?php echo e(\App\Models\Room::FULL); ?>">
                                                                        Đã đủ người
                                                                    </option>
                                                                    <option <?php if($room->status == \App\Models\Room::NEED_MORE): ?> selected
                                                                            <?php endif; ?> value="<?php echo e(\App\Models\Room::NEED_MORE); ?>">
                                                                        Cần người ở ghép
                                                                    </option>

                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label>Số điện khởi tạo</label>
                                                            <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                                <input type="text" class="form-control"
                                                                       disabled placeholder="" name="start_electric"
                                                                       value="<?php echo e($room->start_electric); ?>"></div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label>Số điện tháng trước</label>
                                                            <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                                <input type="text" class="form-control"
                                                                       disabled placeholder="" value="0"></div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label>Ngày trống phòng</label>
                                                            <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                                <?php if(!empty($room->date_available)): ?>
                                                                    <input type="text" class="form-control datepicker"
                                                                           name="date_available"
                                                                           placeholder=""
                                                                           value="<?php echo e(\Carbon\Carbon::createFromFormat('Y-m-d',$room->date_available)->format('d/m/Y')); ?>">
                                                            </div>
                                                            <?php else: ?>
                                                                <input type="text" class="form-control datepicker"
                                                                       name="date_available"
                                                                       placeholder="" value=""></div>
                                                        <?php endif; ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-body">
                                                    <div class="form-group">
                                                        <label>Tầng</label>
                                                        <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                            <input type="text" class="form-control" name="floor"
                                                                   placeholder="" value="<?php echo e($room->floor); ?>"></div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label>Loại phòng</label>
                                                        <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                            <?php if(auth('backend')->check()): ?>
                                                                <?php $roomTypes = DB::table('room_types')->where('owner_id', auth('backend')->user()->id)->get() ?>
                                                            <?php else: ?>
                                                                <?php $roomTypes = DB::table('room_types')->get() ?>
                                                            <?php endif; ?>

                                                            <select class="form-control select2" name="type">

                                                                <option value="">Vui lòng chọn</option>
                                                                <?php $__currentLoopData = $roomTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $roomType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <option <?php if($room->type == $roomType->id): ?> selected
                                                                            <?php endif; ?> value="<?php echo e($roomType->id); ?>"><?php echo e($roomType->name); ?>

                                                                    </option>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label>Số nước khởi tạo</label>
                                                        <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                            <input type="text" class="form-control"
                                                                   disabled placeholder=""
                                                                   value="<?php echo e($room->start_water); ?>"
                                                                   name="start_water"></div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label>Số nước tháng trước</label>
                                                        <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                            <input type="text" class="form-control"
                                                                   disabled placeholder="" value="0"></div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label>Số người ở tối đa</label>
                                                        <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <i class="fa fa-envelope"></i>
                                                        </span>
                                                            <input type="number" class="form-control" name="max_renters"
                                                                   placeholder="" value="<?php echo e($room->max_renters); ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                            </div>

                            <div class="portlet light">
                                <div class="portlet-title">
                                    <div class="caption font-red-sunglo">
                                        <i class="icon-settings font-red-sunglo"></i>
                                        <span class="caption-subject bold uppercase"> Chi phí phòng</span>

                                    </div>
                                </div>
                                <div class="portlet-body form">

                                    <div class="row" id="fees">
                                        <?php echo $__env->make('admin.room.fees', compact('fees', 'room'), \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                                    </div>

                                    <div class="form-actions">
                                        <button type="submit" class="btn blue">Cập nhật</button>
                                    </div>

                                </div>
                            </div>
                            </form>


                        </div>

                        <div class="tab-pane" id="tab_1_1_2">

                            <div class="portlet light portlet-fit bordered">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class=" icon-layers font-green"></i>
                                        <span class="caption-subject font-green bold uppercase">Danh sách người ở phòng hiện tại</span>
                                    </div>
                                </div>
                                <div class="portlet-body">
                                    <div class="mt-element-card mt-element-overlay">
                                        <div class="row" style="margin-bottom: 15px">
                                            <div class="col-md-12">
                                                <a href="#add-renter" data-toggle="modal" class="btn btn-success">Thêm
                                                    khách thuê</a>
                                            </div>
                                        </div>
                                        <div class="row" id="renters">
                                            <?php echo $__env->make('admin.room.renters', compact('renters'), \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="tab-pane" id="tab_1_1_3">
                            <table class="table table-striped table-bordered table-hover" id="log-table">
                                <thead>
                                <tr>
                                    
                                    <th>Nội dung</th>
                                    <th>Thời gian</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

    <div class="modal fade" id="add-renter" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Thêm khách thuê bằng mã</h4>
                </div>
                <div class="modal-body">

                    <form id="form-owner">

                        <input type="hidden" name="type" value="1">
                        <input type="hidden" name="room_id" value="<?php echo e($room->id); ?>">
                        <input type="hidden" name="hostel_id" value="<?php echo e($room->hostel->id); ?>">
                        <div class="form-group">
                            <label>Mã người thuê</label>
                            <div>
                                <input type="text" name="code" class="form-control"
                                       id="code" value="<?php echo e(old('owner-name')); ?>">
                                <span class="help-block"> Không có mã người thuê ? <a href="#add-renter-info"
                                                                                      data-toggle="modal">Bấm để tạo người thuê</a> </span>
                            </div>
                        </div>

                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal">Đóng</button>
                    <button type="button" class="btn green" id="save-code-owner">Lưu</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade bs-modal-lg" id="add-renter-info" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <form id="form-owner-renter" enctype="multipart/form-data" method="post"
                  action="<?php echo e(url('admin/room/add-renter-by-owner')); ?>">
                <?php echo csrf_field(); ?>

                <input type="hidden" name="tag" id="tag" value="">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h4 class="modal-title">Thêm khách thuê bằng thông tin</h4>
                    </div>
                    <div class="modal-body">


                        <div class="row">
                            <div class="col-md-12" style="margin-bottom: 15px">
                                <div class="form-group">
                                    <div class="col-md-4 col-md-offset-4">


                                        <div class="fileinput fileinput-new"
                                             data-provides="fileinput">

                                            <div class="fileinput-new thumbnail"
                                                 style="width: 200px; height: 180px;">
                                                <img id="inp-image-web2"
                                                     src="/frontend3/assets/img/placeholder.png"
                                                     alt=""></div>
                                            <div class="fileinput-preview fileinput-exists thumbnail"
                                                 style="max-width: 200px; max-height: 150px;"></div>
                                            <div>
                                                                            <span class="btn default btn-file"
                                                                                  style="width: 100%">
                                                                                <span class="fileinput-new"> Chọn hình ảnh </span>
                                                                                <span class="fileinput-exists"> Thay đổi </span>
                                                                                <input type="file"
                                                                                       name="image"> </span>
                                                <a href="javascript:;"
                                                   class="btn default fileinput-exists"
                                                   data-dismiss="fileinput"> Xóa </a>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Họ (*)</label>
                                    <div>
                                        <input type="text" name="first_name" class="form-control"
                                               id="first_name" value="<?php echo e(old('first_name')); ?>" required>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Tên (*)</label>
                                    <div>
                                        <input type="text" name="last_name" class="form-control" required
                                               id="last_name" value="<?php echo e(old('last_name')); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Giới tính (*)</label>
                                    <div class="form-group">
                                        <select class="form-control" name="gender" id="gender" required="">

                                            <option value="Nam">Nam</option>
                                            <option value="Nữ">Nữ</option>
                                            <option value="Khác">Khác</option>
                                        </select>
                                    </div>
                                </div>
                            </div>


                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>SĐT (*)</label>
                                    <div>
                                        <input type="text" name="phone" class="form-control"
                                               id="phone" value="<?php echo e(old('phone')); ?>" required>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Email (*)</label>
                                    <div>
                                        <input type="text" name="email" class="form-control" required
                                               id="email" value="<?php echo e(old('email')); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Ngày sinh</label>
                                    <div>
                                        <input type="text" name="birthday" class="form-control datepicker"
                                               id="birthday" value="<?php echo e(old('birthday')); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Tỉnh / thành phố</label>
                                    <div class="form-group">
                                        <select class="form-control select2" name="province_id" id="province">
                                            <option value="" selected>Chọn tỉnh / thành phố</option>
                                            <?php $provinces = \App\Components\Functions::getProvinces(); ?>

                                            <?php $__currentLoopData = $provinces; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $province): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($province->provinceid); ?>"><?php echo e($province->name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>Quận / huyện</label>
                                    <div class="form-group">
                                        <select class="form-control select2" name="district_id" id="district">
                                            <option value="" selected>Chọn quận / huyện</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <label>Phường / Xã</label>
                                <div class="form-group">
                                    <select class="form-control select2" name="ward_id" id="ward">
                                        <option value="" selected>Chọn phường / xã</option>
                                    </select>
                                </div>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-md-12">
                                <label>Địa chỉ chi tiết</label>
                                <div>
                                    <input type="text" name="address" class="form-control"
                                           id="address" value="<?php echo e(old('address')); ?>">
                                </div>
                            </div>

                        </div>

                        <input name="room_id" type="hidden" value="<?php echo e($room->id); ?>">


                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn dark btn-outline" data-dismiss="modal">Đóng</button>
                        <button type="submit" class="btn green" id="save-renter-by-owner">Lưu</button>
                    </div>
                </div>
            </form>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade" id="add-room-fee" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Thêm chi phí</h4>
                </div>
                <div class="modal-body">

                    <form id="form-add-fee">
                        <input type="hidden" name="room_id" value="<?php echo e($room->id); ?>">
                        <input type="hidden" name="hostel_id" value="<?php echo e($room->hostel->id); ?>">

                        <div class="form-group">
                            <label>Tên loại chi phí</label>
                            <div>
                                <input type="text" name="name" class="form-control"
                                       id="name" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>Giá trị</label>
                            <div>
                                <input type="text" name="fee" class="form-control"
                                       id="fee" value="">
                            </div>
                        </div>

                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal">Đóng</button>
                    <button type="button" class="btn green" id="save-fee">Lưu</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade" id="user-detail" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Chi tiết khách thuê</h4>
                </div>
                <div class="modal-body">

                    <form id="form-user">

                        <div class="form-group">
                            <label>Tên loại chi phí</label>
                            <div>
                                <input type="text" name="name" class="form-control"
                                       id="name" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>Giá trị</label>
                            <div>
                                <input type="text" name="fee" class="form-control"
                                       id="fee" value="">
                            </div>
                        </div>

                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal">Đóng</button>
                    <button type="button" class="btn green" id="save-fee">Lưu</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade" id="detail"  role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">Thông tin chi tiết</h4>
                </div>
                <div class="modal-body">

                    <form id="form-account">

                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn dark btn-outline" data-dismiss="modal">Đóng</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

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

<?php $__env->startPush('scripts'); ?>
<script src="/js/jquery.validate.min.js"></script>
<script>


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

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

    $("#form-owner-renter").validate(
        {
            rules: {
                phone: {
                    required: true,
                    remote: {
                        url: "<?php echo e(url('admin/check-unique-phone')); ?>",
                        type: "post",
                        data: {
                            phone: function () {
                                return $("#phone").val();
                            }
                        }
                    }
                },
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: "<?php echo e(url('admin/check-unique-email')); ?>",
                        type: "post",
                        data: {
                            email: function () {
                                return $("#email").val();
                            }
                        }
                    }
                }
            },
            messages: {
                first_name: "Vui lòng không bỏ trống Họ",
                last_name: "Vui lòng không bỏ trống Tên",
                gender: "Vui lòng không bỏ trống Giới tính",
                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: {
                    required: "Vui lòng không bỏ trống Email",
                    remote: jQuery.validator.format("{0} đã được sử dụng")
                },
                // image: 'Vui lòng không bỏ trống hình ảnh'
            }
        }
    );

    $('.datepicker').datepicker({
        format: 'dd/mm/yyyy',
        autoclose: true
    });

    $(document).ready(function () {
        $('#myTab a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
        });

        // store the currently selected tab in the hash value
        $("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) {
            var id = $(e.target).attr("href").substr(1);
            window.location.hash = id;
        });

        // on load of the page: switch to the currently selected tab
        var hash = window.location.hash;
        $('#myTab a[href="' + hash + '"]').tab('show');
        $('#tag').val(hash);
    });


    var table;
    $(document).ready(function () {
        $('.datepicker').datepicker({
            format: 'dd/mm/yyyy',
            autoclose: true,
        });
        table = $('#log-table').DataTable({
            "bDestroy": true,
            processing: true,
            //  serverSide: true,
            "aaSorting": [],
            searching: true,
            ajax: {
                url: '<?php echo url('admin/room/log.data'); ?>',
                data: {
                    room_id: '<?php echo e($room->id); ?>'
                }
            },
            columns: [
//                {data: 'id', name: 'id'},
                {data: 'content', name: 'content'},
                {data: 'created_at', name: 'created_at'},
            ]
        });
    });

    $(document).on('click', '#save-code-owner', function (e) {
        e.preventDefault();

        var data = $('#form-owner').serialize();

        $.ajax({
            url: '<?php echo e(url('admin/room/add-renter-by-code')); ?>',
            data: data,
            type: 'post',
            dataType: 'json',
            success: function (response) {
                if (response.status == 1) {
                    $('#log-table').DataTable().ajax.reload();
                    $('#add-renter-info').modal('hide');
                    $('#add-renter').modal('hide');
                    swal('Thành công', '', 'success');
                    $('#renters').html(response.html);

                } else {
                    swal('Thông báo', response.message, 'warning');
                }
            }
        });

    });

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

        $.ajax({
            url: '<?php echo e(url('admin/room/add-renter-by-code')); ?>',
            data: {
                code: $('#code').val(),
                room_id: '<?php echo e($room->id); ?>'
            },
            type: 'post',
            dataType: 'json',
            success: function (response) {
                if (response.status == 1) {
                    $('#log-table').DataTable().ajax.reload();
                    $('#add-renter-info').modal('hide');
                    $('#add-renter').modal('hide');
                    swal('Thành công', '', 'success');
                    $('#renters').html(response.html);

                } else {
                    swal('Thông báo', response.message, 'warning');
                }
            }
        });

    });

    $(document).on('click', '.renter-info', function (e) {
        e.preventDefault();
        var url = $(this).attr('data-url');

        $.ajax({
            url: url,
            type: 'get',
            dataType: 'json',
            success: function (response) {
                if (response.status == 1) {
                    $('#form-account').html(response.html);

                } else {
                    swal('Thông báo', response.message, 'warning');
                }
            }
        });

    });


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

        var data = $('#form-add-fee').serialize();

        $.ajax({
            url: '<?php echo e(url('admin/room/add-fee')); ?>',
            data: data,
            type: 'post',
            dataType: 'json',
            success: function (response) {
                if (response.status == 1) {
                    $('#add-room-fee').modal('hide');
                    $('#fees').html(response.html);
                } else {
                    swal('Thông báo', response.message, 'warning');
                }
            }
        });

    });


    $(document).on('click', '.btn-delete-renter', function (e) {
        e.preventDefault();
        var renter_id = $(this).attr('data-renter-id');
        $.ajax({
            url: '<?php echo e(url('/admin/room/delete-renter')); ?>',
            data: {
                renter_id: renter_id,
                user_id: '<?php echo e($room->id); ?>'
            },
            type: 'post',
            success: function (response) {
                if (response.status == 1) {
                    $(this).parent().parent().parent().remove();
                }
            }
        });
    });

</script>

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

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