
<?php

// $name = 123;

// echo "<img class='news-thumb' src='barcode/".$name.".gif'/>";

include("sass/icon_for_datepicker_and_datatable.php");


$branch_id = $_SESSION['user_id'] ;
			$result_for_supplier = mysqli_query($connection,"SELECT * FROM branch WHERE branch_id  = '$branch_id'");
		$test_for_supplier = mysqli_fetch_array($result_for_supplier);
				$branch_name=$test_for_supplier['branch_name'];


$sql="SELECT * FROM `product_setup`";
$result=mysqli_query($connection,$sql);




?>
   

<div class="col-md-6 col-md-offset-3" style="margin-top:20px;">
<h2 style="text-align:center;">BAR CODE PRINT</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select class="form-control" name="name">
<?php
while($row=mysqli_fetch_array($result))
{
?>
 <option value="<?php echo $row['barcode']."-".$row['product_name']."-".$row['selling_price']; ?>"><?php echo $row['product_name']." - ".$row['barcode']; ?></option>
<?php } ?>
</select>
Quantity: <input type="number" class="form-control" name="quantity">

Size:<select class="form-control" name="class">
<option value="ssmall">Super Small</option>
 <option value="small">Small</option>
 <option value="normal">Normal</option>
 <option value="large">Large</option>
</select>

<br>
<input type="submit" name="submit">
</form>
</div>


<script type="text/javascript">     
        function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=900,height=900');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<div class="row" style="margin-top:170px;"><input type="button" value="print" onclick="PrintDiv();" /></div>


 <div class="col-md-8 col-md-offset-4" id="divToPrint" style="padding: 20px;margin:auto">

 
 <style>
 .small
{
 float: left;
    font-size: 10px;
    text-align: center;
	margin: 5px;
}

.small .price
{
margin-top: -7px;
font-size: 10px;
}
.ssmall .product
{
margin-bottom: -2px;
}
 
 
 
.ssmall
{
 float: left;
    font-size: 10px;
    text-align: center;
	margin: 5px;
}

.ssmall .price
{
margin-top: -7px;
font-size: 9px;
font-weight:700;
}
.ssmall .product
{
margin-bottom: 0px;
}

.normal
{
 float: left;
    font-size: 10px;
    text-align: center;
	margin: 5px;
	font-weight:700;
}

.normal .price
{
margin-top: -5px;
}

.large
{
 float: left;
    font-size: 11px;
    text-align: center;
	margin: 5px;
	font-weight:700;
}

.large .price
{
margin-top: -5px;
}

</style>










<?php


if(isset($_POST['quantity'])) 
{ 

$name = $_POST['name'];
$class = $_POST['class'];
$pieces = explode("-", $name);
$name = $pieces[0]; // piece1


include "Barcode39.php"; 

// set Barcode39 object 
$bc = new Barcode39($name); 



// set barcode bar thickness (thick bars) 
// $bc->barcode_bar_thick = 1; 

if($class=="large")
{
$bc->barcode_height = 50;
$bc->barcode_text_size = 1; 
$bc->barcode_bar_thin = 1; 
$bc->barcode_bar_thick = 2;
$bc->barcode_padding = 1;
}


if($class=="normal")
{
$bc->barcode_height = 40;
$bc->barcode_text_size = 1; 
$bc->barcode_bar_thin = 1; 
$bc->barcode_bar_thick = 2;
$bc->barcode_padding = 1;
}


if($class=="small")
{
$bc->barcode_height = 30;
$bc->barcode_text_size = 0.5; 
$bc->barcode_bar_thin = 1; 
$bc->barcode_bar_thick = 2;
$bc->barcode_padding = 1;
}


if($class=="ssmall")
{
$bc->barcode_height = 25;
$bc->barcode_text_size = 0; 
$bc->barcode_bar_thin = 1; 
$bc->barcode_bar_thick = 2;
$bc->barcode_padding = 0.5;
}

// set barcode bar thickness (thin bars) 
// $bc->barcode_bar_thin = 3; 

// display new barcode 
$bc->draw("barcode/".$name.".gif");

for($i=1;$i<=$_POST['quantity']; $i++)
{

echo "<div class='".$class."'>";
if($class!="small" && $class!="ssmall")
echo "$branch_name</br>";
echo "<div class='product'>".$pieces[1]."</div>";
echo "<img class='news-thumb' src='barcode/".$name.".gif'/>";
echo "<div class='price'>TK.".$pieces[2]."</div>";
echo "</div>";
}

// $bc->draw();
}

?>

</div>


