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

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{
	header("Location:login.php");
	exit;
}

$row = mysql_fetch_array(mysql_query("SELECT enable_buyerToseller FROM ".$tableprefix."settings "));
if($row["enable_buyerToseller"]<>"Y")
{
	header("Location:artistmain.php");
	exit;
}


$txtPaypalEmail = $_POST["txtPaypalEmail"];
$txtPaypalIDTOKEN= $_POST["txtPaypalIDTOKEN"];

$chkSandbox= $_POST["chkSandbox"];
$chkPaypal= $_POST["chkPaypal"];

if ($_POST["chkPaypal"]) {
    $chkPaypal = "Y";
} else {
    $chkPaypal = "N";
}

if ($_POST["chkSandbox"]) {
    $chkSandbox = "Y";
} else {
    $chkSandbox = "N";
}


if ($_POST["btnSaveChanges"] == "Save") {
    $message = "" ;

	if (!isNotNull($txtPaypalEmail)) {
        $message .= "* Email Address cannot be empty! <br>";
    } else{
		if (!isValidEmail($txtPaypalEmail)) {
	        $message .= "* Invalid Email Address! <br>";
	    } 
	}


	if (!isNotNull($txtPaypalIDTOKEN)) {
        $message .= "* Identity Token cannot be empty! <br>";
    }
	echo $message;

    if ($message != "") { // error
        $message = "<br>Please correct the following errors to continue!<br>" . $message;
    } else { // no error so insert user details
		 $sql = "UPDATE ".$tableprefix."artists SET 
			enablepaypal = '".addslashes($chkPaypal)."',
			paypalemail = '".addslashes($txtPaypalEmail)."',
			paypalidentitytoken='".addslashes($txtPaypalIDTOKEN)."',
			enablepaypalsandbox='".addslashes($chkSandbox)."'
			WHERE artist_id =  '".addslashes($artistid)."'
			";
		mysql_query($sql) or die(mysql_error());;
		$message= "Profile updated successfully!";
    } 
} 
$sql = "SELECT enablepaypal, enablepaypalsandbox, paypalidentitytoken, paypalemail FROM ".$tableprefix."artists WHERE artist_id = '".addslashes($artistid)."' ";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0){
	$row = mysql_fetch_array($result);
	$chkPaypal= $row["enablepaypal"];
	$chkSandbox = $row["enablepaypalsandbox"];
	$txtPaypalIDTOKEN = $row["paypalidentitytoken"];
	$txtPaypalEmail = $row["paypalemail"];



}
$countrylist = makeCountryList();
include "../includes/htmltop.php";
?>


		<body>
		
		<center>
		
		<div align="left" 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_once("../includes/artisttopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title">Payment Settings</div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">																			
						<form name="frmProfile" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
						<!-- The id of the country field(s).  If more than one, seperate with spaces -->
						<input type="hidden" value="billCountrySelect" name="cs_config_country_field" id="cs_config_country_field">
						<input type="hidden" value="billStateSelect" name="cs_config_state_field"   id="cs_config_state_field">
						
						
						<!-- The id of the the fields holding the default values.  If more than one, seperate with spaces -->
						<input type="hidden" value="billCountryDefault" name="cs_config_country_default" id="cs_config_country_default">
						<input type="hidden" value="billStateDefault"   name="cs_config_state_default"   id="cs_config_state_default">
						<!-- The actual default values -->
						<input type="hidden" value="<?php echo $ddlCountry;?>" name="billCountryDefault" id="billCountryDefault">
						<input type="hidden" value="<?php echo $txtState;?>"   name="billStateDefault"   id="billStateDefault">
					<SCRIPT type="text/javascript" SRC="../js/country-state.js"></SCRIPT>
					
						<input type="hidden" name="userid" value="<?php echo htmlentities($artistid);?>">
							<table cellpadding="0" cellspacing="0" align="center" class="manage_table" width="100%">
								<tr><td colspan="3" align="right">&nbsp;</td></tr>
								<tr><td width="13%" align="right" valign="middle">Enable Paypal</td>
									<td width="0%" align="center" valign="middle">:</td>
									<td width="87%" colspan="2" align="left" valign="middle">&nbsp;<input type="checkbox" id="chkPaypal" onClick="checkPaypalGateway();" name="chkPaypal" <?php if (isset($chkPaypal) and ($chkPaypal == "Y")) {    echo " CHECKED ";} ?> />
									Select the checkbox to enable Paypal									</td>
								  </tr>
								  
								  <tr>
								    <td></td>
									<td></td>
									<td colspan="1">
											<table cellpadding="0" cellspacing="0" border="0" width="100%">
											<!--	<tr>
													<td colspan="3">
													<br>While enabling paypal, you need to set the return page in your site after the paypal payment process is over, in the PayPal Merchant Panel.<br>
													Given below are the details of doing it<br>
													Setting Up Auto Return<br>
													<p>To set up Auto Return: <br>
													  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. Click the Profile tab. <br>
													  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. Click the Website Payment Preferences link under Selling Preferences. <br>
													  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. Click the On radio button to enable Auto Return. <br>
													  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4. Enter the Return URL.<br>
														The return urls are <br>
														&nbsp;&nbsp;&nbsp;&nbsp;Success:&nbsp;<b><?php echo SITE_URL?>/success.php</b>													</p>
													<br>
													<input type="checkbox" id="chkSandbox" name="chkSandbox" <?php if (isset($chkSandbox) and ($chkSandbox == "Y")) {    echo " CHECKED ";} ?>>&nbsp;Paypal Sandbox/Test mode (Uncheck to change to real mode)													</td>
												</tr>  -->
												<tr align="left">												
												  <td valign="middle" colspan="3"><input type="checkbox" id="chkSandbox" name="chkSandbox" <?php if (isset($chkSandbox) and ($chkSandbox == "Y")) {    echo " CHECKED ";} ?>>&nbsp;Paypal Sandbox/Test mode (Uncheck to change to real mode)</td>
											  </tr>												
												<tr align="left">
												  <td valign="middle">Start a new account </td>
												  <td valign="middle">:</td>
												  <td valign="middle"><a href="https://www.paypal.com/us/mrb/pal=NCGEZ2VF6YL62" target="_blank"><img src="../images/paypal_small.jpg" width="77" height="30" border="0" alt="Start A New Account" title="Start A New Account"></a></td>
											  </tr>
												<tr align="left">
													<td valign="middle" width="25%">Email Address&nbsp;<span class="required">*</span></td>
													<td valign="middle" width="2%">:</td>
													<td valign="middle"><input type="text" class="textbox" value="<?php echo htmlentities($txtPaypalEmail);?>" name="txtPaypalEmail"  maxlength="100" onMouseOver="fixedtooltip('Please Enter Pay Pal Email Address .',this,event,'220px');" onMouseout="delayhidetip();">												  </td>
												</tr>
												<tr align="left">
													<td valign="middle" width="25%">Identity Token&nbsp;<span class="required">*</span></td>
													<td valign="middle" width="2%">:</td>
													<td valign="middle"><input type="text" value="<?php echo htmlentities($txtPaypalIDTOKEN);?>" name="txtPaypalIDTOKEN" style="width:300px" onMouseOver="fixedtooltip('Please Enter Pay Pal Identity Token .',this,event,'220px');" onMouseout="delayhidetip();">												  </td>
												</tr>
										  </table>	
																			</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td colspan="3" align="center">
										<input type="submit" value="Save" name="btnSaveChanges"  class="button" >
									</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
							</table>
						</form>
				
				</div>
										
				<!--content area end-->
								
				</div>
				
								
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
?>