<?php session_start();  //Developed by ITechScripts
error_reporting(0);
require 'include/configurations.php'; // ITECHBIDS Configuration File
require 'include/header.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 <table width="600" cellpadding="5" cellspacing="0" align="center" border="0">
<?
if(!empty($_GET[productid]))
{
$productid=$_GET[productid];
$_SESSION[productid]=$productid;
}
else
{
$productid=$_SESSION[productid];
}
$sql="select * from auction_details where productid=$productid";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$flag=$_POST[flag];
if($flag==1)
{
$world=$_POST[world];

$payid=$_POST[payid];
$payname=$_POST[payname];
$payment=$_POST[payment];
$shipping_amt=$_POST[txtship_amt];
$tax=$_POST[tax];
$rdbut=$_POST[rdbut];
if($world=="world")
{
$shipping_route="Africa Australia Americanada Europe United Kingtom";
}
else
{
$aus=$_POST[aus];
$asia=$_POST[asia];
$america=$_POST[america];
$europe=$_POST[europe];
$africa=$_POST[africa];
$shipping_route="";
 if($aus=="aus")
  $shipping_route.="Australia ";
  if($asia=="uk")
 $shipping_route.="United Kingdom ";
  if($america=="america")
 $shipping_route.="Americanada ";
  if($europe=="europe")
 $shipping_route.="Europe ";
  if($africa=="africa")
 $shipping_route.="Africa";
}

  if($err_flag!=1)
  {
    $bidding_start_date = date("Y-m-j G:i:s"); 
   
   
   
   // insert to table
   $userid=1;   
   $cat_id=$_SESSION[categoryid];

   
   
   $producttitle=$_SESSION[item_name];
   $qty=$_SESSION[qty];
   $itemdes=$_SESSION[des];
   $currency=$_SESSION[currency];
   $postmethod=$_SESSION[postmethod];
   $min_amt=$_SESSION[min_amt];  
   $bid_inc=$_SESSION[bid_inc];
   $dur=$_SESSION[dur];
   $rev_price=$_SESSION[rev_price];
   $quick=$_SESSION[quick_price];	
 if($qty==""){
$qty=1;
}
   $size_of_qty=$_SESSION[size_of_qty];
   $start_delay=0;
   $img1=$_SESSION[image1];
   $img2=$_SESSION[image2];
   $img3=$_SESSION[image3];
   $img4=$_SESSION[image4];
   $img5=$_SESSION[image5];
   $img6=$_SESSION[image6];
   $img7=$_SESSION[image7];
   $img8=$_SESSION[image8];
   $repost=$_SESSION[repost];
$days=$_SESSION[days];
$mins=$_SESSION[mins];
$hours=$_SESSION[hours];
$secs=$_SESSION[secs];


$delaydays=$_SESSION[delaydays];
$delaymins=$_SESSION[delaymins];
$delayhours=$_SESSION[delayhours];
$delaysecs=$_SESSION[delaysecs];

  function AddDays3($date,$interval) 
{ 
  if (!isset($date)) 
  $date = date("Y-m-d H:i:s"); 
  $first = explode(" ", $date); 

  $elts1 = explode("-", $first[0]);
  $elts2 = explode(":", $first[1]);
  $inter=$interval; 
  $dcour=mktime($elts2[0],$elts2[1],$elts2[2],$elts1[1],$elts1[2],$elts1[0]); 
  $dres=$dcour+$inter; 
  $date1=date("Y-m-d H:i:s",$dres);
  $ret_date="$date1";
  return $ret_date; 
}

$duration= $secs + ($mins*60) + ($hours*3600) + ($days*3600*24);




$or_price=$_SESSION[or_price];
$return_pol=$_SESSION[return_pol];
$postformat=$_SESSION[postformat];
$rel=$_SESSION[rel];

   $timetoadd=$_SESSION[timetoadd];

//$expire_date2 = mktime(date("G")+$hours, date("i")+$mins, date("s")+$secs, date("m")  , date("j")+$days, date("Y"));
//$expire_date = date("Y-m-j G:i:s",$expire_date2);

$bid_starting_date2 = mktime(date("G")+$delayhours, date("i")+$delaymins, date("s")+$delaysecs, date("m")  , date("j")+$delaydays, date("Y"));
$bid_starting_date = date("Y-m-j G:i:s",$bid_starting_date2);

$expire_date = AddDays3($bid_starting_date,$duration); 

$default_currency="select * from genaralsettings where set_id=55";
$default_res=mysql_query($default_currency);
$default_row=mysql_fetch_array($default_res);
$default_cur=$default_row[set_value];
   if($_SESSION[sub_cat])
   {
   $cat_id=$_SESSION[sub_cat];
   }
   $cat_id_main=$_SESSION[cat_id];

   $sql="insert into auction_details(user_id, category_main, category_id,producttitle,quantity,detailed_descrip,currency,selling_method,min_bid_amount,bidincrement,duration,reserve_price,quick_buy_price,bid_starting_date,picture1,picture2,picture3,picture4,picture5,picture6,picture7,picture8,size_of_quantity,start_delay,expire_date,shipping_route,shipping_cost,status,tax,payment_gateway,payment_name,payment_id,no_of_repost,or_price,return_pol,timetoadd,or_expire_date)";
   $sql.="values('$userid','$cat_id_main','$cat_id','$producttitle',$qty,'$itemdes','$default_cur','$postformat','$min_amt','$bid_inc','$dur','$rev_price','$quick','$bidding_start_date','$img1','$img2','$img3','$img4','$img5','$img6','$img7','$img8','$size_of_qty',$start_delay,'$expire_date','$shipping_route','$shipping_amt','Active','$tax','$payment','$payname','$payid','$repost','$or_price','$return_pol','$timetoadd','$expire_date')"; 
   $res=mysql_query($sql) or die ("Query failed: " . mysql_error());  
  
// insert end

  
if(!empty($_SESSION[Highlight]) || !empty($_SESSION[Privateauc]) || !empty($_SESSION[Border]) || !empty($_SESSION[Bold]) || !empty($_SESSION[Gallery]) || !empty($_SESSION[Home]))
{  
   $productid=mysql_insert_id();
   $feature_sql="insert into featuredproducts(productid,gallery_feature,home_feature,bold,border,highlight,privateauc)";
   $feature_sql.="values($productid,'$_SESSION[Gallery]','$_SESSION[Home]','$_SESSION[Bold]','$_SESSION[Border]','$_SESSION[Highlight]','$_SESSION[Privateauc]')";
   $feature_res=mysql_query($feature_sql);
   
}   
 
   $up="update auction_details set expire_date='$expire_date',bid_starting_date='$bidding_start_date',shipping_route='$shipping_route',";
    $up.="shipping_cost='$shipping_amt',tax='$tax',payment_gateway='$payment',payment_name='$payname',payment_id='$payid', where productid=".$productid;  
  $up1=mysql_query($up);
   $item_sql="select * from auction_details where productid=$productid";	
   $item_res=mysql_query($item_sql);
   $item_row=mysql_fetch_array($item_res);
   $sucess=1;  
	  }
  }
 ?>
 <body>
