<!-- Main navbar -->
<?php
use App\Libraries\MyEncrypt;
$session = \Config\Services::session();
?>
<div class="navbar navbar-inverse">
	<div class="navbar-header">
		<a class="navbar-brand" href="admin"> 
			<img src="<?php echo base_url("content/site/".site_info('site_logo'));?>" alt="">

		</a>

		<ul class="nav navbar-nav pull-right visible-xs-block">
			<li><a data-toggle="collapse" data-target="#navbar-mobile"><i class="icon-profile"></i></a></li>
		</ul>
	</div>

	<div class="navbar-collapse collapse" id="navbar-mobile">
		<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
					<i class="icon-people"></i>
					<span class="visible-xs-inline-block position-right"></span>
				</a>
				
				<div class="dropdown-menu dropdown-content">
					<div class="dropdown-content-heading">
						<?php echo lang('language_lang.dash_users_list'); ?>
						<ul class="icons-list">
							<li><a href="<?php echo base_url()."admin/users"; ?>"><i class="icon-gear"></i></a></li>
						</ul>
					</div>

					<ul class="media-list dropdown-content-body width-300">

					<?php 
					$myencrypt = new MyEncrypt(true);
						$user_data = $this->common_model->GetUsers(); 
					
	
                     	if($user_data) {
                     		foreach ($user_data as $row) {
                                if($row->online == '1'){
                                 	$class = "status-mark border-success";
                                } else{
                                 	$class = "status-mark border-danger";
                                }
                    ?>

						<li class="media">
							<div class="media-left"><img src="<?php echo base_url('styles/img/usr.png');?>" class="img-circle img-sm" alt=""></div>
							<div class="media-body">
								<a href="<?php echo base_url().'admin/users/view/'.$myencrypt->encode($row->uusersid);?>" class="media-heading text-semibold"><?php echo ucfirst($row->username); ?></a>
								<span class="display-block text-muted text-size-small"><?php echo ($row->Country) ? $row->Country : '';?></span>
							</div>
							<div class="media-right media-middle"><span class="<?php echo $class; ?>"></span></div>
						</li>
						<?php } } ?>
						
					</ul>

					<div class="dropdown-content-footer">
						<a href="<?php echo base_url()."admin/users"; ?>" data-popup="tooltip" title="All users"><i class="icon-menu display-block"></i></a>
					</div>
				</div>
			</li>
		</ul>

		<p class="navbar-text"><span class="label bg-success-400">Online</span></p>

		<ul class="nav navbar-nav navbar-right">
			<li class="dropdown language-switch">
				<?php 
					$active_lan_res = activeLanginfo((session()->get('site_lang'))? session()->get('site_lang'): 'English' );
				    $active_lan_res->language_code = 'en';
					$language_code=strtolower($active_lan_res->language_code);
				$language_code = 'en';
				// if($active_lan_res->language_name == ""){
				// 	$active_lan_res->language_name = "English";
				// }
				?>

				<a class="dropdown-toggle" data-toggle="dropdown">
					<img src="<?php echo base_url("assets/images/flags/".$language_code.'.png') ;?>" class="position-left" alt="">
					<?php echo ucfirst("English");?>
					<span class="caret"></span>
				</a>

				<ul class="dropdown-menu">
					<?php 
						$list_lan_res = activelang();
						foreach ($list_lan_res as $lang_row) {
					?>
						<li class="<?php if(strtolower(session()->get('site_lang')) == strtolower($lang_row->language_name))  echo 'active'; ?>"><a href="<?php echo base_url().'lang/'.$lang_row->language_name;?>" class="english"><img src="<?php echo base_url().'assets/images/flags/'.$lang_row->language_code.'.png';?>" alt=""> <?php echo ucfirst($lang_row->language_name);?></a></li>
					<?php } ?>
				</ul>

			</li>

			<li class="dropdown">
				<a href="<?php echo base_url()."admin/support"; ?>" class="dropdown-toggle" data-toggle="dropdown">
					<i class="icon-bubbles4"></i>
					<span class="visible-xs-inline-block position-right"></span>
				</a>
				
				<div class="dropdown-menu dropdown-content width-350">
					<div class="dropdown-content-heading">
						<?php echo lang('language_lang.ticket_lbl_view'); ?>
						<ul class="icons-list">
							<li><a href="<?php echo base_url()."admin/support"; ?>"><i class="icon-compose"></i></a></li>
						</ul>
					</div>

					<ul class="media-list dropdown-content-body">
					<?php $ticket_data = $this->common_model->GetResults('tickets',''); 
                     if($ticket_data) {
                     	// $this->load->library('MyEncrypt');
							$myencrypt = new MyEncrypt;
                     foreach ($ticket_data as $row) {

                     $encode_data = $myencrypt->encode($row->ticket_no);	
                     $condition = "uusersid = '".$row->uusers_id."'";
					 $username = $this->common_model->GetRow('uusers',$condition);
					 if($username) {
                      ?>
                     	
                    
						<li class="media">
							<div class="media-left">
								<img src="<?php echo site_url('styles/img/usr.png');?>" class="img-circle img-sm" alt="">
							</div>

							<div class="media-body">
								<a href="<?php echo base_url()."admin/support/ticketdetails/".$encode_data; ?>" class="media-heading">
									<span class="text-semibold"><?php echo $username->username; ?></span>
									<span class="media-annotation pull-right"><?php echo $row->post_date; ?></span>
								</a>
								<span class="text-muted"><?php echo substr($row->message,0,43); ?></span>
							</div>
						</li>

		            <?php     } } }
					?>
					</ul>

					<div class="dropdown-content-footer">
						<a href="<?php echo base_url()."admin/support"; ?>" data-popup="tooltip" title="All messages"><i class="icon-menu display-block"></i></a>
					</div>
				</div>
			</li>

			<li class="dropdown dropdown-user">
		        <?php 
				  	$condition="id = '".$session->get('userid')."'";
                   	$admin = $this->common_model->GetRow('admin',$condition); 
                   	
                ?>
				<a class="dropdown-toggle" data-toggle="dropdown">
					<?php if(isset($admin->profile_pic)) { ?>
					<img src="<?php echo base_url("content/profile/".$admin->profile_pic);?>" alt="logo">
					<?php } else { ?>
					<img src="<?php echo base_url("content/site/logo.png");?>">
					<?php } ?>
					
					<span><?php echo ucfirst($admin->username); ?></span>
					<i class="caret"></i>
				</a>

				<ul class="dropdown-menu dropdown-menu-right">
					<li><a href="<?= site_url("admin/profile/"); ?>"><i class="icon-user-plus"></i> My profile</a></li>
					<li><a href="<?= site_url("admin/changepassword");?>"><i class="icon-user-lock"></i> Change password</a></li>
					<li><a href="<?= site_url("admin/accountsettings");?>"><i class="icon-cog5"></i> Account settings</a></li>
					<li><a href="<?= site_url("admin/login/logout"); ?>"><i class="icon-switch2"></i> Logout</a></li>
				</ul>
			</li>
		</ul>
	</div>
</div>
<!-- /main navbar -->