<?php session_start();?>
<?php require_once('open_connection.php');?>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<!DOCTYPE html>
<html>
<head>
      <title>PICCSB e-Directory System</title>

</head>
<body bgcolor="#333333"> 

<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="auto"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="auto"></th>
</tr>

<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >
<tr><td>&nbsp;</td></tr>
<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
							$user_id=$_SESSION['user_id'];
							echo 'Welcome: ' . $_SESSION['user_name'];
?>
							<a href="admin_logout.php"><img src="images/logout3.gif" align="right"/></a>							
							</td>
</tr>
<tr><td>
<h2 align="center">UPDATE USER RECORD</h2>

<?php
$user_id=$_GET['user_id'];
 
       $sql = "SELECT * FROM tbl_dir_user WHERE user_id = '$user_id'" ;
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $user_name=$row['user_name'];
			
		?>
				<!--?php echo $user_name;?-->
				
				<form  method="post" >
<table class="imagetable" align="center">
<tr><td>Salutation</td><td> : </td><td><select name="user_salutation" class="input-xlarge">
						<option ><?php echo  $row['user_salutation']; ?></option>
						<option >Mr</option>
						<option >Ms</option>
                                  
                            
                            </select></td></tr>
<tr><td>Fullname</td><td> : </td><td><input type="text" size="50" name="user_fullname" value="<?php echo $row['user_fullname']?>"></td></tr>    
							
<tr><td>UserName</td><td> : </td><td><input type="text" size="10" name="user_name" value="<?php echo $row['user_name']?>"></td></tr>    
<tr><td>Password</td><td> : </td><td><input type="text" size="10" name="user_password" value="<?php echo $row['user_password']?>"></td></tr>   

<?php
     $category_name = $_POST['category_name'];
  //$subCategory_name = $_POST['subCategory_name'];
             $type= $_POST['type'];
 
if (isset($_GET['page'])) 
		{ 
			$page = $_GET['page']; 
		} 
		else 
		{ 
			$page = 1; 
		}
		$start_from = ($page-1) * 10; 
$listcat = mysql_query("SELECT user_section FROM tbl_ref_ecategory");
//$cat_id = mysql_query("Select category_id form tbl_ref_ecategory where category_name='$listcat'");
/*$listsub = mysql_query("SELECT  tbl_ref_esubcategory.subCategory_name from tbl_ref_esubcategory 
Left join  tbl_ref_ecategory ON tbl_ref_esubcategory.category_name=tbl_ref_ecategory.category_name
where 
tbl_ref_ecategory.category_name='$category_name' ");
//$listitem = mysql_query("SELECT * FROM item ORDER BY subcategoryname ASC LIMIT $start_from, 10");

//$sub_id = mysql_query("Select SubCategory_id form tbl_ref_esubcategory where SubCategory_name='$listsub'");*/
?>
                          
<!--tr><td>User Section </td><td> : </td>

							<td><select name="user_section" >
                                <option ><!?php echo  $row['user_section']; ?></option>
                                <!?php $user_query=mysql_query("select * from tbl_dir_user order by user_id")or die(mysql_error());
                                       while($row_section=mysql_fetch_array($user_query)){?>
                                <option> <!?php echo $row_section['user_section']; ?>
                                <!?php } ?>
                                </option>
                              </select></td>
</tr-->

<tr><td>Section Name</td><td> : </td><td><select name="section_name" >
                                <option ><?php echo  $row['section_name']; ?></option>
                                <?php $section_query=mysql_query("select * from tbl_ref_section order by section_name asc")or die(mysql_error());
                                       while($row_section=mysql_fetch_array($section_query)){?>
                                <option> <?php echo $row_section['section_name']; ?>
                                <?php } ?>
                                </option>
                              </select></td></tr>

							
<tr><td>Access</td><td> : </td><td><select name="user_access" class="input-xlarge">
						<option ><?php echo  $row['user_access']; ?></option>
						<option >admin</option>
						<option >user</option>
                        </select></td></tr>
		
<tr><td>Designation</td><td> : </td><td><select name="designation_name" >
                                <option ><?php echo  $row['designation_name']; ?></option>
                                <?php $designation_query=mysql_query("select * from tbl_ref_designation order by designation_name asc")or die(mysql_error());
                                       while($row_section=mysql_fetch_array($designation_query)){?>
                                <option> <?php echo $row_section['designation_name']; ?>
                                <?php } ?>
                                </option>
                              </select></td></tr>
<!--<tr><td>Assign Name</td><td> : </td><td><input type="text" size="20" name="staff_assign" value="<?php echo $row['staff_assign']?>"></td></tr>-->
<tr><td colspan="3" align="center">
<input type="submit" class="myButton" value="UPDATE" name="save" id="save">
<input type="button" class="myButton" value="USER LIST" onClick="window.location.href='administrator_user_view.php'">
</td></tr>
</table>
</td></tr>
<input type="hidden" name="staff_id" value="<?php echo $row['staff_id']?>">
</form>
<?php
// escape variables for security
if (isset($_POST['save'])){
$user_salutation=$_POST['user_salutation'];
$user_fullname=$_POST['user_fullname'];
       $user_name = $_POST['user_name'];
    	$user_password =$_POST['user_password'];
		//$user_section = $_POST['user_section'];
        $section_name = $_POST['section_name'];
         $user_access =$_POST['user_access'];
		 $designation_name=$_POST['designation_name'];
       

// insert record into database
$sql="update tbl_dir_user set user_id='$user_id',user_salutation='$user_salutation',user_fullname='$user_fullname',user_name='$user_name',
user_password='$user_password', section_name='$section_name',user_access='$user_access', designation_name='$designation_name' where user_id='$user_id'";

$result=mysql_query($sql);
if($result)
echo "<script language='javascript'>window.location='administrator_user_view.php'</script>";

else
   
   echo 'Unsuccessfull update';
   }
?>
<!-- row for footer -->	
<tr>
	<th align="center" colspan="4">
	<?php include('footer.php');?>
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="20%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>

</body>
</html>