<?php
session_start();
include("../include/config.php");
include("../include/functions.php"); 
 validate_admin();
 if($_POST['submit']=='Update'){
	 $department=mysqli_real_escape_string($GLOBALS['conn'],$_POST['department']);	
$email=mysqli_real_escape_string($GLOBALS['conn'],$_POST['email']);
$fullname=mysqli_real_escape_string($GLOBALS['conn'],$_POST['name']);	
$mobile=mysqli_real_escape_string($GLOBALS['conn'],$_POST['mobile']);		
		  
		         $obj->query("update tbl_authemail set email='$email', full_name='$fullname', user_type='$department',mobile='$mobile' where id=".$_REQUEST['id']."");
						
	
	  $_SESSION['sess_msg']='email updated sucessfully';  
	   
   header("location:email-list.php");
   exit();
  }
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITE_TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />

</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<?php include("header.php"); 
	   
if($_REQUEST['id']!=''){
$sql=$obj->query("select * from tbl_authemail where id=".$_REQUEST['id']);
$result=$obj->fetchNextObject($sql);
}
?>

<tr>
	<td align="right" class="paddRtLt70" valign="top">
		<table width="99%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			
				<td align="right" valign="top">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td align="left" valign="middle" class="headingbg bodr text14">
					<em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>Admin: Edit <?php echo $result->email; ?> 
					<span  style="float:right; padding-right:10px;">
					<input type="button" name="add" value="View emails"  class="button" onclick="location.href='email-list.php'" /></span></td>
						</tr>
						
						<tr>
							<td height="100" align="left" valign="top" bgcolor="#f3f4f6" class="bodr">
                            <form name="frm" method="POST" enctype="multipart/form-data" action="">
												
							<table width="100%" cellpadding="0" cellspacing="0">
									<tr>
										<td align="center" colspan="2" class="paddRt14 paddBot11">
										<font color="#FF0000"><strong><?php echo $_SESSION['sess_msg']; $_SESSION['sess_msg']='';?></strong></font></td>
									</tr>
									<tr>
										<td width="23%" align="right" class="paddBot11 paddRt14">&nbsp;</td>
										<td width="77%" align="left" class="paddBot11"></td>
									</tr>
								<tr>
                                      <td align="right" class="paddBot11 paddRt14"><strong>Department :</strong></td>
									  <td align="left" class="paddBot11"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="32%"><select name="department" style="width:250px;" required>
                                      <option value="<?php echo $result->user_type; ?>"><?php echo $result->user_type; ?></option>
                                      <option value="All">All</option>
                                      <option value="General">General</option>
                                       <option value="Order">Order</option>
                                        <option value="Store">Store</option>
                                      </select></td>
   
  </tr>
</table>
</td>
							  </tr>
                             
									<tr>
                                      <td align="right" class="paddBot11 paddRt14"><strong>email:</strong></td>
									  <td align="left" class="paddBot11"><input name="email" type="email" size="150" value="<?php echo $result->email; ?>" style="width:250px;" required="required"  /></td>
							  </tr>
                              <tr>
                                      <td align="right" class="paddBot11 paddRt14"><strong>Full Name:</strong></td>
									  <td align="left" class="paddBot11"><input name="name" type="text" size="150" value="<?php echo $result->full_name; ?>" style="width:250px;" /></td>
							  </tr>
                               <tr>
                                      <td align="right" class="paddBot11 paddRt14"><strong>Mobile:</strong></td>
									  <td align="left" class="paddBot11"><input name="mobile" type="text" size="150" value="<?php echo $result->mobile; ?>" style="width:250px;" /></td>
							  </tr>
                              
									
									<tr  ><td colspan="2" id="resultField"></td>
</tr>
									<tr>
									  <td align="right" class="paddRt14 paddBot11">&nbsp;</td>
									  <td align="left" class="paddBot11">&nbsp;</td>
							  </tr>
                             
                              <tr>
									  <td align="right" class="paddRt14 paddBot11">&nbsp;</td>
									  <td align="left" class="paddBot11">&nbsp;</td>
							  </tr>
									<tr>
										<td width="21%" align="right" class="paddRt14 paddBot11">&nbsp;</td>
										<td width="79%" align="left" class="paddBot11">
											<input type="submit" name="submit" value="Update"  class="submit" border="0"/> 	                  		 &nbsp;&nbsp;
																			  </td>
									</tr>
								</table></form>
							</td>
						</tr>
						
					</table>
				</td>
			</tr>
		</table>
	</td>
</tr>
<?php include('footer.php'); ?>
</table>
</body>
</html>


