<?php
error_reporting(0);
ini_set("display_errors", 0 );
header('Content-Type: text/html; charset=utf-8');
include("../configuracao.php");//confirma no banco de dados
include("../inclusos/funcoes.php");
include("../seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página

//RECEBE PÁGINA
$recebepagina	= $_GET['pagina'];
$pagina			= RecebePagina($recebepagina);
?>
<!doctype html>
<html ng-app="myApp">
<head>
<title>MAX LAYOUTS</title>
<link rel="stylesheet" href="inclusos/styles.css">
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="inclusos/script.js"></script>

<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
	background-color: #FFFFFF;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> 
		<script type="text/javascript">
			$(document).ready(function(){
				$("a[rel=modal]").click( function(ev){
					ev.preventDefault();

					var id = $(this).attr("href");

					var alturaTela = $(document).height();
					var larguraTela = $(window).width();
	
					//colocando o fundo preto
					$('#mascara').css({'width':larguraTela,'height':alturaTela});
					$('#mascara').fadeIn(1000);	
					$('#mascara').fadeTo("slow",0.8);

					var left = ($(window).width() /2) - ( $(id).width() / 2 );
					var top = ($(window).height() / 2) - ( $(id).height() / 2 );
					
					$(id).css({'top':top,'left':left});
					$(id).show();	
 				});

 				$("#mascara").click( function(){
 					$(this).hide();
 					$(".window").hide();
 				});

 				$('.fechar').click(function(ev){
 					ev.preventDefault();
 					$("#mascara").hide();
 					$(".window").hide();
 				});
			});
			
			function preLoad() {
			$("#loading").hide();
			}
			
			$(function(){
			$("#loading").show();
			});
			
			$(document).ready(function () {
			   $('input').keypress(function (e) {
					var code = null;
					code = (e.keyCode ? e.keyCode : e.which);                
					return (code == 13) ? false : true;
			   });
			});		
			
			//EXPANDIR
			jQuery.fn.toggleText = function(a,b) {
			return   this.html(this.html().replace(new RegExp("("+a+"|"+b+")"),function(x){return(x==a)?b:a;}));
			}
			
			$(document).ready(function(){
				$('.tgl').before('<span>Exibir Informações</span>');
				$('.tgl').css('display', 'none')
				$('span', '#box-toggle').click(function() {
					$(this).next().slideToggle('slow')
					.siblings('.tgl:visible').slideToggle('fast');
				
					$(this).toggleText('Exibir','Esconder')
					.siblings('span').next('.tgl:visible').prev()
					.toggleText('Exibir','Esconder')
				});
			})				
		</script>
        <script src="https://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="js/jquery-1.2.6.pack.js" type="text/javascript"></script>
		
<meta charset="utf-8">
</head>
<body onLoad="preLoad();">
<div id="loading">
<div class="window" style=" background-color: #FFFFFF; width: 300px; height: 150px; top:50%; margin-top:-75px; left:50%; margin-left:-150px; display: flex; border:#C0C0C0 solid 1px;">
<table width="100%" height="100%">
	<tr>
    	<td align="center" valign="center" class="TituloPagina">Carregando...<br><img src="img/loader.gif" border="0"><br></td>
    </tr>
</table> 
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="500%" height="50" colspan="5" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="40"><span class="TituloPagina" style="padding-left: 5px;">RELATÓRIO DE CLIENTES</span></td>
        <td align="right"><table width="100" border="0" align="right" cellpadding="2" cellspacing="0">
          <tr>
            <td width="167" align="left">&nbsp;</td>
            <td width="150" align="left">&nbsp;</td>
            <td width="125" align="left">&nbsp;</td>
            <td width="370" align="right"><table width="180" border="0" align="right" cellpadding="0" cellspacing="0" class="BoxMenuBranco" style="border: 1px solid #CCC;">
              <form method="post" action="relatorio_clientes.php" enctype="multipart/form-data">
                <tr>
                  <td width="148" align="left" bgcolor="#FFFFFF"><input type="text" name="busca" id="busca" style="width: 100%; height: 20px;" class="InputBranco" /></td>
                  <td width="28" align="center" bgcolor="#FFFFFF"><input type="image" src="img/icone_buscar.gif" /></td>
                </tr>
              </form>
            </table></td>
          </tr>
        </table></td>
        <td width="80" align="right" style="padding-right: 8px;"><table width="70" border="0" cellspacing="0" cellpadding="2" class="BoxMenuCinza" onclick="history.go(-1);">
          <tr>
            <td height="25" align="center" class="TextoMenuBranco">Voltar</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="middle">
    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
      <tr class="TextoCinzaEscuro">
        <td width="5%" bgcolor="#97D6FF"><strong>CÓD.</strong></td>
        <td width="20%" height="30" bgcolor="#97D6FF" class="TextoCinzaEscuro"><strong>RAZÃO SOCIAL</strong></td>
        <td width="20%" align="left" bgcolor="#97D6FF"><strong>ENDEREÇO</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>CONTATO</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>EMAIL</strong></td>
        <td width="15%" align="left" bgcolor="#97D6FF"><strong>CNPJ</strong></td>
        <td width="15%" align="left" bgcolor="#97D6FF"><strong>IE</strong></td>
        </tr>
              <?php
		$busca = $_POST['busca'];
			$cor_fundo = "#FFFFFF";			  
		  if(empty($busca)){
			  //$seleciona = mysql_query("SELECT Fantasia, RazaoSoc, Email FROM clientes ORDER BY Fantasia ASC LIMIT 0,100");
			 	$seleciona = Seleciona("clientes", "", "ORDER BY Fantasia ASC");
		  }else{
			  	$seleciona = Seleciona("clientes", "WHERE Fantasia LIKE '%".$busca."%' OR RazaoSoc LIKE '%".$busca."%'", "ORDER BY Fantasia ASC");
		  }
			while($linha=mysql_fetch_array($seleciona)){
			
			if($cor_fundo == "#FFFFFF"){
				$cor_fundo = "#E4E4E4";
			}else{
				$cor_fundo = "#FFFFFF";
			}
		?>
        
        <tr class="TextoCinzaPequeno" bgcolor="<?php echo $cor_fundo;?>" onmouseover="javascript:this.style.backgroundColor='#CCCCCC'" onmouseout="javascript:this.style.backgroundColor='<?php echo $cor_fundo;?>'" style="cursor:pointer;" onclick="location.href='manutencao_clientes.php?CodCli=<?php echo $linha['CodCli'];?>';">
          <td><?php echo $linha['CodCli'];?></td>
          <td height="30"><?php echo $linha['Fantasia'];?></td>
          <td align="left"><?php echo $linha['Endereco'];?></td>
          <td align="left"><?php echo $linha['ContatoMD'];?></td>
          <td align="left"><?php echo $linha['Email'];?></td>
          <td align="left"><?php echo $linha['CNPJ'];?></td>
          <td align="left"><?php echo $linha['IE'];?></td>
        </tr>
        
        <?php }?>
    </table></td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="middle">
</td>
  </tr>
</table>
</body>
</html>