<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";
/*
print_r($_REQUEST);

Array ( [pid] => 138,137,136 [tx] => 8D6794175K085704F [st] => Pending 
    [amt] => 207.00 [cc] => USD [cm] => [item_number] => 1314182533urf56bkqtbr76u70lj7fnh39j7 
    [__utma] => 111872281.2066770493.1311758338.1313670404.1314019879.19 
    [__utmz] => 111872281.1311758338.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) 
    [km_ai] => null [km_ni] => null [km_uq] => [km_lv] => x 
    [PHPSESSID] => urf56bkqtbr76u70lj7fnh39j7 ) 
        */

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 

if(isset( $_SESSION["sess_artistid"]) and $_SESSION["sess_artistid"]!= ""){
	$artistid = $_SESSION["sess_artistid"];
}else{
	if(!isset($_SESSION['SESS_insertQry']))
	{
		header("Location:login.php");
		exit;
	}	
}
$pids = $_GET['pid'];

$productListingFee = getSettingsValue('product_listing_fee');

if($pids != '')
{
    //$pids = explode($pids, ',');
    if(!empty($pids))
    {
        //$pids = array_unique($pids);
        $sql = "SELECT product_id, product_name
                  FROM ".$tableprefix."products p
                 WHERE p.product_id IN (". mysql_real_escape_string($pids) .")
            AND p.product_artist_id = " . $artistid;
        
        $resultsP = mysql_query($sql) or die(mysql_error());
        $prdCount = mysql_num_rows($resultsP);
    }
}

if(!($productListingFee > 0) || !($prdCount > 0))
{
    header("Location:mycatalog.php");
    exit;
}


$sql = "SELECT *  FROM ".$tableprefix."settings ";
$res = mysql_query($sql);

if(mysql_num_rows($res)>0)
{
    $row = mysql_fetch_array($res);

    $chkPaypal = $row["enablepaypal"];
    $siteurl=$row["site_url"];
    //========================================Check Tax Settings for  Products
    $enable_tax=$row["enable_tax"];
    $default_tax_rate=$row['defaulttax_rate'];
    //==============================================End Tax Check 
    //worldpay account Details
    $chkworldpay = $row["enableworldpay"];
    $worldpaytestmode = $row["worldpay_testmode"];
    $Instid = $row["worldpay_inst_Id"];
    $worldpayEmail = $row["worldpay_email"];
    $worldauthmode = $row["worldpay_transact_method"];
    
    $txtPaypalEmail = $row["paypalemail"];
$txtPaypalSandbox = $row["enablepaypalsandbox"];
}

switch($worldpaytestmode)
{
    case "100":
    $worldpayserver="https://select-test.worldpay.com/wcc/purchase";
    break;

    case "0":
    $worldpayserver="https://select.worldpay.com/wcc/purchase";
    break;

    default:
    $worldpayserver="https://select.worldpay.com/wcc/purchase";
    break;
}

$google_payment_array = array('vgoogle_check_enable','vyourpay_enable','vauthorize_enable','venable_gift_payment');
$google_payment_settings = getSiteGeneralSettings($google_payment_array);

if($google_payment_settings[0] == "Y")
{
	$google_block = "";
}
else
{
	$google_block = "none";
}

if($google_payment_settings[1] == "Y")
{
	$yourpay_block = "";
}
else
{
	$yourpay_block = "none";
}



include "../includes/htmltop.php";
?>
<script>


var xmlhttp;

function showDesc(str)
{
xmlhttp=GetXmlHttpObject();

var subOption=document.getElementById("subOption").value;
if(subOption!=""){
if (xmlhttp==null)
  {
  alert ("<?php echo ALERT_HTTP;?>");
  return;
  }
var url="getPlanDetails.php";
url=url+"?planID="+subOption;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}else{
document.getElementById('showDisc').style.display = "none";
document.getElementById('payMethod').style.display = "none";
document.getElementById('palnID').value="";
}
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
var resText=xmlhttp.responseText;
var resText=resText.split("~IscriptsIamamcdelimiterIscripts~");
document.getElementById('planCharge').innerHTML="<strong>"+resText[3]+"&nbsp;&nbsp;($"+resText[1]+")</strong>";
document.getElementById('palnID').value=resText[0];
document.getElementById('planDescription').innerHTML=resText[2];
document.getElementById('showDisc').style.display = "block";
document.getElementById('payMethod').style.display = "block";


}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
</script>

		<body>
		<center>
		
		<div id="layout">
				
				<!--header area start -->
				
<?php

	include_once("../includes/topheader_seller.php")

?>						
				
				<!--header area end -->
				
				
				<div align="left" class="main_body" >
				<!--main body start -->
<?php	
			
include "../includes/artisttopmenu.php";
	
?>
																
				
					
								
				<div class="content_area">
					<!--content area start -->
									
                                        <h2><?php echo MSG_MAKE_PAY;?></h2>
                                        
					<!--content area ends -->
					
					<div >
<div>
<table cellpadding="0" border="0" cellspacing="0" width="50%" class="manage_table">
    <tr>
        <td>
            <h3><?php echo TEXT_PRODUCT;?></h3>
        </td>
    </tr> 
    <?php
    $count = 0;
    while($row = mysql_fetch_object($resultsP))
    {
        
?>
    <tr>
        <td>
           <strong><?php echo ++$count . '. ' . ucfirst($row->product_name); ?></strong>
        </td>
    </tr>        
        
<?php
    }
    ?>
    <tr>
        <td>
            <h3><?php echo TEXT_LISTFEE;?> : $<?php echo ($productListingFee); ?></h3>
        </td>
    </tr>  
    <tr>
        <td>
            <h3><?php echo TEXT_TOTAL_LISTFEE;?> : $<?php echo ($productListingFee * $prdCount); ?><h3>
        </td>
    </tr>  
	
    </table>
    <table>
    </tr>  
	<tr>
        <td>
            <h3><?php echo MSG_SEL_PAY;?></h3>
        </td>
    </tr> 

