<?php
if($_SESSION['nivel'] == 1 || $_SESSION['nivel'] == 3){

$result = mysql_query("SELECT 
            crm_chamado.`idChamado`,
            crm_chamado.`id_cliente`,
            crm_chamado.`id_usuario`,
            crm_chamado.`titulo`,
            crm_chamado.`dataHoraCriacao`,
            crm_statusChamado.`titulo` 
          FROM
            crm_chamado 
            JOIN crm_statusChamado 
              ON crm_chamado.`statusChamado` = crm_statusChamado.`idStatusChamado` 
          WHERE crm_chamado.`id_cliente` = '".$_GET['cod']."' AND crm_chamado.`id_usuario` = '".$_SESSION['idUser']."' 
          ORDER BY crm_chamado.`dataHoraCriacao` DESC") or die (mysql_error());

$rescli=mysql_query("select empresa from crm_cliente where id = '".$_GET['cod']."'") or die (mysql_error());

$aempre=mysql_fetch_array($rescli);
?>
 <table width="700" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
  
      <td colspan="2"><hr /></td></tr>
    <tr>
      <td height="25" colspan="2"><span class="style2">Lista de Chamados:</span></td>
    </tr>

<?Php
    require 'auxiliares/formata-data.php';
    while ($linha = mysql_fetch_array($result)){
    list($cod, $codcli, $coduser, $titulo, $dh_iniciado, $statusChamado) = $linha;
    
    ?>  
    <tr>
      <td><span class='style2'>Iniciado em:</span></td>
      <td><span class='style2'><?php echo dataPTBRTime($dh_iniciado); ?></span></td>
    </tr>
      <tr>
        <td><span class='style2'>Chamado:</span></td>
        <td><span class='style2'><b><?php echo $titulo; ?></b></span></td>
      </tr>
    <tr>
      <td><span class='style2'>Status: </span></td>
      <td><span class='style2'><b><?php echo $statusChamado ?></b></span></td>
    </tr>
    <tr>
      <td colspan="2"><a href="miolo.php?miolo=chamados&acao=responder&cod=<?php echo $cod; ?>">Gerenciar</a></td>
    </tr>
    <tr><td colspan='2'><hr /></td></tr>
  <?
    }
  
?>
</table>

<?php 
}
?>