<?php
/**
 * 课程列表
 * $Id: product_category_list.inc,v 1.1 2015/10/08 11:18:53 wanggb Exp $
 * @author zhouhj
 * @access public
 * @package manager.templates
 */

?>

<b>课程列表(<?=$valid_title?>)</b><br />
<br />
<a class="flatbutton" href="course_list.php?valid=ALL">全部</a>
<a class="flatbutton" href="course_list.php?valid=TRUE">上线中</a>
<a class="flatbutton" href="course_list.php?valid=FALSE">已下架</a>
<br /><br />
<a class="flatbutton" href="course_edit_input.php">添加课程</a>
<br /><br />
<div id="result_list">
	<table>
		<tr>
			
			<th class="contents_title" width="15%">课程名称</th>
			<th class="contents_title" width="10%">封面</th>
			<th class="contents_title" width="5%">原价</th>
			<th class="contents_title" width="5%">活动价</th>
			<th class="contents_title" width="15%">分期设置</th>
			<th class="contents_title" width="28%">购买链接</th>
			<th class="contents_title" width="5%">首页</th>
			<th class="contents_title" width="5%">排序</th>
			<th class="contents_title">操作</th>
		</tr>

		<?
		if (count($course_list) > 0) {
			foreach ($course_list as $course) {
				$valid_title = "上架";
				if($course->is_valid) {
					$valid_title = "下架";
				}
				//分期设置
				$huabei_string = "";
				if($course->is_free3) {
					$huabei_string .= "[3期免息]";
				} else {
					$huabei_string .= "[3期不免息]";
				}
				if($course->is_free6) {
					$huabei_string .= "[6期免息]";
				} else {
					$huabei_string .= "[6期不免息]";
				}
				if($course->is_free12) {
					$huabei_string .= "[12期免息]";
				} else {
					$huabei_string .= "[12期不免息]";
				}
				$url = "http://" . SCHOOL_DOMAIN . "/course_detail.php?course_id=" . $course->id;
				
				//首页显示
				$is_top_title = "X";
				if($course->is_top) {
					$is_top_title = "〇";
				}
		?>
				<tr<?=!$course->is_valid ? " class=\"gray_mask\"" : "" ?>>
					
					<td align="center"><?=htmlspecialchars($course->title) ?></td>
					<td align="center">
						<?
							if(!empty($course->thumbnail)) {
						?>
						<img src="<?=KoalaHandler::getImageUrl($course->thumbnail, "course", "") ?>" style="height:60px;" />
						<?
							}
						?>
					</td>
					<td align="right"><?=number_format($course->original_price, 2) ?></td>
					<td align="right"><?=number_format($course->price, 2) ?></td>
					<td align="right"><?=$huabei_string ?></td>
					<td align="left"><?=$url ?></td>
					<td align="center"><a class="flatbutton" href="course_change_top.php?id=<?=$course->id ?>"><?=$is_top_title ?></a></td>
					<td align="center">
						<a class="flatbutton" href="course_change_display_order.php?id=<?=$course->id ?>&type=up">↑</a>
						<a class="flatbutton" href="course_change_display_order.php?id=<?=$course->id ?>&type=down">↓</a>
					</td>
					<td align="center">
						<a class="flatbutton" href="course_edit_input.php?id=<?=$course->id ?>">编集</a>
						<a class="flatbutton" href="course_change_valid.php?id=<?=$course->id ?>"><?=$valid_title?></a>
					</td>
				</tr>
				<?
			}
		}
		?>
	</table>
</div>