<script language="javascript">
function confsenha(){
  if(document.form1.senha.value == document.form1.confirma.value){
    document.form1.submit()
    return true
  } else {
    alert("Sua senha não confere!")
    form1.senha.focus()
    return false
  }

}
</script>

<?php
if($_SESSION['nivel'] == 1){ 
  $buscaCliente = "SELECT cli.id, cli.empresa, cli.logradouro, cli.numero, cli.complemento, cli.bairro, cli.cidade, cli.uf, cli.cep, cli.telefone, cli.telefone01, cli.telefone02, cli.telefone03, cli.segmento, cli.qtfunc, cli.email, cli.email01, cli.email02, cli.email03, cli.login, cli.senha, cli.statusag, cli.statusle, cli.statusup, cli.total_credito, cli.responsavel, cli.cargo from 
            crm_cliente cli 
            WHERE cli.id='".$_GET['cod']."'";

  $result=mysql_query($buscaCliente) or die (mysql_error());
  list($cod, $nome, $logradouro, $numero, $complemento, $bairro, $cidade, $uf, $cep, $telefone, $telefone01, $telefone02, $telefone03, $segmento, $qtfunc, $email, $email01, $email02, $email03, $loginemp, $senha, $statusag, $statusle, $statusup, $total_credito, $responsavel, $cargo)=$linha=mysql_fetch_array($result);
  ?>

  <table width="100%" height="595" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
    <form id="form1" name="form1" method="post" action="miolo.php?miolo=clientes&acao=update">
    <tr class="linha-topo">
      <td height="28" colspan="2" align="left" valign="middle" class="titulos-internos">ALTERAR DADOS</td>
    </tr>
    <tr>
      <td width="155" height="28" align="left" valign="middle"><span class="titulo">Nome da Empresa: </span></td>
      <td width="546" align="left" valign="middle"><label>
        <input name="cod" id="cod" type="hidden" value="<? echo $cod; ?>" />
        <input name="empresa" type="text" id="empresa" value="<? echo utf8_encode($nome); ?>" />
        </label></td>
    </tr>
    <!-- <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Nome do Respons&aacute;vel:</span></td>
      <td height="28" align="left" valign="middle"><input name="responsavel" type="text" id="responsavel" value="<?Php echo $responsavel; ?>" size="50" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Cargo: </span></td>
      <td height="28" align="left" valign="middle"><input name="cargo" type="text" id="cargo" value="<?Php echo $cargo; ?>" size="50" /></td>
    </tr> -->
     <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">CEP:</span></td>
      <td height="28" align="left" valign="middle"><input name="cep" type="text" id="cep" value="<? echo utf8_encode($cep); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Logradouro:</span></td>
      <td height="28" align="left" valign="middle"><input name="logradouro" type="text" id="logradouro" value="<? echo utf8_encode($logradouro); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">N&uacute;mero:</span></td>
      <td height="28" align="left" valign="middle"><input name="numero" type="text" id="numero" value="<? echo utf8_encode($numero); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Complemento:</span></td>
      <td height="28" align="left" valign="middle"><input name="complemento" type="text" id="complemento" value="<? echo utf8_encode($complemento); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Bairro:</span></td>
      <td height="28" align="left" valign="middle"><input name="bairro" type="text" id="bairro" value="<? echo utf8_encode($bairro); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Cidade:</span></td>
      <td height="28" align="left" valign="middle"><input name="cidade" type="text" id="cidade" value="<? echo utf8_encode($cidade); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Estado:</span></td>
      <td height="28" align="left" valign="middle"><input name="uf" type="text" id="uf" value="<? echo utf8_encode($uf); ?>" size="2" maxlength="2" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone" type="text" id="telefone" value="<? echo utf8_encode($telefone); ?>" /></td>
      </tr>
       <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone01" type="text" id="telefone01" value="<? echo utf8_encode($telefone01); ?>" /></td>
      </tr>
       <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone02" type="text" id="telefone02" value="<? echo utf8_encode($telefone02); ?>" /></td>
      </tr>
       <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone03" type="text" id="telefone03" value="<? echo utf8_encode($telefone03); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail principal:</span></td>
      <td height="28" align="left" valign="middle"><input name="email" type="text" id="email" value="<? echo utf8_encode($email); ?>" size="50" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail alternativo:</span></td>
      <td height="28" align="left" valign="middle"><input name="email01" type="text" id="email01" value="<? echo utf8_encode($email01); ?>" size="50" /></td>
      </tr>
    <!-- <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail 02:</span></td>
      <td height="28" align="left" valign="middle"><input name="email02" type="text" id="email02" value="<? echo $email02; ?>" size="50" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail 03:</span></td>
      <td height="28" align="left" valign="middle"><input name="email03" type="text" id="email03" value="<? echo $email03; ?>" size="50" /></td>
      </tr> -->
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Segmento:</span></td>
      <td height="28" align="left" valign="middle"><input name="segmento" type="text" id="segmento" value="<? echo utf8_encode($segmento); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Qtd. de Funcion&aacute;rios: </span></td>
      <td height="28" align="left" valign="middle"><input name="qtfunc" type="text" id="qtfunc" value="<? echo utf8_encode($qtfunc); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Login:</span></td>
      <td height="28" align="left" valign="middle"><input name="login" type="text" id="login" value="<? echo $loginemp; ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Senha:</span></td>
      <td height="28" align="left" valign="middle"><input name="senha" type="text" id="senha" value="" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Confirma Senha: </span></td>
      <td height="28" align="left" valign="middle"><input name="confirma" type="text" id="confirma" /></td>
      </tr>
    <tr>
      <td height="35" colspan="2" align="center" valign="middle"><input name="voltar" type="button" onclick="javascript:history.go(-1);" id="voltar" value="Voltar" />
        <input name="gravar" type="button" onclick="return confsenha();" id="gravar" value="Gravar" />
        <input name="limpar" type="reset" id="limpar" value="Limpar" /></td>
      </tr>
  </form></table>
<?php
}

