403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/(Del)pathways.org.hk/MIS_bk/student/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS_bk/student/form.php
<?php
require_once(__DIR__ . '/../checkuser.php');
function getStudentAssessment(&$student, $child_name, $subject_id) {
	$assessment = array();
	foreach ($student[$child_name] ?: array() as $tmp_assessment) {
		if ($tmp_assessment['subject_id'] == $subject_id) {
			$assessment = $tmp_assessment;
			break;
		}
	}
	return $assessment;
}
function saveAssessments(&$student, $child_name, $table) {
	global $dbh;
	
	$childs = array();
	if (is_array($student[$child_name]) && !empty($student[$child_name])) {
		foreach ($student[$child_name] as $id => $child) {
			if (empty($child['subject_id'])) {
				continue;
			}
			$new_child = array_merge($child, array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
			));
			$new_child['id'] = Db\Util::create($dbh, $table, $new_child);
			
			$childs[] = $new_child;
		}
	}
	return $childs;
}
function saveChilds(&$student) {
	global $dbh;
	
	// Photo
	if (empty($student['photo'])) {
		$destination_dir = 'photos';
		if (!file_exists($destination_dir)) {
			if (!mkdir($destination_dir, 0775, true)) {
				throw new Exception("Create directory fail.");
			}
		}

		$files = new UploadedFiles($_FILES);
		$file_info = $files['student']['photo'];
		$is_uploaded_file = is_uploaded_file($file_info['tmp_name']);
		if (!$is_uploaded_file) {
			if ($file_info['error'] != UPLOAD_ERR_NO_FILE) {
				$student['photo'] = UploadedFiles::codeToMessage($file_info['error']);
			}
		} else {
			$path_info = pathinfo($file_info['name']);
			$file_name = $student['id'] . '.' . $path_info['extension'];
			if (!in_array(strtolower($path_info['extension']), array('jpg', 'jpeg', 'png', 'bmp', 'gif'))) {
				$file_name .= '.png';
			}
			$file_destination = "$destination_dir/$file_name";
			if (!move_uploaded_file($file_info['tmp_name'], $file_destination)) {
				throw new Exception('File upload error: ' . UploadedFiles::codeToMessage($file_info['error']));
			}
			$student['photo'] = $file_name;
		}
		Db\Util::update($dbh, 'mis_student', $student);
	}
	
	// Diagnoses
	$student_diagnoses = array();
	foreach ($student['diagnoses']['others'] ?: array() as $diagnose_other) {
		if (!empty($diagnose_other)) {
			$student_diagnose = array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
				'others' => $diagnose_other,
			);
			$student_diagnose['id'] = Db\Util::create($dbh, 'mis_student_diagnose', $student_diagnose);
			
			$student_diagnoses[] = $student_diagnose;
		}
	}
	foreach ($student['diagnoses']['diagnose_id'] ?: array() as $diagnose_id) {
		if (!empty($diagnose_id)) {
			$student_diagnose = array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
				'diagnose_id' => $diagnose_id,
			);
			$student_diagnose['id'] = Db\Util::create($dbh, 'mis_student_diagnose', $student_diagnose);
			
			$student_diagnoses[] = $student_diagnose;
		}
	}
	$student['diagnoses'] = $student_diagnoses;
	
	// Additional Aspects
	$student_additional_aspects = array();
	foreach ($student['additional_aspects']['others'] ?: array() as $additional_aspect_other) {
		if (!empty($additional_aspect_other)) {
			$student_additional_aspect = array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
				'others' => $additional_aspect_other,
			);
			$student_additional_aspect['id'] = Db\Util::create($dbh, 'mis_student_additional_aspect', $student_additional_aspect);
			
			$student_additional_aspects[] = $student_additional_aspect;
		}
	}
	foreach ($student['additional_aspects']['additional_aspect_id'] ?: array() as $additional_aspect_id) {
		if (!empty($additional_aspect_id)) {
			$student_additional_aspect = array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
				'additional_aspect_id' => $additional_aspect_id,
			);
			$student_additional_aspect['id'] = Db\Util::create($dbh, 'mis_student_additional_aspect', $student_additional_aspect);
			
			$student_additional_aspects[] = $student_additional_aspect;
		}
	}
	$student['additional_aspects'] = $student_additional_aspects;
	
	// Subsidies
	$student_subsidies = array();
	foreach ($student['subsidies'] ?: array() as $subsidy_id) {
		if (!empty($subsidy_id)) {
			$student_subsidy = array(
				'actived' => 1,
				'deleted' => 0,
				'student_id' => $student['id'],
				'subsidy_id' => $subsidy_id,
			);
			$student_subsidy['id'] = Db\Util::create($dbh, 'mis_student_subsidy', $student_subsidy);
			
			$student_subsidies[] = $student_subsidy;
		}
	}
	$student['subsidies'] = $student_subsidies;
	
	// zh assessments
	$student['zh_assessments'] = saveAssessments($student, 'zh_assessments', 'mis_student_assessment_zh');
	// en assessments
	$student['en_assessments'] = saveAssessments($student, 'en_assessments', 'mis_student_assessment_en');
	// math assessments
	$student['math_assessments'] = saveAssessments($student, 'math_assessments', 'mis_student_assessment_math');
}
function form() {
	global $dbh;
	
	$today = date('Y-m-d');
	$student = array(
		'actived' => 1,
		'deleted' => 0,
		'status' => 1,
		'data_input_date' => $today,
		'registration_date' => $today,
		'subsidy' => 1, // none
		'input_by' => $_SESSION['webadmin']['username'],
	);
	
	$root_id = isset($_GET['root_id']) ? $_GET['root_id'] : null;
	if (!empty($root_id)) {
		$sql = "SELECT * FROM mis_student WHERE root_id = ? AND is_latest = ? AND deleted = ?";
		$parameters = array($root_id, 1, 0);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student = $sth->fetch(PDO::FETCH_ASSOC);
		
		// Get input by
		$sql = "
SELECT user.*
FROM mis_student student
INNER JOIN sys_login user ON user.id = student.createby
WHERE student.id = (SELECT MIN(root_student.id) AS min_id FROM mis_student root_student WHERE root_student.root_id = ?)";
		$parameters = array($student['root_id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student_createby_user = $sth->fetch(PDO::FETCH_ASSOC);
		$student['input_by'] = $student_createby_user['username'];
		
		// Get diagnoses
		$sql = "SELECT * FROM mis_student_diagnose WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['diagnoses'] = $sth->fetchAll();
		
		// Get additional aspects
		$sql = "SELECT * FROM mis_student_additional_aspect WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['additional_aspects'] = $sth->fetchAll();
		
		// Get subsidies
		$sql = "SELECT * FROM mis_student_subsidy WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['subsidies'] = $sth->fetchAll();
		
		// Get zh assessments
		$sql = "SELECT * FROM mis_student_assessment_zh WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['zh_assessments'] = $sth->fetchAll();
		
		// Get en assessments
		$sql = "SELECT * FROM mis_student_assessment_en WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['en_assessments'] = $sth->fetchAll();
		
		// Get math assessments
		$sql = "SELECT * FROM mis_student_assessment_math WHERE student_id = ? ORDER BY id";
		$parameters = array($student['id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['math_assessments'] = $sth->fetchAll();
		
		// Get allocated classes
		$sql = "
SELECT evt.code AS event_code, program.code AS program_code, subject.code AS subject_code,
	(SELECT MIN(lesson.`date`) FROM mis_event_lesson lesson WHERE lesson.event_id = evt.id AND deleted = 0) AS start_date,
	(SELECT MAX(lesson.`date`) FROM mis_event_lesson lesson WHERE lesson.event_id = evt.id AND deleted = 0) AS end_date,
	(
		SELECT GROUP_CONCAT(
			DISTINCT CONCAT(latest_staff.last_name, ' ', latest_staff.first_name)
			ORDER BY latest_staff.last_name, latest_staff.first_name
			SEPARATOR ', '
		)
		FROM mis_staff staff
		INNER JOIN mis_staff latest_staff ON latest_staff.root_id = staff.root_id AND latest_staff.is_latest = 1
		INNER JOIN mis_lesson_staff lesson_staff ON lesson_staff.staff_id = staff.id
		INNER JOIN mis_event_lesson lesson ON lesson.id = lesson_staff.lesson_id
		WHERE lesson.event_id = evt.id
		GROUP BY lesson.event_id
	) AS teacher
FROM mis_event evt
LEFT JOIN mis_program program ON program.id = evt.program_id
LEFT JOIN mis_subject subject ON subject.id = evt.subject_id
WHERE evt.deleted = 0 AND evt.is_waiting_list = ?
	AND EXISTS(
		SELECT *
		FROM mis_student student
		INNER JOIN mis_student latest_student ON latest_student.root_id = student.root_id AND student.is_latest = 1
		INNER JOIN mis_lesson_student lesson_student ON lesson_student.student_id = student.id
		INNER JOIN mis_event_lesson lesson ON lesson.id = lesson_student.lesson_id
		WHERE lesson.event_id = evt.id AND student.root_id = ?
	)
ORDER BY event_code, program_code, subject_code, start_date, end_date, teacher
";
		$parameters = array(0, $student['root_id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['allocated_classes'] = $sth->fetchAll();
		
		$parameters = array(1, $student['root_id']);
		$sth = Db\Util::execute($dbh, $sql, $parameters);
		$student['waiting_lists'] = $sth->fetchAll();
	}
	
	if (isPost()) {
		$student = array_merge($student, $_POST['student']);
		if (empty($student['root_id'])) {
			$sql = "SELECT * FROM mis_campus WHERE id = ?";
			$parameters = array($student['reg_campus_id']);
			$sth = Db\Util::execute($dbh, $sql, $parameters);
			$tmp_reg_campus = $sth->fetch(PDO::FETCH_ASSOC);
			
			// Save
			$student = array_merge($student, array(
				'root_id' => Db\Util::uuid($dbh),
				'is_latest' => 1,
				'registration_number' => 'STU' . $tmp_reg_campus['code'] . substr($student['reg_sem_year'], -2) . substr(($student['reg_sem_year']+1), -2),
			));
			Db\Util::transaction($dbh, function() use ($dbh, &$student) {
				$sql = "SELECT * FROM mis_student FOR UPDATE";
				$sth = Db\Util::execute($dbh, $sql);
				
				$sql = "SELECT COUNT(DISTINCT root_id) AS max_seq FROM mis_student";
				$parameters = array($student['reg_campus_id']);
				$sth = Db\Util::execute($dbh, $sql, $parameters);
				$record = $sth->fetch(PDO::FETCH_ASSOC);
				$max_seq = $record['max_seq'];
				
				$student['id'] = Db\Util::create($dbh, 'mis_student', $student);
				$student['registration_number'] .= sprintf('%04d', ($max_seq + 1));
				Db\Util::update($dbh, 'mis_student', $student);
				saveChilds($student);
			});
		} else {
			// Save
			Db\Util::transaction($dbh, function() use ($dbh, $root_id) {
				$student_columns = Db\Util::columns($dbh, 'mis_student');
				
				$sql = "SELECT * FROM mis_student WHERE root_id = ? AND is_latest = ? AND deleted = ? FOR UPDATE";
				$parameters = array($root_id, 1, 0);
				$sth = Db\Util::execute($dbh, $sql, $parameters);
				$student = $sth->fetch(PDO::FETCH_ASSOC);
				
				$new_student = $student;
				$new_student = array_merge($new_student, $_POST['student']);
				foreach (General::fields() as $field) {
					unset($new_student[$field]);
				}
				
				$student['is_latest'] = 0;
				Db\Util::update($dbh, 'mis_student', $student, $student_columns);
				
				$new_student['id'] = Db\Util::create($dbh, 'mis_student', $new_student, $student_columns);
				saveChilds($new_student);
			});
		}
		
		$data = array(
			'message' => 'Saved',
		);
		redirectAndExit(Util::link(__DIR__ . '/index.php') . '?' . http_build_query($data));
	}
	
	$sql = "SELECT * FROM mis_district WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$districts = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_area WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$areas = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_assessor WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$assessors = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_student_grade WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$student_grades = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_campus WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$campuses = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_diagnose WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$diagnoses = $sth->fetchAll();
	$diagnose_map = array();
	foreach ($diagnoses as $diagnose) {
		$diagnose_map[$diagnose['id']] = $diagnose;
	}
	
	$sql = "SELECT * FROM mis_additional_aspect WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$additional_aspects = $sth->fetchAll();
	$additional_aspect_map = array();
	foreach ($additional_aspects as $additional_aspect) {
		$additional_aspect_map[$additional_aspect['id']] = $additional_aspect;
	}
	
	$sql = "
SELECT
	TRIM(CONCAT(column1.code, ' ', column1.name)) AS column_1, column1.id AS column_1_id,
	TRIM(CONCAT(column2.code, ' ', column2.name)) AS column_2, column2.id AS column_2_id,
	TRIM(CONCAT(column3.code, ' ', column3.name)) AS column_3, column3.id AS column_3_id,
	column3.remarks
FROM mis_student_assessment_zh_subject column1
LEFT JOIN mis_student_assessment_zh_subject column2 ON column2.parent_id = column1.id
LEFT JOIN mis_student_assessment_zh_subject column3 ON column3.parent_id = column2.id
WHERE column1.parent_id IS NULL
ORDER BY column1.sort, column2.sort, column3.sort";
	$sth = Db\Util::execute($dbh, $sql);
	$zh_assessment_columns = $sth->fetchAll();
	
	return array(
		'student' => $student,
		'studentStatusOptions' => Student::statusOptions(),
		'genderOptions' => General::genderOptions(),
		'districts' => $districts,
		'areas' => $areas,
		'assessors' => $assessors,
		'student_grades' => $student_grades,
		'campuses' => $campuses,
		'diagnoses' => $diagnoses,
		'diagnose_map' => $diagnose_map,
		'additional_aspects' => $additional_aspects,
		'additional_aspect_map' => $additional_aspect_map,
		'subsidies' => Subsidy::getAll($dbh),
		'zh_assessment_columns' => $zh_assessment_columns,
	);
}
extract(form());
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	
	<?php require(__DIR__ . '/../inc/_head_meta.php'); ?>
	
	<?php require(__DIR__ . '/../inc/_head_css.php'); ?>
	
	<?php require(__DIR__ . '/../inc/_head_script.php'); ?>
	
	<style type="text/css">
		/*
		#assessment_en_collapse table input[type=checkbox] {
			margin-left: 10px;
		}
		*/
	</style>
	
</head>
<body>
	
	<?php require( __DIR__ . '/../inc/_navbar.php'); ?>
	
	<div class="text-right">
		<ul class="breadcrumb">
			<li><a href="#">Master</a> <span class="divider">&gt;</span></li>
			<li class="active">Student</li>
		</ul>
	</div>
	
	<div class="container-fluid pathways-container">

		<h3><?=empty($student['root_id']) ? 'Add' : 'Modify'?> Student</h3>
		
		<form id="form" class="form-horizontal" method="post" enctype="multipart/form-data">
			<?php $attribute = 'root_id'; ?>
			<input type="hidden" name="student[<?=$attribute?>]" value="<?=h($student[$attribute])?>" />
			
			<div class="control-group">
				<?php $attribute = 'number'; $label = 'Student No. (Old System)'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php if (!empty($student['root_id'])): ?>
					<?php $attribute = 'registration_number'; $label = 'Registration #'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="" class="" style="margin-left:15px" readonly="readonly" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php endif; ?>
				</div>
			</div>

			<div class="control-group">
				<?php $attribute = 'data_input_date'; $label = 'Data Input Date'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<div class="input-append date-picker">
						<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
						<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
					</div>
					<?php $attribute = 'input_by'; $label = 'Input By'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="" class="" style="margin-left:15px" readonly="readonly" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<hr />

			<h5>Student Information</h5>
			
			<div class="row-fluid">
				<div class="span6">
					<div class="control-group">
						<?php $attribute = 'status'; $label = 'Status'; ?>
						<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
						<div class="controls">
							<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="required" placeholder="<?=h($label)?>">
								<option value=""></option>
								<?php foreach ($studentStatusOptions as $studentStatusValue => $studentStatusLabel): ?>
								<option value="<?=$studentStatusValue?>"<?=$studentStatusValue == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($studentStatusLabel)?></option>
								<?php endforeach; ?>
							</select>
						</div>
					</div>

					<div class="control-group">
						<?php $attribute = 'application_date'; $label = 'Application Date'; ?>
						<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
						<div class="controls">
							<div class="input-append date-picker">
								<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
								<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
							</div>
						</div>
					</div>

					<div class="control-group">
						<?php $attribute = 'registration_date'; $label = 'Registration Date'; ?>
						<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
						<div class="controls">
							<div class="input-append date-picker">
								<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
								<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
							</div>
						</div>
					</div>
					
					<div class="control-group">
						<?php $label = 'Type'; ?>
						<label class="control-label"><?=$label?></label>
						<div class="controls form-inline">
							<?php
							$tmp_attributes = array(
								'type_of_pathway_student' => 'Pathway Student',
								'type_of_in_school_student' => 'In-School Student',
							);
							?>
							<?php foreach ($tmp_attributes as $attribute => $label): ?>
							<input type="hidden" id="<?=$attribute?>" name="student[<?=$attribute?>]" value="<?=$student[$attribute] == 1 ? '1' : '0'?>" />
							<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student[$attribute] == 1 ? ' checked="checked"' : ''?> />
							<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
							<?php endforeach; ?>
						</div>
					</div>
			
					<div class="control-group">
						<?php $attribute = 'reg_campus_id'; $label = 'Registration Campus'; ?>
						<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
						<div class="controls form-inline">
							<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="required" placeholder="<?=h($label)?>">
								<option value=""></option>
								<?php foreach ($campuses as $campus): ?>
								<option value="<?=h($campus['id'])?>"<?=$campus['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($campus['name'])?></option>
								<?php endforeach; ?>
							</select>
						</div>
					</div>
					
					<div class="control-group">
						<?php $attribute = 'reg_sem_year'; $label = 'Registration Sem.'; ?>
						<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
						<div class="controls form-inline">
							<?php $tmp_year = date('Y'); ?>
							<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="required" placeholder="<?=h($label)?>">
								<option value=""></option>
								<?php for ($year = 2000; $year <= $tmp_year; $year++): ?>
								<?php $value = $year; $label = $year . ' - ' . ($year + 1); ?>
								<option value="<?=h($value)?>"<?=$value == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($label)?></option>
								<?php endfor; ?>
							</select>
						</div>
					</div>
				</div>
				<div class="span6">
					<?php $attribute = 'photo'; $label = 'Personal Photo'; $width = 150; $height = 200; ?>
					<div class="fileupload fileupload-<?=empty($student[$attribute]) ? 'new' : 'exists'?> text-center" data-provides="fileupload">
						<?php if (!empty($student[$attribute])): ?>
						<input type="hidden" name="student[<?=$attribute?>]" value="<?=h($student[$attribute])?>" />
						<?php endif; ?>
						<div class="fileupload-new thumbnail" style="width: <?=$width?>px; height: <?=$height?>px;">
							<img src="<?=Util::link(__DIR__ . '/../images/personal_photo.gif')?>" alt="<?=$label?>" style="width:100%; height:100%" />
						</div>
						<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: <?=$width?>px; max-height: <?=$height?>px; line-height: 20px;">
							<?php if (!empty($student[$attribute])): ?>
							<img src="<?=Util::link(__DIR__ . '/photos/' . $student[$attribute])?>" alt="<?=$label?>" style="max-height: <?=$height?>px;" />
							<?php endif; ?>
						</div>
						<div class="">
							<span class="btn btn-file">
								<span class="fileupload-new">Select image</span>
								<span class="fileupload-exists">Change</span>
								<input type="file" name="student[<?=$attribute?>]" />
							</span>
							<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
						</div>
					</div>
				</div>
			</div>

			<hr />
			
			<div class="control-group">
				<?php $attribute = 'last_name'; $label = 'Last Name'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="required" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'first_name'; $label = 'First Name'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="required" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'zh_name'; $label = '中文姓名'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'gender'; $label = 'Gender'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($genderOptions as $genderValue => $genderLabel): ?>
						<option value="<?=$genderValue?>"<?=$genderValue == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($genderLabel)?></option>
						<?php endforeach; ?>
					</select>
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'dob'; $label = 'Date of Birth'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<div class="input-append date-picker">
						<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
						<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
					</div>
					<?php if (!empty($student['dob'])): ?>
					<?php $attribute = 'age'; $label = 'Age'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="" class="" style="margin-left:15px" readonly="readonly" value="<?=h(Util::getAge($student['dob']))?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php endif; ?>
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'tel_home'; $label = 'Tel (Home)'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'fax'; $label = 'Fax'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'email'; $label = 'E-mail'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="input-xlarge email" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'address'; $label = 'Address'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="input-block-level" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'district_id'; $label = 'District'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($districts as $district): ?>
						<option value="<?=h($district['id'])?>"<?=$district['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($district['title'])?></option>
						<?php endforeach; ?>
					</select>
					<?php $attribute = 'area_id'; $label = 'Area'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($areas as $area): ?>
						<option value="<?=h($area['id'])?>"<?=$area['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($area['title'])?></option>
						<?php endforeach; ?>
					</select>
				</div>
			</div>
			
			<hr />
			
			<div class="control-group">
				<?php $attribute = 'school_name'; $label = 'Name of School Attending'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="input-xxlarge" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="400" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'student_grade_id'; $label = 'Year / Grade'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($student_grades as $student_grade): ?>
						<option value="<?=h($student_grade['id'])?>"<?=$student_grade['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($student_grade['title'])?></option>
						<?php endforeach; ?>
					</select>
				</div>
			</div>
			
			<hr />
			
			<h5>Father</h5>
			
			<div class="control-group">
				<?php $attribute = 'father_name'; $label = 'Name'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'father_occupation'; $label = 'Occupation'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'father_mobile'; $label = 'Mobile'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'father_tel_business'; $label = 'Tel (Business)'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<hr />
			
			<h5>Mother</h5>
			
			<div class="control-group">
				<?php $attribute = 'mother_name'; $label = 'Name'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'mother_occupation'; $label = 'Occupation'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'mother_mobile'; $label = 'Mobile'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'mother_tel_business'; $label = 'Tel (Business)'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<hr />
			
			<h5>Guardian</h5>
			
			<div class="control-group">
				<?php $attribute = 'guardian_name'; $label = 'Name'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'guardian_occupation'; $label = 'Occupation'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'guardian_relationship'; $label = 'Relationship'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'guardian_tel_home'; $label = 'Tel (Home)'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'guardian_mobile'; $label = 'Mobile'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'guardian_tel_business'; $label = 'Tel (Business)'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<hr />
			
			<h5>Emergency Contact Person</h5>
			
			<div class="control-group">
				<?php $attribute = 'emergency_contact_name'; $label = 'Name'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
					<?php $attribute = 'emergency_contact_number'; $label = 'Contact No.'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'emergency_contact_relationship'; $label = 'Relationship'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<hr />
			
			<div class="row-fluid">
				<div class="span6">
					<a href="#add_diagnose_modal" class="btn pull-right" role="button" data-toggle="modal"><i class="icon-plus"></i> Add Diagnose</a>
					<div id="add_diagnose_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="add_diagnose_modal_label" aria-hidden="true" data-keyboard="false">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h4 id="add_diagnose_modal_label">Diagnoses</h4>
						</div>
						<div class="modal-body">
							<ul class="unstyled form-inline">
								<?php foreach ($diagnoses as $diagnose): ?>
								<li>
									<input type="checkbox" id="diagnose_<?=$diagnose['id']?>" class="diagnose-checkbox" value="<?=h($diagnose['id'])?>" data-title="<?=h($diagnose['title'])?>" />
									<label for="diagnose_<?=$diagnose['id']?>"><?=h($diagnose['title'])?></label>
								</li>
								<?php endforeach; ?>
								<li>
									<label for="diagnose_others">Others</label>
									<input type="text" id="diagnose_others" value="" maxlength="200" />
								</li>
							</ul>
						</div>
						<div class="modal-footer">
							<button type="button" id="add_diagnose_confirm_btn" class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Confirm</button>
							<script type="text/javascript">
								$(function() {
									$('#add_diagnose_confirm_btn').click(function() {
										$('.diagnose-checkbox:checked').each(function(index, Element) {
											var $this = $(this);
											if ($('input[name="student[diagnoses][diagnose_id][]"][value="' + $this.val() + '"]', $('#form')).length == 0) {
												var $row = $(
														'<tr>' +
															'<td style="width:50px"><button type="button" class="btn diagnose-remove-btn"><i class="icon-remove"></i></button></td>' +
															'<td>' +
																$this.data('title') +
																'<input type="hidden" name="student[diagnoses][diagnose_id][]" value="' + $this.val() + '" />' +
															'</td>' +
														'</tr>');
												$row.appendTo($('#diagnose_tbody'));
											}
										});
										var others = $('#diagnose_others').val();
										if (others && others.length && others.length > 0) {
											var $row = $(
													'<tr>' +
														'<td style="width:50px"><button type="button" class="btn diagnose-remove-btn"><i class="icon-remove"></i></button></td>' +
														'<td>' +
															others +
															'<input type="hidden" name="student[diagnoses][others][]" value="' + others + '" />' +
														'</td>' +
													'</tr>');
											$row.appendTo($('#diagnose_tbody'));
										}
										
										$('.diagnose-checkbox:checked').prop('checked', false);
										$('#diagnose_others').val('');
										if ($.browser.msie) {
											$(window).resize(); // fix IE placeholder position
										}
									});
								});
							</script>
						</div>
					</div>
					<h5>Diagnoses</h5>
					<table class="table table-striped table-bordered table-hover table-condensed">
						<tbody id="diagnose_tbody">
							<?php foreach ($student['diagnoses'] ?: array() as $student_diagnose): ?>
							<tr>
								<td style="width:50px"><button type="button" class="btn diagnose-remove-btn"><i class="icon-remove"></i></button></td>
								<td>
									<?php if (!empty($student_diagnose['others'])): ?>
									<?=h($student_diagnose['others'])?>
									<input type="hidden" name="student[diagnoses][others][]" value="<?=h($student_diagnose['others'])?>" />
									<?php else: ?>
									<?=h($diagnose_map[$student_diagnose['diagnose_id']]['title'])?>
									<input type="hidden" name="student[diagnoses][diagnose_id][]" value="<?=h($student_diagnose['diagnose_id'])?>" />
									<?php endif; ?>
								</td>
							</tr>
							<?php endforeach; ?>
						</tbody>
					</table>
				</div>
				<div class="span6">
					<a href="#add_additional_aspect_modal" class="btn pull-right" role="button" data-toggle="modal"><i class="icon-plus"></i> Add Additional Aspect</a>
					<div id="add_additional_aspect_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="add_additional_aspect_modal_label" aria-hidden="true" data-keyboard="false">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h4 id="add_additional_aspect_modal_label">Additional Aspects</h4>
						</div>
						<div class="modal-body">
							<ul class="unstyled form-inline">
								<?php foreach ($additional_aspects as $additional_aspect): ?>
								<li>
									<input type="checkbox" id="additional_aspect_<?=$additional_aspect['id']?>" class="additional-aspect-checkbox" value="<?=h($additional_aspect['id'])?>" data-title="<?=h($additional_aspect['title'])?>" />
									<label for="additional_aspect_<?=$additional_aspect['id']?>"><?=h($additional_aspect['title'])?></label>
								</li>
								<?php endforeach; ?>
								<li>
									<label for="additional_aspect_others">Others</label>
									<input type="text" id="additional_aspect_others" value="" maxlength="200" />
								</li>
							</ul>
						</div>
						<div class="modal-footer">
							<button type="button" id="add_additional_aspect_confirm_btn" class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Confirm</button>
							<script type="text/javascript">
								$(function() {
									$('#add_additional_aspect_confirm_btn').click(function() {
										$('.additional-aspect-checkbox:checked').each(function(index, Element) {
											var $this = $(this);
											if ($('input[name="student[additional_aspects][additional_aspect_id][]"][value="' + $this.val() + '"]', $('#form')).length == 0) {
												var $row = $(
														'<tr>' +
															'<td style="width:50px"><button type="button" class="btn additional-aspect-remove-btn"><i class="icon-remove"></i></button></td>' +
															'<td>' +
																$this.data('title') +
																'<input type="hidden" name="student[additional_aspects][additional_aspect_id][]" value="' + $this.val() + '" />' +
															'</td>' +
														'</tr>');
												$row.appendTo($('#additional_aspect_tbody'));
											}
										});
										var others = $('#additional_aspect_others').val();
										if (others && others.length && others.length > 0) {
											var $row = $(
													'<tr>' +
														'<td style="width:50px"><button type="button" class="btn additional-aspect-remove-btn"><i class="icon-remove"></i></button></td>' +
														'<td>' +
															others +
															'<input type="hidden" name="student[additional_aspects][others][]" value="' + others + '" />' +
														'</td>' +
													'</tr>');
											$row.appendTo($('#additional_aspect_tbody'));
										}
										
										$('.additional-aspect-checkbox:checked').prop('checked', false);
										$('#additional_aspect_others').val('');
										if ($.browser.msie) {
											$(window).resize(); // fix IE placeholder position
										}
									});
								});
							</script>
						</div>
					</div>
					<h5>Additional Aspect</h5>
					<table class="table table-striped table-bordered table-hover table-condensed">
						<tbody id="additional_aspect_tbody">
							<?php foreach ($student['additional_aspects'] ?: array() as $student_additional_aspect): ?>
							<tr>
								<td style="width:50px"><button type="button" class="btn additional-aspect-remove-btn"><i class="icon-remove"></i></button></td>
								<td>
									<?php if (!empty($student_additional_aspect['others'])): ?>
									<?=h($student_additional_aspect['others'])?>
									<input type="hidden" name="student[additional_aspects][others][]" value="<?=h($student_additional_aspect['others'])?>" />
									<?php else: ?>
									<?=h($additional_aspect_map[$student_additional_aspect['additional_aspect_id']]['title'])?>
									<input type="hidden" name="student[additional_aspects][additional_aspect_id][]" value="<?=h($student_additional_aspect['additional_aspect_id'])?>" />
									<?php endif; ?>
								</td>
							</tr>
							<?php endforeach; ?>
						</tbody>
					</table>
				</div>
			</div>
			<script type="text/javascript">
				$(function() {
					$(document).on('click', '.additional-aspect-remove-btn, .diagnose-remove-btn', function() {
						var $this = $(this), $e = $this.parent();
						while ($e.prop('tagName').toLowerCase() != 'tr') {
							$e = $e.parent();
						}
						$e.remove();
						if ($.browser.msie) {
							$(window).resize(); // fix IE placeholder position
						}
					});
				});
			</script>
			
			<div class="control-group">
				<?php $attribute = 'refer_by_assessor_id'; $label = 'Refer By'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($assessors as $assessor): ?>
						<option value="<?=h($assessor['id'])?>"<?=$assessor['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($assessor['title'])?></option>
						<?php endforeach; ?>
					</select>
					<?php $attribute = 'other_refer_by'; $label = 'Others'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'assessed_by_assessor_id'; $label = 'Assessed By'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls form-inline">
					<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($assessors as $assessor): ?>
						<option value="<?=h($assessor['id'])?>"<?=$assessor['id'] == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($assessor['title'])?></option>
						<?php endforeach; ?>
					</select>
					<?php $attribute = 'other_assessed_by'; $label = 'Others'; ?>
					<label class="control-label" style="float:none" for="<?=$attribute?>"><?=$label?></label>
					<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" style="margin-left:15px" value="<?=h($student[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" />
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'others'; $label = 'Others'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls">
					<textarea id="<?=$attribute?>" name="student[<?=$attribute?>]" class="input-block-level" rows="3" placeholder="<?=h($label)?>"><?=h($student[$attribute])?></textarea>
				</div>
			</div>
			
			<div class="control-group">
				<?php $attribute = 'medication'; $label = 'Medication'; ?>
				<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
				<div class="controls">
					<textarea id="<?=$attribute?>" name="student[<?=$attribute?>]" class="input-block-level" rows="3" placeholder="<?=h($label)?>"><?=h($student[$attribute])?></textarea>
				</div>
			</div>
			
			<?php if (!empty($student['root_id'])): ?>
			<hr />
			
			<h5>Waiting For Assessment</h5>
			<div>
				<?php if (empty($student['waiting_lists'])): ?>
				There are no records.
				<?php else: ?>
				<table class="table table-striped table-bordered table-hover table-condensed">
					<thead>
						<tr>
							<th>Code</th>
							<th>Program</th>
							<th>Subject</th>
							<th>Start Date</th>
							<th>End Date</th>
							<th>Teacher</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($student['waiting_lists'] ?: array() as $waiting_list): ?>
						<tr>
							<td><?=h($waiting_list['event_code'])?></td>
							<td><?=h($waiting_list['program_code'])?></td>
							<td><?=h($waiting_list['subject_code'])?></td>
							<td><?=h($waiting_list['start_date'])?></td>
							<td><?=h($waiting_list['end_date'])?></td>
							<td><?=h($waiting_list['teacher'])?></td>
						</tr>
						<?php endforeach; ?>
					</tbody>
				</table>
				<?php endif; ?>
			</div>
			<?php endif; ?>
			
			<hr />
			
			<h5>Assessment Result</h5>
			
			<div class="accordion" id="assessment_zh_accordion">
				<div class="accordion-group">
					<div class="accordion-heading">
						<a class="accordion-toggle" data-toggle="collapse" data-parent="#assessment_zh_accordion" href="#assessment_zh_collapse">
							中文評估結果 <span class="pull-right dropdown"><i class="caret"></i></span>
						</a>
					</div>
					<div id="assessment_zh_collapse" class="accordion-body collapse">
						<div class="accordion-inner">
							<div class="control-group">
								<?php $attribute = 'zh_assessment_date'; $label = 'Assessment Date'; ?>
								<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
								<div class="controls">
									<div class="input-append date-picker">
										<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
										<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
									</div>
								</div>
							</div>
							
							<?php
							$column_1s = array();
							foreach ($zh_assessment_columns as $column) {
								$column_1 = $column['column_1'];
								if (!in_array($column_1, $column_1s)) {
									$column_1s[] = $column_1;
								}
							}
							
							foreach ($column_1s as $column_1):
								$hide_column_2 = true;
								foreach ($zh_assessment_columns as $column) {
									if ($column['column_1'] == $column_1 && !empty($column['column_2'])) {
										$hide_column_2 = false;
										break;
									}
								}
							?>
							<table class="table table-striped table-bordered table-hover table-condensed">
								<caption class="text-left"><?=h($column_1)?></caption>
								<thead>
									<tr>
										<th style="min-width:150px; width:150px">
											<?php if (!$hide_column_2): ?>
											測試範疇
											<?php endif; ?>
										</th>
										<th style="min-width:300px; width:300px">題目類型</th>
										<th>測試結果</th>
									</tr>
								</thead>
								<tbody>
							<?php
								foreach ($zh_assessment_columns as $column):
									if ($column['column_1'] == $column_1):
										$student_assessment = getStudentAssessment($student, 'zh_assessments', $column['column_3_id']);
							?>
									<tr>
										<td>
											<?php if (!$hide_column_2): ?>
											<?=h($column['column_2'] != $column_2 ? $column_2 = $column['column_2'] : '')?>
											<?php endif; ?>
										</td>
										<td><?=h($column['column_3'])?></td>
										<td>
											<input type="hidden" name="student[zh_assessments][<?=h($column['column_3_id'])?>][subject_id]" value="<?=h($column['column_3_id'])?>" />
											<input type="text" id="zh_assessment_<?=h($column['column_3_id'])?>"
												   name="student[zh_assessments][<?=h($column['column_3_id'])?>][answer]"
												   class="input-<?=empty($column['remarks']) ? 'small' : 'normal' ?>"
												   value="<?=h($student_assessment['answer'])?>" maxlength="200" autocomplete="off" />
											<script type="text/javascript">
												$(function() {
													var selector = '#zh_assessment_<?=h($column['column_3_id'])?>',
														$selector = $(selector);
											<?php if (empty($column['remarks'])): ?>
													$selector.popover({
														trigger: 'focus',
														delay: { show: 200, hide: 0 },
														title: 'Sample',
														content: '5/10'
													});
											<?php else: ?>
													$selector.typeahead({
														source: <?=json_encode(explode('", "', $column['remarks']))?>,
														minLength: 0
													});
													$selector.popover({
														trigger: 'focus',
														delay: { show: 200, hide: 0 },
														title: 'Note',
														content: 'Remove all content and click again to show selection.'
													});
													$(document).on('focus click', selector, function(event) {
														var query = $selector.val();
														if (query.length == 0) {
															setTimeout($selector.typeahead.bind($selector, 'customLookup'), 200);
															event.preventDefault();
														}
													});
											<?php endif; ?>
												});
											</script>
										</td>
									</tr>
							<?php
									endif;
								endforeach;
							?>
								</tbody>
							</table>
							<?php
							endforeach;
							?>
						</div>
					</div>
				</div>
			</div>
			
			<div class="accordion" id="assessment_en_accordion">
				<div class="accordion-group">
					<div class="accordion-heading">
						<a class="accordion-toggle" data-toggle="collapse" data-parent="#assessment_en_accordion" href="#assessment_en_collapse">
							English Assessment Result <span class="pull-right dropdown"><i class="caret"></i></span>
						</a>
					</div>
					<div id="assessment_en_collapse" class="accordion-body collapse">
						<div class="accordion-inner">
							<div class="control-group">
								<?php $attribute = 'en_assessment_date'; $label = 'Assessment Date'; ?>
								<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
								<div class="controls">
									<div class="input-append date-picker">
										<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
										<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
									</div>
								</div>
							</div>
							
							<table class="table table-striped table-bordered table-hover table-condensed">
								<caption class="text-left">English Assessment Result</caption>
								<thead>
									<tr>
										<th style="min-width:250px; width:250px">Scope</th>
										<th>Result</th>
									</tr>
								</thead>
								<tbody class="form-inline">
									<tr>
										<td>Listening</td>
										<td>
											<?php $attribute = 'en_assessment_listening_lc'; $label = 'LC'; $subject_id = '1'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<label class="" for="<?=$attribute?>"><?=$label?></label>
											<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-small" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
											
											<?php $attribute = 'en_assessment_listening_independent'; $label = 'Independent'; $subject_id = '2'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_listening_instructional'; $label = 'Instructional'; $subject_id = '3'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_listening_frustration'; $label = 'Frustration'; $subject_id = '4'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
										</td>
									</tr>
									<tr>
										<td>Speaking</td>
										<td>
											<?php $attribute = 'en_assessment_speaking_native'; $label = 'Native'; $subject_id = '5'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_speaking_medium'; $label = 'Medium'; $subject_id = '6'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_speaking_low'; $label = 'Low'; $subject_id = '7'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_speaking_pp'; $label = 'PP'; $subject_id = '8'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
										</td>
									</tr>
									<tr>
										<td>Grapheme to Phoneme Awareness</td>
										<td>
											<?php $attribute = 'en_assessment_grapheme_substitution'; $label = 'Substitution'; $subject_id = '9'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_grapheme_segmentations'; $label = 'Segmentations'; $subject_id = '10'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_grapheme_blending'; $label = 'Blending'; $subject_id = '11'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_grapheme_i_m_e_sounds'; $label = 'Init/Mid/End Sounds'; $subject_id = '12'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
										</td>
									</tr>
									<tr>
										<td>Phonemic Awareness</td>
										<td>
											<table>
												<tr>
													<td>
														<?php $attribute = 'en_assessment_phonemic_d_r_controlled'; $label = 'Diphthings + r-controlled'; $subject_id = '13'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
													<td>
														<?php $attribute = 'en_assessment_phonemic_l_vowels'; $label = 'Long vowels'; $subject_id = '14'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
												</tr>
												<tr>
													<td>
														<?php $attribute = 'en_assessment_phonemic_c_b_digraphs'; $label = 'Cononant blends + digraphs'; $subject_id = '15'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
													<td>
														<?php $attribute = 'en_assessment_phonemic_26_l_sounds'; $label = '26 letter sounds'; $subject_id = '16'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>Dictation</td>
										<td>
											<?php $attribute = 'en_assessment_dictation_advanced'; $label = 'Advanced'; $subject_id = '17'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_dictation_high'; $label = 'High'; $subject_id = '18'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_dictation_medium'; $label = 'Medium'; $subject_id = '19'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_dictation_low'; $label = 'Low'; $subject_id = '20'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_dictation_pp'; $label = 'PP'; $subject_id = '21'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
										</td>
									</tr>
									<tr>
										<td><?=h('Reading Aloud & Comprehension')?></td>
										<td>
											<?php $attribute = 'en_assessment_reading_rc'; $label = 'RC'; $subject_id = '22'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<label class="" for="<?=$attribute?>"><?=$label?></label>
											<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-small" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
											
											<?php $attribute = 'en_assessment_reading_independent'; $label = 'Independent'; $subject_id = '23'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_reading_instructional'; $label = 'Instructional'; $subject_id = '24'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_reading_frustration'; $label = 'Frustration'; $subject_id = '25'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
										</td>
									</tr>
									<tr>
										<td>Word decoding</td>
										<td>
											<table>
												<tr>
													<td>
														<?php $attribute = 'en_assessment_word_s_words'; $label = 'Sight words'; $subject_id = '26'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
													<td>
														<?php $attribute = 'en_assessment_word_s_words_level'; $label = 'Level'; $subject_id = '27'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<label class="" for="<?=$attribute?>"><?=$label?></label>
														<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-mini" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
														,

														<?php $attribute = 'en_assessment_word_s_words_percent'; $label = '%'; $subject_id = '28'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-super-mini" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
														<label class="" for="<?=$attribute?>"><?=$label?></label>
													</td>
												</tr>
												<tr>
													<td>
														<?php $attribute = 'en_assessment_word_ks_words'; $label = 'KS words'; $subject_id = '29'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
														<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
														<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
													</td>
													<td>
														<?php $attribute = 'en_assessment_word_ks_words_level'; $label = 'Level'; $subject_id = '30'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<label class="" for="<?=$attribute?>"><?=$label?></label>
														<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-mini" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
														,

														<?php $attribute = 'en_assessment_word_ks_words_percent'; $label = '%'; $subject_id = '31'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
														<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
														<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-super-mini" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
														<label class="" for="<?=$attribute?>"><?=$label?></label>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>Attitude</td>
										<td>
											<?php $attribute = 'en_assessment_attitude_motivated'; $label = 'Motivated'; $subject_id = '32'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_attitude_reluctant'; $label = 'Reluctant'; $subject_id = '33'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_attitude_attention'; $label = 'Attention'; $subject_id = '34'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<input type="hidden" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" value="<?=$student_assessment['answer'] == 1 ? '1' : '0'?>" />
											<input type="checkbox" id="checkbox_<?=$attribute?>" class="checkbox-hidden-value" data-id="<?=$attribute?>" value="1"<?=$student_assessment['answer'] == 1 ? ' checked="checked"' : ''?> />
											<label for="checkbox_<?=$attribute?>"><?=h($label)?></label>
											
											<?php $attribute = 'en_assessment_attitude_span'; $label = 'span'; $subject_id = '35'; $student_assessment = getStudentAssessment($student, 'en_assessments', $subject_id); ?>
											<input type="hidden" name="student[en_assessments][<?=h($subject_id)?>][subject_id]" value="<?=h($subject_id)?>" />
											<label class="" for="<?=$attribute?>"><?=$label?></label>
											<input type="text" id="<?=$attribute?>" name="student[en_assessments][<?=h($subject_id)?>][answer]" class="input-super-mini" value="<?=h($student_assessment['answer'])?>" placeholder="<?=h($label)?>" maxlength="200" />
											mins
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
			
			<div class="accordion" id="assessment_math_accordion">
				<div class="accordion-group">
					<div class="accordion-heading">
						<a class="accordion-toggle" data-toggle="collapse" data-parent="#assessment_math_accordion" href="#assessment_math_collapse">
							Maths Assessment Result <span class="pull-right dropdown"><i class="caret"></i></span>
						</a>
					</div>
					<div id="assessment_math_collapse" class="accordion-body collapse">
						<div class="accordion-inner">
							<div class="control-group">
								<?php $attribute = 'math_assessment_date'; $label = 'Assessment Date'; ?>
								<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
								<div class="controls">
									<div class="input-append date-picker">
										<input type="text" id="<?=$attribute?>" name="student[<?=$attribute?>]" class="dateISO" value="<?=h(Util::value_to_date_string($student[$attribute]))?>" data-format="yyyy-MM-dd" placeholder="<?=h($label)?>" maxlength="200" />
										<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
									</div>
								</div>
							</div>
							
							<!-- TODO: Maths Assessment Result -->
							Details to be adviced
						</div>
					</div>
				</div>
			</div>
			
			<?php if (!empty($student['root_id'])): ?>
			<hr />
			
			<h5>Allocated Classes</h5>
			<div>
				<?php if (empty($student['allocated_classes'])): ?>
				There are no records.
				<?php else: ?>
				<table class="table table-striped table-bordered table-hover table-condensed">
					<thead>
						<tr>
							<th>Event Code</th>
							<th>Program</th>
							<th>Subject</th>
							<th>Start Date</th>
							<th>End Date</th>
							<th>Teacher</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($student['allocated_classes'] ?: array() as $allocated_class): ?>
						<tr>
							<td><?=h($allocated_class['event_code'])?></td>
							<td><?=h($allocated_class['program_code'])?></td>
							<td><?=h($allocated_class['subject_code'])?></td>
							<td><?=h($allocated_class['start_date'])?></td>
							<td><?=h($allocated_class['end_date'])?></td>
							<td><?=h($allocated_class['teacher'])?></td>
						</tr>
						<?php endforeach; ?>
					</tbody>
				</table>
				<?php endif; ?>
			</div>
			<?php endif; ?>
			
			<hr />
			
			<h5>Subsidy</h5>
			
			<div>
				<?php $attribute = 'subsidy'; ?>
				<select id="<?=$attribute?>" name="student[<?=$attribute?>]" class="" placeholder="<?=h($label)?>">
					<!-- <option value=""></option> -->
					<?php foreach (Subsidy::typeOptions() as $typeValue => $typeLabel): ?>
					<option value="<?=h($typeValue)?>"<?=$typeValue == $student[$attribute] ? ' selected="selected"' : ''?>><?=h($typeLabel)?></option>
					<?php endforeach; ?>
				</select>
				<script type="text/javascript">
					$(function() {
						var changeFunc = function() {
								var $subsidy = $('#subsidy'),
									$subsidy_ul = $('#subsidy_ul');
								$('li', $subsidy_ul).addClass('hide');
								$('li[data-type="' + $subsidy.val() + '"]', $subsidy_ul).removeClass('hide');
								calculateSubsidyTotalPercent();
							};
						$('#subsidy').change(changeFunc);
						changeFunc();
					});
				</script>
				
				<input type="text" id="subsidy_total_percent" class="input-small" value="Calculating..." readonly="readonly" />
				<script type="text/javascript">
					function calculateSubsidyTotalPercent() {
						var subsidy = $('#subsidy').val(),
								$subsidy_ul = $('#subsidy_ul'),
								total = 0.0;
						$('input.subsidy-checkbox[data-type="' + subsidy + '"]:checked', $subsidy_ul).each(function(index, Element) {
							var value = $(this).data('percent');
							value = parseFloat(value);
							if (isNaN(value)) {
								value = 0;
							}
							total += value;
						});
						$('#subsidy_total_percent').val(total + '%');
					}
				</script>
				
				<ul id="subsidy_ul" class="unstyled form-inline">
				<?php foreach (Subsidy::typeOptions() as $typeValue => $typeLabel): ?>
					<?php foreach ($subsidies[$typeValue] ?: array() as $subsidy): ?>
						<?php
						$tmp_hide = $student['subsidy'] != $typeValue;
						$tmp_checked = false;
						foreach ($student['subsidies'] ?: array() as $student_subsidy) {
							if ($student_subsidy['subsidy_id'] == $subsidy['id']) {
								$tmp_checked = true;
								break;
							}
						}
						?>
					<li class="<?=$tmp_hide ? 'hide' : '' ?>" data-type="<?=$subsidy['type']?>">
						<input type="checkbox" id="subsidy_<?=$subsidy['id']?>" name="student[subsidies][]" value="<?=$subsidy['id']?>"
							   class="subsidy-checkbox"
							   data-type="<?=$subsidy['type']?>"
							   data-percent="<?=$subsidy['percent']?>"
							   <?=$tmp_checked ? ' checked="checked"' : ''?>
							   />
						<label class="" style="" for="subsidy_<?=$subsidy['id']?>">
							<?=$subsidy['title']?> - <?=$subsidy['percent']?>%
						</label>
					</li>
					<?php endforeach; ?>
				<?php endforeach; ?>
				</ul>
				<script type="text/javascript">
					$(function() {
						$(document).on('change', 'input.subsidy-checkbox', function() {
							calculateSubsidyTotalPercent();
						});
					});
				</script>
			</div>
			
			<div class="control-group">
				<button type="submit" class="btn btn-danger">Save</button>
				<div class="controls">
				</div>
			</div>
		</form>
		
		<script type="text/javascript">
			$(function() {
				$('.date-picker').datetimepicker({ pickTime: false });
				$('#form').validate();
				$('.checkbox-hidden-value').change(function() {
					var $this = $(this),
						checked = $this.prop('checked'),
						id = $this.data('id'),
						$target = $('#'+id, $this.parent());
					$target.val(checked ? '1' : '0');
				});
			});
		</script>
	
		<?php require( __DIR__ . '/../inc/_footer.php'); ?>

	</div> <!-- /container -->
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit