<?
session_start();
include("../opendb.php");
include("../test.php");
if($che)
{
 $dt=$y.'-'.$m.'-'.$d;
//$re=mysqli_query($db,"select prospect from inquiry where user='$exuser' and ondate<='$dt'");
$re=mysqli_query($db,"select prospect from inquiry where user='$exuser'");
while($row=mysqli_fetch_array($re))
{
 $sq="update prospmaster set exec='$newuser' where exec='$exuser' and pcode='$row[0]'";
 mysqli_query($db,$sq);
}
 // change prospect here
// $sql="update inquiry set user='$newuser' where user='$exuser' and ondate<='$dt'";
 $sql="update inquiry set user='$newuser' where user='$exuser'";
mysqli_query($db,$sql);
// $sql="update followup set user='$newuser' where user='$exuser' and ondate<='$dt'";
 $sql="update followup set user='$newuser' where user='$exuser'";
mysqli_query($db,$sql);
}
?>
<style>
tr{font-family:arial;font-size:13;background-color:white}
TH{COLOR:WHITE;BACKGROUND-COLOR:STEELBLUE}
</style>

<link rel="stylesheet" href="style.css" type="text/css" />
<script>
function valid()
{
 if(document.f1.exuser.selectedIndex==0 ||document.f1.newuser.selectedIndex==0)
  {
    alert('Invalid User Selection');
    return false;
  }
 if(document.f1.d.value.length<=0 ||isNaN(document.f1.d.value))
  {
    alert('Invalid Date');
    document.f1.d.focus()
    return false;
  }
 return true;
}
</script>
</head>
<center>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<table cellspacing=1 cellpadding=5 bgcolor='gray'>
<th colspan=5>CHANGE USER</TH>
<tr><td>Existing User</td><td><select name='exuser'>
<option>Select</option>
<?
$r1=mysqli_query($db,"select username from bruser where level=0")or die('err'.mysqli_error($db));
while($row=mysqli_fetch_array($r1))
 print "<option>$row[0]</option>";
?>
</select>

</td></tr>
<tr><td>New User</td><td><select name='newuser'>
<option>Select</option>
<?
$r2=mysqli_query($db,"select username from bruser where level=0")or die(mysqli_error($db));
while($row=mysqli_fetch_array($r2))
 print "<option>$row[0]</option>";
?>
</select>
</td></tr>
<tr><td>Date from</td><td>dd <input type=text name='d' size=2 maxlength=2>
mm <input type=text name='m' size=2 maxlength=2 value='<?print date('m')?>'>
yy <input type=text name='y' size=4 maxlength=4 value='<?print date('Y')?>'>

<tr>
<th colspan=3><input type=submit value='Change Now' name='che'></th>
</tr>
</table>
</form>

