<!DOCTYPE HTML>
<?php 
include('config.php');
$pageid = "";
$navid 	= "home";
$tabid 	= "";


?>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Home</title>
    <?php include('../../common/script_css.php');?>
    <style>
    .font-white{color:#fff}
    </style>
</head>
<body>
    <div class="wrapper">
        <!-- Sidebar  -->
		<?php include('../../sys/sidenav.php');?>

        <!-- Page Content  -->
        <div id="content_wrapper">
		<?php include('../../sys/top_menu.php')?>


        <div class="row mx-2">
           <div class="col-sm-3 mb-2 ">
            	<div class="row  mx-0">
				<div class="col-sm-4 pt-4 pb-3 tc" style="background:#24B958;color:white">
                <i class="fa fa-dollar-sign fa-3x"></i>
                </div>
                <div class="col-sm-8 pt-3 pb-3 tc" style="background:#fff">
                <h4><?php echo number_format($total_order_num)?></h4>
                Jumlah Pesanan
                </div>
                </div>
            </div>
            
            <div class="col-sm-3 mb-2">
            	<div class="row mx-0">
				<div class="col-sm-4 pt-4 pb-3 tc" style="background:#1B8EE4;color:white">
                <i class="fa fa-shopping-cart fa-3x"></i>
                </div>
                <div class="col-sm-8 pt-3 pb-3 tc" style="background:#fff">
                <h4><?php echo $total_order?></h4>
                Jumlah Pesanan
                </div>
                </div>
            </div>
            
            <div class="col-sm-3 mb-2">
            	<div class="row mx-0">
				<div class="col-sm-4 pt-4 pb-3 tc" style="background:#A017BD;color:white">
                <i class="fa fa-user fa-3x"></i>
                </div>
                <div class="col-sm-8 pt-3 pb-3 tc" style="background:#fff">
                <h4><?php echo $total_cust?></h4>
                Jumlah Customer
                </div>
                </div>
            </div>
            
           <div class="col-sm-3 mb-2 ">
            	<div class="row mx-0">
				<div class="col-sm-4 pt-4 pb-3 tc" style="background:#F36;color:white">
                <i class="fa fa-book fa-3x"></i>
                </div>
                <div class="col-sm-8 pt-3 pb-3 tc" style="background:#fff">
                <h4><?php echo $total_product?></h4>
                Jumlah Produk
                </div>
                </div>
            </div>
            



		<div class="col-sm-12">&nbsp;</div>

        <div class="col-sm-12">
			<div class=" my-1 rounded-2 tc bg_white">
				<div class="py-1 bg-dark font-white">
                	<h5 class="my-0">Informasi Stok</h5>
                </div>

				<table class="table table-condensed  my-0">
                <thead>
                <tr class="bold">
                	<td class="tl">Nama Item</td>
                    <td class="tr">Min Stok</td>                
                    <td class="tr">Qty Stok</td>                

                </tr>
                </thead>
                <?php
				$z = 0;
			   	$sqlc = "SELECT (SUM(a.log_inqty) - SUM(a.log_outqty)) as curr_stok, a.pm_autoid, b.pm_min_stok , b.pm_name FROM invlog a, mst_product b 
						WHERE a.pm_autoid = b.pm_autoid GROUP BY pm_autoid ORDER BY pm_name DESC";
				$sqlcon = $conn->query($sqlc) or die($sqlc);
				while($rs = $sqlcon->fetch_assoc()){
					if($rs['curr_stok']<=$rs['pm_min_stok']){
				?>
                <tr>
                	<td class="tl"><?php echo $rs['pm_name']?></td>
                    <td class="tr"><?php echo $rs['pm_min_stok']?></td>
                    <td class="tr"><?php echo $rs['curr_stok']?></td>
                </tr>
                <?php 
				$z = $z+1;
				}}
				for($x=$z;$x<5;$x++){
					echo '<tr><td colspan="5">&nbsp;</td></tr>';
					}
				 ?>
                </table>
            </div>
        </div>
        
        

        </div>


        
        </div><!-- end row mx-2-->
</div>
        
        

    </div><!-- end wrapper -->
</body>

</html>