<?php 

function cp_edit_lesson_cb() {
	if(!isset($_GET['id'])) return_method();
	$post = new post;
	$lesson = $post->get_post_meta($_GET['id']);
    $terms = ['First' => 1, 'Second' => 2, 'Third' => 3];
	?>
	<div class="row justify-content-center mt-4">
        <div class="col-md-6">
            <div id="display-lessons" data-class="<?php echo $lesson['class'] ?>" data-course="<?php echo $lesson['course'] ?>" data-term="<?php echo $lesson['term'] ?>"></div>
            <a href="curriculum" class="btn btn-primary">Add Lesson</a>
        </div>
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h3>Edit Lesson</h3>
                </div>
                <div class="card-body">
                    
                    
                            <form id="add-lesson-form" method="post" action="contents/plugins/classroom_plus/ajax.php" data-callback="cp_get_lessons" data-callbackid="#display-lessons">
                            	<input type="hidden" name="id" id="id" value="<?php echo $lesson['id'] ?>">
                                <div class="row">
                                    <div class="col-md-6">
                                        <?php input(['label' => 'Week', 'id' => 'week', 'type' => 'number', 'required' => 'required', 'value' => $lesson['week']]); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <?php input(['label' => 'Period', 'id' => 'period', 'value' => $lesson['period']]); ?>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php select(['label' => 'Term', 'name' => 'term', 'id' => 'in_term', 'data-form' => 'search-form', 'required' => 'required'], $terms , $lesson['term']); ?>
                                    </div>
                                </div>
                            <?php 
                                
                                input(['label' => 'Topic', 'id' => 'topic', 'required' => 'required', 'value' => $lesson['topic']]);
                                textarea(['label' => 'Objectives', 'id' => 'objectives', 'required' => 'required', 'value' => $lesson['objectives']], true);
                                submit_btn('edit_course_outline');
                             ?>
                            </form>
                        
                </div>
            </div>
        </div>
    </div>
	<?php
	global $post_meta;
    add_page_javascript('contents/plugins/classroom_plus/js/course-outline-filter.js');
	add_page_javascript('contents/plugins/classroom_plus/js/add-lesson.js');
    add_page_javascript('app/assets/js/page-scripts/js-functions.js');
    add_page_javascript('app/assets/js/page-scripts/submit.js');
}