<?php

	$lang	= $_GET['lang'];
	$pid	= $_GET['pid'];
	$xuid	= $_GET['xuid'];	

	include('users.php');
	include('incjshead.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">
<style>
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 20%;
  border: 0px solid black;
}
td {
  font-family:verdana;
  padding: 8px;
  border: 0px solid black;
  font-size: <?php echo $rep_font_size12 ?>;      
}

th {
  font-family:verdana;
  padding: 8px;
  border: 0px solid black;
  background-color: #d6d6d6;
  font-size: <?php echo $rep_font_size12 ?>;      
}

tr:nth-child(even){background-color: #f2f2f2}


p.a {
  font-family:verdana;
  text-align:center;
  font-size: <?php echo $rep_font_size14 ?>;      
}

</style>
</head>
<body>




<p class="a">
<?php
		printf("<b>$htitle</b>");
		printf("<br><br>");		
?>
</p>



<?php


// TAGS REPORT
include('r_dbc.php');

$sql = "SELECT tag,count(id) as tagrecs
		from ccmanager_tags
		where cid in (select distinct cid from ccmanager where pid = '".$pid."')
		group by tag
		order by 1";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
	printf("<div style='overflow-x:auto;'>");
	printf("<table align=center 	>");
			printf("<tr><th style='text-align:center' >$n_tags</th>
						<th style='text-align:center' >$n_tagrecs</th>
						<th style='text-align:center' >$nview</th>
						</tr>");	
      while($row = mysqli_fetch_assoc($result)) {
		$tag 		= $row["tag"];
		$tagrecs	= $row["tagrecs"];		
			printf("<tr><td style='text-align:center' >$tag </td>
						<td style='text-align:center' >$tagrecs </td>
						<td style='text-align:center' ><a href='r_calendar_rep.php?pid=$pid&lang=$lang&tagx=$tag'><img src='view.png' height=22 width=22 title='$nview'/></a></td>
						</tr>");

    }
} 

mysqli_close($conn);

?> 

</table>
</div>

</body>
</html>