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

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


    <style>

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

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

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

        tfoot {
            display: table-header-group;
        }

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

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

        .dataTables_filter {
            display: none;
        }

        #orders-table_length {
            display: none;
        }

        .ws-nr {
            width: 100% !important;
        }

        .select2-selection--single {
            overflow: hidden;
            text-overflow: ellipse;
        }

    </style>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <?php if(session()->has('error')): ?>
        <div class="alert alert-danger"><?php echo e(session()->get('error')); ?></div>
    <?php endif; ?>
    <?php if(session()->has('success')): ?>
        <div class="alert alert-success"><?php echo e(session()->get('success')); ?></div>
    <?php endif; ?>
    <div class="col-md-8 col-md-offset-2" style="padding-bottom: 50px">
        <form role="form" method="POST" action="<?php echo e(route('notifications.store')); ?>" id="form-add-discount">
            <?php echo csrf_field(); ?>
            <div class="form-body">
                <div class="row">
                    <div class="col-md-12">
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>Chọn nhà</label>
                            <select class="form-control" name="hostel_id" id="hostel">
                                <option value="">--Chọn--</option>
                                <?php $__currentLoopData = $hostels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hostel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option 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 phòng</label>
                            <select class="form-control" name="room_id[]" id="room">
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>Tiêu đề <span class="required" aria-required="true"> (*) </span></label>
                            <input class="form-control" name="title">
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>Nội dung <span class="required" aria-required="true"> (*) </span></label>
                            <textarea class="form-control" name="content"></textarea>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>Tệp đính kèm</label>
                            <input type="file" name="image">
                        </div>
                    </div>
                    <div class="col-md-12 text-center">
                        <button type="submit" class="btn green" id="btn-save-room">Lưu</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script>
        $(document).ready(function () {
            var rooms = <?php echo json_encode($rooms, 15, 512) ?>;

            $(document).on('change', '#hostel', function () {
                var hostel_id = $(this).val();

                roomsByHostel = rooms.filter(function (room) {
                    return room.hostel_id == hostel_id
                });
                var options = '';
                roomsByHostel.forEach(function (room) {
                    options += `<option value="${room.id}">
                                       ${room.name}
                                  </option>`
                });
                $("#room").html(options);
            });

            $(document).on('change', '#room', function () {
                var room_id = $(this).val();

                roomSelected = rooms.find(function (room) {
                    return room.id == room_id
                });
                if (!roomSelected) {
                    return true;
                }
            });

            $(document).on('change', '.hostel-item', function () {
                if (!this.checked) {
                    $('#check-all').prop("checked", false);
                }
            });

            $('#room').select2({
                placeholder: "Chọn phòng",
                allowClear: true,
                multiple: true,
                selectOnClose: true
            });
        });
    </script>
<?php $__env->stopPush(); ?>


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