<?php
session_start();
include "includes/database.php";
include "includes/security.php";
$email=$_SESSION["pengguna"];
$dataPengguna=mysqli_query($newcon,"SELECT * from tbl_user where email='$email'");
$showData=mysqli_fetch_array($dataPengguna);
?>
<?php
session_start();
include "includes/database.php";
?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>MyUniversity MarketPlace</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/heroic-features.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <!-- Navigation -->
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">MyUniversity MarketPlace</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li class="nav-item active">
              <a class="nav-link" href="index.php">HOME
                <span class="sr-only">(current)</span>
              </a>
            </li>
                    <li>
                        <a href="client.php">Dashboard</a>
                    </li>
                    <li>
                        <a href="purchase.php">List Of Purchase Product</a>
                    </li>
                    <li class="nav-item">
              <a class="nav-link" href="addproduct.php">Add Product</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="deleteproduct.php">Delete Product</a>
            </li>
                    <li class="nav-item">
              <a class="nav-link active" href="updateproduct.php">Update Product</a>
            </li>
            <li class="nav-item">
              <a class="nav-link active" href="cabout.php">About</a>
            </li>
            
            <li class="nav-item">
              <a class="nav-link active" href="index.php">Logout</a>
            </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

        <!-- Page Content -->
        <div id="page-content-wrapper">
            <div class="container-fluid">
                <h1>Welcome To MyUniversity MarketPlace</h1>
        
            </div>
<br>
        <table class="table">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Picture</th>
                                            <th>Product Name</th>
                                            <th>Product Price</th>
                                            <th>Quantity</th>
                                            <th>Total</th>
                                        </tr>
                                    </thead>
                                   
                                   
                                   
                              <?php
$dataSubjects=mysqli_query($newcon,"SELECT * from tbl_purchase where purchase_id='$_GET[id]'");
$bil_subjects=mysqli_num_rows($dataSubjects);
$showSubjects=mysqli_fetch_array($dataSubjects);
$ttlSemua=0;
?>                              
                                   
<tbody>

<?php
if ($bil_subjects==0)
{
?>
<tr>
<td colspan="6">No record found!</td>

</tr>
<?php
}
else
{

$dataSubjects1=mysqli_query($newcon,"SELECT * from tbl_detail where purchase_id='$showSubjects[tid]'");

while ($showSubjects1=mysqli_fetch_array($dataSubjects1))
    {
$dataSubjects2=mysqli_query($newcon,"SELECT * from tbl_product where product_id='$showSubjects1[product_id]'");
$showSubjects2=mysqli_fetch_array($dataSubjects2)
?>


<tr>
<td><?php echo $showSubjects2['product_id'];?></td>
 <td><img src="product/<?php echo $showSubjects2['product_pic'];?>" width="64" width="64"></td>
<td><?php echo $showSubjects2['product_name'];?></td>
<td>RM <?php echo number_format($showSubjects2['product_price'],2);?></td>
<td><?php echo $showSubjects1['quantity'];?></td>
<td>RM <?php echo number_format($showSubjects1['quantity']*$showSubjects2['product_price'],2);?></td>
</tr>

<?php
$ttlSemua+=($showSubjects1['quantity']*$showSubjects2['product_price']);
}
}
?>
                                       
</tbody>



 <tr>
                                            <th colspan="5" align="right" valign="middle">SUM TOTAL</th>
                                         
                                            <th>RM <?php echo number_format($ttlSemua,2); ?></th>
                                        </tr>
                                        
                                        
 
 
<?php
if ($bil_subjects!=0)
{
?>                                     
 <tr>
                                            <th colspan="6" align="right" valign="middle"><center> 
<a href="lorder.php" class="btn btn-default">Back</a></center></th>
                                         
                                           
                                        </tr>
                                        
                                        <?php
}
?>
                                        
                                        



                                </table>
                               

    </div>






        </div>
        <!-- /#page-content-wrapper -->

    </div>
    <!-- /#wrapper -->





    <!-- Bootstrap core JavaScript -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>


</body>

</html>