<?php require_once('topo.php');?>
<?php require_once('lateral.php');?>
<?php
//VERIFICAÇÃO DO PROGRAMA E NÍVEL PERMISÃO
$idprograma_pagina = 67;
//VERIFICA A AÇÃO DO USUÁRIO

$SelecionaProgramaUsuario = Seleciona("usuarios_programas", "WHERE idusuario='".$_SESSION['usuarioID']."' AND idprograma='$idprograma_pagina'", "LIMIT 0,1");
while($progama_usuario = mysql_fetch_array($SelecionaProgramaUsuario)){
$AcaoUsuario = $progama_usuario['acao'];
}

//AÇÕES
// Visualizar
// Inserir
// Completa
//MASTER ACESSO
if($_SESSION['master'] == 1){
   $AcaoUsuario = "Completa"; 
}
//FIM VERIFICAÇÃO PROGRAMA
?>

      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Contatos Geral (Cliente, Fornecedor, Colaboradores)            
          </h1>
          <ol class="breadcrumb">
            <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="listar_contatos.php">Contatos Geral</a></li>
            <li class="active">Listagem</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12"><!-- /.box -->

              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Listagem de Contatos (Cliente, Fornecedor, Colaboradores)</h3>                 
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="cursor:pointer">Tipo</th>
                        <th style="cursor:pointer">Nome</th>
                        <th style="cursor:pointer">Telefone</th>
                        <th style="cursor:pointer">Telefone 2</th>
                        <th style="cursor:pointer">E-mail</th>
                        <th style="cursor:pointer">Cadastrado por</th>
                        <th style="cursor:pointer"></th>
                      </tr>
                    </thead>
                    <tbody>
					<?php					
					$Seleciona = Seleciona("clientes", "WHERE excluido IS NULL", "ORDER BY nome ASC");
					while($linha = mysql_fetch_array($Seleciona)){
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_clientes.php?idcliente=<?php echo $linha['idcliente'];?>';">
                        <td>CLIENTES</td>
                        <td><?php echo $linha['nome'];?></td>
                        <td><?php echo $linha['telefone'];?></td>
                        <td><?php echo $linha['celular'];?></td>
                        <td><?php echo $linha['email'];?></td>
                        <td><?php echo LoginUsuario($linha['idusuario_cadastro']);?></td>
                        <td><button type='button' class='btn btn-success'><i class="fa fa-search" aria-hidden="true"></i></button></td>
                      </tr>
                      <?php }?>
                      
                    <?php
					$Seleciona_contatos = Seleciona("clientes_contato", "WHERE excluido IS NULL", "ORDER BY Contato ASC");
					while($linha_contatos = mysql_fetch_array($Seleciona_contatos)){
					?>
                      <tr style="cursor:pointer">
                        <td>Contato Cliente</td>
                        <td><?php echo  $linha_contatos['Contato'];?></td>
                        <td><?php echo  $linha_contatos['Fone1'];?></td>
                        <td><?php echo $linha_contatos['Fone2'];?></td>
                        <td><?php echo $linha_contatos['email'];?></td>
                        <td><?php echo LoginUsuario($linha_contatos['idusuario_cadastro']);?></td>
                        <td>                     
                        <a href="manutencao_clientes.php?aba=contatos&idcliente=<?php echo $idcliente;?>&CodCont=<?php echo $linha_contatos['CodCont'];?>">     
						<button type='button' class='btn btn-success'><i class="fa fa-search" aria-hidden="true"></i></button>                        
                        </a>
                        </td>                                                                   
                      </tr>
                      <?php 
					  }			  					  
					  ?>                      
                      
                    <?php
					$Seleciona = Seleciona("fornecedores", "WHERE excluido IS NULL", "ORDER BY nome ASC");
					while($linha = mysql_fetch_array($Seleciona)){
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_fornecedores.php?idfornecedor=<?php echo $linha['idfornecedor'];?>';">
                        <td>FORNECEDORES</td>
                        <td><?php echo $linha['nome'];?></td>
                        <td><?php echo $linha['telefone'];?></td>
                        <td><?php echo $linha['celular'];?></td>
                        <td><?php echo $linha['email'];?></td>
                        <td><?php echo LoginUsuario($linha['idusuario_cadastro']);?></td>
                        <td><button type='button' class='btn btn-success'><i class="fa fa-search" aria-hidden="true"></i></button></td>
                      </tr>
                      <?php }?>   
                      
                   <?php
					$Seleciona_contatos = Seleciona("fornecedores_contato", "WHERE excluido IS NULL", "ORDER BY Contato ASC");
					while($linha_contatos = mysql_fetch_array($Seleciona_contatos)){
					?>
                      <tr style="cursor:pointer">
                        <td>Contato Fornecedor</td>
                        <td><?php echo  $linha_contatos['Contato'];?></td>
                        <td><?php echo  $linha_contatos['Fone1'];?></td>
                        <td><?php echo $linha_contatos['Fone2'];?></td>
                        <td><?php echo $linha_contatos['email'];?></td>
                        <td><?php echo LoginUsuario($linha_contatos['idusuario_cadastro']);?></td>
                        <td>                       
                        <a style="color: #000000;" href="manutencao_fornecedores.php?aba=contatos&idfornecedor=<?php echo $idfornecedor;?>&CodCont=<?php echo $linha_contatos['CodCont'];?>">     
						<button type='button' class='btn btn-success'><i class="fa fa-refresh" aria-hidden="true"></i></button>                        
                        </a>
                        </td>                                                                    
                      </tr>
                      <?php 
					  }			  					  
					  ?>
                       
                      
                    <?php
					$Seleciona = Seleciona("usuarios", "WHERE excluido IS NULL", "ORDER BY nome ASC");
					while($linha = mysql_fetch_array($Seleciona)){
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_usuarios.php?idusuario=<?php echo $linha['idusuario'];?>';">
                        <td>COLABORADOR</td>
                        <td><?php echo utf8_encode($linha['nome']);?></td>                       
                        <td><?php echo $linha['telefone'];?></td>
                        <td><?php echo $linha['celular'];?></td>
                        <td><?php echo $linha['email'];?></td>
                        <td><?php echo LoginUsuario($linha['idusuario_cadastro']);?></td>                        
                        <td><button type='button' class='btn btn-success'><i class="fa fa-search" aria-hidden="true"></i></button></td>
                      </tr>
                      <?php }?>                                         
                      
                    </tbody>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
<?php require_once('rodape.php');?>