<?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";

$sellerid 	=$_GET['sellerid'];


if(isset( $_SESSION["sess_artistid"]) and $_SESSION["sess_artistid"]!= "" and  $_SESSION["sess_artistid"] ==$sellerid){
	$artistid = $_SESSION["sess_artistid"];
}else{
	header("Location:login.php?from=upgrade");
	exit;
}


if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 
$txtUserName = $_POST["txtUserName"];
$txtPassword  = $_POST["txtPassword"];

$username_flag = 1;
$password_flag = 0;

$message="";
$stat=$_GET['stat'];

if(!empty($stat)&& $stat=="Y" )
{
	
	$message=MSG_ACC_APPR_SUC;
}

// Check Current Plan Details 

	$sql_date_check = "SELECT ar . * , am . *
							FROM ".$tableprefix."artists_membershipDetails am
							INNER JOIN ".$tableprefix."artists ar ON ar.artist_id = am.artist_id
							INNER JOIN ".$tableprefix."sellerPlans s ON s.plan_Id = ar.sellerPlanID AND  s.plan_Id = am.plan_Id 
							WHERE  s.plan_Period IN ('Y','M') AND  ar.artist_id=".$artistid." ORDER BY am.artist_memEndDate  DESC LIMIT 1";
	$rs_date_check	=mysql_query($sql_date_check) or die(mysql_error());
	if(mysql_num_rows($rs_date_check)>0)
	{
		$sellerObj=mysql_fetch_object($rs_date_check);
		
		$myPlanID 		=	$sellerObj->sellerPlanID;
		
		$date_expiry	=   $sellerObj->artist_memEndDate;
		
		$exipry_status	=  $sellerObj->plan_expired;
	
	}



include "../includes/htmltop.php";
$memberShipType=$_POST['subOption'];
//--------------------------------payment options----------------------------------------//
$sql = "SELECT *  FROM ".$tableprefix."settings ";
$res = mysql_query($sql);

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

$chkPaypal = $row["enablepaypal"];
$chkDwolla              = $row["dwolla_payment_enable"];
$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"];
$chkStripe     = $row["stripe_payment_enable"];
}
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;
}
//---------------------------------------------------------------------------------------//

/*function call to fetch details from site settings*/

$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";
}
?>
<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();
url=url+"&type=1";
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";
var chkDwolla = '<?php echo $chkDwolla; ?>';
if(chkDwolla=="Y"){
document.getElementById('dwollaPayment').innerHTML=resText[4];
}


}
}

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>
<script>
	function checkArtistLoginForm()
	{
	
	  var form_name = new Array('txtUserName','txtPassword');		
	  var display_name = new Array('User Name','Password');
	  var count = 2;	
	
	  if(check_login('frmLogin',form_name,display_name,count))	
	  {
			
		 	   
	  }
	  else
	  {
	  
			return false;
	  
	  }
	   
	}
	
	function resetAll()
	{
		document.getElementById("txtUserName").value="";
		document.getElementById("txtPassword").value="";
	}
</script>

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

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

?>
<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
		//include_once("../includes/artisttopmenu.php")
?>		
																					
								
					<div align="right" class="content_area">
					<!--content area start -->
									<br>									
									<div class="username_chooseplan"><strong><?php echo TEXT_WELCOME;?>&nbsp;<?php echo getArtistName($artistid); ?>&nbsp;&nbsp;</strong></div>
									<br><br>						
					<!--content area ends -->
					
					<div align="center">
					<table width="200" border="0" align="center" cellspacing="0" bordercolor="#000000">
  <tr>
    <td>
	<table width="600" border="0" align="center">
				<tr align="center">
                        <td align="center">
						<b>
			Your plan  <?php if($exipry_status=='Y') { ?> has expired <?php } else { ?>will expire <?php } ?>   on <?php echo dateFormat($date_expiry , "Y-m-d", "m/d/Y") ;?>. <?php echo MSG_TO_CONTINUE;?>
						</b></td>
                      </tr>
                      <tr align="center">
                        <td align="center">&nbsp;</td>
                      </tr>
                      <tr>
                        <td align="center"><form name="subMembership" method="post" action="chooseYourPlan.php">
													<?php
$sql_Plans = "SELECT plan_Id, plan_Title,plan_Description,plan_Status,plan_SubscriptionCharge
		FROM ".$tableprefix."sellerPlans WHERE plan_Status='Y' AND plan_Period !='F'";
