<?php 

function add_subject_branch_cb() {
	global $post_meta;
	$options = get_select_options_from_post(['type' => 'course'], 'course_name');
	?>
	<div class="row">
		<div class="col-md-6">
			<div class="card card-primary">
				<div class="card-header">
					<h3 class="card-title">Add Course/Subject Branch</h3>
				</div>
				<div class="card-body">
					<form method="post" action="contents/plugins/eedu_portal/ajax.php" id="form" data-clearform=1 data-callback="getSubjectBranch" data-callbackid="#subject-branch">
						<?php  
							input(['label' => 'Branch Name', 'id' => 'course_name', 'required' => 'required']);
							select(['label' => 'Course/Subject', 'id' => 'course_id', 'required' => 'required'], $options);
							submit_btn('add_subject_branch', 'Submit');
						?>
					</form>
				</div>
			</div>
		</div>
		<div class="col-md-6">
			<div id="subject-branch"></div>
		</div>
	</div>
	<?php
	add_page_javascript('contents/plugins/eedu_portal/js/js-functions.js');
	add_page_javascript('app/assets/js/page-scripts/submit.js');
}

function edit_subject_branch_cb() {
	if(!isset($_GET['id'])) return_method();
	$post = new post;
	$branch = $post->get_post_meta($_GET['id']);
	global $post_meta;
	$options = get_select_options_from_post(['type' => 'course'], 'course_name');
	?>
	<div class="row">
		<div class="col-md-6">
			<div class="card card-primary">
				<div class="card-header">
					<h3 class="card-title">Edit Course/Subject Branch</h3>
				</div>
				<div class="card-body">
					<form method="post" action="contents/plugins/eedu_portal/ajax.php" id="form" data-callback="getSubjectBranch" data-callbackid="#subject-branch">
						<input type="hidden" name="id" value="<?php echo $branch['id'] ?>">
						<?php  
							input(['label' => 'Branch Name', 'id' => 'course_name', 'required' => 'required', 'value' => $branch['course_name']]);
							select(['label' => 'Course/Subject', 'id' => 'course_id', 'required' => 'required'], $options, $branch['course_id']);
							submit_btn('edit_subject_branch', 'Submit');
						?>
					</form>
				</div>
			</div>
		</div>
		<div class="col-md-6">
			<div id="subject-branch"></div>
		</div>
	</div>
	<?php
	add_page_javascript('contents/plugins/eedu_portal/js/js-functions.js');
	add_page_javascript('app/assets/js/page-scripts/submit.js');
}