<?php 		
			include('field_names.php'); 
			$xuid 	= $_GET['xuid'];
			$xfdc 	= $_GET['xfdc'];
			include('users.php');
?>

<!DOCTYPE html>
<html>
		<title>
			<?php include('title.php'); ?>
	  </title>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
	<script src="./jquery/jquery-3.5.1.js"></script>
	<script src="./jquery/popper.min.js"></script>  
	<script src="./bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="./fontawesome/css/all.css" >  
	
<style>
html,
body,
header,
.view {
  height: 100%;
}

@media (max-width: 740px) {
  html,
  body,
  header,
  .view {
    height: 1000px;
  }
}
@media (min-width: 800px) and (max-width: 850px) {
  html,
  body,
  header,
  .view {
    height: 650px;
  }
}

.top-nav-collapse {
  background-color: #3f51b5 !important;
}

.navbar:not(.top-nav-collapse) {
  background: transparent !important;
}

@media (max-width: 991px) {
  .navbar:not(.top-nav-collapse) {
    background: #3f51b5 !important;
  }
}

.rgba-gradient {
  background: -webkit-linear-gradient(45deg, rgba(0, 0, 0, 0.7), rgba(72, 15, 144, 0.4) 100%);
  background: -webkit-gradient(linear, 45deg, from(rgba(0, 0, 0, 0.7), rgba(72, 15, 144, 0.4) 100%)));
  background: linear-gradient(to 45deg, rgba(0, 0, 0, 0.7), rgba(72, 15, 144, 0.4) 100%);
}

.card {
  background-color: rgba(126, 123, 215, 0.2);
}

.md-form label {
  color: #ffffff;
}

h6 {
  line-height: 1.7;
}
</style>

<style>
/* unvisited link */
a:link {
  color: black;
}

/* visited link */
a:visited {
  color: black;
}

/* mouse over link */
a:hover {
  color: blue;
}

/* selected link */
a:active {
  color: black;
}
</style>

<script>
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</script>	

</head>
<body>
	<div class="view" style="background-image: url('bg.png'); background-repeat: no-repeat; background-size: cover; background-position: center center;">
<?php if ($demo_user == 1) { ?>
<div id="myModal" class="modal fade" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?php echo $modal_projects_title." ".$user_description; ?></h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close"></button>				
            </div>
            <div class="modal-body">
				<p><?php echo $modal_projects_body ?></p>
            </div>
		<!-- Modal footer -->
        <div class="modal-footer">
		
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo $nclose ?></button>
        </div>			
        </div>
    </div>
</div>
<?php } ?>


<br><br>

<div class="container">
<div class="table-responsive"> 



	<table class='table' >
		<tr>
			<th style='text-align:right;width: 30%'><h3><span style='color:blue'><i class='fas fa-list-ul'></i></span></h3></th>
			<th style='text-align:left;width: 40%'><h3><?php echo strtoupper($select_projects); ?></h3></th>
		</tr>

		
<?php 
include('r_dbc.php');

if ($usprojects == '') 
	{
		$sql = "select 0 as pidx,'A project is not connected to your account<br>Please contact your administrator' as desc_project,'alert.png' as logopic,'ALERT' as project_short";
	}

if ($usprojects != '') 
	{
$sql = "SELECT p.pid as pidx,p.desc_project,p.logopic,p.project_short,p.project_html,u.user_role,r.role_description
		from ccprojects p, members_projects u, members_roles r
		where p.pid in (".$usprojects.")
		and p.pid = u.pids and u.username = '".$xuid."'
		and u.user_role = r.user_role
		order by 1";
	}		
	
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
      while($row = mysqli_fetch_assoc($result)) {
		$pidx 			= $row["pidx"];
		$desc_project 	= $row["desc_project"];
		$logopic 		= $row["logopic"];
		$project_short 	= $row["project_short"];
		$project_html 	= $row["project_html"];
		$user_role 		= $row["user_role"];
		$role_description 		= $row["role_description"];
		$modalpidx		= "mymodal".$pidx;

			if ($demo_user == 1) { $project_dets = "<td><h4><span style='color:green' data-toggle='tooltip' data-placement='top' title='".$project_short."' ><i class='fas fa-info-circle blink'></i></h4></span></td>"; }
			if ($demo_user == 0) { $project_dets = ""; }
		
		
		printf("<tr>
			<td style='text-align:right'  >
			<h4>
			<a href='menu.php?xuid=$xuid&pid=$pidx&lang=$ulang&xfdc=$xfdc'>
			<img src='./logos/$logopic' width=30 height=auto />
			</a>
			</h4>
			</td>
			<td style='text-align:left'  >
			<h5>
			<a href='menu.php?xuid=$xuid&pid=$pidx&lang=$ulang&xfdc=$xfdc'>
				$desc_project
				</a>
				</h5>
			</td>");
			if ($demo_user == 0) {
				printf("<td style='text-align:left'><pre><img src='user_".$user_role.".png' height=auto width=20 /> $role_description </pre></td>");
			}
			if ($demo_user == 1) {
			?>
<td>			
 
   
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#<?php echo $modalpidx ?>">
     <?php echo $ninfo ?>
</button>

<!-- Modal -->
<div class="modal fade" id="<?php echo $modalpidx ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
			<h4 class="modal-title" id="<?php echo $modalpidx ?>"><?php echo "<img src='./logos/$logopic' width=40 height=auto />"; ?>  <?php echo $desc_project ?></h4>		
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <?php echo $project_html ?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo $nclose ?></button>
      </div>
    </div>
  </div>
</div> 
   

  
</td>

		<?php
			}
			printf("</tr>");			
    }
	if ($admins_check == 1)
	{
		printf("<tr>
		<td style='text-align:right'  >
			<a href='projects_add.php?xuid=$xuid&lang=$ulang&xfdc=$xfdc' >
				<img src='./logos/addp.png' width=30 height=auto /> 
			</a>	
		</td>
		<td style='text-align:left;color:green'  > <h5> $nadd_new $nproject </h5></td>
		<td>  </td>
		</tr>");
	}
	
			printf("</table>");
} 

mysqli_close($conn);

?> 


  </div>
</div>
<!-- bakcground image close div -->
</div>
</body>
</html>