
<?

if(isset($_POST['BtnLogin'])) {
	
			$sql = "SELECT * from user WHERE id='$user' and pwd='".md5($pwd)."' and active='Yes'";
			$result =mysql_query($sql)or die(mysql_error());
			if(mysql_num_rows($result)==0)print("<script type='text/javascript'>alert('Invalid username or password')</script>");	
			else{
				while($myrow=MySQL_fetch_array($result))
				{
					$_SESSION["egoUser"]=$myrow["id"];
					$_SESSION["egoPosition"]=$myrow["position"];
					$_SESSION["egoAccess"]=$myrow["access"];	
					$_SESSION["egoPermission"]=$myrow["usergrp"];	
					$_SESSION["egoType"]=$myrow["typelevel"];	
					$_SESSION["egoBlock"]=$myrow["blockdelete"];	
				}
				
				$sql="insert into log (l_user,l_desc) values ('$user','System Login')";
				@mysql_query($sql) or die(mysql_error());


			}
	}
	

if(!$_SESSION["egoUser"]){

?>

<form  name="formLogin" method="post" ONSUBMIT="return ValidateLoginForm(this)" action="<?=$PHP_SELF ?>">
<table width="90%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" bgcolor="#D6DFF7" class="MenuTitle">User Login </td>
  </tr>
  <tr>
    <td class="subItem">&nbsp;</td>
    <td class="subItem">Username:</td>
  </tr>
  <tr>
    <td colspan="2"><div align="center">
      <input name="user" type="text" id="user" />
    </div></td>
  </tr>
  <tr>
    <td class="subItem">&nbsp;</td>
    <td class="subItem">Password:</td>
  </tr>
  <tr>
    <td colspan="2"><div align="center">
      <input name="pwd" type="password" id="pwd" />
    </div></td>
  </tr>
  <tr>
    <td height="30" colspan="2">
      <div align="center">
        <input name="BtnLogin" type="submit" class="btn" id="BtnLogin" value="Login" />
        </div>  </td>
  </tr>
  <tr>
    <td colspan="2"><a href="forgotPwd.php" class="subItemOver">Forgot Password? </a></td>
    </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
</form>
<? 
}else if ($_SESSION["egoUser"]){ 

	$menulist=explode(",",$_SESSION["egoAccess"]);
	$ugrp=split(",",$_SESSION["egoPermission"]);
	$tl=split(",",$_SESSION["egoType"]);
	

?>  
<table width="90%" border="0" cellpadding="0" cellspacing="0">  
  <tr>
    <td colspan="2"  class="MenuTitle"">Login as <? echo $_SESSION["egoUser"]; ?>	</td>
</tr>
  <tr>
    <td width="12"><div align="center"></div></td>
    <td width="1081" class="subItem"><a href="logOut.php"><img src="images/logout.jpg" align="absmiddle" border="0"/> Logout</a> </td>
  </tr>
  <tr>
    <td colspan="2"  class="MenuTitle"">&nbsp;	</td>
</tr>
  <tr>
    <td colspan="2">
	<div class="navbar">
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem" >Account</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:inline;">
		<div class="subItem"><a href="profile.php">Update Profile</a></div>
	    <div class="subItem"><a href="changePwd.php">Change Password</a></div>
	</div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>

<!-- *********************************Start Menu****************************** -->
<? if((array_search("User",$menulist)==true) || (array_search("NewValue",$menulist)==true)){ ?>
<div class="mainDiv" >
<div class="topItem" >Setup</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:inline;">
<? if(array_search("User",$menulist)==true){ ?>
		<div class="subItem"><a href="user.php">User</a></div>
<? } ?>
<? if(array_search("NewValue",$menulist)==true){ ?>
	    <div class="subItem"><a href="newvalue.php">New Value</a></div>
<? } ?>

	</div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("People",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem"  >People</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="ppl_newPerson.php">New Person</a></div>
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="ppl_npSearch.php">All</a></div>	
		<? 
		for($i=0;$i<count($pin["person"]);$i++)
		{
			list($pid,$pname,$psearch)=explode("|",$pin["person"][$i]);
			echo '<div class="subItem"><a href="ppl_npSearch.php?pm='.$pid.'&'.$psearch.'">'.$pname.'</a></div>';
		}
		?>

        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("Companies",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem"  >Companies</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="com_newCompany.php">New Company</a></div>
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="com_CompanySearch.php">All</a></div>		
		<? 
		for($i=0;$i<count($pin["company"]);$i++)
		{
			list($pid,$pname,$psearch)=explode("|",$pin["company"][$i]);
			echo '<div class="subItem"><a href="com_CompanySearch.php?pm='.$pid.'&'.$psearch.'">'.$pname.'</a></div>';
		}
		?>
        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("e-Blaster",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem" >e-Blaster</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="eb_newTemplate.php">New e-Blaster</a></div>
		<div class="subItem"><a href="eb_newAlert.php">New Scheduler</a></div>		
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="eb_tempSearch.php">All Template</a></div>		
		<div class="subItem"><a href="eb_alertSearch.php">All Scheduler</a></div>		
        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("SMS",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem" >SMS</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="sms_newTemplate.php">New SMS</a></div>
		<div class="subItem"><a href="sms_newAlert.php">New Scheduler</a></div>
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="sms_tempSearch.php">All Template</a></div>		
		<div class="subItem"><a href="sms_alertSearch.php">All Scheduler</a></div>		
        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("Customer",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem" >Customer Service</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="cs_ebResponder.php">e-Blaster Responder</a></div>
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="cs_newCase.php">New Case</a></div>
		<div class="subItem"><a href="cs_caseSearch.php?status=all">All</a></div>		
		<div class="subItem"><a href="cs_caseSearch.php?status=Pending">Pending</a></div>		
		<div class="subItem"><a href="cs_caseSearch.php?status=Follow Up">Follow Up</a></div>		
		<div class="subItem"><a href="cs_caseSearch.php?status=Closed">Closed</a></div>		

        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("Memos",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem"  >Memos</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="mm_newMemo.php">New Memo</a></div>
		<div class="subItem"><hr /></div>		
		<div class="subItem"><a href="mm_memoDraft.php">Draft</a></div>		
		<div class="subItem"><a href="mm_memoSent.php">Sent</a></div>		

        </div>
</div>
</div>
<!-- *********************************End Menu****************************** -->
<br>
<? } ?>
<? if(array_search("Report",$menulist)==true){ ?>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv" >
<div class="topItem"  >Report</div>        
<div class="dropMenu" ><!-- -->
	<div class="subMenu" style="display:none;">
		<div class="subItem"><a href="ppl_personRpt.php">Person Details</a></div>		
		<div class="subItem"><a href="com_companyRpt.php">Company Details</a></div>		
		<div class="subItem"><a href="eb_sentSumRpt.php">e-Blaster Summary</a></div>		
		<div class="subItem"><a href="sms_sentSumRpt.php">SMS Summary</a></div>		
		<div class="subItem"><a href="rpt_analyGrp.php">Analysis Graph</a></div>			
		<div class="subItem"><a href="userlogRpt.php">User Log</a></div>			
        </div>
</div>
</div>
<? } ?>
<!-- *********************************End Menu****************************** -->
<script type="text/javascript" src="xpmenuv21.js"></script>	</td>
  </tr>
</table>


<? } ?>