<?php 
	$pid			= $_GET['pid'];
	$lang 			= $_GET['lang'];	
	
	include('config.php');
	include('field_names.php'); 
	
?>

<!DOCTYPE html>
<html>
<head>
<title>
	  <?php include('title.php'); ?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="./bootstrap/css/bootstrap.css" >
    <link rel="stylesheet" href="./fontawesome/css/all.css" >

</head>
<body>


<br>

<div class="container">
	<table class="table table-bordered table-striped">
	<thead>
		<tr>
				<th style='text-align:left' >
				<img src='./users.png' width=50 height=auto />   <?php echo $htitle." ".$nusers." - ".$nprojects." - ".$nroles ?>
				</th>
		</tr>		
	</thead>
	</tbody>



	<table class="table table-bordered table-striped">
	<thead>
<?php
			printf("<tr>");			
			printf("<th style='text-align:center' colspan=2 >$nuser</th>");
			printf("<th style='text-align:center' colspan=2 >$nproject</th>");
			printf("<th style='text-align:center' colspan=2 >$nuser $nrole</th>");
			printf("</tr>");				

/* USERS */

include('r_dbc.php');
$sql = "SELECT p.username, p.pids, p.user_role, d.user_description, x.desc_project, r.role_description
		from members_projects p, members_det d, ccprojects x, members_roles r
		where p.username = d.username
		and p.pids = x.pid
		and p.user_role = r.user_role
		order by p.username, p.pids";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
      while($row = mysqli_fetch_assoc($result)) {
			$username 			= $row["username"];		
			$user_description	= $row["user_description"];		
			$user_role			= $row["user_role"];		
			$desc_project		= $row["desc_project"];		
			$role_description	= $row["role_description"];					
			$pids 				= $row["pids"];
			printf("<tr>");			
			printf("<td style='text-align:right' >$username</td>");
			printf("<td style='text-align:left' >$user_description</td>");
			printf("<td style='text-align:right' >$pids</td>");
			printf("<td style='text-align:left' >$desc_project</td>");
			printf("<td style='text-align:center' ><img src='user_".$user_role.".png' height=auto width=30 /></td>");
			printf("<td style='text-align:left' >$role_description</td>");			
			printf("</tr>");
			}		
    }
mysqli_close($conn);
?> 
	</tbody>
	</table>
	

	

<?php
	include('system_date.php');	
?>	
</div>
</body>
</html>