<? session_start();
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch
?>
<?
$poster=$_POST['poster'];
$amount=$_POST['amount'];
$pay_currency=$_POST['currency_code'];
$itemname=$_POST['itemname'];
list($trn_id, $typeofpay) = explode('||',$_POST['trans_id']); 
$amount=$_SESSION['amount'];
$payment_gateway=$_SESSION['payment_gateway'];
$plan_id=$_SESSION['plan_id'];
$productid=$_SESSION['productid'];
$type=$_REQUEST['type'];
$userid=$_SESSION['userid'];
$trans_date=date('Y-m-d');	
$seller_id=$_SESSION['seller_id'];
$user_id = "$userid";
$txn_id = "";

if($typeofpay=="addfunds")
{
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, txn_id, type, currency, status, typeofpay) values($amount,'$productid','$userid','$trn_id','$trans_date','Add Funds', '$txn_id', 'Credit', '$pay_currency', 'Pending', '$typeofpay')";	
$insert_result=mysql_query($insert_query);
}
if($typeofpay=="regsuccess")
{
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, txn_id, type, currency, status, typeofpay) values($amount,'$productid','$userid','$trn_id','$trans_date', 'Registration Fee', '$txn_id', 'Debit', '$pay_currency', 'Pending', '$typeofpay')";	
$insert_result=mysql_query($insert_query);
}
if($typeofpay=="shopcheck")
{
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, txn_id, type, currency, status, typeofpay, service) values($amount,'$productid','$userid','$trn_id','$trans_date', 'Shop Subscription', '$txn_id', 'Debit', '$pay_currency', 'Pending', '$typeofpay', '$plan_id')";	
$insert_result=mysql_query($insert_query);
}
if($typeofpay=="pr_pay")
{
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, txn_id, type, currency, status, typeofpay, service) values($amount,'$productid','$userid','$trn_id','$trans_date', 'Payment', '$txn_id', 'Debit', '$pay_currency', 'Pending', '$typeofpay', 'ADMIN')";	
$insert_result=mysql_query($insert_query);
}
if($typeofpay=="buy_pay")
{
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, seller_id, txn_id, type, currency, status, typeofpay, service) values($amount,'$productid','$userid','$trn_id','$trans_date', 'Payment','$seller_id', '$txn_id', 'Debit', '$pay_currency', 'Pending', '$typeofpay', 'OTHER')";	
$insert_result=mysql_query($insert_query);
$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, buyer_id, txn_id, type, currency, status, typeofpay, service) values($amount,'$productid','$seller_id','$trn_id','$trans_date', 'Earning','$userid', '$txn_id', 'Credit', '$pay_currency', 'Pending', '$typeofpay', 'OTHER')";	
$insert_result=mysql_query($insert_query);
}

if($poster!='')
{
$to = "$poster";
$auction_query="select * from offline_payments where username='$poster'";
$table=mysql_query($auction_query);
$ret=mysql_fetch_array($table);
$contact_name=$ret['contact_name'];
$acc_title=$ret['acc_title'];
$bank_name=$ret['bank_name'];
$swift_code=$ret['swift_code'];
$acc_number=$ret['acc_number'];
$country=$ret['country'];


$user_sql="select * from member_details where user_id='$poster'";
$user_result=mysql_query($user_sql);
$row=mysql_fetch_array($user_result);
$first=$row[first_name];
$last=$row[last_name];
$emailtosend=$row[email];
$nametosend = "$first $last";
}
if($poster=='')
{
$auction_query="select * from offline_payments where type='1'";
$table=mysql_query($auction_query);
$ret=mysql_fetch_array($table);
$contact_name=$ret['contact_name'];
$acc_title=$ret['acc_title'];
$bank_name=$ret['bank_name'];
$swift_code=$ret['swift_code'];
$acc_number=$ret['acc_number'];
$country=$ret['country'];
}
if($poster=='')
{
$nametosend = "Administrator";
$emailtosend = "$adminmail";
}
?>
<? require 'themes/pay_offline.tpl';?></tr></td>
</table>
