<?php
session_start();
include_once("config.php");
$_SESSION['PCD_Login_Error']="";

include_once("data_definitions.php");

if($_SESSION["seas_brd_language"]==2) {
	$font_increase_value=3;
}
else {
	$font_increase_value=0;
}


if(isset($_REQUEST['Btn_Save'])) {
	$oOptions = array(1,1,1,1,1,1);
	if(isset($_REQUEST['Chk_Strength'])) 	$oOptions[0]=1; else $oOptions[0]=0;
	if(isset($_REQUEST['Chk_Character'])) 	$oOptions[1]=1; else $oOptions[1]=0;
	if(isset($_REQUEST['Chk_Positive'])) 	$oOptions[2]=1; else $oOptions[2]=0;
	if(isset($_REQUEST['Chk_Negative'])) 	$oOptions[3]=1; else $oOptions[3]=0;
	if(isset($_REQUEST['Chk_Average'])) 	$oOptions[4]=1; else $oOptions[4]=0;
	if(isset($_REQUEST['Chk_Graph'])) 		$oOptions[5]=$_REQUEST['Chk_Graph']; else $oOptions[5]=1;
	
	if(isset($_REQUEST['passwd'])) {
		$passwd = trim($_REQUEST['passwd']);
	}
	else {
		$passwd = "";
	}
	if(isset($_REQUEST['username'])) {
		$username = trim($_REQUEST['username']);
	}
	else {
		$username = "";
	}	
	
	$updt_sql = 'update seas_user set user_options="' . implode(",",$oOptions) . '" ';
	if(strlen($passwd)>0) {
		$updt_sql .= ',passwd = password("' . $passwd . '") ';
	}
	if(strlen($username)>0) {
		$updt_sql .= ',fullname = "' . $username . '" ';	
	}
	$updt_sql .= ' where user_id = ' . $_SESSION['seas_user_id'];	

	mysql_query($updt_sql);
	if(strlen(mysql_error()) <=0) {
		$_SESSION['PCD_user_opts'] = implode(",",$oOptions);
		$_SESSION['seas_user_fullname'] = $username;
		echo "<script>";
		//echo "	window.opener.location.href = window.opener.location.href;"; 
		echo "	window.close();"; 
		echo "</script>";
	}
	else {
		$_SESSION['PCD_Login_Error']="Error in updating user profile";
	}
}

if(!isset($_SESSION['seas_user_id'])) $_SESSION['seas_user_id']=0;
if($_SESSION['seas_user_id'] <=0) {
	$_SESSION['PCD_page_ref']="report.php";
	header("location:login");
}