if($_SESSION['nivel'] == 2){ 
  $result=mysql_query("SELECT cli.id, cli.empresa, cli.logradouro, cli.numero, cli.complemento, cli.bairro, cli.cidade, cli.uf, cli.cep, cli.telefone, cli.telefone01, cli.telefone02, cli.telefone03, cli.segmento, cli.qtfunc, cli.email, cli.email01, cli.email02, cli.email03, cli.login, cli.senha, cli.statusag, cli.statusle, cli.statusup, cli.total_credito, cli.responsavel, cli.cargo from 
            crm_cliente cli 
            where cli.id='".$_SESSION['idUser']."'") or die (mysql_error());
  list($cod, $nome, $logradouro, $numero, $complemento, $bairro, $cidade, $uf, $cep, $telefone, $telefone01, $telefone02, $telefone03, $segmento, $qtfunc, $email, $email01, $email02, $email03, $loginemp, $senha, $statusag, $statusle, $statusup, $total_credito, $responsavel, $cargo)=$linha=mysql_fetch_array($result);
  ?>

  <table width="100%" height="595" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
    <form id="form1" name="form1" method="post" action="miolo.php?miolo=dados&acao=update">
    <tr class="linha-topo">
      <td height="28" colspan="2" align="left" valign="middle" class="titulos-internos">ALTERAR DADOS</td>
    </tr>
    <tr>
      <td width="155" height="28" align="left" valign="middle"><span class="titulo">Nome da Empresa: </span></td>
      <td width="546" align="left" valign="middle"><label>
        <input name="cod" id="cod" type="hidden" value="<? echo $cod; ?>" />
        <input name="empresa" type="text" id="empresa" value="<? echo utf8_encode($nome); ?>" />
        </label></td>
    </tr>
    <!-- <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Nome do Respons&aacute;vel:</span></td>
      <td height="28" align="left" valign="middle"><input name="responsavel" type="text" id="responsavel" value="<?Php echo $responsavel; ?>" size="50" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Cargo: </span></td>
      <td height="28" align="left" valign="middle"><input name="cargo" type="text" id="cargo" value="<?Php echo $cargo; ?>" size="50" /></td>
    </tr> -->
     <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">CEP:</span></td>
      <td height="28" align="left" valign="middle"><input name="cep" type="text" id="cep" value="<? echo utf8_encode($cep); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Logradouro:</span></td>
      <td height="28" align="left" valign="middle"><input name="logradouro" type="text" id="logradouro" value="<? echo utf8_encode($logradouro); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">N&uacute;mero:</span></td>
      <td height="28" align="left" valign="middle"><input name="numero" type="text" id="numero" value="<? echo utf8_encode($numero); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Complemento:</span></td>
      <td height="28" align="left" valign="middle"><input name="complemento" type="text" id="complemento" value="<? echo utf8_encode($complemento); ?>" /></td>
    </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Bairro:</span></td>
      <td height="28" align="left" valign="middle"><input name="bairro" type="text" id="bairro" value="<? echo utf8_encode($bairro); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Cidade:</span></td>
      <td height="28" align="left" valign="middle"><input name="cidade" type="text" id="cidade" value="<? echo utf8_encode($cidade); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Estado:</span></td>
      <td height="28" align="left" valign="middle"><input name="uf" type="text" id="uf" value="<? echo utf8_encode($uf); ?>" size="2" maxlength="2" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone" type="text" id="telefone" value="<? echo utf8_encode($telefone); ?>" /></td>
      </tr>
      <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone01" type="text" id="telefone01" value="<? echo utf8_encode($telefone01); ?>" /></td>
      </tr>
      <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone02" type="text" id="telefone02" value="<? echo utf8_encode($telefone02); ?>" /></td>
      </tr>
      <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Telefone:</span></td>
      <td height="28" align="left" valign="middle"><input name="telefone03" type="text" id="telefone03" value="<? echo utf8_encode($telefone03); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail:</span></td>
      <td height="28" align="left" valign="middle"><input name="email" type="text" id="email" value="<? echo utf8_encode($email); ?>" size="50" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail alternativo:</span></td>
      <td height="28" align="left" valign="middle"><input name="email01" type="text" id="email01" value="<? echo utf8_encode($email01); ?>" size="50" /></td>
      </tr>
   <!--  <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail 02:</span></td>
      <td height="28" align="left" valign="middle"><input name="email02" type="text" id="email02" value="<? echo $email02; ?>" size="50" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">E-mail 03:</span></td>
      <td height="28" align="left" valign="middle"><input name="email03" type="text" id="email03" value="<? echo $email03; ?>" size="50" /></td>
      </tr> -->
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Segmento:</span></td>
      <td height="28" align="left" valign="middle"><input name="segmento" type="text" id="segmento" value="<? echo utf8_encode($segmento); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Qtd. de Funcion&aacute;rios: </span></td>
      <td height="28" align="left" valign="middle"><input name="qtfunc" type="text" id="qtfunc" value="<? echo utf8_encode($qtfunc); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Login:</span></td>
      <td height="28" align="left" valign="middle"><input name="login" type="text" id="login" value="<? echo utf8_encode($loginemp); ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Senha:</span></td>
      <td height="28" align="left" valign="middle"><input name="senha" type="text" id="senha" value="<?php echo $senha; ?>" /></td>
      </tr>
    <tr>
      <td height="28" align="left" valign="middle"><span class="titulo">Confirma Senha: </span></td>
      <td height="28" align="left" valign="middle"><input name="confirma" type="text" id="confirma" /></td>
      </tr>
    <tr>
      <td height="35" colspan="2" align="center" valign="middle"><input name="voltar" type="button" onclick="javascript:history.go(-1);" id="voltar" value="Voltar" />
        <input name="gravar" type="button" onclick="return confsenha();" id="gravar" value="Gravar" />
        <input name="limpar" type="reset" id="limpar" value="Limpar" /></td>
      </tr>
  </form></table>
<?
}
?>