<?php
/**
 * grade_input_view.php - add/edit grade form
 *
 * @author $Author: wichai $
 * @version $Id: grade_input_view.php,v 1.3 2011/03/01 10:04:22 wichai Exp $
 * @copyright Copyright (c) 2011, Tiller Software Co., Ltd.
*/
	$baseurl_page = base_url() . $page;
	$refresh_link = $baseurl_page . '/index/';

	$result = new stdClass();
	$mode = CMS_ADMIN_UPDATE;
	if ( $action == CMS_ACTION_ADD ){
		$result->id = '';
		$result->name = '';
		$result->sort = $selected_sort;
		$result->schoolid = '';
		$mode = CMS_ADMIN_INSERT;
	}
	else if ( $action == CMS_ACTION_EDIT ){
		if ( isset($grade_data) == FALSE || count ($grade_data) == 0 ) {
			echo lang('admin_grade_error_nograde_data');
			return;
		}
		$result = $grade_data[0];
	}
	else {
		return;
	}
	$mode = $baseurl_page . '/' . $mode;
?>
<div style="text-align: center;">
<form method="POST" action= "<?php echo $mode; ?>" name="grade_form" >
<?php	echo form_hidden('id', $result->id); ?>
	<div class="grade_title"><?php echo $selected_title; ?></div>
	<div class="grade_table">
		<div id="grade_name">
			<table class="grade_table_edit" >
				<tr >
					<td class="grade_field_required" ><?php echo lang('admin_grade_column_name'); ?></td>
					<td class="grade_text_left" >
					<?php
						$gradename_array = array('id' => 'name', 'name' => 'name' , 'size' => '30', 'value' => $result->name );
						echo form_input($gradename_array);
					?>
					</td>
				</tr>
			</table>
		</div>
		<div id="grade_school">
			<table class="grade_table_edit" >
				<tr >
					<td class="grade_field_required" ><?php echo lang('admin_grade_column_school'); ?></td>
					<td class="grade_text_left" >
					<?php
						echo form_dropdown('schoolid', $all_schools, $default_dropdown);
					?>
					</td>
				</tr>
			</table>
		</div>
		<div id="grade_sort">
			<table class="grade_table_edit" >
				<tr >
					<td class="grade_field_required" ><?php echo lang('admin_grade_column_sort'); ?></td>
					<td class="grade_text_left" >
					<?php
						$gradesort_array = array('id' => 'sort', 'name' => 'sort' , 'size' => '3', 'value' => $result->sort );
						echo form_input($gradesort_array);
					?>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<span class="admin_req" style="color:red"><?php echo lang('admin_red'); ?></span>
	<span class="admin_req"><?php echo lang('admin_req'); ?></span>
	<center><div style="width:85%;font-size:10px"><?php echo lang('admin_grade_sort_desscription')?></div></center>
	<br />
	<div class="reswin_buttons">
		<input type="button" value="<?php echo lang('admin_btn_cancel'); ?>" name="cancel" <?php osa_btn()?> onClick="cancelDhtml('grade_input'); return false;" />
		<span style="margin-left:30px">&nbsp;</span>
		<input type="button" value="<?php echo lang('admin_btn_save'); ?>" name="save" <?php osa_btn()?> onClick="submitDhtml('<?php echo $mode; ?>','grade_form','<?php echo $refresh_link; ?>','page_content','grade_input'); return false;" />
	</div>
</form>
</div>