<?
session_start();
if(!isset($_SESSION['login']))
{
	 header("Location: $siteURL/index?message=Please Login first ");
	exit;
}
if(isset($_REQUEST['action']) && $_REQUEST['action']=='change_admin_email'){
	$_SESSION['email_admin']=$_REQUEST['email_admin'];
	$_SESSION['email_info']=$_REQUEST['email_info'];
	$_SESSION['email_sales']=$_REQUEST['email_sales'];
	$_SESSION['email_enquiry']=$_REQUEST['email_enquiry'];
	$_SESSION['admin_color']=$_REQUEST['admin_color'];

	$sql_update_admin_email	=	"UPDATE admin SET email_enquiry ='".$_REQUEST['email_enquiry']."', email_info ='".$_REQUEST['email_info']."', email_sales ='".$_REQUEST['email_sales']."', email_admin ='".$_REQUEST['email_admin']."', admin_color ='".$_REQUEST['admin_color']."'  WHERE uname ='".$_SESSION['login']."'";
	mysqli_query($conn,$sql_update_admin_email);
	header("location: index?page=change_email&message=Admin options changed successfully.");
	
}
?>

<td width="100%" align="left" valign="top" bgcolor="" class="red">
<table width="100%" border="0" align="center" cellpadding="0"
	cellspacing="0" bordercolor="#000000">
	<tr>
		<td class="head_ing">&nbsp;</td>
	</tr>
	<tr>
		<td class="head_ing">Change Admin Options</td>
	</tr>
	<tr>
		<td align="center" valign="top" class="red"><? if(isset($_REQUEST['message'])){?>
		<? echo $_REQUEST['message'];?> <? }?></td>
	</tr>
	<tr>
		<td height="254" bordercolor="#FFFFFF" valign="top">
		<table width="100%" border="0" cellspacing="4" cellpadding="0">
			<tr>
				<td align="center" valign="middle">
				<form name="form1" method="POST" action="?page=change_email&action=change_admin_email">
				<table width="60%" border="0" cellpadding="5" cellspacing="1"
					bgcolor="#CCCCCC">
					<tr align="center" bgcolor="#800080">
						<td colspan="2" align="left" bgcolor="#000000" class="white"><strong>Change
						Admin Options</strong></td>
					</tr>
					<tr>
						<td align="left" valign="top" bgcolor="#FFFFFF">Admin panel color&nbsp;:</td>
						<td  align="left" bgcolor="#FFFFFF"><input style="width:300px;" class="color" type="text" name="admin_color" value="<?php echo $_SESSION['admin_color'];?>" /></td>
					</tr>
					<tr>
						<td align="left" valign="top" bgcolor="#FFFFFF" class="admin-txt">Email admin(email_admin) &nbsp;:</td>
						<td align="left" bgcolor="#FFFFFF" class="admin-txt"><input style="width:300px;"  type="text" name="email_admin" value="<?php echo $_SESSION['email_admin'];?>" /></td>
					</tr>
					<tr>
						<td align="left" valign="top" bgcolor="#FFFFFF" class="admin-txt">Email info(email_info)&nbsp;:</td>
						<td align="left" bgcolor="#FFFFFF" class="admin-txt"><input style="width:300px;"  type="text" name="email_info" value="<?php echo $_SESSION['email_info'];?>"></td>
					</tr>
					<tr>
						<td align="left" valign="top" bgcolor="#FFFFFF" class="admin-txt">Email sales(email_sales)&nbsp;:</td>
						<td align="left" bgcolor="#FFFFFF" class="admin-txt"><input style="width:300px;"  type="text" name="email_sales" value="<?php echo $_SESSION['email_sales'];?>"  /></td>
					</tr>
					<tr>
						<td align="left" valign="top" bgcolor="#FFFFFF">Email enquiry(email_enquiry)&nbsp;:</td>
						<td  align="left" bgcolor="#FFFFFF"><input style="width:300px;" type="text" name="email_enquiry" value="<?php echo $_SESSION['email_enquiry'];?>" /></td>
					</tr>					
					<tr>
						<td colspan="2" align="center" bgcolor="#000000" class="admin-txt">&nbsp;
						<input type="submit" name="Submit" value="Submit" /></td>
					</tr>
				</table>
				</form>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</td>
<script language="javascript">
function check()
{
   	var doc=document.form1;
	var email=doc.new1.value;
	if(doc.current.value=="")
	{
		alert("Please enter current email id.");
		doc.current.focus();
		return false;
	}
	else if(doc.new1.value=="")
	{
		alert("Please enter new email id.");
		doc.new1.focus();
		return false;
	}
	else if(email.indexOf('@')==-1)
	{
	alert('Invalid email id, check(@ or .\'s)');
	doc.new1.focus();	
	return false;
	}
	else if(email.indexOf('.')==-1)
	{
	alert('Invalid email id, check(@ or .\'s)');
	doc.new1.focus();	
	return false;
	}
	else if(doc.conform.value=="")
	{
		alert("Please enter confirm email id .");
		doc.conform.focus();
		return false;
	}
	else if(doc.conform.value!=doc.new1.value)
	{
		alert("New email id and confirm email id does not match.");
		var len=doc.conform.value.length;
		doc.conform.select(0,len-1);		
		doc.conform.focus();
		return false;
	}else{
	return true;
	}
	
	
}


</script>