<? 
 if($sucess==1)
{
?>
<tr ><td align="center">
<br>
<br>
<br>
<font size="2" color="red"><b>You have successfully listed your item.</b></font>
<br>
<br>
<br>
 </td></tr>
 </table>
 <?
 require 'include/footer.php';
 exit();
 }
 ?>
<!-- <tr align="center"><td align="center"><a href="pay.php">Pay Now</a></td></tr> -->

<tr>
<td>

<? if($err_flag==1)
{ 
?>
<table width="758" 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="ship_itechd.php#world">Shipping Location</a> - <?= $err_route; ?></td></tr>
<? 
}
?>
<? if(!empty($err_amt))
 {
 ?>
<tr><td>&nbsp;</td>
<td><a href="ship_itechd.php#txtship_amt">Shipping Amount</a> - <?= $err_amt; ?></td></tr>
 <? 
 }
 ?>

</table>
<? 
}
?>
</td></tr>

<tr><td>
<form name="ship" method="post" action="ship_itechd.php">
<table width="100%" cellpadding="5" cellspacing="2" border="0">



<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="350" cellpadding="5" cellspacing="2">
<tr><td>
<? if($world=="all")
{
?>
<input type="checkbox" name=world value="all" onClick="selectall()" checked>Worldwide</td>
<?
}
else
{
?>
<input type="checkbox" name=world value="all" onClick="selectall()">Worldwide</td>
<?
}
if($asia=="uk")
{
?>
<td><input type="checkbox" name=asia value="uk" checked>United Kingdom</td>
<?
}
else
{
?>
<td><input type="checkbox" name=asia value="uk">United Kingdom</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>

<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>
<br>
<input type="hidden" name=flag value=1>



</table>




<tr><td align="center">
<input type="submit" class="button"   name=submit value="submit" class="buttonsearch"></td></tr>
</table>
</form>
</td></tr>
</table>
<? require 'include/footer.php'?>
</table>
  </body>
</html>
<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;
}
}


function payment_fun()
{
	payment=document.ship.payment.value;
	if(payment=="") {
		pay.innerHTML="";
	}
	else if(payment==1){ 
		txt="<input type=text name=payid value=<?=$payid;?>>";
		pay.innerHTML="<b>Paypal Id</b>"+txt;
	}
	else if(payment==2){ 
		txt="<input type=text name=payid value=<?=$payid;?>>";
		pay.innerHTML="<b>2Checkout Id</b> "+txt;
	}
	else if(payment==3){ 
		txt="<input type=text name=payid value=<?=$payid;?>>";
		txtname="<input type=text name=payname value=<?= $payname; ?>>";
		pay.innerHTML="<b>WorldPay Id</b> "+txt;
	}
	else if(payment==4){ 
		txt="<input type=text name=payid value=<?=$payid;?>>";
		pay.innerHTML="<b>Money Bookers Id</b> "+txt;
	}
	else if(payment==5){ 
	txt="<input type=text name=payid value=<?=$payid;?>>";
		txtname="<input type=text name=payname value=<?= $payname; ?>>";
		pay.innerHTML="<b>Nochex Id</b> "+txt;
		}

else if(payment==7){ 
		txt="<input type=text name=payid value=<?=$payid;?>>";
txt1="<input type=text name=contact_name value=<?= $contact_name ?>>";
txt2="<input type=text name=acc_title value=<?= $acc_title ?>>";
txt3="<input type=text name=bank_name value=<?= $bank_name ?>>";
txt4="<input type=text name=swift_code value=<?= $swift_code ?>>";
txt5="<input type=text name=acc_number value=<?= $acc_number ?>>";
txt6="<input type=text name=country value=<?= $country ?>>";
pay.innerHTML="<b>Contact Name</b> "+txt1+"<br><b>Account Name</b> "+txt2+"<br><b>Bank Name</b> "+txt3+"<br><b>Swift Code</b> "+txt4+"<br><b>Account Number</b> "+txt5+"<br><b>Country</b> "+txt6;
}
}



</script>
