<?php
// 发送短信验证码
require_once ("../user_include.inc");

$ta = new TemplateAction();
if(!$ta->isLogin()) {
	print json_encode(array("class_count"=>0, "html"=>""));
	exit;
}

ErrorLogger::doOutput("Koala...ajax_get_my_course.php....Start.", 0);

//检索用户的班级设定
$param = array();
$param["user_id"] = $ta->user->id;
$param["is_valid"] = true;
$param["delete_flg"] = false;
$user_class_list = UserClassDat::getList($param, "update_date", "desc", 0, 1);
$user_class_dat = null;
$class_count = 0;
if(!empty($user_class_list)) {
	$user_class_dat = $user_class_list[0];
	$class_count = 1;
}

ob_start();
if(!empty($user_class_dat)) {
	$url = $user_class_dat->live_url;
?>
	<div class="class_item">
		<div class="class_title"><?=$user_class_dat->title ?></div>
		<div class="class_button" onClick="goPath('<?=$url?>')">去上课</div>
	</div>
<?
} else {
	$url = SCHOOL_TOP;
?>
	<div class="class_item">
		<div class="class_title">暂无课程</div>
		<div class="class_button" onClick="goPath('<?=$url?>')">购买课程</div>
	</div>
<?
}
$html = ob_get_contents();
ob_end_clean();
print json_encode(array("class_count"=>$class_count, "html"=>$html));
?>