if(strlen($_SESSION['PCD_user_opts'])>0) {
	$usr_opts = explode(",",$_SESSION['PCD_user_opts']);

}
else {
	$usr_opts = array(1,1,1,1,1,1);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <? if($_SESSION["seas_brd_language"]==2) echo 'dir="rtl"'; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User Options</title>
<style type="text/css">
body {
	background-color: #FCC;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
h1 {
	font-family:Verdana, Geneva, sans-serif;
	font-size:<?php echo 16+$font_increase_value; ?>px;
	font-weight:bolder;
	color:#000;
}
</style>
<style type="text/css">
.tbl_cell {
	font-family:Verdana, Geneva, sans-serif;
	font-size:<?php echo 11+$font_increase_value; ?>px;
	color:#000;
	font-weight:bolder;
}
.tbl_cell_hdr {
	font-family:Verdana, Geneva, sans-serif;
	font-size:<?php echo 13+$font_increase_value; ?>px;
	color:#000;
	font-weight:bolder;
}
.tbl_cell_hdr2 {
	font-family:Verdana, Geneva, sans-serif;
	font-size:<?php echo 12+$font_increase_value; ?>px;
	color:#000;
	font-weight:bolder;
	text-decoration:none;
}
.tbl_cell_hdr2:hover {
	color:#FFF;
}
.tbl_cell_err {
	font-family:Verdana, Geneva, sans-serif;
	font-size:<?php echo 10+$font_increase_value; ?>px;
	color: #F00;
}

</style>
</head>
<body>
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr><td>
<h1><?php  echo $language_array['user_profile']; ?></h1>
<form id="form1" name="form1" method="post" action="">
  <table width="100%" border="1" style="border-collapse:collapse; border: thin #000">
    <tr>
      <td nowrap="nowrap" class="tbl_cell_hdr"><?php  echo $language_array['user_full_name']; ?></td>
      <td colspan="5" nowrap="nowrap" class="tbl_cell"><input type="textbox" name="username" id="username" style="width:200px" value="<?php echo $_SESSION['seas_user_fullname']; ?>" /></td>
    </tr>
    <tr>
      <td nowrap="nowrap" class="tbl_cell_hdr"><?php  echo $language_array['new_password']; ?></td>
      <td colspan="5" nowrap="nowrap" class="tbl_cell">     <input type="password" name="passwd" id="passwd"  style="width:200px"/></td>
    </tr>   
    <tr>
      <td nowrap="nowrap" class="tbl_cell_hdr"><?php  echo $language_array['columns_to_show_in_report']; ?></td>
      <td nowrap="nowrap" class="tbl_cell" bgcolor="#91C8FF"><input type="checkbox" name="Chk_Strength" id="Chk_Strength" value="1" <?php if($usr_opts[0]==1) echo "checked"; ?> />
        <label for="Chk_Strength"><strong><?php  echo $language_array['strength']; ?></strong></label></td>
      <td nowrap="nowrap" class="tbl_cell" bgcolor="#ff00ff"><input type="checkbox" name="Chk_Character" id="Chk_Character"  value="1" <?php if($usr_opts[1]==1) echo "checked"; ?>  />
        <label for="Chk_Character"><strong><font color="#000"><?php  echo $language_array['tone']; ?></font></strong></label></td>
      <td nowrap="nowrap" class="tbl_cell" bgcolor="#00FF00"><input type="checkbox" name="Chk_Positive" id="Chk_Positive"  value="1" <?php if($usr_opts[2]==1) echo "checked"; ?>  />
        <strong>
        <label for="Chk_Positive"><?php  echo $language_array['positive']; ?></label>
        </strong></td>
      <td nowrap="nowrap" class="tbl_cell" bgcolor="#FF0000"><input type="checkbox" name="Chk_Negative" id="Chk_Negative"  value="1" <?php if($usr_opts[3]==1) echo "checked"; ?>  />
        <label for="Chk_Negative"><strong><?php  echo $language_array['negative']; ?></strong></label></td>
      <td nowrap="nowrap" class="tbl_cell" bgcolor="#FFFFCC"><input type="checkbox" name="Chk_Average" id="Chk_Average"  value="1" <?php if($usr_opts[4]==1) echo "checked"; ?>  />
        <label for="Chk_Average"><strong><?php  echo $language_array['average']; ?></strong></label></td>
    </tr>
    <tr>
      <td nowrap="nowrap" class="tbl_cell_hdr"><?php  echo $language_array['type_of_graph_in_report']; ?></td>
      <td nowrap="nowrap" class="tbl_cell"><input type="radio" name="Chk_Graph" id="Chk_Radar" value=1  <?php if($usr_opts[5]==1) echo "checked"; ?> />
      <label for="Chk_Radar"><?php  echo $language_array['radar']; ?></label></td>
      <td nowrap="nowrap" class="tbl_cell"><input type="radio" name="Chk_Graph" id="Chk_Bar" value=2  <?php if($usr_opts[5]==2) echo "checked"; ?> />
      <label for="Chk_Bar"><?php  echo $language_array['bar']; ?></label></td>
      <td colspan="3" nowrap="nowrap" class="tbl_cell">&nbsp;</td>
    </tr>    

    <?php 
	if(strlen(trim($_SESSION['PCD_Login_Error']))>0) {
	?>	
    <tr>
      <td colspan="6" nowrap="nowrap" class="tbl_cell_err"><?php echo $_SESSION['PCD_Login_Error']; ?></td>
    </tr> 
	<?php
	}
	?>
  </table>

<p><span class="tbl_cell_hdr">
  <input type="submit" value="<?php  echo $language_array['save']; ?>" name="Btn_Save" style="height:30px; width: 100px; background-color: #BCC7FA font-size:14px; font-weight:bold">
</span></p>
</form>
</td>
</tr>
</table>


<table width="100%" cellpadding="5">
	<tr>
		<td width="10%" height="46" align="center" background="images/bg.png"><a href="definition.php" target="my_frame"  class="tbl_cell_hdr2">Definitions</a></td>
	  <td width="14%" align="center" background="images/bg.png"><a href="arabic_trans.php" target="my_frame"  class="tbl_cell_hdr2">Interface Translation</a></td>
	  <td width="12%" align="center" background="images/bg.png"><a href="arabic_trans_target.php" target="my_frame"  class="tbl_cell_hdr2">Target Translation</a></td>
		<td width="64%"  background="images/bg.png">&nbsp;</td>
  </tr>
</table>
<iframe id="my_frame" name="my_frame" width="100%" height="700px" scrolling="auto" src="definition.php" frameborder="0"></iframe>


</body>
</html>