$res_Plans =	mysql_query($sql_Plans);
if(mysql_num_rows($res_Plans)>0){
							?>
							<select name="subOption" id="subOption" onchange="showDesc(this.value)" style="width: 250px; font-size:12px; font-weight:bold;">							
							<option value=""><?php echo TEXT_CHOOSE_PLAN;?></option>
							<?php
								
					while($data_plan=mysql_fetch_array($res_Plans))
					{
						echo '<option value="'.$data_plan['plan_Id'].'"';
						if($data_plan['plan_Id']==$myPlanID)
						echo "selected";
						
						echo	'>'.$data_plan['plan_Title'].'</option>';
					}

							?>
							</select>
<?php }?>			
<div id="showDisc" style="display:none;"><br><br><br>
							<div style="border:1px solid #A8A8A8; margin-bottom:10px; padding: 10px 5px 10px 5px; ">
<table width="85%" border="0" cellspacing="0" >
  <tr>
    <td style=" border-bottom-width:2px; border-bottom-style:dotted; border-bottom-color:#333333; ">&nbsp;&nbsp;<div align="justify" id="planCharge"></div><br></td>
  </tr>
  <tr>
    <td><br><div align="justify" id="planDescription"></div></td>
  </tr>
</table>


</div></div>
<input type="hidden" name="palnID"  id="palnID" value="">
							</form></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
          </table>
	</td>
  </tr>
</table>		

<br><br>
<div id="payMethod" style="display:none">
<table cellpadding="0" border="0" cellspacing="0" width="100%">
		
<?php

$txtEnableAuthorize 	= getSettingsValue('vauthorize_enable');
$txtEnableBluepay       = getSettingsValue('vbluepay_enable');
$txtEnableFirstData	= getSettingsValue('vyourpay_enable');
$enable_buyerToseller	= getSettingsValue('enable_buyerToseller');
																										
	if($chkPaypal == "Y")
	{
 ?>		
		<tr>
		  <td align="center"><?php echo MSG_PAYPL_ORDER;?></td>
		  </tr>
		<tr>
			<td align="center">

		<a href="pay_upgrade.php?paymentMethod=PP"><img src="../images/pp.jpg" alt="Click here to complete Paypal order payment" border="0" title="Make payments with PayPal - it's fast, free and secure! " ></a>



<br>
<?php echo MSG_MAKE_SURE;?></td>
	</tr>
	<?php
	 } 
?>
        <?php     if($chkDwolla=="Y" && $adminCurrency['currency_code']=='USD'){ ?>
        <tr>
          <td align="center"><?php echo CLICK_DWOLLA_PAYPAL_TEXT; ?></td>
        </tr>
		 <tr>
                    <td align="center" id="dwollaPayment">
                      <?php echo generateDwollaPaymentScript(1,'dwolla_success.php'); ?> 
		                                
                        
                        </td>
                       
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
        
             
    <?php     } ?>


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


	if(($txtEnableAuthorize == "Y" || $txtEnableBluepay == "Y" || $txtEnableFirstData == "Y" || $chkStripe=="Y") && $enable_buyerToseller == 'N')
	{
		$secureurl = SECURE_SITE_URL."/sellers/payment_upgrade.php";
?>
		<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 align="center">
		  <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 align="center">&nbsp;		    </td>
		  </tr>
		</table>
		</form>
		
		</div></td>
		</tr>
		<?
		}
		?>
				<tr>
			<td align="center">
				<div id="yourPayBlock" style="display:<?php echo $yourpay_block?>">
					<table cellpadding="0" cellspacing="0" border="0" width="30%">
						<tr>
							<td align="center"><a href="<?php echo SECURE_SITE_URL."file:///C|/Documents%20and%20Settings/devloper/Application%20Data/Macromedia/Dreamweaver%20MX%202004/Configuration/ServerConnections/rads/"?>yourpay_payment.php"><img src="images/yourpay.jpg" valign="top" title="Pay with YourPay Payment Gateway" border="0" ></a></td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
		
				<tr>
			<td align="center">
				<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($google_payment_settings[3] == "Y" && $_SESSION['gift_certificate_flag'] == "N")
	{

?>		
		
		
		<tr>
			<td align="center"><a href="giftcoupon_payment.php"><img src="images/giftcoupon_payment.jpg" border="0" title="Pay with Gift Certificate"></a></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 align="center"><input type="button" class="button" name="back" value="Back" onClick="Javscript:history.go(-1);"></td>
		</tr>	
<?php

	}

?>		
	</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";

?>