<?php

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


include("config.inc.php");
include("Functions_Purchase.php");
include("Forms_DataGrid_Items.php");

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


$querylog="SELECT ifnull(FI_SupplierItemAuction,0) as loginaccess, ifNull(Login_FastPrint,0) As Login_FastPrint from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");

	
	
//Read From Setup Table							
$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);
}


$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];}   
$mainaction = $_POST["mainaction"]; if ($mainaction == ""){$mainaction = $_GET["mainaction"];}   


if (empty($mainaction))	$mainaction = 'insert';

$message = ereg_replace("'"," ",$message);

print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 

<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">
<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>

<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<link type="text/css" href="js/calendar/jquery.datepick.css" rel="stylesheet">



<link type="text/css" href="js/grid/scripts/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="js/grid/scripts/jquery-ui.min.js"></script>

<script type="text/javascript" language="javascript">

function getAllAuction(auction_id){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText.split("[BRK]");
			document.getElementById('headerGrid').innerHTML='';
			document.getElementById('headerGrid').innerHTML=data[1];
			document.getElementById('bidHistoryGrid').innerHTML='';
			document.getElementById('bidHistoryGrid').innerHTML=data[2];
			document.getElementById('detailGrid').innerHTML='';
			document.getElementById('detailGrid').innerHTML=data[3];
		}
	  }
	var orderBid = '';
	if(document.getElementById('orderBid'))
		orderBid = document.getElementById('orderBid').value;
	
	xmlhttp.open("GET","Form_SupplierAuction_Action.php?mode=getAllAuction&auction_id="+auction_id+"&orderBid="+orderBid,true);
	xmlhttp.send(); 
}

function ClearPage(){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText.split("[BRK]");
			document.getElementById('headerGrid').innerHTML='';
			document.getElementById('headerGrid').innerHTML=data[1];
			document.getElementById('bidHistoryGrid').innerHTML='';
			document.getElementById('detailGrid').innerHTML='';
			
		}
	  }
	
	xmlhttp.open("GET","Form_SupplierAuction_Action.php?mode=clearPage2",true);
	xmlhttp.send(); 
}

function PrintAuction(auction_id){
	var orderBid = document.getElementById("orderBid").value;
	var str = "Exp_AuctionReport.php?auction_id="+auction_id+"&orderBid="+orderBid;
	window.open(str);
}
</script>
<title>Supplier Bid</title>


<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>

<style>
.tstyle1 {
	color: #000000;
	font-weight: bold;
	font-size: 12px;
	font-family: Verdana, Geneva, sans-serif;
}
.tstyle11 {
	color: #000000;
	font-size: 12px;
	font-family: Verdana, Geneva, sans-serif;
}
</style>
</head>
<body>
<form name='bidauction' method='post'>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='message' value='$message' size='200'>

HERE;


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

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>SUPPLIER BID</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='30'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";


echo" <button type='button' id='btnClear' name='btnClear' onclick=\"ClearPage();return false;\" title='Clear Page'><span><span>Clear Page</span></span></button>";				
			
				
echo"	</td></tr></table>";
echo"</td></tr>";				

		
echo"<tr><td id='content-body'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
   <tr bgcolor='#F7F7F7'><td valign='top' align='left' colspan='10'>";	


print <<<HERE
	
		<table border="0" style='table-layout:fixed'>
		  <col width=90>
		  <col width=250>
		  <col width=200>	
		  <col width=430>		
		<tr height='30px' style='background-color: rgba(1, 106, 132, 0.5);' >
          <td valign="center" align='left' colspan='4' style='padding-left: 10px;' ><span class="style1">AUCTIONS LIST</td></tr>
		
HERE;

echo "<tr><td colspan='4'><div id='headerGrid' style='width:1090px;height:300px; overflow-y:scroll; overflow-x:hidden; '>";
	showAllAuctionsGrid($auction_id, $connection);
echo "</div></td></tr>";


//***********Auction Details*******************
	
echo"   <tr><td colspan='3' valign='top'>";

echo"	<div id='bidHistoryGrid'  style='width:630px;' >";
	if($auction_id!=''){
	showHistoryBidGrid($auction_id, $orderBid, $connection);
	}
echo"	  </div>"; 
echo"   </td><td colspan='2' valign='top'>";
echo"	<div id='detailGrid'  style='width:400px;' >";
	if($auction_id!=''){
	showAuctionDetailGrid($auction_id, $connection);
	}
echo"	  </div>"; 
echo "</td></tr>"; 


echo"   </table></td></tr>"; 
 echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>";  


echo" </table>  ";//end of last table menu
	
	

print <<<HERE
</form>
</body>

HERE;

?>
