<link rel="stylesheet" href="css/new_mxerp.css">

<div class="body_contain">
<div class="tab_div">
<h1>CRM Login History</h1>
		   
			<div  align="center"><?php 
			//echo $_SESSION['UserID'];
			$sql_state=DB_query("SELECT id,userid , realname FROM  www_users where blocked ='0'  ",$db);		
					if(!$sql_state)
					{
					   die('Error.'.DB_error_msg($db));
					}
					echo "<select name='loginid' style='width:150px;' onchange=ShowDiv(this.value,'hid-Roleid','CRMLoginHistory.php') >";
					echo "<option value='000'>---</option>";
					while($row=DB_fetch_array($sql_state))
					{
					   $p='';
					   if($row['userid']==$_REQUEST['loginid'])
					   $p='selected';
					  echo "<option value='".$row['userid']."' $p >".$row['userid']."</option>";
					}
					echo "</select>";
			
			?></div>
<h3>		   Login History</h3>
		 <table width="100%" border="0">

		  <tr>
		    <td><div id='hid-Roleid'>
			
	<?php 		  
 $sql_state=DB_query("SELECT * FROM  crm_login_history where userid ='".$_SESSION['UserID']."' ",$db);		
if(!$sql_state)
{
die('Error.'.DB_error_msg($db));
}
?>
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata">UserName</td>
    <td class="tabledata">IP Address</td>
    <td class="tabledata">Mac Address</td>
    <td class="tabledata">SignIN Time</td>
    <td class="tabledata">SignOut Time</td>
    <td class="tabledata">Status</td>
  </tr>
   

<?php 
while($row=DB_fetch_array($sql_state))
{?>
<tr bgcolor="#c1c1c1">
    <td style="padding-left:5px; padding-right:5px;"><?php  //echo $row['userid'];
	echo $s->GetFieldValue('www_users',"id='".$row['userid']."' and blocked=0",'userid');?></td>
     <td style="padding-left:5px; padding-right:5px;"><?php  echo $row['id_address']?></td>
     <td style="padding-left:5px; padding-right:5px;"><?php  echo $row['mac_address']?></td>
     <td style="padding-left:5px; padding-right:5px;"><?php  echo $row['sign_intime']?></td>
     <td style="padding-left:5px; padding-right:5px;"><?php  echo ($row['sign_outtime']==''?'---':$row['sign_outtime']);?></td>
 <td style="padding-left:5px; padding-right:5px; white-space:nowrap;"><?php  
 if($row['sign_intime']!='' && $row['sign_outtime']=='')
 echo "Signed IN";
 else
  echo "Signed off";

 ?></td>
  </tr>
 <?php 
 }

?>
</table>

			
			
			</div></td>
	      </tr>
		</table>



</div></div>
		