<?php
	include("includes/dbconfig.php");
	$pagetitle = "Item Stock Level";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1>Item Stock Level</h1>
					<ol class="breadcrumb">
					</ol>
				</section>

				<!-- Main content -->
				<section class="content">
					<!-- Default box -->
					<?php
						if(($_SESSION["connectedusergroup"] == 1) || ($_SESSION["connectedusergroup"] == 2) || ($_SESSION["connectedusergroup"] == 3))
						{
					?>
					<div class="row">
						<div class="col-md-12">
							<div id="servererrormessage">
							</div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-md-12">
							<div class="box box-primary" style="">
							
								<div class="box-body ">
								<form class="form" method="get" action="stockinout.php">
													
													<div class="row">
														<div class="col-lg-3">
														Shop<br />
														
														<select  class="form-control" name="shop_id" id="">
															<?php
																$shops = DB::query("SELECT id, full_name FROM shop");
																
																foreach ($shops as $shop)
																{
															?>
															<option value="<?php echo $shop['id']; ?>"><?php echo $shop['full_name']; ?></option>
															<?php
																}
															?>
														</select>
										
														</div>
														
														
														<div class="col-lg-2">
															&nbsp;<br />
															<input type="submit" class="form-control" value="Search" />
														</div>
													</div>
														  
													</form>
								</div>
							
							</div>
						</div>
					</div>
				
					<div class="row">
						<div class="col-md-12">
							<div class="box box-primary" id="customerclaims" style="">
								<div class="box-body table-responsive">
									
									<div class="table-responsive">
										<div class="table-responsive">
										
										
													
											<table class="table table-hover"  id="example2">
												<thead>
													<tr>
														<th>Item Name</th>
														<th>Quantity</th>
													</tr>
												</thead>
												<tbody>
													
													
													
													<?php
													
													if(isset($_GET['shop_id'])){
															$shop_id = $_GET['shop_id'];
													}else{
														$shop_id = 1;
													}
													
													if(isset($_GET['product_id'])){
															$product_id = $_GET['product_id'];
													}else{
														$product_id = null;
													}
													
													if(isset($_GET['start_date'])){
															$start_date = $_GET['start_date'];
													}else{
														$start_date = date('Y-m-d');
													}
													
													if(isset($_GET['end_date'])){
															$end_date = $_GET['end_date'];
													}else{
														$end_date = date('Y-m-d');
													}
													
														$items = DB::query("SELECT id, shop, item, (select item_name from stock_item where id = s_i_l.item) as item_name, quantity FROM item_stock_level as s_i_l where shop = ".$shop_id);
														
														
														
														foreach ($items as $item)
														{
													?>
													<tr>
														<td><?php echo $item['item_name']; ?></td>
														
														<td>
														<?php echo $item['quantity']; ?>
														
														</td>
													</tr>
													<?php
														}
													?>
												</tbody>
											</table>
										</div>
									</div>
								</div><!-- /.box-body -->
							</div><!-- /.box -->
						</div>
						
						
					</div>
					<?php
						}
						else
						{
					?>
					<div class="alert alert-danger alert-dismissable">
						<i class="glyphicon glyphicon-ban-circle"></i>
						Limited Access
					</div>
					<?php
						}
					?>
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->

			<footer class="main-footer text-center">
				<strong>Copyright &copy; <?php echo date("Y"); ?> BSMPOS.</strong> All rights reserved.
			</footer>
		</div><!-- ./wrapper -->
		
		
		
		<!-- jQuery 2.1.3 -->
		<script src="plugins/jQuery/jQuery-2.1.3.min.js"></script>
		<!-- Bootstrap 3.3.2 JS -->
		<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
		<!-- SlimScroll -->
		<script src="plugins/slimScroll/jquery.slimScroll.min.js" type="text/javascript"></script>
		<!-- FastClick -->
		<script src='plugins/fastclick/fastclick.min.js'></script>
		<!-- DATA TABES SCRIPT -->
		<script src="plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
		<script src="plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
		<!-- AdminLTE App -->
		<script src="dist/js/app.min.js" type="text/javascript"></script>
		
		<script src="plugins/bert/jquery.price_format.min.js" type="text/javascript"></script>
		<script src="plugins/bert/storepos.js" type="text/javascript"></script>
		<script src="plugins/bert/cashsalesregister.js" type="text/javascript"></script>
		
		<!-- bootstrap datepicker -->
<script src="<?php echo $base_url; ?>plugins/datepicker/bootstrap-datepicker.js"></script>
		
		<script type="text/javascript">
		//Date picker
    $('#start_date').datepicker({
      autoclose: true, 
	  format: 'yyyy-mm-dd'
    });
	
	$('#end_date').datepicker({
      autoclose: true, 
	  format: 'yyyy-mm-dd'
    });
		</script>
		<script>
  $(function () {
    $("#example1").DataTable();
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false
    });
  });
</script>
	</body>
</html>