<?php
//user.php
include('db_con.php');
include('function.php');
if (isset($_SESSION['user_id'])) {
    $user_type = $_SESSION['user_type'];
    $user_id = $_SESSION['user_id'];
    $user_name = $_SESSION['user_name'];
    $branch_id = $_SESSION['branch_id'];
    $branch_name = $_SESSION['branch_name'];
    $store_id = $_SESSION['store_id'];
    $store_name = $_SESSION['store_name'];
}else{
  header('Location: login');
  die();
}

stock_update($connect);
//if(!isset($_SESSION["type"]))
//{
//  header('location:login');
//}
//if($_SESSION["type"] != 'master')
//{
//  header("location:index.php");
//}
$sql = "SELECT IFNULL(doc_status,'OFF') FROM user_rights WHERE user_id = '".$user_id."' and doc_name = 'cost'";
            $statement = $connect->prepare($sql);
            $statement->execute(); // no need to add `$sql` here, you can take that out
            $cost = $statement->fetchColumn();
?>
<!DOCTYPE html>
<html>
<head>
  <?php include('include/head.php'); ?>
  
</head>
<body>
  <?php include('include/header.php'); ?>
  <?php include('include/sidebar.php'); ?>
<div class="main-container">
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"></h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Inventory</a></li>
              <li class="breadcrumb-item active">Item Inquiry </li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
     <span id="alert_action"></span>
    <div class="row">
        <div class="col-12">
          <div class="card">
            <div class="card-header">
              <div class="row">
                          <div class="col-lg-10 col-md-10 col-sm-8 col-xs-6">
                              <h3 class="panel-title">Item Inquiry</h3>
                            </div>
                            
                </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              
                        <table width="100%" id="_dataTable" class="table table-bordered table-striped table-hover">
                          <thead>
                  <tr>
                    
                                    
                    <th width="10%">No</th>                 
                    <th width="25%">Item Name</th>
                    
                    
                    
                  
                    <?php if($cost=='ON')
                    echo '
                    <th width="15%">Cost</th>
                    ';?>
                    
                    <th width="15%">Price</th>                    
                    <th width="15%">Stock</th>    
                     <th width="10%">Search</th>    
                                      
                    
                    
                    
                  </tr>
                </thead>
                        </table>
                         </div>
              </div>
          </div>
      </div>
             
        
        
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
 
  <!-- /.content-wrapper -->
 <?php include('include/footer.php'); ?>
    </div>
    </div>
  <?php include('include/script.php'); ?>
  
</body>
</html>
        <div id="dataModal" class="modal fade">
          <div class="modal-dialog">
            <form method="post" id="data_form">
              <div class="modal-content">
              <div class="modal-header">
                
            <h4 class="modal-title"><i class="fa fa-plus"></i> Stock Detail</h4>
              </div>
              <div class="modal-body">
              <div class="form-group">
              <label>Item Name :</label>
              <span id="item_name"></span>
              <span id="span_item_detail"></span>
              <hr />
              <span id="total_stock"></span>
            </div>
                
                
              </div>
              <div class="modal-footer">
                <input type="hidden" name="item_no" id="item_no" />
                <input type="hidden" name="btn_action" id="btn_action" />
                <input type="hidden" name="op_stock" id="op_stock" value="1" />
                
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              </div>
            </div>
            </form>
          </div>
        </div>
        

  <script type="text/javascript">
    document.getElementById("findme").onclick = function () {
      
    };
</script>
<script>
$(document).ready(function(){
  
  var _dataTable = $('#_dataTable').DataTable({
    "processing": true,
    "serverSide": true,
    "order": [],
    "ajax":{
      url:"inventory_fetch.php",
      type:"POST"
    },
    "columnDefs":[
      {
        "target":[2,3,4,5,6],
        "orderable":false
      }
    ],
    "language": {
          "info": "_START_-_END_ of _TOTAL_ entries",
          searchPlaceholder: "Search"
        },
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        
        "pageLength": 25
  });
  $(document).on('click', '.findme', function(){
   var item_no = $(this).attr("id")
        window.open('inventory_detail?print=1&item_no='+item_no,'_blank');
    
  });
  
  
});
    
</script>
<?php
//include('footer.php');
?>
