<?php
/**
 * user_course_view.php - User Edit file
 *
 * @author $Author: dtong $
 * @version $Id: user_course_view.php,v 1.19 2011/05/09 07:48:52 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
 */

$href = osa_imagepath();
$imgdis = 'dis_right.gif';
$imgsave = $href.'forward.gif';
$imgdelete = 'deletes.gif';
$img_save = "<img src=". $href. "$imgdis  title='".lang('admin_user_course_disable')."' border='0' >";
//$img_close = "<img src=". $href. "$imgclose  title='Close'        border='0' >";
$img_del = "<img src=". $href. "$imgdelete    title='Delete'    border='0' >";

$href_save = base_url() . "admin/course/insert_usercourse/$courseid/$iseditor/";
$href_del = base_url().'admin/course/delete_usercourse/'.$courseid.'/';
//$href_refresh = base_url().'admin/course/select/'.$courseid.'/false/'.$descid;
//$href_refresh = base_url().'admin/course/select/'.$courseid.'/'.$descid;
$href_refresh = base_url(). "admin/course/select/$courseid/$iseditor/$enable_flag/$refresh_urlpart";
//$href_descid = base_url().'/course/desc/edit/'.$descid;

$user_course_col_name = lang('admin_course_col_usercourse');
$user_course_name	= lang('admin_course_name');
$seleteuser = lang('admin_course_seleteuser');
$resultuser = lang('admin_course_resultuser');
$user_cource_deletemsg = lang('admin_user_cource_deletemsg');
$href = base_url();
?>
<form method="POST" name="resource_form">
<center>
<div id='dhtmlwin_resource' style="width:96%">
<div class="user_course_head"><?php
	if ( $iseditor ) {
		echo lang('admin_user_course_head_editor');
	}
	else {
		echo lang('admin_user_course_head');
	}
?></div>
<div class="user_course_coursename"><?php echo $user_course_name; ?> <?php echo $coursename; ?></div>
<table class="user_course_table" border=0>
	<tr>
		<td class="user_course_dropdownlist" valign="top">
		<div class="user_course_title"><?php echo $seleteuser; ?></div>
		<?php
		if (isset($user) && is_array($user)) {
			$fieldname  = 'data[][userid]';
			$button  = "change_button('img_button', '$imgsave', '" . lang('admin_user_course_assign') . "','','resource_form'); return false;";
			$jscript = "onChange=\"$button\"";
			echo form_dropdown($fieldname, $user,'',"style='width:250px' width='250' size='23' multiple='multiple' $jscript");
		}
		?></td>
		<?php
		//$jscript_add = "onClick=\"user_course('$href_save','$href_refresh','$href_descid', 'resource_form','$descid');return false;\"";
		$jscript_add = "onClick=\"user_course('$href_save','$href_refresh','resource_form');return false;\"";
		?>
		<td class="user_course_image" valign=top>
		<div id="img_add" style="margin-top: 30px"><a id="add" name="add"
		<?php echo $jscript_add ?>><span id="img_button"><?php echo $img_save ?></span></a>
		</div>
		</td>
		<td class="user_course_data" valign=top>
		<div class="user_course_title"><?php echo $resultuser; ?></div>
		<table class="user_course_table" border=0>
			<tr>
				<th class="user_course_table_header"><?php echo $user_course_col_name ?>
				</th>
				<th class="user_course_table_header"></th>
			</tr>
			<?php
			$swap='';
			if (isset($usercourse) && is_array($usercourse)) {
				foreach ($usercourse as $row) {
					if ($swap  == '') {
						$tr_class = "table_body_row";
						$swap = '_none';
					}
					else {
						$tr_class = "table_body_row_none";
						$swap = '';
					}
					?>
			<tr class="<?php echo $tr_class; ?>">
				<td class="user_course_col_header_Name"><?php echo osa_user_getname($row) ; ?></td>
				<?php
				$href=$href_del.$row->id;
				$jscript_del = "onClick=\"if(confirm('$user_cource_deletemsg')==true) {" .
				//"user_course('$href','$href_refresh','$href_descid', 'resource_form','$descid');return false;}\"";
					"user_course('$href','$href_refresh','resource_form');return false;}\"";
				?>
				<td class="user_course_col_header_del"><a <?php echo $jscript_del ?>><?php echo $img_del ?></a>
				</td>
			</tr>
			<?php
				}
			}
			$url_delall = base_url() . "admin/course/delete_usercourse_all/{$courseid}/{$iseditor}";
			if ( is_array($usercourse) && count($usercourse)>0 ) {
				$disable_deleteall = osa_btn(false);
			}
			else {
				$disable_deleteall = ' disabled="disabled" class="dis" ';
			}
			?>
		</table>
		<div align="left" style="margin-top:10px">
			<input type="button" value="<?php echo lang('admin_course_btn_deleteall'); ?>" name="delall"
				<?php
					echo $disable_deleteall;
					$refresh_url = site_url("admin/$refresh_urlpart/refresh/$enable_flag");
				?>
				onClick="if (confirm('<?php echo lang('admin_course_delete_all_teachers')?>')) {user_course('<?php echo $url_delall?>','<?php echo $href_refresh?>','');}return false;" />
			&nbsp;&nbsp;&nbsp;
			<input type="button" value="<?php echo lang('admin_course_btn_done'); ?>" name="Done"
				<?php osa_btn()?>
				onClick="closeDhtmlWindow('course_input');ajaxGetpage('page_content','<?php echo $refresh_url?>');return false;" />
		</div>
		</td>
	</tr>
</table>
<table width="96%">
	<tr>
		<td>
		<div class="user_course_footer"><?php
				echo lang('admin_user_course_footer') . '<br />';
				if ( !$iseditor ) {
					echo lang('admin_user_course_footer_readonly');
				}
				else {
					echo lang('admin_user_course_footer_editor');
				}
			?></div>
		</td>
	</tr>
</table>
</div>
</center>
</form>
