<div class="right_col" role="main">
	<div class="">
		<div class="page-title">
			<div class="title_left">
				<table>
					<tr>
						<td width="150px"><h3>Inventory list</h3></td>
						<td><a href="index.php?pagecontent=inventory_new"><button type="button" class="btn btn-dark">Add Inventory</button></a></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_content">
						<table id="datatable" class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>ID</th>
									<th>Code</th>
									<th>Title</th>
									<th>Price</th>
									<th>QTY</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$result=mysqli_query($conn, "SELECT * FROM inventories") or die (mysql_error());
									while($row = mysqli_fetch_array($result))
									{
										$stockId=$row['iv_id'];
								?>
								<tr>
									<td width="150"><?php echo $row['iv_id'];?></a></td>
									<td width="150"><?php echo $row['iv_code'];?></a></td>
									<td width="150"><a href="<?php echo $row['iv_photolink'];?>" target="_blank"><?php echo $row['iv_title'];?></a></td>
									<td width="150"><?php echo $row['iv_price'];?></a></td>
									<td width="150"><?php echo $row['iv_qty'];?></a></td>
						
									<td>
										<a href="?pagecontent=inventory_update&id=<?php echo $row['iv_id']; ?>"><button class="btn btn-xs btn-primary">Update</button></a>
										
										<a href="?pagecontent=inventories&delete=<?php echo $row['iv_id']; ?>"><button class="btn btn-xs btn-danger">Delete</button></a>
									</td>
								</tr>
								<?php
									}
								?>
						</table>
					</div>
				</div>
			</div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['delete'])){
		
		$id = $_REQUEST['delete'];
		
		mysqli_query($conn,"DELETE FROM inventories WHERE iv_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=inventories');  
	}
?>