<?php 
include("header.php");
if(!empty($_GET['view_id']))
$view_id = $_GET['view_id'];
elseif(!empty($_POST['view_id']))
$view_id = $_POST['view_id'];
else
$view_id = '';

if(!empty($_GET['lesson_id']))
$lesson_id = $_GET['lesson_id'];
elseif(!empty($_POST['lesson_id']))
$lesson_id = $_POST['lesson_id'];
else
$lesson_id = '';

 $get_data= get_lesson($lesson_id,'','','','','');

?>
<div class="card shadow-lg border-0 mb-4">


    <div class="card-header bg-dark text-white d-flex justify-content-between align-items-center">
        <h4 class="mb-0">
            <i class="bi bi-play-circle"></i> Lesson Details
        </h4>

        <div>
            
        </div>
    </div>


    <div class="card-body">

        <div class="row">

        
            <div class="col-md-4 text-center">

              
                <?php if($get_data[0]['lesson_type'] == 'Video Lessons'){ ?>
                    
                    <?php if(!empty($get_data[0]['video_url'])){ ?>
                        <iframe width="100%" height="200"
                        src="<?php echo $get_data[0]['video_url']; ?>"
                        frameborder="0" allowfullscreen></iframe>
                    <?php } else { ?>
                        <video width="100%" controls>
                            <source src="../instructor/lessons_uploads/<?php echo $get_data[0]['video_upload']; ?>">
                        </video>
                    <?php } ?>

                <?php } ?>
                
                <?php if($get_data[0]['lesson_type'] == 'Text Lessons'){ ?>
                    
                    <a href="<?php echo '../instructor/lessons_uploads/'.$get_data[0]['text_upload']; ?>"
                       target="_blank" class="btn btn-info w-100 mt-2">
                        <i class="bi bi-file-earmark-text"></i> View File
                    </a>

                <?php } ?>

               
                <?php if($get_data[0]['lesson_type'] == 'Material Lessons'){ ?>
                    
                    <a href="<?php echo $get_data[0]['material_url'] ?: 'lessons_uploads/'.$get_data[0]['material_upload']; ?>"
                       target="_blank" class="btn btn-info w-100 mt-2">
                        <i class="bi bi-file-earmark-text"></i> View Material
                    </a>

                <?php } ?>

                <?php if($get_data[0]['lesson_type'] == 'Assignments'){ ?>

                    <a href="<?php echo '../instructor/lessons_uploads/'.$get_data[0]['assignment_upload']; ?>"
                       target="_blank" class="btn btn-warning w-100 mt-2">
                        <i class="bi bi-upload"></i> View Assignment
                    </a>

                <?php } ?>

             
                <div class="mt-3">
                    <span class="badge bg-primary">
                        <?php echo ucfirst($get_data[0]['lesson_type']); ?>
                    </span>
                </div>

            </div>

        
            <div class="col-md-8">

                <h3 class="fw-bold">
                    <?php echo $get_data[0]['lesson_title'] ?? ""; ?>
                </h3>

                <table class="table table-borderless mt-3">

                    <tr>
                        <th width="160"><i class="bi bi-book"></i> Course</th>
                        <td><?php echo $get_data[0]['course_title'] ?? ""; ?></td>
                    </tr>

                    <tr>
                        <th><i class="bi bi-folder"></i> Module</th>
                        <td><?php echo $get_data[0]['module_title'] ?? ""; ?></td>
                    </tr>

                    <tr>
                        <th><i class="bi bi-layers"></i> Lesson Type</th>
                        <td><?php echo ucfirst($get_data[0]['lesson_type']); ?></td>
                    </tr>

					 <?php if($get_data[0]['lesson_type'] == 'Material Lessons'){ ?>
                    <tr>
                        <th><i class="bi bi-link-45deg"></i> Material URL</th>
                        <td>
                            <a href="<?php echo $get_data[0]['material_url'] ?? "#"; ?>" target="_blank">
                                Open Link
                            </a>
                        </td>
                    </tr>
                    <?php } ?>
                    
                

                </table>

            </div>

        </div>

        <hr class="my-4">
        
         <?php if($get_data[0]['lesson_type'] == 'Assignments'){ ?>
         <div>
            <h5 class="fw-bold text-primary">
                <i class="bi bi-file-text"></i> Lesson Content
            </h5>

            <div class="p-3 bg-light rounded">
                <?php echo $get_data[0]['assign_instruction'] ?? ""; ?>
            </div>
        </div>
		<?php }else {?>
       
        <div>
            <h5 class="fw-bold text-primary">
                <i class="bi bi-file-text"></i> Lesson Content
            </h5>

            <div class="p-3 bg-light rounded">
                <?php echo $get_data[0]['lesson_content'] ?? ""; ?>
            </div>
        </div>
        
        <?php } ?>

    </div>

</div>

<?php include("footer.php"); ?>