<?php include 'topmost.php';ini_set('max_execution_time', '0');?>
<!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, shrink-to-fit=no"><meta name="description" content="">
<meta name="author" content="">

    <title>My Outlet</title>
    <?php  include 'toplinks.php';  ?>
</head>
<body id="page-top"><div id="wrapper"><?php  include 'menus.php';  ?>

        

<?php include 'top.php';   ?>



                <!-- End of Topbar -->

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                    <div class="d-sm-flex align-items-center justify-content-between mb-4">
<?php  include 'greet.php';  ?><?php  include 'process.php';  ?>

                       <!--  <a href="#" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
                                class="fas fa-download fa-sm text-white-50"></i> Generate Report</a> -->
                    </div>

                    <!-- Content Row -->
                    <div class="row">




                        <!-- Earnings (Monthly) Card Example -->
                        <div class="col-xl-4 col-md-6 mb-4">
                            <div class="card border-left-primary shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
        <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
         TOTAL PRODUCTS IN STOCK</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo QueryDB("SELECT COUNT(*) FROM products")->fetchColumn(); ?></div></div><div class="col-auto"><i class="fas fa-calendar fa-2x text-gray-300"></i></div></div></div></div>
                        </div>

<div class="col-xl-4 col-md-6 mb-4"><div class="card border-left-success shadow h-100 py-2"><div class="card-body"><div class="row no-gutters align-items-center"><div class="col mr-2"><div class="text-xs font-weight-bold text-success text-uppercase mb-1">
TOTAL BRANCHES</div><div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo QueryDB("SELECT COUNT(*) FROM branch ")->fetchColumn();?></span></div></div>
<div class="col-auto"><i class="fas fa-dollar-sign fa-2x text-gray-300"></i></div>
</div></div></div></div>

                       
<div class="col-xl-4 col-md-6 mb-4"><div class="card border-left-info shadow h-100 py-2">
<div class="card-body"><div class="row no-gutters align-items-center"><div class="col mr-2"><div class="text-xs font-weight-bold text-info text-uppercase mb-1">WHAREHOUSE PRODUCT COUNT</div><div class="row no-gutters align-items-center"><div class="col-auto"><div class="h5 mb-0 mr-3 font-weight-bold text-gray-800"><?php 
$lib =QueryDB("SELECT SUM(item_qty) as qtyT FROM storekeeper ");
$k =$lib->fetch(PDO::FETCH_ASSOC); echo $k['qtyT'];

?></span></div></div></div></div><div class="col-auto"><i class="fas fa-clipboard-list fa-2x text-gray-300"></i></div></div></div>
</div></div>

                       
                    </div>

                    <!-- Content Row -->

                    <div class="row">

                        <!-- Area Chart -->
                        <div class="col-xl-12 col-lg-12">
                            <div class="card shadow mb-4">
                                <!-- Card Header - Dropdown -->
 <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between bg-success text-white"><h6 class="m-0 font-weight-bold text-white">WHAREHOUSE STOCK VIEW</h6>
<div class="dropdown no-arrow">
<button class="btn btn-dark btn-sm text-white" id="exp_whrhs_stock"><i class="fa fa-file-excel small"> Export CSV</i></button>
</div>
 </div>
                               
<div class="card-body">

