<form role="form" id="form-edit-hostel">
    <div class="form-body">
        <div class="row">
            <div class="col-md-8">
                <div class="form-group">
                    <label>Tên nhà <span class="required" aria-required="true"> (*) </span></label>
                    <input type="text" class="form-control" placeholder="" name="name" value="<?php echo e($hostel->name); ?>">
                </div>
            </div>
            <div class="col-md-4">

                <div class="form-group">
                    <label>Loại nhà <span class="required" aria-required="true"> (*) </span></label>
                    <?php $hostelTypes = \App\Models\HostelType::all(); ?>
                    <select class="form-control" name="type">
                        <?php $__currentLoopData = $hostelTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hostelType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php if($hostel->type == $hostelType->id): ?> selected=""
                                    <?php endif; ?> value="<?php echo e($hostelType->id); ?>"><?php echo e($hostelType->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </select>
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-md-8">
                <div class="form-group">
                    <label>Địa chỉ <span class="required" aria-required="true"> (*) </span></label>
                    <input type="text" class="form-control" name="address" value="<?php echo e($hostel->address); ?>">
                    <span class="help-block"> (Không nhập địa chỉ Phường, Xã, Tỉnh, Thành phố) </span>
                </div>
            </div>
            <div class="col-md-4">

                <div class="form-group">
                    <label>Hình thức cho thuê <span class="required" aria-required="true"> (*) </span>
                        <a href="#explain-type-rent" data-toggle="modal"><span
                                    class="glyphicon glyphicon-question-sign"></span></a></label>
                    <select class="form-control" name="type_rent" disabled>

                        <option <?php if($hostel->type_rent == \App\Models\Hostel::TYPE_RENT_ALL): ?> selected
                                <?php endif; ?> value="<?php echo e(\App\Models\Hostel::TYPE_RENT_ALL); ?>">Bao phòng
                        </option>
                        <option <?php if($hostel->type_rent == \App\Models\Hostel::TYPE_RENT_EVERY): ?> selected
                                <?php endif; ?> value="<?php echo e(\App\Models\Hostel::TYPE_RENT_EVERY); ?>">Ký túc xá
                        </option>

                    </select>
                </div>
            </div>
        </div>
        <div class="row">

            <div class="col-md-4">

                <div class="form-group">
                    <label>Tỉnh / TP <span class="required" aria-required="true"> (*) </span></label>
                    <select class="form-control select2" name="province_id" id="province_id">
                        <?php $__currentLoopData = $provinces; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $province): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php if($province->provinceid == $hostel->province_id): ?> 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-4">

                <div class="form-group">
                    <label>Quận / Huyện <span class="required" aria-required="true"> (*) </span></label>
                    <select class="form-control select2" name="district_id" id="district_id">

                        <?php if(!empty($hostel->province_id)) {
                            $districts = DB::table('district')->where('provinceid', $hostel->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 == $hostel->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 class="col-md-4">

                <div class="form-group">
                    <label>Phường / Xã <span class="required" aria-required="true"> (*) </span></label>
                    <select class="form-control select2" name="ward_id" id="ward_id">
                        <?php if(!empty($hostel->district_id)) {
                            $wards = DB::table('ward')->where('districtid', $hostel->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 == $hostel->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>
        
            

                
                    
                    
                
            
            

                
                    
                    
                           
                
            
            

                
                    
                    
                
            
        
        <div class="row">

            <div class="col-md-12">
                <div class="row">
                    

                        
                            
                            
                                   
                        
                    
                    <div class="col-md-6">

                        <div class="form-group">
                            <label>Ngày ghi chỉ số điện nước <span class="required" aria-required="true"> (*) </span>

                                <a href="#explain-date-ew" data-toggle="modal"><span
                                            class="glyphicon glyphicon-question-sign"></span></a>
                            </label>
                            <select class="form-control select2" name="date_ew" id="edit-hostel-date-ew">
                                <?php for($i = 1; $i <= 31; $i++): ?>
                                    <option <?php if($hostel->date_ew == $i): ?> selected
                                            <?php endif; ?> value="<?php echo e($i); ?>"> <?php echo e($i); ?></option>
                                <?php endfor; ?>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">

                        <div class="form-group">
                            <label>Ngày chốt sổ - tính phí <span class="required" aria-required="true"> (*) </span>

                                <a href="#explain-date-money" data-toggle="modal"><span
                                            class="glyphicon glyphicon-question-sign"></span></a>
                            </label>
                            <select class="form-control select2" name="date_money">
                                <?php for($i = 1; $i <= 31; $i++): ?>
                                    <option <?php if($hostel->date_money == $i): ?> selected
                                            <?php endif; ?> value="<?php echo e($i); ?>"> <?php echo e($i); ?></option>
                                <?php endfor; ?>
                            </select>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <?php if(request()->input('type') == 'verify'): ?>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">

                        <div class="mt-checkbox-list">
                            <label class="mt-checkbox">
                                <input type="checkbox" name="status_confirm" <?php if($hostel->status_confirm == 1): ?> checked <?php endif; ?>> Đã được xác thực
                                <span></span>
                            </label>
                        </div>

                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label>Ghi chú</label>
                        <textarea class="form-control" name="note"></textarea>

                    </div>
                </div>
            </div>
        <?php endif; ?>
        <div class="row">
            <div class="col-md-12">
                <div class="form-group">

                    <div class="mt-checkbox-list">
                        <label class="mt-checkbox">
                            <input type="checkbox" name="is_display" <?php if($hostel->is_display): ?> checked <?php endif; ?>> Hiển thị
                            trên cổng thông tin itro
                            <span></span>
                        </label>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <ul class="nav nav-tabs">
        <li class="active">
            <a href="#edit_tab_1_1" data-toggle="tab" aria-expanded="true"> Tiện ích </a>
        </li>
        <li>
            <a href="#edit_tab_1_2" data-toggle="tab" aria-expanded="false"> Nội quy </a>
        </li>
        <li>
            <a href="#edit_tab_1_3" data-toggle="tab" aria-expanded="false"> Vị trí trên bản đồ </a>
        </li>
        <li>
            <a href="#edit_tab_1_4" data-toggle="tab" aria-expanded="false"> Hình ảnh </a>
        </li>
        <li>
            <a href="#edit_tab_1_5" data-toggle="tab" aria-expanded="false"> Mô tả chi tiết </a>
        </li>

    </ul>
    <div class="tab-content">
        <div class="tab-pane fade in active" id="edit_tab_1_1">
            <div class="row">

                <?php $hostelAmenities = $hostel->amenities2->pluck('id')->toArray();?>

                <?php $__currentLoopData = $amenities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $amenity): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="col-md-3">

                        <label class="mt-checkbox mt-checkbox-outline ws-nr">
                            <input type="checkbox" <?php if(in_array($amenity->id, $hostelAmenities)): ?> checked=""
                                   <?php endif; ?> name="amenities[]" value="<?php echo e($amenity->id); ?>">
                            <?php if(!empty($amenity->web_image)): ?>
                                <img src="/files/<?php echo e($amenity->web_image); ?>" class="svg"
                                     style="max-height: 18px; max-width: 18px; margin-right: 3px">
                            <?php else: ?>
                                <img src="/frontend3/amenity.svg" class="svg"
                                     style="max-height: 18px; max-width: 18px; margin-right: 3px">
                            <?php endif; ?>
                            <?php echo e($amenity->name); ?>

                            <span></span>
                        </label>

                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                <div class="col-md-12 text-center">
                    <hr style="border-top: 1px dashed">
                    <p>Nếu nhà của bạn có tiện ích không xuất hiện trong danh sách. Hãy ấn nút "Bổ sung tiện ích" để
                        thêm</p>
                    <button class="btn btn-success" id="btn-add-amenity-edit-hostel">Bổ sung tiện ích</button>
                </div>

                <div class="col-md-12">
                    <div class="row" id="user_edit_amenities">

                    </div>
                </div>


            </div>
        </div>
        <div class="tab-pane fade" id="edit_tab_1_2">
            <div class="row">

                <?php $hostelPolicies = $hostel->policies->pluck('id')->toArray();?>
                <?php $__currentLoopData = $policies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $policy): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="col-md-4">

                        <label class="mt-checkbox mt-checkbox-outline ws-nr">
                            <input type="checkbox" <?php if(in_array($policy->id, $hostelPolicies)): ?> checked
                                   <?php endif; ?> name="policies[]" value="<?php echo e($policy->id); ?>">

                            <?php if(!empty($policy->web_image)): ?>
                                <img src="/files/<?php echo e($policy->web_image); ?>" class="svg"
                                     style="max-height: 18px; max-width: 18px; margin-right: 3px">
                            <?php else: ?>
                                <img src="/frontend3/policy.svg" class="svg"
                                     style="max-height: 18px; max-width: 18px; margin-right: 3px">
                            <?php endif; ?>

                            <?php echo e($policy->name); ?>

                            <span></span>
                        </label>

                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-12 text-center">
                    <hr style="border-top: 1px dashed">
                    <p>Nếu nhà của bạn có nội quy không xuất hiện trong danh sách. Hãy ấn nút "Bổ sung nội quy" để
                        thêm</p>
                    <button class="btn btn-success" id="btn-add-policy-edit-hostel">Bổ sung nội quy</button>
                </div>
                <div class="col-md-12">
                    <div class="row" id="user_policies">

                    </div>
                </div>

            </div>
        </div>
        <div class="tab-pane fade" id="edit_tab_1_3">
            <button class="btn btn-success" type="button" id="btn-get-current-position-edit"
                    style="margin-top: 10px; margin-bottom: 10px">Lấy tọa độ hiện tại
            </button>
            <label class="control-label" style="display: inline-block; margin-left: 15px; margin-right: 15px">Hoặc nhập
                vị trí tương đối xung quanh</label>
            <div class="form-group" style="display: inline-block; width: 300px">
                <input type="text" class="form-control" id="query_place_edit">
            </div>
            <div id="map_edit">

            </div>
            <input type="hidden" name="lat" id="lat-e" value="<?php echo e($hostel->lat); ?>">
            <input type="hidden" name="lng" id="lng-e" value="<?php echo e($hostel->lng); ?>">
        </div>
        <div class="tab-pane fade" id="edit_tab_1_4">
            <div class="center text-center" style="margin-top: 15px">

                <p>Hãy chọn ít nhất 1 hình ảnh thật về nhà của bạn để tin đăng hấp dẫn hơn và và giúp khách thuê thấy được ảnh nhà của bạn</p>
                <button class="btn btn-success" id="btn-add-edit-image-hostel">Thêm ảnh nhà</button>
                <hr style="border-top: 1px dashed">
            </div>
            <?php
                $images = DB::table('hostel_images')->where('hostel_id', $hostel->id)->get(); ?>

            <div class="row">
                <div class="col-md-12">
                    <div class="row" id="hostel_images_list">

                        <?php if($images->count() > 0): ?>
                            <?php $__currentLoopData = $images; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $image): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="col-sm-6 col-md-3" style="margin-top: 15px">
                                    <i class="fa fa-trash btn-delete-hostel-image" data-id="<?php echo e($image->id); ?>" style="position: absolute; top: 0px; right: 0px; padding: 10px 10px;
    font-size: 18px; margin-right: 15px;
    background: red; color: white"></i>
                                    <a href="javascript:;" class="thumbnail"
                                       style="width: 100%; height: 179px; background-image: url('/files/<?php echo e($image->image); ?>');
                                               background-size: contain; background-repeat: no-repeat">
                                        
                                        
                                        
                                    </a>
                                    <select class="form-control" name="image-types[<?php echo e($image->id); ?>][]">

                                        <option <?php if($image->type == \App\Models\Room::IMAGE_LIVING_ROOM): ?> selected
                                                <?php endif; ?> value="<?php echo e(\App\Models\Room::IMAGE_LIVING_ROOM); ?>">Ảnh phòng
                                            khách
                                        </option>
                                        <option <?php if($image->type == \App\Models\Room::IMAGE_BED_ROOM): ?> selected
                                                <?php endif; ?> value="<?php echo e(\App\Models\Room::IMAGE_BED_ROOM); ?>">Ảnh phòng ngủ
                                        </option>
                                        <option <?php if($image->type == \App\Models\Room::IMAGE_KITCHEN): ?> selected
                                                <?php endif; ?> value="<?php echo e(\App\Models\Room::IMAGE_KITCHEN); ?>">Ảnh nhà bếp
                                        </option>
                                        <option <?php if($image->type == \App\Models\Room::IMAGE_OTHER): ?> selected
                                                <?php endif; ?> value="<?php echo e(\App\Models\Room::IMAGE_OTHER); ?>">Vị trí khác
                                        </option>
                                    </select>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </div>

                </div>
            </div>


            <div class="row">
                <div class="col-md-12">
                    <div class="row" id="hostel_images">
                    </div>
                </div>
            </div>
        </div>
        <div class="tab-pane fade" id="edit_tab_1_5">
            <textarea class="form-control ckeditor" name="desc" rows="6"><?php echo $hostel->desc; ?></textarea>
        </div>
    </div>

</form>