<?php
include 'header.php';
include 'erpc_gp_tarifas_toolbar.php'; //Nome da tabela _list.php
include_once 'connect.php';

// Método para post de Query Avançada
	$consulta = "select  t.id
                		,t.vl_gp_tarifa 
                        ,c.ds_nome
                        ,f.ds_funcao
                	from erpc_gp_tarifas t
                		inner join erpc_clientes c
                			on t.id_cliente = c.id
                        inner join erpc_gp_funcoes f
                			on t.id_gp_funcao = f.id
                	where t.st_ativo = 1";


?>

<div class="block">
  <div class="header">
  <h2>Setores</h2>
  </div>
  <div class="content">
    <div class="table-responsive">
      <table class="table table-bordered table-striped table-responsible sortable">
        <thead>
          <tr>
          	<th width=0% hidden></th>
			<th width=05%>ID</th>
            <th width=30%>Cliente</th>
            <th width=30%>Função</th>
            <th width=30%>Tarifa</th>
			<th width=05%>Editar</th>
			<th width=05%>Excluir</th>
          </tr>
        </thead>
        <tbody>

          <?php

			$resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
			if (mysqli_num_rows($resultado)>0) {
            while ($registro = mysqli_fetch_assoc($resultado)){

            $id       	   = $registro['id'];
            $id_crip	   = base64_encode($id);
	  		$ds_cliente	   = $registro['ds_nome'];
	  		$ds_funcao     = $registro['ds_funcao'];
	  		$vl_tarifa     = $registro['vl_gp_tarifa'];
						// $ds_nacionalidade= $registro['ds_nacionalidade'];
			echo "<tr>";
			echo "<td hidden></td>";
            echo "<td>$id</td>";
            echo "<td>$ds_cliente</td>";
            echo "<td>$ds_funcao</td>";
            echo "<td>R$ " . str_replace('.', ',', $vl_tarifa) . "</td>";
            echo "<td class='text-center'><a href='erpc_gp_tarifas_edit.php?id=$id_crip'>  <i class='glyphicon glyphicon-pencil' title='Editar'><span class='sr-only'>Editar</span></i></a></td>";
            echo "<td class='text-center'><a href='erpc_gp_tarifas_remove.php?id=$id_crip'><i class='glyphicon glyphicon-remove' title='Remover'><span class='sr-only'>Remover</span></i></a></td>";
          echo "</tr>";
            }
          }
          ?>
        </tbody>
      </table>
    </div> <!-- table-responsive -->
  </div> <!-- content -->
</div> <!-- block -->
<?php include 'footer.php';?>
