<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/invfunctions.php');
include ('../inc/repfunctions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){    
$_SESSION['cuPages']='sel_sinvlist.php';   
$cuPage='sel_sinvlist.php';    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}
?>

<div class="side-head">
<div class="row"> 
<div class="col-md-12">
<div class="col-md-10 text-right"></div>
<div class="col-md-2 text-right">
<button class="btn btn-flat bg-red" id="closepop"><span><i class="fa fa-times"></i></span></button>
</div>    
</div>
</div>
</div>
<div id="addsitem">
<div class="col-md-12">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">    
<div class="printableArea print_label">
<style>
@media print {
body  
{ 
    /* this affects the margin on the content before sending to printer */ 
    margin: 0px;  
}
}
@page {
  size: 45mm 35mm;
  margin: 0;
  padding-top: 0;
}

.print_label {
  height: 35mm; /* should be 31.0 */
  width: 45mm; /* should be 63.5 */
}

.print_label {
  padding: 1mm;
  float: left;
  font-size: 3mm;
}
.print_label img {
    margin-top: 3px;
    margin-left: -7px;    
}    
</style>
<?php 
if(isset($_POST['stiker'])){
$unqid=$_POST['stiker'];
$sql="SELECT stk.id,stk.pid,stk.unqid,name,pcode,stk.price,IFNULL(brqty,0) AS brqty,IFNULL(whqty,0) AS whqty,(IFNULL(brqty,0)+IFNULL(whqty,0)) AS avqty FROM (SELECT id,pid,unqid,price FROM tbl_stock) stk LEFT JOIN (SELECT name,pcode,unqid,SUM(avqty) AS brqty FROM tbl_brstock GROUP BY unqid) bst ON bst.unqid=stk.unqid LEFT JOIN (SELECT unqid,SUM(avqty) AS whqty FROM tbl_whstock GROUP BY unqid) wst ON wst.unqid=stk.unqid WHERE (IFNULL(brqty,0)+IFNULL(whqty,0))>0 AND stk.unqid='$unqid'";     
$query=mysqli_query($con,$sql)or die(mysqli_error($con));
$rowadd=mysqli_fetch_array($query);    
}
?>
<div class="text-center" style="break-before: page; margin-top: 4px;margin-left: 4px;">
<?php echo $rowadd['pcode'].' - '.$rowadd['name'];?>
<br>
<img src="../inc/barcode.php?text=<?php echo $rowadd['pcode'];?>&amp;codetype=code128&amp;orientation=horizontal&amp;size=25&amp;print=false">
<br>
    
<div><strong>MRP:</strong><?php echo $rowadd['price'];?></div>
</div>
</div>
</div>
<div class="col-md-2"></div>    
</div>    
<button class="btn btn-flat bg-teal" id="prints"><i class="fa fa-print"></i></button>
</div>    
<script type="text/javascript">
$("#prints").click(function() {    
var mode = 'iframe'; //popup
var close = mode == "popup";
var options = {
mode: mode,
popClose: close
};
$("div.printableArea").printArea(options);
});
</script>
</div>    
