<?php 

function cp_select_topic_cb() {
	if(!isset($_GET['class']) || !isset($_GET['subject'])) return_method();
	$current_term = get_option("current_academic_term");
	$post = new post;
	$class = $_GET['class'];
	$subject = $_GET['subject'];
	$term_meta = $post->get_post_meta($current_term);
	global $app;
	?>
	<div class="row">
		<div class="col-12">
			<?php do_action("cp_get_available_quiz", ["student_meta" => $app->user_meta, "subject" => $subject]); ?>
			<div class="cp-combo-box">
				<div class="cp-combo-box-header">
					<h2>First Term</h2>
				</div>
				<div class="cp-combo-box-body">
					<div>
					<?php 
						$lessons = $post->get_post_by_meta_data(['type' => 'cp_course_outline', 'term' => 1, 'course' => $subject, 'class' => $class]);
					    $table = new table("lessons-table-1", $lessons);
					    $table->term_meta = $term_meta;
					    $table->set_display_columns([
					        "week" => "Week",
					        "topic" => "Topic"
					    ]);
					    $table->set_dynamic_columns([
					        "week" => "_cp_tf_get_week"
					    ]);
					    $table->set_action_links([
					        "View" => "cp-view-lesson"
					    ]);
					    $table->set_action_access([
					        "View" => "cp_view_lesson"
					    ]);
					    $table->set_action_callback([
					        "View" => false
					    ]);
					    $table->set_action_args([
					        "View" => ["id" => "id"]
					    ]);
					    $table->table_id = "table-1";
					    $table->table_class = "table";
						$table->display();
					 ?>
					</div>
				</div>
			</div>
			<div class="cp-combo-box">
				<div class="cp-combo-box-header">
					<h2>Second Term</h2>
				</div>
				<div class="cp-combo-box-body">
					<div>
					<?php 
						$lessons = $post->get_post_by_meta_data(['type' => 'cp_course_outline', 'term' => 2, 'course' => $subject, 'class' => $class]);
					    $table = new table("lessons-table-2", $lessons);
					    $table->term_meta = $term_meta;
					    $table->set_display_columns([
					        "week" => "Week",
					        "topic" => "Topic"
					    ]);
					    $table->set_dynamic_columns([
					        "week" => "_cp_tf_get_week"
					    ]);
					    $table->set_action_links([
					        "View" => "cp-view-lesson"
					    ]);
					    $table->set_action_access([
					        "View" => "cp_view_lesson"
					    ]);
					    $table->set_action_callback([
					        "View" => false
					    ]);
					    $table->set_action_args([
					        "View" => ["id" => "id"]
					    ]);
					    $table->table_id = "table-2";
					    $table->table_class = "table";
						$table->display();
					 ?>
					</div>
				</div>
			</div>
			<div class="cp-combo-box">
				<div class="cp-combo-box-header">
					<h2>Third Term</h2>
				</div>
				<div class="cp-combo-box-body">
					<div>
					<?php 
						$lessons = $post->get_post_by_meta_data(['type' => 'cp_course_outline', 'term' => 3, 'course' => $subject, 'class' => $class]);
					    $table = new table("lessons-table-3", $lessons);
					    $table->term_meta = $term_meta;
					    $table->set_display_columns([
					        "week" => "Week",
					        "topic" => "Topic"
					    ]);
					    $table->set_dynamic_columns([
					        "week" => "_cp_tf_get_week"
					    ]);
					    $table->set_action_links([
					        "View" => "cp-view-lesson"
					    ]);
					    $table->set_action_access([
					        "View" => "cp_view_lesson"
					    ]);
					    $table->set_action_callback([
					        "View" => false
					    ]);
					    $table->set_action_args([
					        "View" => ["id" => "id"]
					    ]);
					    $table->table_id = "table-3";
					    $table->table_class = "table";
						$table->display();
					 ?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php
}