<?php
session_start();

if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass'],true,65536) or die("Could not connect to DB");
$connection1 = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass'],true,65536) or die("Could not connect to DB");

/*
$connection_history = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($config['dbName_history'],$connection_history) or die("Could not find DB");
*/
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");
mysql_select_db($_SESSION['dbName'],$connection1) or die("Could not find DB");

$item_code      = $_GET['item_code'];
$GeneratedLines = $_GET['GeneratedLines'];

$query_setup  = "select BASE1, BASE2 from setup";
$result_setup = mysql_query($query_setup);
$row_setup    = mysql_fetch_array($result_setup);
extract($row_setup);

$query_barcode  = "select item_code, Item_Description, format(Item_SellingPrice1Base1, 2) as Item_SellingPrice1Base1, format(Item_SellingPrice1Base2, 2) as Item_SellingPrice1Base2, format(Item_SellingPrice5Base1, 2) as Item_SellingPrice5Base1, item_barcode3, item_vat from items where item_code = '$item_code'";
$result_barcode = mysql_query($query_barcode, $connection);
$row_barcode    = mysql_fetch_array($result_barcode);
extract($row_barcode);

if($item_vat > 0 ){
	$star = "*";
	$Item_SellingPrice1Base2 = $Item_SellingPrice1Base2 * 1;
}
echo "<div style='width: 250px; text-align: center'>";

$i = 1;
while($i <= $GeneratedLines){
	$i++;
echo "<div style='height: 20px'></div>";
echo "<div style='font-size: 14px; text-align: center; font-family: Arial;'>$Item_Description</div>";
echo "<img src='test_1D.php?text=$item_barcode3' height='40px'  width='180px' border=0>";
echo "<br>";
//echo "<div style='height: 10px'></div>";
echo "<div style='font-size: 12px; text-align: center; font-family: Arial;'>$item_barcode3</div>";
//echo "<div style='height: 25px'></div>";
echo "<div style='margin-top: 10px; font-size: 22px; text-align: center; font-family: Arial;'><span style='text-decoration: line-through'>$Item_SellingPrice5Base1</span> $Item_SellingPrice1Base1 $BASE1</div>";
echo "<div style='height: 15px'></div>";
}
echo "</div>";

echo "<script>
window.print();
</script>";
?>