<div class="row d-block d-md-none">
<?php  $weCount=1;foreach(QueryDB("SELECT * FROM products where tm_status=1 ")as $sel_p){

     $stk=lastStock($sel_p['id'],'',"and load_code=''");
    $supplied =totalStock($sel_p['id'],'',"and load_code!=''");
    $tStock = totalStock($sel_p['id'],'',"and load_code=''");
    ?>
    <div class="col-md-12 mt-1 mb-2" style="box-shadow: 5px 4px 10px gray;min-height:80px;border-top:6px solid green;border-radius: 2px;padding-bottom:5px;">
        <div class="row">
<div class="col-10"><span style="font-size:20px;"><b><?php echo $sel_p['item_name'];  ?></b></span>
   <br> <b><?php  echo $sized_by[$sel_p['size']].','.$colored_by[$sel_p['color']];  ?></b>
</div>  <div class="col-2"><span class="bg-dark text-white badge"><?php echo $weCount;  ?></span></div>  
<div class="col-12"><?php  echo $company[$sel_p['company']].', '.$brand[$sel_p['brand']];  ?></div>
<div class="col-8 small"><b>LStk Date:</b> <?php  echo @date('D jS M,Y',$stk['item_time']);  ?></div>
<div class="col-4 small"><b>LStk Qty:</b> <?php  echo @$stk['item_qty'];  ?></div>
<div class="col-5 small"><b>Overall Loaded:</b> <span class="badge bg-primary text-white"><?php  echo @$tStock;  ?></span></div>
<div class="col-3 small"><b>TSupld:</b> <span class="badge bg-warning text-white"><?php  echo @abs($supplied);  ?></span></div>
<div class="col-4 small"><b>CurrQty:</b> <span class="badge bg-success text-white"><?php  echo @($tStock-abs($supplied));  ?></span></div>

<div class="col-7 small"><b>Cost:</b> &#8358;<span class="large text-danger" style="font-size:18px;"><?php  echo number_format($sel_p['item_cost'],2);  ?></span></div>
<div class="col-5 small"><a href="whrs_itemView?sel_product='.$sel_p['id'].'" class="btn btn-info btn-sm small" style="font-size:9px;"><i class=""> View Sply Hist</i></a></div>
        </div>



    </div>
    <?php $weCount++; } ?>
</div>


<div class="table-responsive d-none d-md-block">
<table class="table table-bordered std_table whrhs_stock" id="dataTable" width="100%" cellspacing="0"><thead><tr class="small"><th>#</th><th>NAME</th>
<th class="hide">Size</th><th class="hide">Color</th><th class="hide">Category</th><th class="hide">Company</th>
    <th>Cost</th><th><i class="fa fa-camera"></i></th><th>Lst Stock</th><th>lststk No</th><th>Total</th><th>TSupplied</th><th>CurrQty</th><th class="noExl">Action</th></tr></thead>
<?php $weCount=1;foreach(QueryDB("SELECT * FROM products where tm_status=1 ")as $sel_p){
    // echo $sel_p['id'];
    $stk=lastStockWhouse($sel_p['id'],'',"");
    $supplied =totalStockSupplied($sel_p['id'],'',"and load_code!=''");
    $tStock = totalStockWHouse($sel_p['id'],'',"");
echo '<tr class="small"><th>'.$weCount.'</th><th>'.$sel_p['item_name'].'</th>
<th>'.$sized_by[$sel_p['size']].'</th><th>'.$colored_by[$sel_p['color']].'</th><th>'.$brand[$sel_p['brand']].'</th><th>'.$company[$sel_p['company']].'</th>

<th>&#8358;'.number_format($sel_p['item_cost'],2).'</th>
<th>'; if(file_exists(explode(',',$sel_p['item_img'])[0])){
    $view_sel_img =explode(',',$sel_p['item_img'])[0];
echo '<img src="'.$view_sel_img.'" class="img img-thumbnail" style="width:150%;height:100px">';}echo '</th>
<th>'.@date('D jS M,Y',$stk['item_time']).'</th>


<th>'.@$stk['item_qty'].'</th><th>'.$tStock.'</th><th>'.abs($supplied).'</th><th>'.($tStock-abs($supplied)).'</th><th class="noExl">
<a href="whrs_itemView?sel_product='.$sel_p['id'].'" class="btn btn-info btn-sm small" style="font-size:9px;"><i class=""> Sply Hist</i></a>
</th></tr>';
    ?>


<?php $weCount++; } ?> 

</table></div>





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

                        
                       
                    </div>

                    <!-- Content Row -->
               

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

            <!-- Footer -->
        <?php  include 'bottom_most.php'; ?>
<script>
var classVal = "<?php  echo date('D jS F Y'); ?>"+" WhareHouse Supply & Stock Inventory";
$('#exp_whrhs_stock').on('click',function(){$(".whrhs_stock").table2excel({exclude: ".noExl",name: "Excel Document Name",filename: classVal +'.xls',fileext:".xls",exclude_img: true,exclude_links: true,exclude_inputs: true});});
</script>





</html>