<?php
/**
 * header_view.php - Header view file
 *
 * @author $Author: dtong $
 * @version $Id: header_view.php,v 1.58 2011/06/07 04:47:39 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
 */
osa_load_lang('header');
//It is much easier to put this logic here instead of inside of the controller
//Since multiple controller calls this.
if ( isset($user) && property_exists($user, 'userold') && is_object($user->userold) && property_exists($user->userold, 'username') ) {
	$userold = $user->userold;
}
$site_url = site_url();
$value_goal = lang('header_button_goal');
$button_goal = "<input type='button' onClick='return ShowHideTree(9,\"{$site_url}\",\"menu/menu_tree/index/goal\");' " .
					"value='{$value_goal}'". osa_btn(FALSE)." >";
// Must add another if we have more tree
$trees_jstree = "#course_tree, #dept_tree, #grade_tree";
?>

<table width="100%" cellspacing="0" cellpadding="0"
	style="border: 0px; margin-top: 0px; margin-bottom: 0px;">
	<tr>
		<td colspan='2'
			bgcolor="<?php echo $this->config->item('cms_header_image_bkcolor');?>" nowrap="nowrap">
		<?php if ($this->config->item('cms_header_image_left_align')===FALSE) {?>
			<center>
				<img src="<?php echo osa_image_toppath() . $this->config->item('cms_header_image');?>" />
			</center>
		<?php } else { ?>
			<img src="<?php echo osa_image_toppath() . $this->config->item('cms_header_image');?>" />
		<?php }?>
		</td>
	</tr>
	<?php
		$header_msg = $this->config->item('cms_header_message');
		$loginheader_msg = $this->config->item('cms_loginheader_message');
		if ( !empty($header_msg) || !empty($loginheader_msg) ) {
	?>
	<tr>
		<td bgcolor="#F0F0F0" colspan="2" align="center">
		<?php
			if ( isset($user) && is_object($user) ) {
				if ( !empty($header_msg) ) {
					echo "<div class='header_msg'>{$header_msg}</div>";
				}
			}
			else {
				if ( !empty($loginheader_msg) ) {
					echo "<div class='header_login_msg'>{$loginheader_msg}</div>";
				}
			}
		?>
		</td>
	</tr>
	<?php } ?>
	<?php if ( isset($user) && is_object($user) ) {?>
	<tr>
		<td align='left' nowrap="nowrap"> <?php
		if ( isset($userold) ) {
			?><a HREF="<?php echo site_url()?>admin/user/login/<?php echo $userold->username . '/' . CMS_ADMIN_DISABLE;?>">
		<span style="font-weight: bold; font-size: 11px; color: blue;"> [<?php echo osa_user_getname($userold);?>]</span></a>
		<?php } ?>
		<?php echo lang('header_message_login') ;?>: <span
			style="font-size: 11px; color: blue;"> <?php echo osa_user_getname($user);?>
		</span> <?php if ($this->config->item('cms_manage_mode') || $this->config->item('cms_sitestop'))
		echo '<br /><font color="red"><b>'.lang('header_message_manage_mode').'</b></font>'; ?>
			</td>
			<?php //Home ?>
		<td align='right' nowrap="nowrap"><input type="button"
			onClick="/* $('<?php echo $trees_jstree; ?>').jstree('deselect_all');ShowHideTree(0); */
						window.location='<?php echo site_url('home')?>'; return false;"
			value="<?php echo lang('header_button_home') ;?>" <?php osa_btn();?> />

			<?php //Resources ?>
			<input type="button" onClick="ajaxGetpage('page_content','<?php echo site_url()?>cms/site_res');return false;"
			value="<?php echo lang('header_button_resources') ;?>" <?php osa_btn();?> />

			<?php //Goal ?>
			<?php if ($this->config->item('cms_goal_mode')) {
						echo $button_goal; } ?>
			<?php
			if ($this->access_model->is_user_management()){ //admin panel
			 ?> <input type="button"
			onClick="return ShowHideTree(9,'<?php echo site_url();?>','menu/menu_tree/index/admin');"
			value="<?php echo lang('header_button_admin') ;?>" <?php osa_btn();?> />
			<?php
			} //Profile
			?> <input type="button"
			onClick="newDhtmlWindow('<?php echo site_url(). 'admin/user/editprofile/'; ?>',
			        '<?php echo lang('header_button_profile');?>', 550, 360,'user_profile'); return false;"
			value="<?php echo lang('header_button_profile') ;?>"
			<?php osa_btn();?> />
			<?php //Mapping ?>
			<input type="button"
				onClick="return ShowHideTree(2,'<?php echo site_url();?>');"
				value="<?php echo lang('header_button_mapping') ;?>"
			<?php osa_btn();?> /> <?php
			if ( $this->config->item('cms_use_it_standard') ) {
				$url_menu = 'menu/menu_ict/index/'. CMS_ITSTANDARDS_TYPE.'/'.CMS_ITSTANDARDS_RESOURCE_TYPE.'/'. CMS_ICT_USER_TYPE;
			 	if ( $this->access_model->is_ict_editor(CMS_ICT_USER_TYPE) ) { ?>
			 		<?php //ICT upload ?>
			 		<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_'.CMS_ICT_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
				else { ?>
					<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_ro_' . CMS_ICT_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
			} ?>

			<?php
			if ( $this->config->item('cms_use_gc') ) {
				$url_menu = 'menu/menu_ict/index/'. CMS_GLOBAL_CITIZEN_TYPE.'/'.CMS_GLOBAL_CITIZEN_UPLOAD_TYPE.'/'. CMS_GC_USER_TYPE;
			 	if ( $this->access_model->is_ict_editor(CMS_GC_USER_TYPE) ) { ?>
			 		<?php //GC ?>
			 		<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_'.CMS_GC_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
				else { ?>
					<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_ro_' . CMS_GC_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
			} ?>

			<?php
			if ( $this->config->item('cms_use_tail') ) {
				$url_menu = 'menu/menu_ict/index/'. CMS_TAIL_TYPE.'/'.CMS_TAIL_UPLOAD_TYPE.'/'. CMS_TAIL_USER_TYPE;
			 	if ( $this->access_model->is_ict_editor(CMS_TAIL_USER_TYPE) ) { ?>
			 		<?php //Tail ?>
			 		<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_'.CMS_TAIL_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
				else { ?>
					<input type="button"
					onClick="return ShowHideTree(9,'<?php echo site_url();?>','<?php echo $url_menu?>');"
					value="<?php echo lang('header_button_uploads_ro_' . CMS_TAIL_USER_TYPE);?>"
					<?php osa_btn();?> /> <?php
				}
			} ?>

			<?php
			if ( $this->config->item('cms_help_config') !== FALSE ) {
			 ?> <input type="button"
			<?php //Help ?>
			onClick="return newIframeWindow('<?php echo site_url().'menu/help';?>', 'Help', 1200, 800, 'help_iframe');"
			value="<?php echo lang('header_button_help');?>" <?php osa_btn();?> />
			<?php } ?>
			<input type="button" <?php //Todcm.org doc ?>
				onClick="openBrowserWindow('http://todcm.org/doc.php',1024,800,'todcmorg_doc');"
				value="Doc" <?php osa_btn();?> /> &nbsp;&nbsp;
			<input type="button" <?php //Logout ?>
				onClick="newLocation('<?php echo site_url();?>login/logout');"
				value="Logout" <?php osa_btn();?> />&nbsp;</td>
	</tr>
	<?php }?>
</table>
