<form id="form-edit-renter">
    <input type="hidden" name="id" value="<?php echo e($renter->id); ?>">
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN Portlet PORTLET-->

                    <div class="row">
                        <div class="text-center">
                            <h4><strong>Thông tin khách hàng</strong></h4>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-4">

                                    <div class="form-group">
                                        <label class="">Ảnh đại diện khách hàng</label>
                                        <div class="">
                                            <div class="fileinput fileinput-new" data-provides="fileinput"
                                                 style="width: 100%">
                                                <div class="fileinput-new thumbnail" style="width: 100%;">
                                                    <img src="<?php echo e($renter->image_url); ?>" alt=""/></div>
                                                <div class="fileinput-preview fileinput-exists thumbnail"
                                                     style="width: 100%; max-height: 500px;"></div>
                                                <div>
                            <span class="btn default btn-file" style="width: 100%">
                                <span class="fileinput-new"> Chọn ảnh </span>
                                                                   <span class="fileinput-exists"> Thay đổi </span>
                                                                   <input type="file" name="image"> </span>
                                                    <a href="javascript:;"
                                                       class="btn red fileinput-exists fileinput-delete"
                                                       data-dismiss="fileinput">
                                                        Xóa </a>
                                                </div>
                                            </div>
                                            <div class="clearfix margin-top-10">

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

                                </div>
                                <div class="col-md-8">
                                    <!-- BEGIN Portlet PORTLET-->

                                    <div class="form-body">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>SĐT <span class="required" aria-required="true"> (*) </span></label>
                                                    <input type="text" class="form-control" name="phone"
                                                           id="phone-contract" value="<?php echo e($renter->phone); ?>">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Họ tên <span class="required"
                                                                        aria-required="true"> (*) </span></label>
                                                    <input type="text" class="form-control" name="name" value="<?php echo e($renter->name); ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">

                                                <div class="form-group">
                                                    <label>Email</label>
                                                    <input type="text" class="form-control" name="email" value="<?php echo e($renter->email); ?>">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Ngày sinh</label>
                                                    <input type="text" class="form-control datepicker" name="birthday"
                                                           value="<?php if(!empty($renter->birthday)): ?><?php echo e($renter->birthday->format('d/m/Y')); ?> <?php endif; ?>">
                                                </div>
                                            </div>



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

                                                <div class="form-group">
                                                    <label>Tỉnh / thành phố</label>
                                                    <select class="form-control select2" name="province_id" id="province1">
                                                        <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 <?php if($user->province_id == $province->provinceid): ?> selected="" <?php endif; ?> value="<?php echo e($province->provinceid); ?>"><?php echo e($province->name); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-md-6">

                                                <div class="form-group">
                                                    <label>Quận / Huyện</label>
                                                    <select class="form-control select2" name="district_id" id="district1">
                                                        <?php if(!empty($user->province_id)) {
                            $districts = DB::table('district')->where('provinceid', $user->province_id)->get();
                        } else {
                            $districts = null;
                        }?>

                                                        <?php if(!empty($districts)): ?>
                                                            <option value="" selected disabled>Quận / Huyện</option>
                                                            <?php $__currentLoopData = $districts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $district): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option <?php if($district->districtid == $user->district_id): ?> selected=""
                                                                        <?php endif; ?> value="<?php echo e($district->districtid); ?>"><?php echo e($district->name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php else: ?>
                                                            <option value="" selected disabled>Quận / Huyện</option>
                                                        <?php endif; ?>
                                                    </select>
                                                </div>
                                            </div>



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

                                                <div class="form-group">
                                                    <label>Phường / Xã</label>
                                                    <select class="form-control select2" name="ward_id" id="ward1">
                                                        <?php if(!empty($user->district_id)) {
                            $wards = DB::table('ward')->where('districtid', $user->district_id)->get();
                        } else {
                            $wards = null;
                        }?>

                                                        <?php if(!empty($wards)): ?>

                                                            <option value="" selected disabled>Xã / Phường</option>
                                                            <?php $__currentLoopData = $wards; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ward): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option <?php if($ward->wardid == $user->ward_id): ?> selected=""
                                                                        <?php endif; ?> value="<?php echo e($ward->wardid); ?>"><?php echo e($ward->name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php else: ?>
                                                            <option value="" selected disabled>Xã / Phường</option>
                                                        <?php endif; ?>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Địa chỉ </label>
                                                    <input type="text" class="form-control" name="address"
                                                           value="<?php echo e($renter->address); ?>">
                                                </div>
                                            </div>

                                        </div>

                                        <div class="row">

                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label>Ghi chú (mã vân tay,...)</label>
                                                    <textarea type="text" class="form-control" name="note"><?php echo e($renter->note); ?></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Tạm trú</label>
                                                    <select class="form-control" name="residence_status"
                                                            id="edit-renter-residence-status">
                                                        <option value="<?php echo e(\App\Models\RenterRoom::RESIDENCE_NOT_DECLARE); ?>"
                                                                <?php if($renter->residence_status == \App\Models\RenterRoom::RESIDENCE_NOT_DECLARE): ?> selected="" <?php endif; ?>>
                                                            Chưa khai báo
                                                        </option>
                                                        <option value="<?php echo e(\App\Models\RenterRoom::RESIDENCE_LIMIT); ?>" <?php if($renter->residence_status == \App\Models\RenterRoom::RESIDENCE_LIMIT): ?> selected="" <?php endif; ?>>
                                                            Tạm trú có thời hạn
                                                        </option>
                                                        <option value="<?php echo e(\App\Models\RenterRoom::RESIDENCE_NOT_LIMIT); ?>" <?php if($renter->residence_status == \App\Models\RenterRoom::RESIDENCE_NOT_LIMIT): ?> selected="" <?php endif; ?>>
                                                            Tạm trú không có thời hạn
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group" id="edit-renter-date-end-residence"
                                                     style="display: none">
                                                    <label>Thời hạn tạm trú</label>
                                                    <input type="text" class="form-control datepicker"
                                                           name="date_end_residence" value="<?php echo e(empty($renter->date_end_residence) ? null : $renter->date_end_residence->format('d/m/Y')); ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>CMTND</label>
                                                    <input type="text" class="form-control" name="id_number" value="<?php echo e($user->id_number); ?>">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Ngày cấp CMTND / CCCD</label>
                                                    <input type="text" class="form-control datepicker" name="id_number_date" value="<?php if(!empty($renter->id_number_date)): ?> <?php echo e(\Carbon\Carbon::createFromFormat('Y-m-d' ,$renter->id_number_date)->format('d/m/Y')); ?> <?php endif; ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label>Nơi cấp CMTND / CCCD</label>
                                                    <input type="text" class="form-control" name="id_number_location" value="<?php echo e($renter->id_number_location); ?>">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- END Portlet PORTLET-->
                                </div>

                            </div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4 col-md-offset-4">

                            <div class="form-group">
                                <label class="">Ảnh CMT mặt trước</label>
                                <div class="">
                                    <div class="fileinput fileinput-new" data-provides="fileinput" style="width: 100%">
                                        <div class="fileinput-new thumbnail" style="width: 100%;">
                                            <img src="<?php if(empty($renter->id_number_front)): ?>/frontend3/assets/img/placeholder.png <?php else: ?> /files/<?php echo e($renter->id_number_front); ?> <?php endif; ?>" alt=""/></div>
                                        <div class="fileinput-preview fileinput-exists thumbnail"
                                             style="width: 100%; max-height: 500px;"></div>
                                        <div>
                            <span class="btn default btn-file" style="width: 100%">
                                <span class="fileinput-new"> Chọn ảnh </span>
                                                                   <span class="fileinput-exists"> Thay đổi </span>
                                                                   <input type="file" name="id_number_front"> </span>
                                            <a href="javascript:;" class="btn red fileinput-exists fileinput-delete"
                                               data-dismiss="fileinput">
                                                Xóa </a>
                                        </div>
                                    </div>
                                    <div class="clearfix margin-top-10">

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

                        </div>
                        <div class="col-md-4">

                            <div class="form-group">
                                <label class="">Ảnh CMT mặt sau</label>
                                <div class="">
                                    <div class="fileinput fileinput-new" data-provides="fileinput" style="width: 100%">
                                        <div class="fileinput-new thumbnail" style="width: 100%;">
                                            <img src="<?php if(empty($renter->id_number_back)): ?>/frontend3/assets/img/placeholder.png <?php else: ?> /files/<?php echo e($renter->id_number_back); ?> <?php endif; ?>" alt=""/></div>
                                        <div class="fileinput-preview fileinput-exists thumbnail"
                                             style="width: 100%; max-height: 500px;"></div>
                                        <div>
                            <span class="btn default btn-file" style="width: 100%">
                                <span class="fileinput-new"> Chọn ảnh </span>
                                                                   <span class="fileinput-exists"> Thay đổi </span>
                                                                   <input type="file" name="id_number_back"> </span>
                                            <a href="javascript:;" class="btn red fileinput-exists fileinput-delete"
                                               data-dismiss="fileinput">
                                                Xóa </a>
                                        </div>
                                    </div>
                                    <div class="clearfix margin-top-10">

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

                        </div>
                    </div>


                    <div class="row">
                        <?php if($bikes->count() > 0): ?>
                        <div class="col-md-12">
                            <div class="form-group">
                                <h4>Danh sách xe</h4>


                                    <div class="table-scrollable">
                                        <table class="table table-bordered table-hover">
                                            <thead>
                                            <tr>
                                                <th> STT</th>
                                                <th> Tên xe</th>
                                                <th> Loại xe</th>
                                                <th> Biển số xe</th>
                                                <th> Hình ảnh</th>
                                                <th> Hành động</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php $__currentLoopData = $bikes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bike): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <tr>
                                                    <td> <?php echo e($loop->index + 1); ?> </td>
                                                    <td> <?php echo e($bike->name); ?> </td>
                                                    <td> <?php echo e($bike->type_text); ?> </td>
                                                    <td> <?php echo e($bike->bks); ?> </td>
                                                    <td>
                                                        <img src="<?php echo e(url('files/'.$bike->image)); ?>" style="object-fit: contain; width: 100px; height: 100px; text-align: center" alt="">
                                                    </td>
                                                    <td>
                                                        <a href="#" class="btn btn-sm btn-default btn-edit-bikes" data-id="<?php echo e($bike->id); ?>" data-renter="<?php echo e($renter->id); ?>" data-room="<?php echo e($renterDt->room_id); ?>"><i
                                                                    class="fa fa-pencil" ></i> Sửa</a>
                                                        <a href="#" class="btn btn-sm btn-default btn-delete-bike"  data-id="<?php echo e($bike->id); ?>" data-renter="<?php echo e($renter->id); ?>" data-room="<?php echo e($renterDt->room_id); ?>"><i
                                                                    class="fa fa-trash"></i> Xóa</a>
                                                    </td>
                                                </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                        </table>
                                    </div>


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


                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <hr style="border-top: 1px dashed">
                        </div>
                        <?php if(auth('backend')->user()->can('add-bike')): ?>
                        <div class="col-md-12">

                            <button class="btn btn-success btn-add-bike" id="btn-add-bike-2">Thêm xe sở hữu</button>
                        </div>
                        <?php endif; ?>
                        <div class="col-md-12" id="renter-bikes-2">

                        </div>
                    </div>

                    <!-- END Portlet PORTLET-->
                </div>
            </div>

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