 <?php
    require_once '../controller/CheckLoginState.php'; 
    require_once '../service/CourseInfoService.class.php';
    require_once '../phpbean/CourseInfo.class.php';
    $courseNumber = $_GET['courseNumber'];
    $courseInfoService = new CourseInfoService();
    $courseInfo = $courseInfoService->GetCourseInfo($courseNumber);
 ?>
<html>
<head>
<title>修改课程信息</title>
<link href="/css/add_modify.css" rel="stylesheet" type="text/css" />
<script src="/js/util.js" type="text/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 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">
			<table width="100%" border="0" cellpadding="0" cellspacing="2" align="center">
				<tr>
					<td height="21"><img src="../images/ico/ico29.gif" width="32" height="32" hspace="2" vspace="2" align="absmiddle">
					    <strong> 课程信息修改 </strong>
					</td>
				</tr>
			</table>
		</div>

		<div id="content">
			<form id="form1" method="post" action="/controller/CourseInfoAction.php?action=update" enctype="multipart/form-data">
				<p>
					课程编号: &nbsp;
					<input id="courseNumber" class="text" type="text" readOnly style="width: 200px" value="<?php echo $courseInfo->getCOURSENUMBER()?>" name="courseInfo[courseNumber]" />
					<font color=red>*</font>
				</p>
				<p>
					课程名称: &nbsp;
					<input id="courseName" class="text" type="text" style="width: 200px" value="<?php echo $courseInfo->getCourseName()?>" 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];
						  if($row['teacherNumber'] == $courseInfo->getCourseTeacher())
						    echo "<option selected value={$row['teacherNumber']}>{$row['teacherName']}</option>";
						  else
						    echo "<option value={$row['teacherNumber']}>{$row['teacherName']}</option>";
						}
					?>
					</select>
				</p>

				<p>
					上课时间: &nbsp;
					<input id="courseTime" class="text" type="text" style="width: 400px" value="<?php echo $courseInfo->getCourseTime()?>" name="courseInfo[courseTime]" />
				</p>
				<p>
					上课地点: &nbsp;
					<input id="coursePlace" class="text" type="text" style="width: 400px" value="<?php echo $courseInfo->getCoursePlace()?>" name="courseInfo[coursePlace]" />
				</p>
				<p>
					课程学分:&nbsp; <input id="courseScore" class="text" type="text" style="width: 60px" value="<?php echo $courseInfo->getCourseScore()?>" name="courseInfo[courseScore]" />
					<font color=red>*</font>
				</p>
				<p>
					附加信息: &nbsp;
					<input id="courseMemo" class="text" type="text" style="width: 1000px" value="<?php echo $courseInfo->getCourseMemo()?>" name="courseInfo[courseMemo]" />
				</p>
				<p>
					<input type="button" style="cursor: hand;" class="btn" value="修改" onClick="CheckForm();" />
				</p>
			</form>
		</div>
	</div>
</body>
</html>
