<?php
    session_start();
    ob_start();
    require_once("config/conexao.class.php");
    require_once("config/crud.class.php");
	
	$con = new conexao(); 
    $con->connect(); 
	
	
	$customer = $_GET['customer'];
	
	$query = mysql_query("SELECT * FROM chat WHERE customer = '$customer'");
 	while($result = mysql_fetch_array($query)){	
	$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') { ?>
	<!-- chat item -->
                  <div class="item">
                    <img src="<?php echo gravatar($customer['email']); ?>" style="width:30px;height:30px;" alt="<?php echo $customer['name']; ?>" class="online">
                    <p class="message">
                      <a href="?mod=Profile&id=<?php echo base64_encode($customer['id']); ?>&customer=<?php echo $customer['id']; ?>" class="name">
                        <small class="text-muted pull-right"><i class="fa fa-clock-o"></i> <?php $time = strtotime($result['date']); echo humanTiming($time); ?> ago</small>
                      <?php echo $customer['name']; ?> - Customer
                      </a><?php echo $result['msg']; ?>
                    </p>
                  </div><!-- /.item -->
              <?php } ?>      
      <?php if($result['tp'] == '2') { ?>
		  
		  <!-- chat item -->
                  <div class="item">
                    <img src="<?php echo gravatar($user['email']); ?>" style="width:30px;height:30px;" alt="<?php echo $user['name_user']; ?>" class="offline">
                    <p class="message">
                      <a href="javascript:void(0);" class="name">
                        <small class="text-muted pull-right"><i class="fa fa-clock-o"></i> <?php $time = strtotime($result['date']); echo humanTiming($time); ?> ago</small>
                      <?php echo $user['name_user']; ?> - Support
                      </a><?php echo $result['msg']; ?>
                    </p>
                  </div><!-- /.item -->
		   
		<?php } ?>  
<?php } ?>
