<?php 
session_start();
require_once '../../includes/conn.php'; 
error_reporting( ~E_NOTICE );
?>

<!DOCTYPE html>
<html>
<head> 

<link rel="stylesheet" href="css/table_data_center_with_border_black.css">
</head>
<body>
 <div class="container-fluid">
 <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']; ?>
				 </span> 
	<?php }?> <br>
	
	
	<span style="font-size:19;">
   <b> Assets Report By Room </b><br>
  
 
				   <?php 
				   $RomId = $_POST['RomId'];
				   $pq=mysqli_query($con,"select distinct room_name from asset_rooms  where rom_id = '$RomId' ");
				   while($pqrow=mysqli_fetch_array($pq)){
				?>
			    <b> Room Name : </b> <?php echo $pqrow['room_name']; ?>
				  
				   <?php }?>
	 </span> 			   
				   <br>
	<span style="font-size:18;">
Date : <?php echo date("d-F-Y") ;?> |
Time : <?php date_default_timezone_set("Asia/Dhaka"); echo  date("h:i:sa");?>
 </span> 
 </center> 
<br>  

<?php 
 
if($_POST) {
    
	 $RomId = $_POST['RomId'];

	$sql = "SELECT * from assets                             
 		  left join asset_cat on asset_cat.ast_id=assets.ast_cat
 		  left join asset_rooms on asset_rooms.rom_id=assets.rooms 
	      where  assets.rooms='$RomId'  and assets.user_id='".$_SESSION['id']."' ";
	$query = $con->query($sql);

	$table = '
	<table border="1" cellspacing="0" cellpadding="0" class="table table-bordered" style="width:100%;">
		<tr>
							<th>SL</th> 
							<th>Assets Name</th>
							<th>Details</th>
							<th>Qty</th>
							<th>Price</th> 
							<th>Total</th> 
							<th>Buy Date</th>
							
		</tr>

		<tr>';
		$TotalQty =0;	
		$exp_cost =0;	
$sl=0;		
		while ($result = $query->fetch_assoc()) {
			$table .= '<tr>
				<td><center>'.++$sl.'</center></td>	 
				<td><center>'.$result['ast_name'].'</center></td>
				<td><center>'.$result['details'].'</center></td>
				<td><center>'.$result['quantity'].'</center></td>
				<td><center>'.$result['price'].'</center></td> 
				<td><center>'.$result['quantity'] * $result['price'].'</center></td> 
				<td><center>'.date("d-M-Y", strtotime($result['entry_date'])).'</center></td>
			</tr>';	
			
			$TotalQty+= $result['quantity'];
			$exp_cost+= $result['price'];
			$TotalP+= $result['quantity'] * $result['price'];
		}
		$table .= '
		</tr>
		
        <tr>
			<td colspan="3" style="text-align:right; "><b> Total = </b></td>
			<td><center><b> '.$TotalQty.'</b></center></td>
			<td> </td>
			<td><center><b> '.$TotalP.'</b></center></td>
		</tr>
		
	</table>
	';	

	echo $table;

}
?>

</div>
 
</body>
</html>
