<div class="page-inner">
    <?php echo $__env->make('admin.dashboard.components.breadcrumb', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="col-md-12">
        <div class="card">
            <div class="card-header d-flex justify-content-between">
                <h4 class="card-title float-left">Tài liệu cán bộ</h4>
                <div class="action">
                    <?php if(session('user_role') == 1): ?>
                        <a href="<?php echo e(route('teacher.create-materials')); ?>" class="btn btn-primary">Tải lên tài liệu mới</a>
                    <?php endif; ?>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <div id="basic-datatables_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4">
                        <div class="row">
                            <div class="col-sm-12 col-md-6">
                                <form action="<?php echo e(route('materials.index')); ?>" method="GET" id="filter-form">
                                    <div class="form-group">
                                        <label for="course_id">Khóa Học</label>
                                        <select name="course_id" id="course_id" class="form-control" onchange="document.getElementById('filter-form').submit();">
                                            <option value="">Tất cả</option>
                                            <?php $__currentLoopData = $courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($course->id); ?>" <?php echo e(request('course_id') == $course->id ? 'selected' : ''); ?>>
                                                    <?php echo e($course->name); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                </form>
                            </div>
                            <div class="col-sm-12 col-md-6">
                                <div class="dataTables_length" id="basic-datatables_length">
                                    <!-- Optional: Can be used to set page length if needed -->
                                </div>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-sm-12">
                                <table id="basic-datatables" class="display table table-striped table-hover dataTable"
                                    role="grid" aria-describedby="basic-datatables_info">
                                    <thead>
                                        <tr role="row">
                                            <th>Tiêu đề</th>
                                            <th>Mô tả</th>
                                            <th>Cán Bộ</th>
                                            <th>Khóa Học</th> <!-- Add a column for Course -->
                                            <th>Hành động</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $__currentLoopData = $materials; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $material): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td><?php echo e($material->title); ?></td>
                                                <td><?php echo e($material->description); ?></td>
                                                <td><?php echo e($material->officer->name); ?></td> <!-- Use officer instead of teacher -->
                                                <td><?php echo e($material->course->name); ?></td> <!-- Display the course name -->
                                                <td>
                                                    <a href="<?php echo e(route('materials.show', $material->id)); ?>" class="btn btn-info">Xem</a>
                                                    <?php if(session('user_role') == 1): ?>
                                                        <form action="<?php echo e(route('teacher.materials.destroy', $material->id)); ?>" method="POST" style="display:inline-block;" onsubmit="return confirmDelete()">
                                                            <?php echo csrf_field(); ?>
                                                            <?php echo method_field('DELETE'); ?>
                                                            <button type="submit" class="btn btn-danger">Xóa</button>
                                                        </form>
                                                    <?php endif; ?>
                                                </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12 col-md-7">
                                <div class="dataTables_paginate paging_simple_numbers" id="basic-datatables_paginate">
                                    <ul class="pagination"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php /**PATH C:\Users\phama\OneDrive\Desktop\Tai_Nguyen_Hoc_Tap\DuAnPHP3\SchoolManagementSystem\resources\views/admin/teacher/teachermaterials/pages/index.blade.php ENDPATH**/ ?>