<?php  
session_start();
require_once '../../includes/conn.php';
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/table_data_center_with_border_black.css">
</head>
<body>

<div class="container" style="width:100%;">
 <br>
 <center>
<?php
				   $pq=mysqli_query($con,"select * from stuff left join `user` on user.userid=stuff.userid where stuff.userid='".$_SESSION['id']."'");
				   while($pqrow=mysqli_fetch_array($pq)){
				?>
			    <span style="font-size:21;font-weight:bold;">
			  <?php echo $pqrow['business_name']; ?><br>
				 </span> 
				   <?php }?>
  <span style="font-size:20;">        
Course Wise Dues List <br>
</span> 
<span style="font-size:19;"> 
			
			<?php
				   $CourseId = $_POST['CourseId'];
				   $pq=mysqli_query($con,"select * from product where product_id= '$CourseId' and user_id='".$_SESSION['id']."' ");
				   while($pqrow=mysqli_fetch_array($pq)){
				?>				 
			      Course Name  :  <?php echo $pqrow['product_name']; ?> 
				  
				   <?php }?>
				   
	
<br>
Print Date : <?php echo date("M d, Y") ;?> | 
Time   : <?php date_default_timezone_set("Asia/Dhaka"); echo  date("h:i:sa");?>  
		  </span> </center>  
<br>

<?php  
if($_POST) {
    
	$CourseId = $_POST['CourseId']; 
	
	$sql = "SELECT  orders_dues.customer_id,batch.batch_name,customer.customer_name,customer.contact_info, customer.address,customer.join_date, 
	                product.product_name, orders_dues.last_update, orders_dues.recent_due

	FROM orders_dues
	
	left join customer on customer.customer_id =orders_dues.customer_id
	left join product on product.product_id =customer.course_id
	LEFT JOIN batch ON batch.id = customer.batch_no
	where customer.course_id='$CourseId' and customer.member_id='".$_SESSION['id']."' 
	order by orders_dues.customer_id asc ";
	
	$query = $con->query($sql);
    
	$sl=0;
	$table = '
	<table border="1" cellspacing="0" cellpadding="0" class="table table-bordered" style="width:100%;">
		
		<tr>          
                                <th>SL</th> 
                                <th>Batch</th> 
                                <th>Students Name</th> 
								<th>Phone</th>
								<th>Due Money</th>
				                <th>Last Paid</th> 
								<th>Comments</th>
							
		</tr>

		<tr>';
		
		while ($result = $query->fetch_assoc()) {
			$table .= '<tr>
				 
				<td><center>'.++$sl.'</center></td> 
				<td><center>'.$result['batch_name'].'</center></td>
				<td><center>'.$result['customer_name'].'</center></td> 
				 
				<td><center>'.$result['contact_info'].'</center></td>
				<td><center>'.$result['recent_due'].'</center></td>
	 	<td><center>'.date(" d-M-Y", strtotime($result['last_update'])).'</center></td>  
			     <td></td>
			</tr>';	
			
			
		}
		$table .= '
		</tr>
	
		
	</table>
	';	

	echo $table;

}

?>
 
</body>
</html>
