<?php
 	/**
 * course_input_view.php - course Edit file
 *
 * @author $Author: dtong $
 * @version $Id: course_input_view.php,v 1.18 2011/04/27 05:46:26 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/

	$href = base_url();
	$refresh = base_url().$page.'/refresh/'.$selectlistitem.'/'.$filter;
	$page = base_url().$page;
	//$imgreq = 'req.gif';
	//$img_req = "<img src=". osa_imagepath() . "$imgreq    title='Required field'   alt='Required field'    border='0' >";
	$img_req = '';

   $mode = CMS_ADMIN_UPDATE;
 	if ($action==CMS_ACTION_ADD) {
 		$row->id = '';
 		$row->sis_course_number = '';
 		$row->sis_course_dbid = '';
 		$row->name = '';
 		$row->shortname = '';
 		$row->url_key = '';
 		$row->description = '';
 		$row->autogen = '';
 		$row->enabled = 1;
 		$row->tree_sort = 100;
 	 	$mode = CMS_ADMIN_INSERT;
 	}
 	elseif ($action==CMS_ACTION_EDIT) {
 		if ( isset($data)==FALSE || count($data) == 0 )  {
			echo lang('admin_course_error_nodata');
			return;
		}
		$row  = $data[0];
 	}
 	else {
 		return;
 	}
 		$mode = $page.'/'.$mode;
?>
<form method="POST"  name="course_form">
<input type="hidden" id="id" name="id" size="30" value="<?php echo $row->id?>" />
<center>
<div class="user_title"><?php echo $selected_display; ?></div>
<div class="course_table">


<div id="name">
	<table class="course_table_edit">
	<tr >
		<td class="field_req"><?php echo lang('admin_course_col_name'); ?><?php echo $img_req; ?></td>
		<td class="course_text_left"><input type="text" id="name" name="name" size="40" value="<?php   echo $row->name; ?>" />
	</tr>
	</table>
</div>

<div id="shortname">
	<table class="course_table_edit">
	<tr >
		<td class="course_edit_left"><?php echo lang('admin_course_col_shortname'); ?></td>
		<td class="course_text_left"><input type="text" id="shortname" name="shortname" size="40" value="<?php   echo $row->shortname; ?>" />
	</tr>
	</table>
</div>

<div id="department">
	<table class="course_table_edit">
	<tr >
	<td class="field_req"><?php echo lang('admin_course_col_department'); ?><?php echo $img_req; ?></td>
	<td class="course_text_left">
 	<?php
    	echo form_dropdown("departmentid", $department, $selected_dep, "size=1 style=width:50%");
	?>
	</td>
	</tr>
	</table>
</div>

<div id="sis_course_number">
	<table class="course_table_edit">
	<tr >
	<td class="course_edit_left"><?php echo lang('admin_course_col_course_number'); ?></td>
	<td class="course_text_left"><input type="text" id="sis_course_number" name="sis_course_number" size="30" value="<?php   echo $row->sis_course_number; ?>" />
	</tr>
	</table>
</div>

<div id="mingradeid">
	<table class="course_table_edit">
	<tr >
	<td class="field_req"><?php echo lang('admin_course_col_mingrade'); ?><?php echo $img_req; ?></td>
	<td class="course_text_left">
 	<?php
    	echo form_dropdown("mingradeid", $grade, $selected_grade_min, "size=1 style=width:50%");
	?>
	</td>
	</tr>
	</table>
</div>

<div id="maxgradeid">
	<table class="course_table_edit">
	<tr >
	<td class="field_req"><?php echo lang('admin_course_col_maxgrad'); ?><?php echo $img_req; ?></td>
	<td class="course_text_left">
 	<?php
    	echo form_dropdown("maxgradeid", $grade, $selected_grade_max, "size=1 style=width:50%");
	?>
	</td>
	</tr>
	</table>
</div>

<div id="description">
	<table class="course_table_edit">
	<tr >
	<td class="course_edit_left"><?php echo lang('admin_course_col_description'); ?></td>
	<td class="course_text_left"><TEXTAREA id="description"  NAME="description" COLS='50' ROWS='8' ><?php   echo $row->description; ?></TEXTAREA>
	</td>
	</tr>
	</table>
</div>

<div id="enabled">
	<?php
		$checked = '';
		if ($row->enabled == '1')
			$checked = 'checked="checked"';
	?>
	<table class="course_table_edit">
	<tr >
	<td class="course_edit_left"><?php echo lang('admin_course_col_enabled'); ?></td>
	<td class="course_text_left"><input type="checkbox"  name="enabled" <?php echo $checked; ?>  /></td>
	</tr>
	</table>
</div>

<div id="advance" style="visibility:hidden; display:none; ">
	<?php
		$checked = '';
		if ($row->autogen == '1')
			$checked = 'checked="checked"';
	?>
	<table class="course_table_edit">
	<tr>
	<td class="course_edit_left"><?php echo lang('admin_course_col_tree_sort'); ?></td>
	<td class="course_text_left">
		<div id="hide_name">
			<input type="text" id="tree_sort" name="tree_sort" size="5" value="<?php echo $row->tree_sort?>" /></div>
	</td>
	</tr>
	<tr>
	<td class="course_edit_left"><?php echo lang('admin_course_col_course_dbid'); ?></td>
	<td class="course_text_left"><div id="hide_name"><input type="text" id="sis_course_dbid" name="sis_course_dbid" size="30" value="<?php   echo $row->sis_course_dbid; ?>" /></div></td>
	</tr>
	<tr >
	<td class="course_edit_left"><?php echo lang('admin_course_col_autogen'); ?></td>
	<td class="course_text_left">
		<table cellspacing="0" cellpadding="0">
		<tr><td>
			<input type="checkbox"  name="autogen" <?php echo $checked; ?>  /></td>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
				<?php echo lang('admin_course_remark_autogen'); ?>
		</td></tr>
		</table>
	</td>
	</tr>
	</table>
</div>

<div id="button">
	<?php
	    $jscript_show = "onClick=\"display(true, 'button_show','button_hide','advance');return false; \"";
	    $jscript_hide = "onClick=\"display(false,'button_show','button_hide','advance');return false; \"";
	?>
	<table class="course_table_edit">
	<tr >
	<td class="course_edit_left">&nbsp;</td>
	<td class="course_text_left">
	<div id="button_show"  style="visibility:visible; ">
		<input type="button" value="<?php echo lang('admin_course_btn_Advances_show'); ?>" name="advance" <?php osa_btn()?>
	 	<?php  echo $jscript_show; ?>  />
 	</div>
 	<div id="button_hide" style="visibility:hidden; display:none; ">
		<input type="button" value="<?php echo lang('admin_course_btn_Advances_hide'); ?>" name="advance" <?php osa_btn()?>
	 	<?php  echo $jscript_hide; ?>  />
	</div>
	</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 class="reswin_buttons">
<input type="button" value="<?php echo lang('admin_btn_cancel'); ?>" name="cancel" <?php osa_btn()?>
	   onClick="cancelDhtml('course_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; ?>','course_form',
               '<?php echo $refresh; ?>','page_content','course_input');return false;" />
</div>
<br />
</form>