<?php
session_start();
require("php_con.php");
require("check_user.php");
require("function.php");

if(isset($_SESSION['colum_count'])){
	
}
else{
$_SESSION['colum_count']=1;
}

if(isset($_POST['c_val'])){
	$_SESSION['colum_count']=mysqli_real_escape_string($connation,$_POST['c_val']);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<title><?php echo $system_name; ?></title>
<link rel="stylesheet" href="main_css.css">
	
<script src="data_table/js/jquery-3.5.1.js"></script>
<script src="data_table/js/jquery.dataTables.min.js"></script>
<script src="data_table/js/dataTables.bootstrap4.min.js"></script>
<link rel="stylesheet" href="data_table/css/bootstrap.css">
<link rel="stylesheet" href="data_table/css/dataTables.bootstrap4.min.css">
	
<link rel="stylesheet" href="icon/css/font-awesome.css">
<link rel="stylesheet" href="icon/css/font-awesome.min.css">
	
<link rel="stylesheet" href="alert/sweetalert2.min.css">
<script src="alert/sweetalert2.min.js"></script>
<script src="barcode/JsBarcode.all.js"></script>
</head>
<style>
	.bar-main{
		padding: 5px;
		border-radius: 5px;
		margin: 5px;
		border: 1px solid #000000;
		display: inline-block;
	}
	.bar-shopname{
		font-weight: bold;
		text-align: center;
		text-transform: capitalize;
	}
	.bar-price{
		font-weight: bold;
		text-align: center;
	}
	.bar-p-name{
		text-align: center;
		text-transform: capitalize;
	}
	.link-dis,.link-dis:hover{
		text-decoration: none;
		color: black;
	}
</style>
<body>
<script>
window.addEventListener("load",function(){
	var load_screen=document.getElementById('load_screen');
	document.body.removeChild(load_screen);
});
</script>

<div id="load_screen"><div id="loading"><img src="image/loading.gif" width="80px;"></div></div>
	
<?php require("header.php"); ?>
	
<div class="contaner">

	
<strong>Barcode Create</strong>
	
<?php require("sub_menu/product.php"); ?>
	
	
<form method="post">
<table class="table-sm">
  <tbody>
    <tr>
      <td>Column Count:</td>
      <td><input name="c_val" type="number" required="required" class="form-control form-control-sm" id="c_val" min="1" step="1" value="<?php echo $_SESSION['colum_count']; ?>"></td>
    </tr>
  </tbody>
</table>
</form>
	

<?php
$product_barcode=mysqli_real_escape_string($connation,$_GET['product_barcode']);
$bb_qury=mysqli_query($connation,"SELECT *
FROM price_details prd INNER JOIN product_details pd ON prd.price_systemid=pd.product_systemid
WHERE pd.product_barcode='$product_barcode'
ORDER BY prd.price_id DESC");
while($bb_resalt=mysqli_fetch_assoc($bb_qury)){
?>
<a href="barcode_print.php?price_id=<?php echo $bb_resalt['price_id']; ?>" class="link-dis" target="barcode_print_load">
<div class="bar-main">
<div class="bar-shopname"><?php echo setting_view("bill_title"); ?></div>
<div class="bar-p-name"><?php echo $bb_resalt['product_name']; ?></div>
	
	<div style="text-align: center;">
		<img id="barcode<?php echo $bb_resalt['price_id']; ?>"/>
		<script>JsBarcode("#barcode<?php echo $bb_resalt['price_id']; ?>", "<?php echo $product_barcode; ?>", {
			format:"CODE128",
			displayValue:true,
			fontSize:14,
			height:25,
			margin:0
		});</script>
	</div>
	
<div class="bar-price"><?php echo number_format((float)$bb_resalt['price_sale'],2); ?></div>
	
</div>
</a>
<?php } ?>
	
	
<iframe name="barcode_print_load" style="display: none;"></iframe>

</div>	
	
<datalist id="product_list">
	<?php 
	$sug_list_qury=mysqli_query($connation,"SELECT * FROM product_details ORDER BY product_name");
	while($sug_list_resalt=mysqli_fetch_array($sug_list_qury)){
	?>
	<option value="<?php echo $sug_list_resalt['product_barcode']; ?>"><?php echo $sug_list_resalt['product_name']." | ".$sug_list_resalt['product_name_sinhala']; ?></option>
	<?php } ?>
</datalist>
	
</body>
</html>
<?php @mysqli_close($connation); ?>