<?php $__env->startSection('page-title'); ?>
    <?php echo e(__('Learning Management')); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('title'); ?>
    <div class="d-inline-block">
        <h5 class="h4 d-inline-block font-weight-400 mb-0 "><?php echo e(__('Learning Management')); ?></h5>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>"><?php echo e(__('Dashboard')); ?></a></li>
    <li class="breadcrumb-item"><?php echo e(__('Learning Management')); ?></li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="row mb-3">
        <div class="col-md-3">
            <div class="card">
                <div class="card-body">
                    <p class="text-muted mb-1"><?php echo e(__('Courses')); ?></p>
                    <h4 class="mb-0"><?php echo e($stats['courses']); ?></h4>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card">
                <div class="card-body">
                    <p class="text-muted mb-1"><?php echo e(__('Lessons')); ?></p>
                    <h4 class="mb-0"><?php echo e($stats['lessons']); ?></h4>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card">
                <div class="card-body">
                    <p class="text-muted mb-1"><?php echo e(__('Enrollments')); ?></p>
                    <h4 class="mb-0"><?php echo e($stats['enrollments']); ?></h4>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card">
                <div class="card-body">
                    <p class="text-muted mb-1"><?php echo e(__('Completed')); ?></p>
                    <h4 class="mb-0"><?php echo e($stats['completed']); ?></h4>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-xl-6">
            <div class="card">
                <div class="card-header"><h5 class="mb-0"><?php echo e(__('Add Course')); ?></h5></div>
                <div class="card-body">
                    <form method="POST" action="<?php echo e(route('learning-management.courses.store')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Title')); ?></label>
                            <input type="text" name="title" class="form-control" required>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Code')); ?></label>
                            <input type="text" class="form-control" value="<?php echo e($courseCodePreview); ?>" readonly disabled>
                            <small class="text-muted"><?php echo e(__('Auto-generated with COURS prefix when you save.')); ?></small>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Description')); ?></label>
                            <textarea name="description" rows="3" class="form-control"></textarea>
                        </div>
                        <button class="btn btn-primary"><?php echo e(__('Create Course')); ?></button>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-xl-6">
            <div class="card">
                <div class="card-header"><h5 class="mb-0"><?php echo e(__('Add Lesson')); ?></h5></div>
                <div class="card-body">
                    <form method="POST" action="<?php echo e(route('learning-management.lessons.store')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Course')); ?></label>
                            <select name="course_id" class="form-control" required>
                                <option value=""><?php echo e(__('Select course')); ?></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($course->title); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Lesson Title')); ?></label>
                            <input type="text" name="title" class="form-control" required>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Duration (minutes)')); ?></label>
                            <input type="number" name="duration_minutes" class="form-control" min="0">
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Order')); ?></label>
                            <input type="number" name="position" class="form-control" min="0" value="0">
                        </div>
                        <button class="btn btn-primary"><?php echo e(__('Create Lesson')); ?></button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-xl-6">
            <div class="card">
                <div class="card-header"><h5 class="mb-0"><?php echo e(__('Add Enrollment')); ?></h5></div>
                <div class="card-body">
                    <form method="POST" action="<?php echo e(route('learning-management.enrollments.store')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Course')); ?></label>
                            <select name="course_id" class="form-control" required>
                                <option value=""><?php echo e(__('Select course')); ?></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($course->title); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('User')); ?></label>
                            <select name="user_id" class="form-control" required>
                                <option value=""><?php echo e(__('Select user')); ?></option>
                                <?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); ?> (<?php echo e($user->email); ?>)</option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <button class="btn btn-primary"><?php echo e(__('Enroll User')); ?></button>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-xl-6">
            <div class="card">
                <div class="card-header"><h5 class="mb-0"><?php echo e(__('Track Progress')); ?></h5></div>
                <div class="card-body">
                    <form method="POST" action="<?php echo e(route('learning-management.progress.store')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Enrollment')); ?></label>
                            <select name="enrollment_id" class="form-control" required>
                                <option value=""><?php echo e(__('Select enrollment')); ?></option>
                                <?php $__currentLoopData = $enrollments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $enrollment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($enrollment->id); ?>"><?php echo e($enrollment->course->title); ?> - <?php echo e($enrollment->user->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Lesson (optional)')); ?></label>
                            <select name="lesson_id" class="form-control">
                                <option value=""><?php echo e(__('No specific lesson')); ?></option>
                                <?php $__currentLoopData = $lessons; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lesson): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($lesson->id); ?>"><?php echo e($lesson->course->title); ?> / <?php echo e($lesson->title); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Progress %')); ?></label>
                            <input type="number" name="progress_percent" class="form-control" min="0" max="100" step="0.01" required>
                        </div>
                        <div class="mb-2">
                            <label class="form-label"><?php echo e(__('Spent Minutes')); ?></label>
                            <input type="number" name="spent_minutes" class="form-control" min="0" value="0">
                        </div>
                        <button class="btn btn-primary"><?php echo e(__('Save Progress')); ?></button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="card mt-3">
        <div class="card-header"><h5 class="mb-0"><?php echo e(__('Courses & Lessons')); ?></h5></div>
        <div class="card-body table-border-style">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th><?php echo e(__('Course')); ?></th>
                        <th><?php echo e(__('Code')); ?></th>
                        <th><?php echo e(__('Lessons')); ?></th>
                        <th><?php echo e(__('Enrollments')); ?></th>
                        <th><?php echo e(__('Action')); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($course->title); ?></td>
                            <td><?php echo e($course->code ?: '-'); ?></td>
                            <td><?php echo e($course->lessons_count); ?></td>
                            <td><?php echo e($course->enrollments_count); ?></td>
                            <td>
                                <form method="POST" action="<?php echo e(route('learning-management.courses.destroy', $course->id)); ?>" onsubmit="return confirm('<?php echo e(__('Delete this course?')); ?>')">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button class="btn btn-sm btn-danger"><?php echo e(__('Delete')); ?></button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="5" class="text-center"><?php echo e(__('No courses found.')); ?></td></tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="card mt-3">
        <div class="card-header"><h5 class="mb-0"><?php echo e(__('Enrollments & Progress')); ?></h5></div>
        <div class="card-body table-border-style">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th><?php echo e(__('Course')); ?></th>
                        <th><?php echo e(__('User')); ?></th>
                        <th><?php echo e(__('Status')); ?></th>
                        <th><?php echo e(__('Completion %')); ?></th>
                        <th><?php echo e(__('Action')); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $enrollments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $enrollment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($enrollment->course->title); ?></td>
                            <td><?php echo e($enrollment->user->name); ?></td>
                            <td><?php echo e(ucfirst($enrollment->status)); ?></td>
                            <td><?php echo e(number_format((float)$enrollment->completion_percent, 2)); ?></td>
                            <td>
                                <form method="POST" action="<?php echo e(route('learning-management.enrollments.destroy', $enrollment->id)); ?>" onsubmit="return confirm('<?php echo e(__('Delete this enrollment?')); ?>')">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button class="btn btn-sm btn-danger"><?php echo e(__('Delete')); ?></button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="5" class="text-center"><?php echo e(__('No enrollments found.')); ?></td></tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="card mt-3">
        <div class="card-header"><h5 class="mb-0"><?php echo e(__('Recent Progress Logs')); ?></h5></div>
        <div class="card-body table-border-style">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th><?php echo e(__('Course')); ?></th>
                        <th><?php echo e(__('User')); ?></th>
                        <th><?php echo e(__('Lesson')); ?></th>
                        <th><?php echo e(__('Progress %')); ?></th>
                        <th><?php echo e(__('Spent Minutes')); ?></th>
                        <th><?php echo e(__('Updated At')); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $progresses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $progress): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e(optional(optional($progress->enrollment)->course)->title ?: '-'); ?></td>
                            <td><?php echo e(optional(optional($progress->enrollment)->user)->name ?: '-'); ?></td>
                            <td><?php echo e(optional($progress->lesson)->title ?: '-'); ?></td>
                            <td><?php echo e(number_format((float)$progress->progress_percent, 2)); ?></td>
                            <td><?php echo e($progress->spent_minutes); ?></td>
                            <td><?php echo e($progress->created_at); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="6" class="text-center"><?php echo e(__('No progress logs found.')); ?></td></tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>



<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\FromHardDisk\Davies\CleverSys\The Systems\erp.cleversys.co.ke\resources\views/learning-management/index.blade.php ENDPATH**/ ?>