<?php session_start();  //Developed by ITechScripts
require 'include/configurations.php'; // ITECHBIDS Configuration File
if($_REQUEST[productid])
$_SESSION[productid]=$_REQUEST[productid];
if($_SESSION[productid])
{
$productid=$_SESSION[productid];
}
$sql="select * from auction_details where productid=$productid";
$res=mysql_query($sql);
$row=mysql_fetch_array($res); 
$shipping_route=$row[shipping_route];
if($shipping_route=="Australia ")
$aus="aus";
else if($shipping_route=="UK ")
$UK="UK";
else if($shipping_route=="Americanada ")
$america="america";
else if($shipping_route=="Europe ")
$europe="europe";
else if($shipping_route=="Africa ")
$africa="africa";
else 
$world="all";
$shipping_amt=$row[shipping_cost];
$tax=$row[tax];
$flag=$_POST[flag];
if($flag==1)
{
$world=$_POST[world];
$shipping_amt=$_POST[txtship_amt];
$tax=$_POST[tax];
if(!empty($shipping_amt))
{
if(!is_numeric($shipping_amt))
	{
		$err_amt=$err_72;
      //$err_amt="Your Shipping amount is invalid";
	  $err_flag=1;
	}
}
if(!empty($tax))
{
	if(!is_numeric($tax))
	{
		$err_tax=$err_73;
      //$err_tax="Your Tax is invalid";
	  $err_flag=1;
	}
}
if($world=="world")
{
$shipping_route="Asia Africa Australia Americanada Europe";
}
else
{
$aus=$_POST[aus];
$UK=$_POST[UK];
$america=$_POST[america];
$europe=$_POST[europe];
$africa=$_POST[africa];
$shipping_route="";
 if($aus=="aus")
 $shipping_route.="Australia ";
 if($UK=="UK")
 $shipping_route.="UK ";
  if($america=="america")
 $shipping_route.="Americanada ";
  if($europe=="europe")
 $shipping_route.="Europe ";
  if($africa=="africa")
 $shipping_route.="Africa";
}
  if($err_flag!=1)
  {
    function AddDay($date,$interval) 
{ 
   if (!isset($date)) 
  $date = date("Y-m-d"); 
  $elts = explode("-", $date); 
  $inter=$interval*24*3600; 
  $dcour=mktime(1,0,0,$elts[1],$elts[2],$elts[0]); 
  $dres=$dcour+$inter; 
  $date1=date("Y-m-d",$dres);
  $sec=date("G:i:s");
  $ret_date="$date1"." "."$sec";
  return $ret_date;  
}
   $bidding_start_date = $row['bid_starting_date'];
   $up="update auction_details set shipping_route='$shipping_route',shipping_cost='$shipping_amt',status='Active',tax='$tax' where productid=".$productid;  
   $up1=mysql_query($up);
	require  'include/header.php';
	echo "<table width=600 border=0 cellpadding=5 cellspacing=2 align=center><tr><td style=padding-left:60px>
	<font size=2 color=red><b>Edited Successfully!</b> </font></td></tr>"; 
	
	echo "<tr><td style=padding-left:60px><font size=2><b>Where do you want to go?</b></font></td></tr>";
	echo '<tr><td style=padding-left:60px><a href="home.php">Admin Home Page</a></td></tr>';
	echo '<tr><td style=padding-left:60px><a href="auction.php">Auction </a><br><br></td></tr></table>';
    require  'include/footer.php';
	exit();
  	  }
  }
 ?>

  <link href="cssfiles/css.css" rel="stylesheet" type="text/css">
<? require 'include/header.php'; ?>
 <table width="600" border="0" cellpadding="0" cellspacing="0" align="center" >
 <tr><td class="table_border">
