<?php
	require_once '../controller/CheckLoginState.php';
?>
<html>
<head>
<title>课程信息登记</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/add_modify.css" rel="stylesheet" type="text/css" />
<script src="../js/util.js" language="JavaScript"></script>
<script src="../js/calendar.js"></script>
<script type="text/javascript">
        function CheckForm() {
            var re = /^[0-9]+.?[0-9]*$/;
            var resc=/^[1-9]+[0-9]*]*$/ ;
            var courseNumber = document.getElementById("courseNumber").value;
            if (courseNumber == "") {
                alert("请输入课程编号...");
                document.getElementById("courseNumber").focus();
                return false;
            }

            var courseName = document.getElementById("courseName").value;
            if (courseName == "") {
                alert("请输入课程名称...");
                document.getElementById("courseName").focus();
                return false;
            }

            var courseScore = document.getElementById("courseScore").value;
            if(courseScore == ""){
                alert("请输入课程学分...");
                document.getElementById("courseScore").focus();
                return false;
            }
            else if (!re.test(courseScore))
            {
                alert("课程学分请输入数字");
                document.getElementById("courseScore").focus();
                //input.rate.focus();
                return false;
            }

            document.forms[0].submit();
       } 
    </script>
</head>
<body>
	<div id="container">
		<div id="title">
			<img src="../images/ADD.gif" />课程信息录入 (带*号的为必填项)
		</div>
		<div id="content">
			<form method="post" name="courseInfoAddForm"
				action="/controller/CourseInfoAction.php?action=add"
				enctype="multipart/form-data">
				<br />
				<p>
					课程编号: &nbsp;
					<input id="courseNumber" class="text" type="text" style="width: 200px" value="" name="courseInfo[courseNumber]" />
					<font color=red>*</font>
				</p>
				<p>
					课程名称: &nbsp;
					<input id="courseName" class="text" type="text" style="width: 200px" value="" name="courseInfo[courseName]" />
					<font color=red>*</font>
				</p>
				<p>
					上课老师:&nbsp;
					<select name="courseInfo[courseTeacher]">
					<?php
						require_once '../service/TeacherService.class.php';
						$teacherService = new TeacherService ();
						$teacher_res = $teacherService->QueryAllTeacher ();
						for($i = 0; $i < count ( $teacher_res ); $i ++) {
						  $row = $teacher_res [$i];
						  echo "<option value={$row['teacherNumber']}>{$row['teacherName']}</option>";
						}
					?>
					</select>
				</p>

				<p>
					上课时间: &nbsp;
					<input id="courseTime" class="text" type="text" style="width: 400px" value="" name="courseInfo[courseTime]" />
				</p>
				<p>
					上课地点: &nbsp;
					<input id="coursePlace" class="text" type="text" style="width: 400px" value="" name="courseInfo[coursePlace]" />
				</p>
				<p>
					课程学分:&nbsp; <input id="courseScore" class="text" type="text" style="width: 60px" value="" name="courseInfo[courseScore]" />
					<font color=red>*</font>
				</p>
				<p>
					附加信息: &nbsp;
					<input id="courseMemo" class="text" type="text" style="width: 1000px" value="" name="courseInfo[courseMemo]" />
				</p>
				<p>
					<input type="button" style="cursor: hand;" class="btn" value="添加" onClick="CheckForm();" />
				</p>

			</form>
		</div>
	</div>
</body>
</html>
