<?php
if(stripos($_SERVER['SCRIPT_NAME'],"/admin/")===false?false:true){
	include_once("../connect.php");
	include_once("../session.php");
}else{
	include_once("connect.php");
	include_once("session.php");
}
?>
<!doctype html>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		
		<title>INVENTORY</title>
		
		
		<link href="../css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../css/bootstrap-combobox.css" />
		<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/jqc-1.12.3/moment-2.18.1/dt-1.10.16/b-1.5.1/b-html5-1.5.1/fh-3.1.3/sl-1.2.5/datatables.min.css">
		<link rel="stylesheet" type="text/css" href="../css/generator-base.css">
		<link rel="stylesheet" type="text/css" href="../css/editor.bootstrap.min.css">

		<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
		
		<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/bs/jqc-1.12.3/moment-2.18.1/dt-1.10.16/b-1.5.1/b-html5-1.5.1/fh-3.1.3/sl-1.2.5/datatables.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="../js/jszip.min.js"></script>
		
		<script type="text/javascript" charset="utf-8" src="../js/pdfmake.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="../js/vfs_fonts.js"></script>
		<script type="text/javascript" charset="utf-8" src="../js/bootstrap.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="../js/dataTables.editor.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="../js/editor.bootstrap.min.js"></script>
		<script type="text/javascript">
			
			/*
			 * Editor client script for DB table INVENTORY
			 * Created by http://editor.datatables.net/generator
			 */
			
			(function($){
			
			$(document).ready(function() {
				var editor = new $.fn.dataTable.Editor( {
					ajax: '../modules/inventorymanage/table.INVENTORY.php',
					table: '#INVENTORY',
					fields: [
						{
							"label": "Description:",
							"name": "Description"
						},
						{
							"label": "OnHand:",
							"name": "Qty"
						},
						{
							"label": "Cost:",
							"name": "AvgCost"
						},
						{
							"label": "PriceA:",
							"name": "PriceA"
						},
						{
							"label": "PriceB:",
							 "name": "PriceB"
						},
						{
							"label": "PriceC:",
							"name": "PriceC"
						},
						{
							"label": "Commission:",
							"name": "CommissionRate"
						},
						{
							"label": "Location:",
							"name": "Location"
						}
					]
				} );
				$('#INVENTORY').on( 'click', 'tbody td:not(:first-child)', function () {
					editor.inline( this );
				} );
				var table = $('#INVENTORY').DataTable( {
					ajax: '../modules/inventorymanage/table.INVENTORY.php',
					columns: [
						{
							"data": "Line"
						},
						
						{
							"data": "SKU"
						},
						{
							"data": "Description"
						},
						{
							"data": "Qty"
						},
						<?php
							if($_SESSION['Level'] <= 1){
						?>
						{
							"data": "AvgCost"
						},
						<?php
							}
						?>
						{
							"data": "PriceA"
						},
						<?php
							if($_SESSION['Level'] <= 1){
						?>
						{
							"data": "PM_A"
						},
						<?php
							}
						?>
						{
							"data": "PriceB"
						},
						<?php
							if($_SESSION['Level'] <= 1){
						?>
						{
							"data": "PM_B"
						},
						<?php
							}
						?>
						{
							"data": "PriceC"
						},
						<?php
							if($_SESSION['Level'] <= 1){
						?>
						{
							"data": "PM_C"
						},
						<?php
							}
						?>
						{
							"data": "CommissionRate"
						},
						{
							"data": "Location"
						}
					],
					select: true,
					lengthChange: false,
					paging: false,
					scrollY: 500,
					dom: 'Bfrtip',
					buttons: [
						
						'excelHtml5',
						'copy',
						'pdf',
						'colvis'
					]
					
				} );
				table.buttons().container().appendTo( $('#exportButtons', table.table().container() ) );
				
				
			} );
			
			}(jQuery));

		</script>
		<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.colVis.min.js"></script>
		
	</head>
	<body class="bootstrap">
		
       <?php
		include_once("./navbar.php");						
		?>
		<br>
		<br>
		<div id="exportButtons"></div>
		<div class="container" width="100%">

			<h1>
				<span>Quick Inventory Manage</span>
			</h1>
			
			<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered cell-border" id="INVENTORY" width="100%">
				<thead>
					<tr>
						<th>Line</th>
						<th>SKU</th>
						<th>Description</th>
						<th>OnHand</th>
						<?php
						if($_SESSION['Level'] <= 1 ){ ?>
						<th>Cost</th>
						<?php
						}
						?>
						<th>PriceA (Retail)</th>
						<?php
						if($_SESSION['Level'] <= 1 ){ ?>
						<th>PM A %</th>
						<?php
						}
						?>
						<th>PriceB (End User)</th>
						<?php
						if($_SESSION['Level'] <= 1 ){ ?>
						<th>PM B %</th>
						<?php
						}
						?>
						<th>PriceC</th>
						<?php
						if($_SESSION['Level'] <= 1 ){ ?>
						<th>PM C %</th>
						<?php
						}
						?>
						<th>Commission (1% = 0.010)</th>
						<th>Location</th>
					</tr>
				</thead>
			</table>

		</div>
	</body>
</html>