<table width="100%" cellpadding="5" cellspacing="0" align="center" border="0">
<tr height=40>
<td class="tr_border"><font size="2"><b>
Edit Your Item:Shipping Details</b></font> </td></tr>
<tr>
<td>
<? if($err_flag==1)
{ 
?>
<table width="600" align="center">
<tr><td>
<img src="../images/xclabid.gif"></td>
<td><font size=2 color="red">The following must be corrected before continuing:</font></td>

<? if(!empty($err_route))
 {
 ?>
<tr><td>&nbsp;</td>
<td><a href="modifyauction_step2.php#world">Shipping Location</a> - <?= $err_route; ?></td></tr>
<? 
}
?>
<? if(!empty($err_amt))
 {
 ?>
<tr><td>&nbsp;</td>
<td><a href="modifyauction_step2.php#txtship_amt">Shipping Amount</a> - <?= $err_amt; ?></td></tr>
 <? 
 }
 ?>
</table>
<? 
}
?>
<form name="ship" method="post" action="modifyauction_step2.php">
<table width="100%" cellpadding="5" cellspacing="2" border="0">
<tr><td><font size=2><b>Title:</b></font>&nbsp;&nbsp;<?= $row[producttitle]; ?></td></tr>
<tr class="tr_border"><td>
 <? if(!empty($err_ship_loc))
 {?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_ship_loc ?></font>
 <br>
 <b><font size=2 color=red>Shipping Location</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2>Shipping Location</font></b>
   <?
   }
   ?>
  </td>
</tr>
<tr><td>
<table align="center" width="250" cellpadding="5" cellspacing="2">
<tr><td>
<? if($world=="all")
{
?>
<input type="checkbox" name=world value="all" onClick="selectall()" checked>Worldwide
<?
}
else
{
?>
<input type="checkbox" name=world value="all" onClick="selectall()">Worldwide
<?
}
if($UK=="UK")
{
?>
<td><input type="checkbox" name=UK value="UK" checked>UK</td>
<?
}
else
{
?>
<td><input type="checkbox" name=UK value="UK">UK</td>
<?
}
if($aus=="aus")
{
?>
<td><input type="checkbox" name=aus value="aus" checked>Australia</td></tr>
<?
}
else
{
?>
<td><input type="checkbox" name=aus value="aus">Australia</td></tr>
<?
}
if($america=="america")
{
?>
<tr><td><input type="checkbox" name=america value="america" checked>America/Canada</td>
<?
}
else
{
?>
<tr><td><input type="checkbox" name=america value="america">America/Canada</td>
<?
}
if($africa=="africa")
{
?>
<td><input type="checkbox" name=africa value="africa" checked>Africa</td>
<?
}
else
{
?>
<td><input type="checkbox" name=africa value="africa">Africa</td>
<?
}
if($europe=="europe")
{
?>
<td><input type="checkbox" name=europe value="europe" checked>Europe</td></tr>
<?
}
else
{
?>
<td><input type="checkbox" name=europe value="europe">Europe</td></tr>
<?
}
?>
</table>
</td></tr>

<tr class="tr_border">
<td><font size="2"><b>Shipping Cost</b></font></td></tr>
<tr><td align="center">
<? if(!empty($err_amt))
 {?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_amt ?></font>
 <br>
 <b><font size=2 color=red>Shipping Amount</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2>Shipping Amount</font></b>
   <?
   }
   ?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" class="bluetext"name=txtship_amt class="txtsmall" value=<?= $shipping_amt;?>></td></tr>
<tr><td align="center">
<input type="hidden" name="flag" value="1">
<input type="submit" class="button"   name=submit value="submit" class="buttonsearch"></td></tr>
</form>
</table>
</td></tr></table>
<tr><td align="center"><? require 'include/footer.php'?></td></tr>
  </body>
</html>

 </td></tr>

<script language="javascript">
function selectall()
{
if(document.ship.world.checked==false)
{
document.ship.aus.checked=false;
document.ship.america.checked=false;
document.ship.europe.checked=false;
document.ship.africa.checked=false;
document.ship.asia.checked=false;
}
else
{
document.ship.aus.checked=true;
document.ship.america.checked=true;
document.ship.europe.checked=true;
document.ship.africa.checked=true;
document.ship.asia.checked=true;
}
}
</script>