<?php			
																										
	if($chkPaypal == "Y")
	{
            
            $totaltopay = $productListingFee * $prdCount;

if($txtPaypalSandbox == "Y"){
    //$paypalurl ="http://192.168.0.11/sudheesh/paypal.php";
	$paypalurl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
	$paypalbuttonurl = "https://www.sandbox.paypal.com/en_US/i/btn/x-click-but23.gif" ;
}else{
    //$paypalurl ="http://192.168.0.11/sudheesh/paypal.php";
	$paypalurl = "https://www.paypal.com/cgi-bin/webscr";
	$paypalbuttonurl = "https://www.paypal.com/en_US/i/btn/x-click-but23.gif" ;
}

/*pass transaction id*/
$uique_sessionid=$userid.time().session_id();
$_SESSION['sess_unique_sessid']=$uique_sessionid;
$uique_sessionid_md5encrypted=md5($uique_sessionid);


$currency_attributes = displayCurrencyType();
 ?>		
		
		<tr>
			<td align="">
                            
<form action="<?php echo $paypalurl;?>" method="post" name="frmPayment">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="<?php echo $txtPaypalEmail; ?>">
    <input type="hidden" name="item_name" value="Product listing fee <?php echo SITE_NAME;?>">
    <input type="hidden" name="item_number" value="<?php echo $uique_sessionid;?>">
    <input type="hidden" name="amount" value="<?php echo $totaltopay;?>">
    <input type="hidden" name="bn" value="armiasystems_shoppingcart_wps_us">
    <input type="hidden" name="return" value="<?php echo SECURE_SITE_URL ."/sellers/product-listing-payment-success.php?&pid=" . $pids; ?>">
    <input type="hidden" name="cancel_return" value="<?php echo SITE_URL ."/sellers/artistmain.php"; ?>">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="<?php echo $currency_attributes[2]?>">
    <input type="image" src="../images/pp.jpg" title="Make payments with PayPal - it's fast, free and secure! " alt="Click here to complete Paypal order payment"/>
</form>                            

<br/><br/>
</td>
	</tr>
	<?php
	 } 
?>

	<tr>
	<td align="">
<?php

$txtEnableAuthorize 	= getSettingsValue('vauthorize_enable');
$txtEnableBluepay       = getSettingsValue('vbluepay_enable');
$txtEnableFirstData	= getSettingsValue('vyourpay_enable');
$enable_buyerToseller	= getSettingsValue('enable_buyerToseller');

	if(($txtEnableAuthorize == "Y" || $txtEnableBluepay == "Y" || $txtEnableFirstData == "Y") && $enable_buyerToseller == 'N')
	{
		$secureurl = SECURE_SITE_URL."/sellers/product-listing-payment-cc.php?&pid=" . $pids;
?>
		<a href="<?php echo $secureurl?>"><img src="../images/cc.gif" valign="top" title="Pay with Credit Card" border="0" ></a>
<?php
	}

?>		
				
		  </td>
		</tr>
		
		<?php /* if($chkworldpay=="Y")
		{?>
		<tr>
		<td> <div id="worldpayBlock">
		<table width="100%">
		<tr><td >
		  <a href="worldpaypayment.php?payment=WP"><img src="../images/worldpay.gif" width="139" height="33" border="0"  title="Make payments with WorldPay - it's fast, free and secure"></a></td>
		</tr>
		<tr>
		  <td >&nbsp;		    </td>
		  </tr>
		</table>
		</form>
		
		</div></td>
		</tr>
		<?
		} 
		?>
				
		
				<tr>
			<td >
				<div id="googleCheckBlock" style="display:<?php echo $google_block?>">
					<table cellpadding="0" cellspacing="0" border="0" width="30%">
						<tr>
							<td>
								<a href="google_checkout_payment.php"><img src="../images/google_checkout.gif"  border="0" title="Google Checkout Payment Gateway"></a>
							</td>	
						</tr>	
					</table>
				</div>
			</td>
		</tr>
		
		<?php
*/
	if($chkPaypal != "Y" && $google_payment_settings[0] != "Y" && $google_payment_settings[1] != "Y" && $google_payment_settings[2] != "Y" && $google_payment_settings[3] != "Y")
	{
?>			
		

		<tr>
			<td class="text_information"> <?php echo MSG_CONT_ADMIN;?>!!</td>
		</tr>	
		<tr>
			<td ><input type="button" class="button" name="back" value="<?php echo BTN_BACK;?>" onClick="Javscript:history.go(-1);"></td>
		</tr>	
<?php

	}

?>		
                <tr>
                    <td>
                        <span style="color:red;"><strong>
			<?php echo MSG_MAKE_SURE;?>	</strong>
							</span>	 
                    </td>
                </tr>	
	

</table>
</div>

							  
							  
							
				  </div>
							


				</div>	
				 
 
                                			
				<div align="left" class="clear_float"><img src="../images/clear_admin.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->

				</div>
<script>
showDesc("<?php echo $myPlanID; ?>");
</script>				

<?php
	include "../includes/footer.php";

?>