

<?php $__env->startSection('styles'); ?>

<?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(session()->has('success_coupon')): ?>
        <?php echo session()->get('success_coupon'); ?>

    <?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 class="row">
        <div class="col-md-4">
            <!-- BEGIN SAMPLE FORM PORTLET-->
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption font-red-sunglo">
                        <i class="icon-settings font-red-sunglo"></i>
                        <span class="caption-subject bold uppercase">Cập nhật hotline</span>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form role="form" action="<?php echo e(url('admin2/setting/hotline/update')); ?>" method="POST"
                          enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>

                        <div class="form-body">
                            <div class="form-group">
                                <label>Chọn nhà</label>

                                <select class="form-control" name="hostel_id" id="hostel_id">
                                    <option value="" data-user-id="">Vui lòng chọn</option>
                                    <?php $__currentLoopData = $hostels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hostel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option data-user-id="<?php echo e($hostel->user_hotline); ?>"
                                                value="<?php echo e($hostel->id); ?>"> <?php echo e($hostel->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>Chọn người nhận hotline</label>

                                <select class="form-control" name="user_id" id="user_id">
                                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($user->id); ?>"> <?php echo e($user->name_text); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            
                            

                        </div>
                        <div class="form-actions">
                            <button type="submit" class="btn blue">Áp dụng</button>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>

<script>

    $('.ckeditor').ckeditor({
        height: '500px'
    });

    $(document).on('change', '#hostel_id', function (e) {

        var user_hotline = $('option:selected', this).attr('data-user-id');
        if (user_hotline != '') {
            $('#user_id').val(user_hotline);
        }

        get_users($(this).val());

    });

    function get_users(hostel_id) {
        $.ajax({
            url: '<?php echo e(url('admin2/setting/hotline/staffs')); ?>',
            type: 'get',
            data: {
                hostel_id: hostel_id
            },
            success: function (response) {
                $('#user_id').html(response.data);
            }
        });
    }

</script>

<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin2', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>