<?php
session_start();

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

include("config.inc.php");
include("Functions_Sales.php");

	
$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");

/// Color Grids    Base1 Base2     Decimal for Amounts

$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2 from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

$query_barcodes="select item_barcode,item_barcode2,item_barcode3 from items where item_id='".$item_id."'";
$resultbarcodes=mysql_query($query_barcodes,$connection) or die(mysql_error());
$row_barcode=mysql_fetch_row($resultbarcodes);
$item_barcode=$row_barcode[0];
$item_barcode2=$row_barcode[1];
$item_barcode3=$row_barcode[2];

print<<<HERE
<html>
<head>

<link rel="stylesheet" href="default.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<SCRIPT type="text/javascript" src="shortcut.js"></script>
<script type="text/javascript" language="javascript">

function SaveChanges(){
	x=document.barcodes;
	x.mainaction.value='editbarcode';
	x.action="Form_Items_Actions.php";
	x.submit();
}

function ClearChanges() {

	x=document.barcodes;
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		x.item_barcode.value='';
		x.item_barcode2.value='';
		x.item_barcode3.value='';
		
	}	
}

</script>
<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}

.style11 {color: #999999; font-weight: bold; }
.style27 {color: #999999 ;font-size: 10px; font-weight:bold;}
.style15 {color: #5151FF; font-size: 11px;}
.selectstyle {font-size: 11px; font-family:arial,verdana,geneva; color:#000000; width=52px}
.selectstyle1 {font-size: 11px; font-family:arial,verdana,geneva; color:#000000; width=35px}
</style>
<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>



<title> Item BarCodes</title>
</head>
<body>
<form name='barcodes' method='post'>
<input type='hidden' name='item_id' value='$item_id'>
<input type='hidden' name='mainaction' value='$mainaction'>

HERE;

$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

echo "<table  border=0><tr><td valign='top'>";
echo "<tr bgcolor='#F7F7F7' height=25px><td height='20' colspan='3' align='center'><font size='1' color='#FF0000' face='Verdana'><b>$message</b></font></td></tr>";


echo "<tr bgcolor='#F7F7F7' height=25px><td colspan='3'><span class='style11'>Please Fill the BarCodes Below</span></td></tr>";

echo "<tr bgcolor='#F7F7F7' height=25px><td><span class='style11'>BarCode 1</span></td><td colspan='2'><input type=text name='item_barcode'  value='".htmlspecialchars($item_barcode, ENT_QUOTES)."' maxlength='20' size='20' ></td></tr>";
echo "<tr bgcolor='#F7F7F7' height=25px><td><span class='style11'>BarCode 2</span></td><td colspan='2'><input type=text name='item_barcode2'  value='".htmlspecialchars($item_barcode2, ENT_QUOTES)."' maxlength='20' size='20' ></td>
</tr>";
echo "<tr bgcolor='#F7F7F7' height=25px><td><span class='style11'>BarCode 3</span></td><td colspan='2'><input type=text name='item_barcode3'  value='".htmlspecialchars($item_barcode3, ENT_QUOTES)."' maxlength='20' size='20' ></td>
</tr>";

echo "<tr bgcolor='#F7F7F7' height=25px>
<td><input type='button' name='clearbutton' value='Clear' ";//post
echo" onclick='ClearChanges();' $style	title='Clear Changes' /></td>
<td><input type='button' name='cancelbutton' value='Cancel' ";//post
echo" onclick='window.close();' $style	title='Close Window' /></td>
	<td><input type='button' name='savebutton' value='Save' ";//post
echo" onclick='SaveChanges();' $style	title='Save Changes' /></td></tr>";


echo"</table>";

if($refresh=='1'){
	echo"<script type='text/javascript'>;";
			echo"	opener.document.items.action='Form_items.php';";
			echo"	opener.document.items.submit();";	
			echo"</script>";
}

echo"</form></body></html>";
?>
