<?php
    session_start();
    ob_start();
    require_once("config/conexao.class.php");
    require_once("config/crud.class.php");
	
	$con = new conexao(); 
    $con->connect(); 
    
    if($_GET['cc'] == 'y') {
	
	$cm = mysql_query("SELECT * FROM chat WHERE status = 'S' group by customer");
    echo $qtd = mysql_num_rows($cm);
	
	} else {
	
	$query = mysql_query("SELECT * FROM chat WHERE status = 'S' group by customer LIMIT 8");
 	while($result = mysql_fetch_array($query)){	
	$qtd = mysql_num_rows($result);
	$idcm = $result['customer'];	
	$acct = mysql_query("SELECT * FROM customers WHERE id = '$idcm'");
 	$customer = mysql_fetch_array($acct);
	$userid = $result['user'];
	$ussrs = mysql_query("SELECT * FROM users WHERE id = '$userid'");
 	$user = mysql_fetch_array($ussrs);			   
	
	if($result['tp'] == '1') { ?>
	<li><!-- start message -->
                        <a href="?mod=Dashboard&customer=<?php echo $idcm; ?>">
                          <div class="pull-left">
                            <img src="<?php echo gravatar($customer['email']); ?>" style="width:30px;height:30px;padding:2px;" class="img-circle" alt="Gravatar">
                          </div>
                          <h4> 
                           <?php echo $customer['name']; ?>
                            <small><i class="fa fa-clock-o"></i> <?php $time = strtotime($result['date']); echo humanTiming($time); ?> ago</small>
                          </h4>
                          <p><?php echo limitText(strip_tags($result['msg']),60); ?></p>
                        </a>
                      </li><!-- end message --><hr>
                    
		       <?php } ?>  
		<?php } ?>  
<?php } ?>
