<?php
/**
 * school_input_view.php - school and school_type input view.
 *
 * @author $Author: suppakit $
 * @version $Id: school_input_view.php,v 1.4 2011/03/11 10:35:57 suppakit Exp $
 * @copyright Copyright (c) 2011, Tiller Software Co., Ltd.
*/
	$baseurl_page = base_url() . $page;
	$refresh_link = $baseurl_page . '/index/' . $table ;

	$result = new stdClass();
	$mode = CMS_ADMIN_UPDATE;
	if ( $action == CMS_ACTION_ADD ){
		$result->id = '';
		$result->shortname = '';
		$result->name = '';
		$result->type = '';
		$mode = CMS_ADMIN_INSERT;
	}
	else if ( $action == CMS_ACTION_EDIT ){
		if ( isset($school_data) == FALSE || count ($school_data) == 0 ) {
			echo lang('admin_school_error_nodata');
			return;
		}
		$result = $school_data[0];
	}
	else {
		return;
	}
	$mode = $baseurl_page . '/' . $mode . '/' . $table;

	if ( $table == 1 ) {
		$column_name = lang('admin_school_column_name');
		$column_shortname = lang('admin_school_column_shortname');
	}
	else if ( $table == 2 ) {
		$column_name = lang('admin_school_type_column_name');
		$column_shortname = lang('admin_school_type_column_shortname');
		$refresh_link = $baseurl_page . '/index/' . $table . '/' . $type;
	}
?>
<style type="text/css">
p {
	font-size: 11px;
}
</style>
<div style="text-align: center;">
<form method="POST" action= "<?php echo $mode; ?>" name="school_form" >
<?php
	echo form_hidden('id', $result->id);
	if ( $table == 2 && is_numeric($type) ) {
		echo form_hidden('type', $type);
	}
?>
	<div class="school_title"><?php echo $selected_title?></div>
	<div class="school_table">
		<div id="school_name">
			<table class="school_table_edit" >
				<tr >
					<td class="field_req" ><?php echo $column_name?></td>
					<td class="school_text_left" >
					<?php
						$schoolname_array = array('id' => 'name', 'name' => 'name' , 'size' => '30', 'value' => $result->name );
						echo form_input($schoolname_array);
					?>
					</td>
				</tr>
			</table>
		</div>

		<div id="school_shortname">
			<table class="school_table_edit" >
				<tr >
					<td class="field_req" ><?php echo $column_shortname?></td>
					<td class="school_text_left" >
					<?php
						$schoolname_array = array('id' => 'shortname', 'name' => 'shortname' , 'size' => '5', 'value' => $result->shortname );
						echo form_input($schoolname_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>
	<div class="reswin_buttons">
		<input type="button" value="<?php echo lang('admin_btn_cancel'); ?>" name="cancel" <?php osa_btn()?> onClick="cancelDhtml('school_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; ?>','school_form','<?php echo $refresh_link; ?>','page_content','school_input'); return false;" />
	</div>
</form>
</div>