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

// Método para post de query avançada
	$consulta = "SELECT id, ds_canal FROM erpc_dom_canal_cliente where st_ativo = 1 ";

	//Efetuando busca avan�ada - se passado os parametros
	if(isset($_POST['pesquisar'])) {
		$id         = $_POST['id'];
		$ds_classificao	= trim($_POST['ds_canal']);
 

	  $consulta .= (!empty($id)  		? " and id like '%$id%'"            : '');
	  $consulta .= (!empty($ds_classificacao)? " and ds_canal like '%ds_canal%'"            : '');

	}
	$consulta .= " order by id asc"
?>

<div class="block">
  <div class="header">
  <h2>Canal de Clientes</h2>
  </div>
  <div class="content">
    <div class="table-responsive">
      <table class="table table-bordered table-striped table-responsible sortable">
        <thead>
          <tr>
            <!--<th width=02%><input type="checkbox" class="checkall" /></th>-->
			<th width=05%>ID</th>
            <th width=50%>Canal</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_canal = $registro['ds_canal'];

			echo "<tr>";
            //echo "<td class='text-center'><input type='checkbox' /></td>";
            echo "<td>$id</td>";
            echo "<td>$ds_canal</td>";


            echo "<td class='text-center'><a href='erpc_dom_canal_cliente_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_dom_canal_cliente_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';?>
