<?php ob_start(); ?> 
<!DOCTYPE html> 
<html lang="en">  

<head>
<?php   require_once 'head_link.php'; ?>

</head>

<body>
 
<?php   require_once 'header1.php'; ?> 


<?php  require_once 'sidebar.php'; ?>


  <main id="main" class="main">

    <div class="pagetitle bg-light rounded p-2"> 
	  <h1><i class="bi bi-box-seam"></i>  Assets List | 
	  Total Asset Price : <?php 
$sql = $con->query("SELECT sum(`price`) as `gtotal` FROM assets where user_id='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
echo $row['gtotal'];
?> |   <a target="_blank" href="assets-print"><i class="bi bi-printer"></i></a> | 
	  <span> <a href="asset-add">  <i class="bi bi-plus-circle-fill"></i> </a> </span>  </h1>
	
    </div> 

    <section class="section">
      <div class="row">
	  
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
             
              <table class="table table-hover datatable">
                <thead class="bg-light">
                        <tr>
							<th>SL</th>
							<th>Equipments</th>
							<th>Details</th>
							<th>Qty</th>
							<th>Total Price</th> 
                        </tr>
                  </thead>
				  
                 <tbody id="tbody">
							<?php
							$sl=0;
								$eq=mysqli_query($con,"select distinct sum(quantity) as total_qty, sum(total_price) as total_price, ast_name, details 
								from assets                             
 							    left join asset_cat on asset_cat.ast_id=assets.ast_cat
							    where assets.user_id='".$_SESSION['id']."' group BY assets.ast_cat ");
							
							while($eqrow=mysqli_fetch_array($eq)){ 
									?>
										<tr> 
											<td><?php echo ++$sl; ?></td>
											<td><?php echo $eqrow['ast_name']; ?></td>
											<td><?php echo $eqrow['details']; ?></td>
											<td><?php echo $eqrow['total_qty']; ?></td>
											<td><?php echo $eqrow['total_price']; ?></td>
										</tr>
		                <?php }   ?>

</tbody>
              </table>
            
            </div>
          </div>

        </div>
      </div>
    </section>

  </main>
  
  <?php  require_once 'footer1.php'; ?>